cli-claw-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +245 -0
- package/config/default-groups.json +1 -0
- package/config/global-agents-md.template.md +37 -0
- package/config/mount-allowlist.json +11 -0
- package/container/Dockerfile +160 -0
- package/container/agent-runner/dist/.tsbuildinfo +1 -0
- package/container/agent-runner/dist/agent-definitions.js +22 -0
- package/container/agent-runner/dist/channel-prefixes.js +16 -0
- package/container/agent-runner/dist/codex-config.js +29 -0
- package/container/agent-runner/dist/image-detector.js +96 -0
- package/container/agent-runner/dist/index.js +2587 -0
- package/container/agent-runner/dist/mcp-tools.js +1076 -0
- package/container/agent-runner/dist/stream-event.types.js +5 -0
- package/container/agent-runner/dist/stream-processor.js +867 -0
- package/container/agent-runner/dist/types.js +6 -0
- package/container/agent-runner/dist/utils.js +115 -0
- package/container/agent-runner/package.json +36 -0
- package/container/agent-runner/prompts/security-rules.md +31 -0
- package/container/agent-runner/src/agent-definitions.ts +27 -0
- package/container/agent-runner/src/channel-prefixes.ts +16 -0
- package/container/agent-runner/src/codex-config.ts +40 -0
- package/container/agent-runner/src/image-detector.ts +116 -0
- package/container/agent-runner/src/index.ts +3107 -0
- package/container/agent-runner/src/mcp-tools.ts +1295 -0
- package/container/agent-runner/src/stream-event.types.ts +10 -0
- package/container/agent-runner/src/stream-processor.ts +932 -0
- package/container/agent-runner/src/types.ts +75 -0
- package/container/agent-runner/src/utils.ts +114 -0
- package/container/agent-runner/tsconfig.json +17 -0
- package/container/build.sh +28 -0
- package/container/entrypoint.sh +64 -0
- package/container/skills/agent-browser/SKILL.md +159 -0
- package/container/skills/install-skill/SKILL.md +64 -0
- package/container/skills/post-test-cleanup/SKILL.md +121 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/agent-output-parser.js +459 -0
- package/dist/app-root.js +52 -0
- package/dist/assistant-meta-footer.js +1 -0
- package/dist/auth.js +91 -0
- package/dist/billing.js +694 -0
- package/dist/channel-prefixes.js +16 -0
- package/dist/cli.js +86 -0
- package/dist/commands.js +79 -0
- package/dist/config.js +120 -0
- package/dist/container-runner.js +981 -0
- package/dist/daily-summary.js +210 -0
- package/dist/db.js +3683 -0
- package/dist/dingtalk.js +1347 -0
- package/dist/feishu-markdown-style.js +97 -0
- package/dist/feishu-streaming-card.js +1875 -0
- package/dist/feishu.js +1628 -0
- package/dist/file-manager.js +270 -0
- package/dist/group-queue.js +1070 -0
- package/dist/group-runtime.js +35 -0
- package/dist/host-workspace-cwd.js +85 -0
- package/dist/im-channel.js +384 -0
- package/dist/im-command-utils.js +142 -0
- package/dist/im-downloader.js +45 -0
- package/dist/im-manager.js +527 -0
- package/dist/im-utils.js +53 -0
- package/dist/image-detector.js +96 -0
- package/dist/index.js +5828 -0
- package/dist/logger.js +22 -0
- package/dist/mcp-utils.js +66 -0
- package/dist/message-attachments.js +69 -0
- package/dist/message-notifier.js +36 -0
- package/dist/middleware/auth.js +85 -0
- package/dist/mount-security.js +315 -0
- package/dist/permissions.js +67 -0
- package/dist/project-memory.js +6 -0
- package/dist/provider-pool.js +189 -0
- package/dist/qq.js +826 -0
- package/dist/reset-admin.js +42 -0
- package/dist/routes/admin.js +543 -0
- package/dist/routes/agent-definitions.js +241 -0
- package/dist/routes/agents.js +533 -0
- package/dist/routes/auth.js +675 -0
- package/dist/routes/billing.js +490 -0
- package/dist/routes/browse.js +210 -0
- package/dist/routes/bug-report.js +387 -0
- package/dist/routes/config.js +1868 -0
- package/dist/routes/files.js +671 -0
- package/dist/routes/groups.js +1367 -0
- package/dist/routes/mcp-servers.js +320 -0
- package/dist/routes/memory.js +523 -0
- package/dist/routes/monitor.js +307 -0
- package/dist/routes/skills.js +777 -0
- package/dist/routes/tasks.js +509 -0
- package/dist/routes/usage.js +64 -0
- package/dist/routes/workspace-config.js +458 -0
- package/dist/runtime-build.js +112 -0
- package/dist/runtime-command-handler.js +189 -0
- package/dist/runtime-command-registry.js +1 -0
- package/dist/runtime-config.js +1777 -0
- package/dist/runtime-identity.js +52 -0
- package/dist/schemas.js +590 -0
- package/dist/script-runner.js +64 -0
- package/dist/sdk-query.js +82 -0
- package/dist/skill-utils.js +145 -0
- package/dist/sqlite-compat.js +19 -0
- package/dist/stream-event.types.js +5 -0
- package/dist/streaming-runtime-meta.js +29 -0
- package/dist/task-scheduler.js +695 -0
- package/dist/task-utils.js +13 -0
- package/dist/telegram-pairing.js +59 -0
- package/dist/telegram.js +897 -0
- package/dist/terminal-manager.js +307 -0
- package/dist/tool-step-display.js +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.js +85 -0
- package/dist/web-context.js +161 -0
- package/dist/web.js +1377 -0
- package/dist/wechat-crypto.js +182 -0
- package/dist/wechat.js +589 -0
- package/dist/workspace-runtime-reset.js +35 -0
- package/package.json +107 -0
- package/shared/assistant-meta-footer.ts +127 -0
- package/shared/channel-prefixes.ts +16 -0
- package/shared/dist/assistant-meta-footer.d.ts +29 -0
- package/shared/dist/assistant-meta-footer.js +85 -0
- package/shared/dist/channel-prefixes.d.ts +4 -0
- package/shared/dist/channel-prefixes.js +16 -0
- package/shared/dist/image-detector.d.ts +20 -0
- package/shared/dist/image-detector.js +96 -0
- package/shared/dist/runtime-command-registry.d.ts +38 -0
- package/shared/dist/runtime-command-registry.js +185 -0
- package/shared/dist/stream-event.d.ts +65 -0
- package/shared/dist/stream-event.js +8 -0
- package/shared/dist/tool-step-display.d.ts +4 -0
- package/shared/dist/tool-step-display.js +11 -0
- package/shared/image-detector.ts +116 -0
- package/shared/runtime-command-registry.ts +252 -0
- package/shared/stream-event.ts +67 -0
- package/shared/tool-step-display.ts +21 -0
- package/shared/tsconfig.json +24 -0
- package/web/dist/assets/BillingPage-B1wBR_o-.js +52 -0
- package/web/dist/assets/ChatPage-6GBZ9nXN.css +32 -0
- package/web/dist/assets/ChatPage-BOJcXtaj.js +161 -0
- package/web/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/web/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/web/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/web/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/web/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/web/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/web/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/web/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/web/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/web/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/web/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/web/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/web/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/web/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/web/dist/assets/SettingsPage-DoY7FoZ_.js +153 -0
- package/web/dist/assets/ShareImageDialog-C1ga8b7l.js +22 -0
- package/web/dist/assets/TasksPage-CRivnNsx.js +14 -0
- package/web/dist/assets/_basePickBy-Bf-bSoS9.js +1 -0
- package/web/dist/assets/_baseUniq-zAOaCuKw.js +1 -0
- package/web/dist/assets/arc-Dm9mVQ9U.js +1 -0
- package/web/dist/assets/architectureDiagram-2XIMDMQ5-BLmzX1wr.js +36 -0
- package/web/dist/assets/band-CquvqAHh.js +1 -0
- package/web/dist/assets/blockDiagram-WCTKOSBZ-B9pcqm3j.js +132 -0
- package/web/dist/assets/c4Diagram-IC4MRINW-Cytx1q3b.js +10 -0
- package/web/dist/assets/channel-BOVj73LR.js +1 -0
- package/web/dist/assets/channel-meta-CQD0Pei-.js +41 -0
- package/web/dist/assets/chunk-4BX2VUAB-0ToDr6RE.js +1 -0
- package/web/dist/assets/chunk-55IACEB6-DQDjnXfS.js +1 -0
- package/web/dist/assets/chunk-FMBD7UC4-Di8ABm6c.js +15 -0
- package/web/dist/assets/chunk-JSJVCQXG-BZQN6rnX.js +1 -0
- package/web/dist/assets/chunk-KX2RTZJC-zBbcpaN_.js +1 -0
- package/web/dist/assets/chunk-NQ4KR5QH-BCrLoU88.js +220 -0
- package/web/dist/assets/chunk-QZHKN3VN-Bqk8juan.js +1 -0
- package/web/dist/assets/chunk-WL4C6EOR-D2YX-MHY.js +189 -0
- package/web/dist/assets/classDiagram-VBA2DB6C-DUUoMyaK.js +1 -0
- package/web/dist/assets/classDiagram-v2-RAHNMMFH-DUUoMyaK.js +1 -0
- package/web/dist/assets/clone-BmaCesfa.js +1 -0
- package/web/dist/assets/cose-bilkent-S5V4N54A-CTsv6qQA.js +1 -0
- package/web/dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/web/dist/assets/dagre-KLK3FWXG-Ci4Jh9nu.js +4 -0
- package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/web/dist/assets/diagram-E7M64L7V-BFRnfTI2.js +24 -0
- package/web/dist/assets/diagram-IFDJBPK2-B7Zhnp0b.js +43 -0
- package/web/dist/assets/diagram-P4PSJMXO-BVyP7nwq.js +24 -0
- package/web/dist/assets/erDiagram-INFDFZHY-NorKdTOF.js +70 -0
- package/web/dist/assets/error-CGD5mp5f.js +1 -0
- package/web/dist/assets/flowDiagram-PKNHOUZH-Ch97nABF.js +162 -0
- package/web/dist/assets/ganttDiagram-A5KZAMGK-BQ2pLWsy.js +292 -0
- package/web/dist/assets/gitGraphDiagram-K3NZZRJ6-bcvnBsD2.js +65 -0
- package/web/dist/assets/graph-CeAEckur.js +1 -0
- package/web/dist/assets/index-CPnL1_qC.js +768 -0
- package/web/dist/assets/index-DVevCbcO.css +10 -0
- package/web/dist/assets/infoDiagram-LFFYTUFH-CcsrFdj-.js +2 -0
- package/web/dist/assets/init-Dmth1JHB.js +1 -0
- package/web/dist/assets/ishikawaDiagram-PHBUUO56-1upyMfHN.js +70 -0
- package/web/dist/assets/journeyDiagram-4ABVD52K-CKUi-V0c.js +139 -0
- package/web/dist/assets/kanban-definition-K7BYSVSG-DOnQwXfL.js +89 -0
- package/web/dist/assets/layout-BmMMqTnJ.js +1 -0
- package/web/dist/assets/linear-DiaJloY5.js +1 -0
- package/web/dist/assets/mermaid.core-BWLV1B2v.js +254 -0
- package/web/dist/assets/mindmap-definition-YRQLILUH-BeAKHVWP.js +68 -0
- package/web/dist/assets/ordinal-DILIJJjt.js +1 -0
- package/web/dist/assets/pieDiagram-SKSYHLDU-DfiMSfWo.js +30 -0
- package/web/dist/assets/quadrantDiagram-337W2JSQ-wZxZOJxd.js +7 -0
- package/web/dist/assets/requirementDiagram-Z7DCOOCP-BK4HHm17.js +73 -0
- package/web/dist/assets/sankeyDiagram-WA2Y5GQK-BX6t2avX.js +10 -0
- package/web/dist/assets/sequenceDiagram-2WXFIKYE-BPQlkbAa.js +145 -0
- package/web/dist/assets/sheet-rI0FfB1g.js +6 -0
- package/web/dist/assets/sliders-horizontal-CuijWFNK.js +6 -0
- package/web/dist/assets/sparkles-BsMYXJoT.js +11 -0
- package/web/dist/assets/square-0CqMX1Q3.js +11 -0
- package/web/dist/assets/stateDiagram-RAJIS63D-DxkV0Vwd.js +1 -0
- package/web/dist/assets/stateDiagram-v2-FVOUBMTO-qLYoiOPe.js +1 -0
- package/web/dist/assets/step-D51IIHGA.js +1 -0
- package/web/dist/assets/tasks-D8JjBTwx.js +1 -0
- package/web/dist/assets/time-O8zIGux3.js +1 -0
- package/web/dist/assets/timeline-definition-YZTLITO2-kNp1DyFc.js +61 -0
- package/web/dist/assets/treemap-KZPCXAKY-CkrClVhk.js +162 -0
- package/web/dist/assets/utils-KGAn0XTg.js +11 -0
- package/web/dist/assets/vennDiagram-LZ73GAT5-CgdzEZz4.js +34 -0
- package/web/dist/assets/xychartDiagram-JWTSCODW-DfYGPfNB.js +7 -0
- package/web/dist/assets/zap-_hKJYy7J.js +6 -0
- package/web/dist/favicon.svg +332 -0
- package/web/dist/fonts/AlibabaPuHuiTi-3-55-Regular.woff2 +0 -0
- package/web/dist/fonts/AlibabaPuHuiTi-3-65-Medium.woff2 +0 -0
- package/web/dist/fonts/AlibabaPuHuiTi-3-75-SemiBold.woff2 +0 -0
- package/web/dist/fonts/DMSans-latin-ext.woff2 +0 -0
- package/web/dist/fonts/DMSans-latin.woff2 +0 -0
- package/web/dist/icons/README.md +20 -0
- package/web/dist/icons/apple-touch-icon-180.png +0 -0
- package/web/dist/icons/icon-128.png +0 -0
- package/web/dist/icons/icon-144.png +0 -0
- package/web/dist/icons/icon-152.png +0 -0
- package/web/dist/icons/icon-192.png +0 -0
- package/web/dist/icons/icon-192.svg +332 -0
- package/web/dist/icons/icon-384.png +0 -0
- package/web/dist/icons/icon-48.png +0 -0
- package/web/dist/icons/icon-512-maskable.png +0 -0
- package/web/dist/icons/icon-512.png +0 -0
- package/web/dist/icons/icon-512.svg +332 -0
- package/web/dist/icons/icon-72.png +0 -0
- package/web/dist/icons/icon-96.png +0 -0
- package/web/dist/icons/loading-logo.svg +332 -0
- package/web/dist/icons/logo-1024.png +0 -0
- package/web/dist/icons/logo-icon.svg +332 -0
- package/web/dist/icons/logo-text.svg +332 -0
- package/web/dist/index.html +30 -0
- package/web/dist/manifest.webmanifest +1 -0
- package/web/dist/registerSW.js +1 -0
- package/web/dist/sw.js +1 -0
- package/web/dist/workbox-08d6266a.js +1 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShareImageDialog-C1ga8b7l.js","assets/index-CPnL1_qC.js","assets/index-DVevCbcO.css","assets/square-0CqMX1Q3.js","assets/channel-meta-CQD0Pei-.js","assets/zap-_hKJYy7J.js","assets/sheet-rI0FfB1g.js","assets/error-CGD5mp5f.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as je,r as g,N as Yt,j as n,Q as Mi,k as Ct,ab as V,X as st,x as Ge,e as Di,L as Ua,f as Ri,M as us,ac as Ps,K as St,l as Js,m as ei,ad as Ka,ae as qa,o as Be,af as Va,ag as Ya,Z as Xa,ah as Ur,ai as Ga,aj as ps,ak as Za,al as go,h as ti,a9 as Qa,am as Ja,g as vo,U as Kr,B as ye,an as el,$ as br,a0 as Sr,a1 as wr,a2 as yr,ao as tl,I as Xe,ap as Xt,b as Ke,V as sl,aq as il,ar as xo,s as dt,as as Cr,n as bo,a8 as rl,a as So,z as It,at as nl,a4 as ol,au as ce,av as al,i as kr,F as Tt,aw as qr,ax as wo,D as yo,ay as Co,az as ko,aA as Ks,aB as ll,aC as hl,aD as cl,aE as dl,aF as ul,aG as fl,aH as ml,aI as _l,aJ as pl,aK as Vr,aL as gl,aM as vl,aN as xl,aO as Yr,aP as bl,aQ as Sl,aR as wl,aS as yl,aT as Ns,aU as Cl,aV as kl}from"./index-CPnL1_qC.js";import{F as Is,S as Nl}from"./square-0CqMX1Q3.js";import{C as El,U as jl,F as No,B as Ml,L as Ti,a as Dl,b as Rl,A as Tl,M as Ll,S as Bl}from"./channel-meta-CQD0Pei-.js";import{Z as Al}from"./zap-_hKJYy7J.js";import{U as Nr,S as Et,a as jt,b as Mt,c as Dt}from"./sheet-rI0FfB1g.js";import{e as pt}from"./error-CGD5mp5f.js";/**
|
|
3
|
+
* @license lucide-react v0.400.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const Pl=je("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
|
|
8
|
+
* @license lucide-react v0.400.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const Il=je("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]]);/**
|
|
13
|
+
* @license lucide-react v0.400.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const Ol=je("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
18
|
+
* @license lucide-react v0.400.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const zl=je("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
|
|
23
|
+
* @license lucide-react v0.400.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const Xr=je("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/**
|
|
28
|
+
* @license lucide-react v0.400.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const Hl=je("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/**
|
|
33
|
+
* @license lucide-react v0.400.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const Fl=je("FileUp",[["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 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/**
|
|
38
|
+
* @license lucide-react v0.400.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const Eo=je("FolderUp",[["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"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]]);/**
|
|
43
|
+
* @license lucide-react v0.400.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const jo=je("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/**
|
|
48
|
+
* @license lucide-react v0.400.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const Li=je("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
|
|
53
|
+
* @license lucide-react v0.400.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const Wl=je("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/**
|
|
58
|
+
* @license lucide-react v0.400.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const $l=je("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/**
|
|
63
|
+
* @license lucide-react v0.400.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const Gr=je("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
|
|
68
|
+
* @license lucide-react v0.400.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const Ul=je("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/**
|
|
73
|
+
* @license lucide-react v0.400.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const Kl=je("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
78
|
+
* @license lucide-react v0.400.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const Mo=je("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/**
|
|
83
|
+
* @license lucide-react v0.400.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const Do=je("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/**
|
|
88
|
+
* @license lucide-react v0.400.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const ql=je("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/**
|
|
93
|
+
* @license lucide-react v0.400.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const Vl=je("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"}]]);function Wt(e,t,s){let i=s.initialDeps??[],r,o=!0;function a(){var l,c,h;let d;s.key&&((l=s.debug)!=null&&l.call(s))&&(d=Date.now());const u=e();if(!(u.length!==i.length||u.some((f,p)=>i[p]!==f)))return r;i=u;let m;if(s.key&&((c=s.debug)!=null&&c.call(s))&&(m=Date.now()),r=t(...u),s.key&&((h=s.debug)!=null&&h.call(s))){const f=Math.round((Date.now()-d)*100)/100,p=Math.round((Date.now()-m)*100)/100,v=p/16,k=(N,L)=>{for(N=String(N);N.length<L;)N=" "+N;return N};console.info(`%c⏱ ${k(p,5)} /${k(f,5)} ms`,`
|
|
98
|
+
font-size: .6rem;
|
|
99
|
+
font-weight: bold;
|
|
100
|
+
color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,s==null?void 0:s.key)}return s!=null&&s.onChange&&!(o&&s.skipInitialOnChange)&&s.onChange(r),o=!1,r}return a.updateDeps=l=>{i=l},a}function Zr(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Yl=(e,t)=>Math.abs(e-t)<1.01,Xl=(e,t,s)=>{let i;return function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),s)}},Qr=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},Gl=e=>e,Zl=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1),i=[];for(let r=t;r<=s;r++)i.push(r);return i},Ql=(e,t)=>{const s=e.scrollElement;if(!s)return;const i=e.targetWindow;if(!i)return;const r=a=>{const{width:l,height:c}=a;t({width:Math.round(l),height:Math.round(c)})};if(r(Qr(s)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(a=>{const l=()=>{const c=a[0];if(c!=null&&c.borderBoxSize){const h=c.borderBoxSize[0];if(h){r({width:h.inlineSize,height:h.blockSize});return}}r(Qr(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return o.observe(s,{box:"border-box"}),()=>{o.unobserve(s)}},Jr={passive:!0},en=typeof window>"u"?!0:"onscrollend"in window,Jl=(e,t)=>{const s=e.scrollElement;if(!s)return;const i=e.targetWindow;if(!i)return;let r=0;const o=e.options.useScrollendEvent&&en?()=>{}:Xl(i,()=>{t(r,!1)},e.options.isScrollingResetDelay),a=d=>()=>{const{horizontal:u,isRtl:_}=e.options;r=u?s.scrollLeft*(_&&-1||1):s.scrollTop,o(),t(r,d)},l=a(!0),c=a(!1);s.addEventListener("scroll",l,Jr);const h=e.options.useScrollendEvent&&en;return h&&s.addEventListener("scrollend",c,Jr),()=>{s.removeEventListener("scroll",l),h&&s.removeEventListener("scrollend",c)}},eh=(e,t,s)=>{if(t!=null&&t.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[s.options.horizontal?"inlineSize":"blockSize"])}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},th=(e,{adjustments:t=0,behavior:s},i)=>{var r,o;const a=e+t;(o=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||o.call(r,{[i.options.horizontal?"left":"top"]:a,behavior:s})};class sh{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var s,i,r;return((r=(i=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let s=null;const i=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const a=()=>{const l=o.target,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);return}this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(l,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),s=null},observe:r=>{var o;return(o=i())==null?void 0:o.observe(r,{box:"border-box"})},unobserve:r=>{var o;return(o=i())==null?void 0:o.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([i,r])=>{typeof r>"u"&&delete s[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Gl,rangeExtractor:Zl,onChange:()=>{},measureElement:eh,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...s}},this.notify=s=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,s)},this.maybeNotify=Wt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=o,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,i)=>{const r=new Map,o=new Map;for(let a=i-1;a>=0;a--){const l=s[a];if(r.has(l.lane))continue;const c=o.get(l.lane);if(c==null||l.end>c.end?o.set(l.lane,l):l.end<c.end&&r.set(l.lane,!0),r.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((a,l)=>a.end===l.end?a.index-l.index:a.end-l.end)[0]:void 0},this.getMeasurementOptions=Wt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(s,i,r,o,a,l)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:a,lanes:l}),{key:!1}),this.getMeasurements=Wt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:a,lanes:l},c)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const _ of this.laneAssignments.keys())_>=s&&this.laneAssignments.delete(_);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(_=>{this.itemSizeCache.set(_.key,_.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,h),u=new Array(l).fill(void 0);for(let _=0;_<h;_++){const m=d[_];m&&(u[m.lane]=_)}for(let _=h;_<s;_++){const m=o(_),f=this.laneAssignments.get(_);let p,v;if(f!==void 0&&this.options.lanes>1){p=f;const D=u[p],T=D!==void 0?d[D]:void 0;v=T?T.end+this.options.gap:i+r}else{const D=this.options.lanes===1?d[_-1]:this.getFurthestMeasurement(d,_);v=D?D.end+this.options.gap:i+r,p=D?D.lane:_%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(_,p)}const k=c.get(m),N=typeof k=="number"?k:this.options.estimateSize(_),L=v+N;d[_]={index:_,start:v,size:N,end:L,key:m,lane:p},u[p]=_}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Wt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,i,r,o)=>this.range=s.length>0&&i>0?ih({measurements:s,outerSize:i,scrollOffset:r,lanes:o}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Wt(()=>{let s=null,i=null;const r=this.calculateRange();return r&&(s=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,i]},(s,i,r,o,a)=>o===null||a===null?[]:s({startIndex:o,endIndex:a,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const i=this.options.indexAttribute,r=s.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,r-o),l=Math.min(this.options.count-1,r+o);return s>=a&&s<=l}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((a,l)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(l))});return}const i=this.indexFromElement(s),r=this.options.getItemKey(i),o=this.elementsCache.get(r);o!==s&&(o&&this.observer.unobserve(o),this.observer.observe(s),this.elementsCache.set(r,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,i)=>{var r;const o=this.measurementsCache[s];if(!o)return;const a=this.itemSizeCache.get(o.key)??o.size,l=i-a;l!==0&&(((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,l,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,i)),this.notify(!1))},this.getVirtualItems=Wt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,i)=>{const r=[];for(let o=0,a=s.length;o<a;o++){const l=s[o],c=i[l];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const i=this.getMeasurements();if(i.length!==0)return Zr(i[Ro(0,i.length-1,r=>Zr(i[r]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,i,r=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),a=this.getScrollOffset();i==="auto"&&(i=s>=a+o?"end":"start"),i==="center"?s+=(r-o)/2:i==="end"&&(s-=o);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,s),0)},this.getOffsetForIndex=(s,i="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.getSize(),o=this.getScrollOffset(),a=this.measurementsCache[s];if(!a)return;if(i==="auto")if(a.end>=o+r-this.options.scrollPaddingEnd)i="end";else if(a.start<=o+this.options.scrollPaddingStart)i="start";else return[o,i];if(i==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),i];const l=i==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,i,a.size),i]},this.scrollToOffset=(s,{align:i="start",behavior:r="auto"}={})=>{const o=this.getOffsetForAlignment(s,i),a=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:a,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:i="auto",behavior:r="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const o=this.getOffsetForIndex(s,i);if(!o)return;const[a,l]=o,c=this.now();this.scrollState={index:s,align:l,behavior:r,startedAt:c,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+s,o=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:o,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var s;const i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((s=i[i.length-1])==null?void 0:s.end)??0;else{const o=Array(this.options.lanes).fill(null);let a=i.length-1;for(;a>=0&&o.some(l=>l===null);){const l=i[a];o[l.lane]===null&&(o[l.lane]=l.end),a--}r=Math.max(...o.filter(l=>l!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:i,behavior:r})=>{this.options.scrollToFn(s,{behavior:r,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,o=1,a=r!==this.scrollState.lastTargetOffset;if(!a&&Yl(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=r,this.scrollState.behavior="auto",this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const Ro=(e,t,s,i)=>{for(;e<=t;){const r=(e+t)/2|0,o=s(r);if(o<i)e=r+1;else if(o>i)t=r-1;else return r}return e>0?e-1:0};function ih({measurements:e,outerSize:t,scrollOffset:s,lanes:i}){const r=e.length-1,o=c=>e[c].start;if(e.length<=i)return{startIndex:0,endIndex:r};let a=Ro(0,r,o,s),l=a;if(i===1)for(;l<r&&e[l].end<s+t;)l++;else if(i>1){const c=Array(i).fill(0);for(;l<r&&c.some(d=>d<s+t);){const d=e[l];c[d.lane]=d.end,l++}const h=Array(i).fill(s+t);for(;a>=0&&h.some(d=>d>=s);){const d=e[a];h[d.lane]=d.start,a--}a=Math.max(0,a-a%i),l=Math.min(r,l+(i-1-l%i))}return{startIndex:a,endIndex:l}}const tn=typeof document<"u"?g.useLayoutEffect:g.useEffect;function rh({useFlushSync:e=!0,...t}){const s=g.useReducer(()=>({}),{})[1],i={...t,onChange:(o,a)=>{var l;e&&a?Yt.flushSync(s):s(),(l=t.onChange)==null||l.call(t,o,a)}},[r]=g.useState(()=>new sh(i));return r.setOptions(i),tn(()=>r._didMount(),[]),tn(()=>r._willUpdate()),r}function nh(e){return rh({observeElementRect:Ql,observeElementOffset:Jl,scrollToFn:th,...e})}function Es({content:e,position:t,onClose:s,chatJid:i,messageId:r,onShareImage:o}){const a=g.useRef(null),[l,c]=g.useState(!1);g.useEffect(()=>{const m=a.current;if(!m)return;const f=m.getBoundingClientRect();f.right>window.innerWidth&&(m.style.left=`${window.innerWidth-f.width-8}px`),f.bottom>window.innerHeight&&(m.style.top=`${t.y-f.height-8}px`)},[t]);const h=async m=>{try{await navigator.clipboard.writeText(m)}catch{const f=document.createElement("textarea");f.value=m,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.select(),document.execCommand("copy"),document.body.removeChild(f)}s()},d=()=>{const m=e.replace(/```[\s\S]*?```/g,f=>f.replace(/```\w*\n?/,"").replace(/\n?```$/,"")).replace(/`([^`]+)`/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/~~([^~]+)~~/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^\s*[-*+]\s+/gm,"").replace(/^\s*\d+\.\s+/gm,"").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1");h(m)},u=()=>h(e),_=async()=>{if(!l){c(!0);return}i&&r&&await V.getState().deleteMessage(i,r),s()};return Yt.createPortal(n.jsx("div",{className:"fixed inset-0 z-[60]",onClick:s,children:n.jsxs("div",{ref:a,className:"absolute bg-surface rounded-xl shadow-lg border border-border py-1 min-w-[160px] animate-in zoom-in-95 fade-in duration-150 select-none",style:{left:t.x,top:t.y},onClick:m=>m.stopPropagation(),children:[n.jsxs("button",{onClick:d,className:"group/item w-full flex items-center gap-3 mx-1 px-3 py-2.5 text-sm text-foreground rounded-lg hover:bg-foreground/10 active:bg-foreground/15 transition-colors",children:[n.jsx(Mi,{className:"w-4 h-4 text-muted-foreground group-hover/item:text-primary transition-colors"}),"复制文本"]}),n.jsx("div",{className:"mx-3 my-0.5 border-t border-border"}),n.jsxs("button",{onClick:u,className:"group/item w-full flex items-center gap-3 mx-1 px-3 py-2.5 text-sm text-foreground rounded-lg hover:bg-foreground/10 active:bg-foreground/15 transition-colors",children:[n.jsx(Is,{className:"w-4 h-4 text-muted-foreground group-hover/item:text-primary transition-colors"}),"复制 Markdown"]}),o&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mx-3 my-0.5 border-t border-border"}),n.jsxs("button",{onClick:()=>{o(),s()},className:"group/item w-full flex items-center gap-3 mx-1 px-3 py-2.5 text-sm text-foreground rounded-lg hover:bg-foreground/10 active:bg-foreground/15 transition-colors",children:[n.jsx(jo,{className:"w-4 h-4 text-muted-foreground group-hover/item:text-primary transition-colors"}),"生成分享图片"]})]}),i&&r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mx-3 my-0.5 border-t border-border"}),n.jsxs("button",{onClick:_,className:`group/item w-full flex items-center gap-3 mx-1 px-3 py-2.5 text-sm rounded-lg transition-colors ${l?"text-red-400 bg-red-500/20 hover:bg-red-500/30":"text-red-400 hover:bg-foreground/10 hover:text-red-500 active:bg-foreground/15"}`,children:[n.jsx(Ct,{className:`w-4 h-4 transition-colors ${l?"":"group-hover/item:text-red-500"}`}),l?"确认删除":"删除消息"]})]})]})}),document.body)}function js({images:e,initialIndex:t,onClose:s}){const[i,r]=g.useState(t),[o,a]=g.useState(1),[l,c]=g.useState(0),[h,d]=g.useState(1),[u,_]=g.useState(!1),[m,f]=g.useState(!1),p=g.useRef({x:0,y:0}),v=g.useRef(0),k=g.useRef(!1);g.useEffect(()=>{requestAnimationFrame(()=>f(!0))},[]);const N=g.useCallback(()=>{_(!0),f(!1),setTimeout(()=>s(),300)},[s]),L=H=>{const U=H.touches[0];p.current={x:U.clientX,y:U.clientY},k.current=!1},D=H=>{const q=H.touches[0].clientY-p.current.y;o===1&&q>0&&(k.current=!0,c(q),d(Math.max(0,1-q/400)))},T=H=>{const U=H.changedTouches[0],q=U.clientX-p.current.x,A=U.clientY-p.current.y;if(k.current&&l>150){N();return}if(k.current){c(0),d(1),k.current=!1;return}if(Math.abs(q)>50&&Math.abs(A)<50&&o===1){q<0&&i<e.length-1?r(i+1):q>0&&i>0&&r(i-1);return}const S=Date.now();S-v.current<300?(a(o===1?2:1),v.current=0):v.current=S},B={opacity:m&&!u?h:0,transition:k.current?"none":"opacity 300ms ease"},I={transform:`translateY(${l}px) scale(${o})`,transition:k.current?"none":"transform 300ms ease"};return Yt.createPortal(n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:N,children:[n.jsx("div",{className:"absolute inset-0 bg-black/90",style:B}),n.jsx("button",{onClick:N,className:"absolute top-4 right-4 z-30 w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 backdrop-blur-sm flex items-center justify-center text-white transition-colors","aria-label":"关闭",style:{opacity:m&&!u?1:0,transition:"opacity 300ms ease"},children:n.jsx(st,{className:"w-6 h-6"})}),n.jsx("div",{className:"relative z-10 w-full h-full flex items-center justify-center p-4",onTouchStart:L,onTouchMove:D,onTouchEnd:T,children:n.jsx("img",{src:e[i],alt:`${i+1} / ${e.length}`,className:"max-w-full max-h-full object-contain select-none",style:I,draggable:!1,onClick:H=>H.stopPropagation()})}),e.length>1&&n.jsxs("div",{className:"absolute bottom-8 left-1/2 -translate-x-1/2 z-20 px-3 py-1 rounded-full bg-black/50 text-white text-sm",style:{opacity:m&&!u?1:0,transition:"opacity 300ms ease"},children:[i+1," / ",e.length]})]}),document.body)}const Bi="chat",Ai=new Set;function oh(e){return`cli-claw-display-mode:${e||"guest"}`}function ah(e){return typeof window>"u"?Bi:window.localStorage.getItem(e)==="compact"?"compact":Bi}function lh(e){return Ai.add(e),()=>Ai.delete(e)}function gs(){const e=Ge(a=>{var l;return((l=a.user)==null?void 0:l.id)??null}),t=oh(e),s=g.useCallback(()=>ah(t),[t]),i=g.useCallback(a=>{typeof window<"u"&&window.localStorage.setItem(t,a),Ai.forEach(l=>l())},[t]),r=g.useSyncExternalStore(lh,s,()=>Bi),o=g.useCallback(()=>{i(r==="chat"?"compact":"chat")},[r,i]);return{mode:r,toggle:o,setMode:i}}function sn(e){return typeof e!="string"?null:e.trim()||null}function Kt(e){return typeof e!="number"||!Number.isFinite(e)?null:e}function hh(e){return Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e)):"0"}function ch(e){if(!e)return null;if(typeof e=="string")try{return JSON.parse(e)}catch{return null}return e}function dh(e){if(!e)return null;const t=Kt(e.inputTokens),s=Kt(e.outputTokens);if(t!==null||s!==null)return Math.max(0,(t||0)+(s||0));if(!e.modelUsage||typeof e.modelUsage!="object")return null;let i=0,r=!1;for(const o of Object.values(e.modelUsage)){const a=Kt(o==null?void 0:o.inputTokens),l=Kt(o==null?void 0:o.outputTokens);(a!==null||l!==null)&&(i+=(a||0)+(l||0),r=!0)}return r?i:null}function uh(e){const t=[],s=e.runtimeIdentity??null,i=ch(e.tokenUsage),r=Kt(i==null?void 0:i.durationMs);r!==null&&r>0&&t.push(`${(r/1e3).toFixed(1)}s`);const o=sn(s==null?void 0:s.model);o&&t.push(o);const a=sn(s==null?void 0:s.reasoningEffort);a&&t.push(a);const l=dh(i);l!==null&&l>0&&t.push(`${hh(l)} tokens`);const c=Kt(i==null?void 0:i.costUSD);return c!==null&&c>0&&t.push(`$${c.toFixed(4)}`),t}function To(e){const t=uh(e);return t.length>0?t.join(" | "):null}function ns({runtimeIdentity:e,tokenUsage:t,className:s}){const i=To({runtimeIdentity:e,tokenUsage:t});return i?n.jsx("div",{className:Di("mt-1.5 text-xs text-muted-foreground",s),children:i}):null}const fh=g.lazy(()=>qa(()=>import("./ShareImageDialog-C1ga8b7l.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(e=>({default:e.ShareImageDialog})));function rn({content:e}){const[t,s]=g.useState(!1);return n.jsxs("div",{className:"mb-3 rounded-xl border border-amber-200/60 dark:border-amber-700/40 bg-amber-50/40 dark:bg-amber-950/30 overflow-hidden",children:[n.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-2 px-3 py-2 pr-16 text-left hover:bg-amber-50/60 dark:hover:bg-amber-950/40 transition-colors",children:[n.jsx("svg",{className:"w-4 h-4 text-amber-500 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"})}),n.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"Reasoning"}),n.jsx("span",{className:"flex-1"}),t?n.jsx(Js,{className:"w-3.5 h-3.5 text-amber-400"}):n.jsx(ei,{className:"w-3.5 h-3.5 text-amber-400"})]}),t&&n.jsx("div",{className:"px-3 pb-3 text-sm text-amber-900/70 dark:text-amber-300/70 whitespace-pre-wrap break-words max-h-64 overflow-y-auto border-t border-amber-100 dark:border-amber-800/40",children:e})]})}const mh=g.memo(function({message:t,showTime:s,thinkingContent:i,isShared:r}){var w;const[o,a]=g.useState(!1),[l,c]=g.useState(null),[h,d]=g.useState(null),[u,_]=g.useState(!1),m=Ge(x=>x.user),f=Ge(x=>x.appearance),{mode:p}=gs(),v=!t.is_from_me,k=r&&v&&t.sender!==(m==null?void 0:m.id),N=new Date(t.timestamp).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(/\//g,"-"),D=(t.attachments?(()=>{try{return JSON.parse(t.attachments)}catch{return[]}})():[]).filter(x=>x.type==="image"),T=D.map(x=>`data:${x.mimeType||"image/png"};base64,${x.data}`),B=v?null:To({runtimeIdentity:t.runtime_identity,tokenUsage:t.token_usage}),I=!t.content.trim()&&D.length>0,H=async()=>{try{await navigator.clipboard.writeText(t.content),a(!0),setTimeout(()=>a(!1),1500)}catch{const x=document.createElement("textarea");x.value=t.content,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.select(),document.execCommand("copy"),document.body.removeChild(x),a(!0),setTimeout(()=>a(!1),1500)}},U=x=>{x.stopPropagation();const E=x.currentTarget.getBoundingClientRect();Ka(),d({x:E.left,y:E.bottom+4})};if(t.sender==="__system__"&&t.content.startsWith("context_overflow:")){const x=t.content.replace(/^context_overflow:\s*/,"");return n.jsxs("div",{className:"mb-6",children:[s&&n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:N}),n.jsx("span",{className:"text-xs font-medium text-red-600",children:"系统消息"})]}),n.jsx("div",{className:"relative bg-red-50 dark:bg-red-950/30 rounded-xl border border-red-200 dark:border-red-800/60 border-l-[3px] border-l-red-500 px-5 py-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-red-500 rounded-full flex items-center justify-center text-white font-bold text-sm",children:"!"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h3",{className:"text-sm font-semibold text-red-900 dark:text-red-200 mb-1",children:"上下文溢出错误"}),n.jsx("p",{className:"text-sm text-red-800 dark:text-red-300 leading-relaxed",children:x})]})]})})]})}if(t.sender==="__billing__"){const x=t.content.replace(/^⚠️\s*/,""),E=x.includes("充值余额后继续使用"),b={daily:"日度",weekly:"周度",monthly:"月度"};let j="";x.includes("日度")?j="daily":x.includes("周度")?j="weekly":x.includes("月度")&&(j="monthly");const C=E?"余额":b[j]||"配额",P=x.match(/约\s*(\d+)\s*(小时|天)后重置/);return n.jsxs("div",{className:"mb-6",children:[s&&n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:N}),n.jsx("span",{className:"text-xs font-medium text-amber-600",children:E?"余额提醒":"配额提醒"})]}),n.jsx("div",{className:"relative bg-amber-50 dark:bg-amber-950/30 rounded-xl border border-amber-200 dark:border-amber-800 border-l-[3px] border-l-amber-500 px-5 py-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-amber-500 rounded-full flex items-center justify-center text-white font-bold text-sm",children:"!"}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("h3",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:E?"余额不足":`${C}配额已用完`}),!E&&j&&n.jsxs("span",{className:`px-1.5 py-0.5 text-[10px] rounded-full font-medium ${j==="daily"?"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300":j==="weekly"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300":"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300"}`,children:[C,"限额"]})]}),n.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-300 leading-relaxed",children:x}),P&&n.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-1",children:["预计 ",P[1]," ",P[2],"后自动重置"]}),n.jsx(Ua,{to:"/billing",className:"inline-block mt-2 text-sm text-primary hover:underline font-medium",children:"查看账单 →"})]})]})})]})}if(p==="compact"){const x=t.is_from_me,E=x?(m==null?void 0:m.ai_name)||(f==null?void 0:f.aiName)||t.sender_name||"AI":k?t.sender_name||"用户":(m==null?void 0:m.display_name)||(m==null?void 0:m.username)||"我";return n.jsxs("div",{className:"group mb-2 border-b border-border pb-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[n.jsx("span",{className:`text-xs font-semibold ${x?"text-primary":"text-muted-foreground"}`,children:E}),s&&n.jsx("span",{className:"text-[11px] text-muted-foreground",children:N}),n.jsx("button",{onClick:H,className:"ml-1 w-5 h-5 rounded flex items-center justify-center text-muted-foreground/50 hover:text-foreground/70 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",title:"复制",children:o?n.jsx(Ri,{className:"w-3 h-3 text-primary"}):n.jsx(Mi,{className:"w-3 h-3"})})]}),i&&n.jsx(rn,{content:i}),D.length>0&&n.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:D.map((b,j)=>n.jsx("img",{src:`data:${b.mimeType||"image/png"};base64,${b.data}`,alt:b.name||`图片 ${j+1}`,className:"max-w-48 max-h-48 rounded-lg object-cover cursor-pointer border border-border hover:border-primary transition-colors",onClick:()=>c({images:T,index:j})},j))}),!I&&n.jsx("div",{className:"min-w-0 overflow-hidden [&>div>*:first-child]:!mt-0",children:x?n.jsx(us,{content:t.content,groupJid:t.chat_jid,variant:"chat"}):n.jsx("p",{className:"text-[15px] leading-relaxed whitespace-pre-wrap break-words text-foreground",children:t.content})}),x&&n.jsx(ns,{runtimeIdentity:t.runtime_identity,tokenUsage:t.token_usage}),l&&n.jsx(js,{images:l.images,initialIndex:l.index,onClose:()=>c(null)}),h&&n.jsx(Es,{content:t.content,position:h,onClose:()=>d(null),chatJid:t.chat_jid,messageId:t.id})]})}if(v){if(k){const E=t.sender_name||"用户",b=((w=E[0])==null?void 0:w.toUpperCase())||"?";return n.jsxs("div",{className:"group mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1.5 lg:hidden",children:[n.jsx("div",{className:"w-6 h-6 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-foreground/70 flex-shrink-0",children:b}),n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:E}),s&&n.jsx("span",{className:"text-xs text-muted-foreground",children:N})]}),n.jsxs("div",{className:"lg:flex lg:gap-3",children:[n.jsx("div",{className:"hidden lg:block flex-shrink-0",children:n.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center text-sm font-medium text-foreground/70",children:b})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"hidden lg:flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:E}),s&&n.jsx("span",{className:"text-xs text-muted-foreground",children:N})]}),n.jsxs("div",{className:"relative",children:[D.length>0&&n.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:D.map((j,C)=>n.jsx("img",{src:`data:${j.mimeType||"image/png"};base64,${j.data}`,alt:j.name||`图片 ${C+1}`,className:"max-w-48 max-h-48 rounded-lg object-cover cursor-pointer border-2 border-primary hover:border-primary transition-colors",onClick:()=>c({images:T,index:C})},C))}),!I&&n.jsx("div",{className:"bg-card border border-border text-foreground px-4 py-2.5 rounded-2xl rounded-tl-sm shadow-sm",children:n.jsx("p",{className:"text-[15px] leading-relaxed whitespace-pre-wrap break-words",children:t.content})}),!I&&n.jsx("button",{onClick:U,className:"absolute -right-8 top-1/2 -translate-y-1/2 w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-foreground/10 lg:opacity-0 lg:group-hover:opacity-100 transition-all cursor-pointer",title:"更多","aria-label":"消息菜单",children:n.jsx(Ps,{className:"w-4 h-4"})})]})]})]}),l&&n.jsx(js,{images:l.images,initialIndex:l.index,onClose:()=>c(null)}),h&&n.jsx(Es,{content:t.content,position:h,onClose:()=>d(null),chatJid:t.chat_jid,messageId:t.id})]})}const x=r;return n.jsxs("div",{className:"group flex justify-end mb-4",children:[n.jsxs("div",{className:"flex flex-col items-end min-w-0 max-w-[75%]",children:[x&&n.jsx("span",{className:"text-xs text-muted-foreground font-medium mb-1 mr-1",children:t.sender_name||(m==null?void 0:m.display_name)||(m==null?void 0:m.username)||"我"}),n.jsxs("div",{className:"relative",children:[D.length>0&&n.jsx("div",{className:"flex flex-wrap gap-2 mb-2 justify-end",children:D.map((E,b)=>n.jsx("img",{src:`data:${E.mimeType||"image/png"};base64,${E.data}`,alt:E.name||`图片 ${b+1}`,className:"max-w-48 max-h-48 rounded-lg object-cover cursor-pointer border-2 border-primary hover:border-primary transition-colors",onClick:()=>c({images:T,index:b})},b))}),!I&&n.jsx("div",{className:"bg-muted text-foreground px-4 py-2.5 rounded-2xl rounded-tr-sm",children:n.jsx("p",{className:"text-[15px] leading-relaxed whitespace-pre-wrap break-words",children:t.content})}),!I&&n.jsx("button",{onClick:U,className:"absolute -left-8 top-1/2 -translate-y-1/2 w-6 h-6 rounded-md flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-foreground/10 lg:opacity-0 lg:group-hover:opacity-100 transition-all cursor-pointer",title:"更多","aria-label":"消息菜单",children:n.jsx(Ps,{className:"w-4 h-4"})})]}),s&&n.jsx("span",{className:"text-xs text-muted-foreground mt-1.5 mr-1",children:N})]}),l&&n.jsx(js,{images:l.images,initialIndex:l.index,onClose:()=>c(null)}),h&&n.jsx(Es,{content:t.content,position:h,onClose:()=>d(null),chatJid:t.chat_jid,messageId:t.id})]})}const q=(m==null?void 0:m.ai_name)||(f==null?void 0:f.aiName)||t.sender_name||"AI",A=(m==null?void 0:m.ai_avatar_emoji)||(f==null?void 0:f.aiAvatarEmoji),S=(m==null?void 0:m.ai_avatar_color)||(f==null?void 0:f.aiAvatarColor),y=m==null?void 0:m.ai_avatar_url;return n.jsxs("div",{className:"group mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1.5 lg:hidden",children:[n.jsx(St,{imageUrl:y,emoji:A,color:S,fallbackChar:q[0],size:"sm"}),n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:q}),s&&n.jsx("span",{className:"text-xs text-muted-foreground",children:N})]}),n.jsxs("div",{className:"lg:flex lg:gap-3",children:[n.jsx("div",{className:"hidden lg:block flex-shrink-0",children:n.jsx(St,{imageUrl:y,emoji:A,color:S,fallbackChar:q[0],size:"md"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"hidden lg:flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:q}),s&&n.jsx("span",{className:"text-xs text-muted-foreground",children:N})]}),n.jsxs("div",{className:"overflow-hidden font-serif",children:[i&&n.jsx(rn,{content:i}),D.length>0&&n.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:D.map((x,E)=>n.jsx("img",{src:`data:${x.mimeType||"image/png"};base64,${x.data}`,alt:x.name||`图片 ${E+1}`,className:"max-w-48 max-h-48 rounded-lg object-cover cursor-pointer border border-border hover:border-primary transition-colors",onClick:()=>c({images:T,index:E})},E))}),!I&&n.jsx("div",{className:"max-w-none overflow-hidden",children:n.jsx(us,{content:t.content,groupJid:t.chat_jid,variant:"chat"})})]}),n.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-xs text-muted-foreground min-h-7",children:[B&&n.jsx("span",{className:"min-w-0 truncate",children:B}),n.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5 lg:opacity-0 lg:group-hover:opacity-100 transition-opacity",children:[B&&n.jsx("span",{className:"px-0.5 text-muted-foreground/40",children:"|"}),n.jsx("button",{onClick:H,className:"h-7 px-2 rounded-md flex items-center gap-1 text-muted-foreground hover:text-foreground hover:bg-foreground/5 text-xs cursor-pointer transition-colors",title:"复制","aria-label":"复制消息",children:o?n.jsx(Ri,{className:"w-3.5 h-3.5 text-primary"}):n.jsx(Mi,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:()=>_(!0),className:"h-7 px-2 rounded-md flex items-center gap-1 text-muted-foreground hover:text-foreground hover:bg-foreground/5 text-xs max-lg:hidden cursor-pointer transition-colors",title:"分享","aria-label":"生成分享图片",children:n.jsx(jo,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:U,className:"h-7 px-2 rounded-md flex items-center gap-1 text-muted-foreground hover:text-foreground hover:bg-foreground/5 text-xs cursor-pointer transition-colors",title:"更多","aria-label":"消息菜单",children:n.jsx(Ps,{className:"w-3.5 h-3.5"})})]})]})]})]}),l&&n.jsx(js,{images:l.images,initialIndex:l.index,onClose:()=>c(null)}),h&&n.jsx(Es,{content:t.content,position:h,onClose:()=>d(null),chatJid:t.chat_jid,messageId:t.id,onShareImage:()=>_(!0)}),u&&n.jsx(g.Suspense,{children:n.jsx(fh,{onClose:()=>_(!1),message:t})})]})},(e,t)=>e.message.id===t.message.id&&e.message.chat_jid===t.message.chat_jid&&e.message.content===t.message.content&&e.message.token_usage===t.message.token_usage&&JSON.stringify(e.message.runtime_identity??null)===JSON.stringify(t.message.runtime_identity??null)&&e.showTime===t.showTime&&e.thinkingContent===t.thinkingContent&&e.isShared===t.isShared);function _h({todos:e}){const t=e.filter(r=>r.status==="completed").length,s=e.length,i=s>0?t/s*100:0;return n.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-3 mb-2",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("span",{className:"text-[13px] font-medium text-primary",children:[t,"/",s," 已完成"]}),n.jsxs("span",{className:"text-[13px] text-muted-foreground",children:[Math.round(i),"%"]})]}),n.jsx("div",{className:"h-1.5 bg-primary/10 rounded-full mb-2.5 overflow-hidden",children:n.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300",style:{width:`${i}%`}})}),n.jsx("div",{className:"space-y-1",children:e.map(r=>n.jsxs("div",{className:"flex items-start gap-2 text-[13px]",children:[n.jsx("span",{className:"flex-shrink-0 mt-0.5",children:r.status==="completed"?n.jsx(Ri,{className:"w-3.5 h-3.5 text-primary",strokeWidth:3}):r.status==="in_progress"?n.jsx(Be,{className:"w-3.5 h-3.5 animate-spin text-primary"}):n.jsx(Ol,{className:"w-3.5 h-3.5 text-muted-foreground"})}),n.jsx("span",{className:`break-words ${r.status==="completed"?"text-muted-foreground line-through":r.status==="in_progress"?"text-primary font-medium":"text-foreground"}`,children:r.content})]},r.id))})]})}function Lo({tool:e}){const t=e.isNested===!0,s=e.toolName==="Skill"?e.skillName:e.toolInputSummary;return n.jsx("div",{className:`${t?"ml-4 border-l-2 border-brand-200 pl-2":""}`,children:n.jsx("div",{className:"rounded-lg border border-brand-200 bg-brand-50/40 px-2.5 py-1.5 text-[13px] text-primary break-all",children:Va(e.toolName,s)})})}function ph({toolInput:e}){const t=[];if(Array.isArray(e.questions))for(const s of e.questions)s&&typeof s=="object"&&"question"in s&&t.push(s);else typeof e.question=="string"&&t.push({question:e.question,options:Array.isArray(e.options)?e.options:void 0});return t.length===0?null:n.jsx("div",{className:"mt-2 mb-2 space-y-2",children:t.map((s,i)=>n.jsxs("div",{className:"rounded-lg border border-brand-200 bg-brand-50/30 p-3",children:[n.jsx("div",{className:"text-sm font-medium text-foreground mb-2",children:s.question}),s.options&&s.options.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.options.map((r,o)=>n.jsx("span",{className:"inline-block px-2.5 py-1 rounded-md text-xs font-medium bg-brand-100 text-primary border border-brand-200",children:r.label||r.value||"—"},o))}),n.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"请在 Agent 终端中回复"})]},i))})}const gh={running:"执行中",completed:"已完成",error:"出错"};function nn({agent:e,groupJid:t}){const s=V(p=>p.agentStreaming[e.id]),i=e.status==="running",[r,o]=g.useState(i),[a,l]=g.useState({});g.useEffect(()=>{i&&o(!0)},[i]),g.useEffect(()=>{if(!(s!=null&&s.activeTools.length)){l({});return}const p=setInterval(()=>{const v=Date.now(),k={};for(const N of s.activeTools)k[N.toolUseId]=(v-N.startTime)/1e3;l(k)},1e3);return()=>clearInterval(p)},[s==null?void 0:s.activeTools]);const c=i?"border-blue-200/60 dark:border-blue-700/40":e.status==="error"?"border-red-200/60 dark:border-red-700/40":"border-emerald-200/60 dark:border-emerald-700/40",h=i?"bg-blue-50/40 dark:bg-blue-950/30":e.status==="error"?"bg-red-50/40 dark:bg-red-950/30":"bg-emerald-50/40 dark:bg-emerald-950/30",d=i?"hover:bg-blue-50/60 dark:hover:bg-blue-900/30":e.status==="error"?"hover:bg-red-50/60 dark:hover:bg-red-900/30":"hover:bg-emerald-50/60 dark:hover:bg-emerald-900/30",u=i?"bg-blue-500 animate-pulse":e.status==="error"?"bg-red-500":"bg-emerald-500",_=i?"text-blue-700 dark:text-blue-300":e.status==="error"?"text-red-700 dark:text-red-300":"text-emerald-700 dark:text-emerald-300",m=i?"text-blue-400 dark:text-blue-500":e.status==="error"?"text-red-400 dark:text-red-500":"text-emerald-400 dark:text-emerald-500",f=i?"border-blue-100 dark:border-blue-800/50":e.status==="error"?"border-red-100 dark:border-red-800/50":"border-emerald-100 dark:border-emerald-800/50";return n.jsxs("div",{className:`mb-3 rounded-xl border ${c} ${h} overflow-hidden`,children:[n.jsxs("button",{onClick:()=>o(!r),className:`w-full flex items-center gap-2 px-3 py-2 text-left ${d} transition-colors`,children:[n.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${u}`}),n.jsxs("span",{className:`text-xs font-medium ${_}`,children:["子 Agent: ",e.name]}),n.jsx("span",{className:`text-[11px] ${_} opacity-70`,children:gh[e.status]||e.status}),n.jsx("span",{className:"flex-1"}),r?n.jsx(Js,{className:`w-3.5 h-3.5 ${m}`}):n.jsx(ei,{className:`w-3.5 h-3.5 ${m}`})]}),r&&n.jsxs("div",{className:`px-3 pb-3 border-t ${f} space-y-2`,children:[n.jsx("p",{className:"text-[13px] text-foreground/60 mt-2 line-clamp-2",children:e.prompt}),i&&s&&n.jsxs(n.Fragment,{children:[s.isThinking&&n.jsxs("p",{className:"text-[13px] text-blue-500 dark:text-blue-400 italic flex items-center gap-1",children:["思考中",n.jsxs("span",{className:"flex gap-0.5 ml-0.5",children:[n.jsx("span",{className:"w-1 h-1 bg-blue-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),n.jsx("span",{className:"w-1 h-1 bg-blue-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),n.jsx("span",{className:"w-1 h-1 bg-blue-400 rounded-full animate-bounce"})]})]}),s.activeTools.length>0&&n.jsx("div",{className:"space-y-1.5",children:s.activeTools.filter(p=>p.toolName!=="AskUserQuestion").map(p=>n.jsx(Lo,{tool:p,localElapsed:a[p.toolUseId]},p.toolUseId))}),s.partialText&&n.jsx("div",{className:"max-w-none overflow-hidden text-sm [&>div>*:first-child]:!mt-0",children:n.jsx(us,{content:s.partialText.length>2e3?"..."+s.partialText.slice(-1500):s.partialText,groupJid:t,variant:"chat",streaming:!0})})]}),!i&&e.result_summary&&n.jsx("p",{className:"text-[13px] text-foreground/70",children:e.result_summary})]})]})}function on({streaming:e,localElapsed:t,groupJid:s,thinkingExpanded:i,setThinkingExpanded:r,thinkingRef:o,handleThinkingScroll:a}){const l=e.activeTools.filter(h=>h.toolName!=="AskUserQuestion"),c=e.activeTools.filter(h=>h.toolName==="AskUserQuestion"&&h.toolInput);return n.jsxs(n.Fragment,{children:[e.systemStatus&&n.jsxs("div",{className:"flex items-center gap-2 text-[13px] text-muted-foreground mb-2",children:[n.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-primary",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),n.jsx("span",{children:e.systemStatus==="compacting"?"上下文压缩中...":e.systemStatus})]}),e.thinkingText&&n.jsxs("div",{className:"mb-3 rounded-xl border border-amber-200/60 dark:border-amber-800/40 bg-amber-50/40 dark:bg-amber-950/30 overflow-hidden",children:[n.jsxs("button",{onClick:()=>r(!i),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-amber-50/60 dark:hover:bg-amber-900/30 transition-colors",children:[n.jsx("svg",{className:"w-4 h-4 text-amber-500 flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.455 2.456L21.75 6l-1.036.259a3.375 3.375 0 00-2.455 2.456z"})}),n.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:e.isThinking?"Reasoning...":"Reasoning"}),e.isThinking&&n.jsxs("span",{className:"flex gap-0.5 ml-0.5",children:[n.jsx("span",{className:"w-1 h-1 bg-amber-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),n.jsx("span",{className:"w-1 h-1 bg-amber-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),n.jsx("span",{className:"w-1 h-1 bg-amber-400 rounded-full animate-bounce"})]}),n.jsx("span",{className:"flex-1"}),i?n.jsx(Js,{className:"w-3.5 h-3.5 text-amber-400"}):n.jsx(ei,{className:"w-3.5 h-3.5 text-amber-400"})]}),i&&n.jsx("div",{ref:o,onScroll:a,className:"px-3 pb-3 text-sm text-amber-900/70 dark:text-amber-200/70 whitespace-pre-wrap break-words max-h-64 overflow-y-auto border-t border-amber-100 dark:border-amber-800/50",children:e.thinkingText})]}),e.activeTools.length>0&&n.jsxs("div",{className:"mb-2 space-y-1.5",children:[l.length>0&&n.jsx("div",{className:"space-y-1.5",children:l.map(h=>n.jsx(Lo,{tool:h,localElapsed:t[h.toolUseId]},h.toolUseId))}),c.map(h=>n.jsx(ph,{toolInput:h.toolInput??{}},h.toolUseId))]}),e.todos&&e.todos.length>0&&n.jsx(_h,{todos:e.todos}),e.recentEvents.length>0&&n.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-2 mb-2",children:[n.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"调用轨迹"}),n.jsx("div",{className:"space-y-0.5 max-h-28 overflow-y-auto",children:e.recentEvents.map(h=>n.jsx("div",{className:"text-[13px] text-foreground/70 break-words",children:h.text},h.id))})]}),e.activeHook&&n.jsxs("div",{className:"flex items-center gap-2 text-[13px] text-muted-foreground mb-2",children:[n.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-primary",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),n.jsxs("span",{children:["Hook: ",e.activeHook.hookName]})]}),e.partialText&&n.jsx("div",{className:"max-w-none overflow-hidden [&>div>*:first-child]:!mt-0",children:n.jsx(us,{content:e.partialText.length>3e3?"..."+e.partialText.slice(-2e3):e.partialText,groupJid:s,variant:"chat",streaming:!0})}),e.interrupted&&n.jsx("div",{className:"mt-3 pt-3 border-t border-border",children:n.jsxs("div",{className:"flex items-center gap-1.5 text-[13px] text-amber-600",children:[n.jsx(Ya,{className:"w-3.5 h-3.5"}),n.jsx("span",{children:"已中断"})]})})]})}const an=[];function mi({groupJid:e,isWaiting:t,senderName:s="AI",agentId:i}){const r=V(A=>A.streaming[e]),o=V(A=>i?A.agentStreaming[i]:void 0),a=i?o:r,l=V(A=>i?an:A.agents[e]??an),c=g.useMemo(()=>l.filter(A=>A.kind==="task"&&A.status==="running"),[l]),h=c.length>0,d=Ge(A=>A.user),u=Ge(A=>A.appearance),_=(d==null?void 0:d.ai_name)||(u==null?void 0:u.aiName)||s,m=(d==null?void 0:d.ai_avatar_emoji)||(u==null?void 0:u.aiAvatarEmoji),f=(d==null?void 0:d.ai_avatar_color)||(u==null?void 0:u.aiAvatarColor),p=d==null?void 0:d.ai_avatar_url,{mode:v}=gs(),k=v==="compact",[N,L]=g.useState(!0),D=g.useRef(null),T=g.useRef(!1),[B,I]=g.useState({}),H=g.useRef(Date.now());g.useEffect(()=>{a&&(H.current=Date.now())},[a]),g.useEffect(()=>{if(!t)return;H.current=Date.now();const A=6e4,S=18e4,y=setInterval(()=>{const w=Date.now()-H.current,x=V.getState(),b=(i?!!x.agentStreaming[i]:!!x.streaming[e])?S:A;w>b&&(V.getState().clearStreaming(e),i&&V.setState(j=>{const C={...j.agentStreaming};return delete C[i],{agentWaiting:{...j.agentWaiting,[i]:!1},agentStreaming:C}}))},1e4);return()=>clearInterval(y)},[t,e,i]),g.useEffect(()=>{if(!N||!D.current||T.current)return;const A=D.current;A.scrollTop=A.scrollHeight},[a==null?void 0:a.thinkingText,N]),g.useEffect(()=>{L(!0),T.current=!1},[e]),g.useEffect(()=>{a||(L(!0),T.current=!1)},[a]),g.useEffect(()=>{if(!(a!=null&&a.activeTools.length)){I({});return}const A=setInterval(()=>{const S=Date.now(),y={};for(const w of a.activeTools)y[w.toolUseId]=(S-w.startTime)/1e3;I(y)},1e3);return()=>clearInterval(A)},[a==null?void 0:a.activeTools]);const U=()=>{if(!D.current)return;const A=D.current,S=A.scrollHeight-A.scrollTop-A.clientHeight<30;T.current=!S},q=a&&(a.partialText||a.thinkingText||a.activeTools.length>0||a.activeHook||a.systemStatus||a.recentEvents.length>0||a.todos&&a.todos.length>0)||h;return!t&&!q?null:t&&!q?k?n.jsxs("div",{className:"mb-2 border-b border-border pb-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:n.jsx("span",{className:"text-xs font-semibold text-primary",children:_})}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"w-1.5 h-1.5 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),n.jsx("span",{className:"w-1.5 h-1.5 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),n.jsx("span",{className:"w-1.5 h-1.5 bg-brand-400 rounded-full animate-bounce"}),n.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"正在思考..."})]}),n.jsx(ns,{runtimeIdentity:a==null?void 0:a.runtimeIdentity,tokenUsage:a==null?void 0:a.tokenUsage,className:"mt-2"})]}):n.jsxs("div",{className:"max-w-4xl mx-auto w-full px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1.5 lg:hidden",children:[n.jsx(St,{imageUrl:p,emoji:m,color:f,fallbackChar:_[0],size:"sm"}),n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:_})]}),n.jsxs("div",{className:"lg:flex lg:gap-3",children:[n.jsx("div",{className:"hidden lg:block flex-shrink-0",children:n.jsx(St,{imageUrl:p,emoji:m,color:f,fallbackChar:_[0],size:"md"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"hidden lg:flex items-center gap-2 mb-1",children:n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:_})}),n.jsxs("div",{className:"bg-surface rounded-xl border border-border/60 px-5 py-4 font-serif shadow-card",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"w-2 h-2 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),n.jsx("span",{className:"w-2 h-2 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),n.jsx("span",{className:"w-2 h-2 bg-brand-400 rounded-full animate-bounce"}),n.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"正在思考..."})]}),n.jsx(ns,{runtimeIdentity:a==null?void 0:a.runtimeIdentity,tokenUsage:a==null?void 0:a.tokenUsage,className:"mt-3"})]})]})]})]}):!a&&!h?null:k?n.jsxs("div",{className:"mb-2 border-b border-border pb-2",children:[n.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[n.jsx("span",{className:"text-xs font-semibold text-primary",children:_}),(a==null?void 0:a.isThinking)&&n.jsxs("span",{className:"flex gap-0.5 ml-0.5",children:[n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce"})]})]}),n.jsxs("div",{className:"min-w-0 overflow-hidden",children:[a&&n.jsx(on,{streaming:a,localElapsed:B,groupJid:e,thinkingExpanded:N,setThinkingExpanded:A=>{L(A),A&&(T.current=!1)},thinkingRef:D,handleThinkingScroll:U}),n.jsx(ns,{runtimeIdentity:a==null?void 0:a.runtimeIdentity,tokenUsage:a==null?void 0:a.tokenUsage,className:"mt-3"}),c.map(A=>n.jsx(nn,{agent:A,groupJid:e},A.id))]})]}):n.jsxs("div",{className:"max-w-4xl mx-auto w-full px-4 py-3",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1.5 lg:hidden",children:[n.jsx(St,{imageUrl:p,emoji:m,color:f,fallbackChar:_[0],size:"sm"}),n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:_}),(a==null?void 0:a.isThinking)&&n.jsxs("span",{className:"flex gap-0.5 ml-1",children:[n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce"})]})]}),n.jsxs("div",{className:"lg:flex lg:gap-3",children:[n.jsx("div",{className:"hidden lg:block flex-shrink-0",children:n.jsx(St,{imageUrl:p,emoji:m,color:f,fallbackChar:_[0],size:"md"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"hidden lg:flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:_}),(a==null?void 0:a.isThinking)&&n.jsxs("span",{className:"flex gap-0.5 ml-1",children:[n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.3s]"}),n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce [animation-delay:-0.15s]"}),n.jsx("span",{className:"w-1 h-1 bg-brand-400 rounded-full animate-bounce"})]})]}),n.jsxs("div",{className:"bg-surface rounded-xl border border-border/60 px-5 py-4 overflow-hidden font-serif shadow-card",children:[a&&n.jsx(on,{streaming:a,localElapsed:B,groupJid:e,thinkingExpanded:N,setThinkingExpanded:A=>{L(A),A&&(T.current=!1)},thinkingRef:D,handleThinkingScroll:U}),n.jsx(ns,{runtimeIdentity:a==null?void 0:a.runtimeIdentity,tokenUsage:a==null?void 0:a.tokenUsage,className:"mt-3"}),c.map(A=>n.jsx(nn,{agent:A,groupJid:e},A.id))]})]})]})]})}const vh=[{icon:El,title:"分析代码",desc:"帮我阅读和分析一段代码的逻辑"},{icon:Al,title:"自动化脚本",desc:"编写一个自动化处理任务的脚本"},{icon:Ga,title:"技术概念",desc:"用简单的语言解释一个技术概念"},{icon:Vl,title:"调试问题",desc:"帮我定位和修复一个 Bug"}];function ln({messages:e,loading:t,hasMore:s,onLoadMore:i,scrollTrigger:r,groupJid:o,isWaiting:a,onInterrupt:l,agentId:c,onSend:h}){const{mode:d}=gs(),u=V(C=>C.thinkingCache??{}),_=V(C=>{var P;return!!((P=C.groups[o??""])!=null&&P.is_shared)}),m=V(C=>o?C.agents[o]:void 0),f=g.useMemo(()=>(m??[]).filter(C=>C.kind==="spawn"&&C.status==="running"),[m]),p=Ge(C=>C.user),v=Ge(C=>C.appearance),k=(p==null?void 0:p.ai_name)||(v==null?void 0:v.aiName)||"AI 助手",N=(p==null?void 0:p.ai_avatar_emoji)||(v==null?void 0:v.aiAvatarEmoji),L=(p==null?void 0:p.ai_avatar_color)||(v==null?void 0:v.aiAvatarColor),D=p==null?void 0:p.ai_avatar_url,T=g.useRef(null),B=g.useRef({autoScroll:!0,atTop:!1}),[I,H]=g.useState(!0),[U,q]=g.useState(!1),A=g.useRef(e.length),S=g.useMemo(()=>{const C=e.reduce((K,ne)=>{const Q=new Date(ne.timestamp).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"});return K[Q]||(K[Q]=[]),K[Q].push(ne),K},{}),P=[];return Object.entries(C).forEach(([K,ne])=>{P.push({type:"date",content:K}),ne.forEach(Q=>{Q.sender==="__system__"?Q.content==="context_reset"?P.push({type:"divider",content:"上下文已清除"}):Q.content==="query_interrupted"?P.push({type:"divider",content:"已中断"}):Q.content.startsWith("agent_error:")?P.push({type:"error",content:Q.content.slice(12)}):Q.content.startsWith("agent_max_retries:")?P.push({type:"error",content:Q.content.slice(18)}):Q.content.startsWith("system_info:")&&P.push({type:"divider",content:Q.content.slice(12)}):!Q.is_from_me&&/^\/(sw|spawn)\s+/i.test(Q.content)?P.push({type:"spawn",content:Q.content.replace(/^\/(sw|spawn)\s+/i,"")}):P.push({type:"message",content:Q})})}),P},[e]),y=nh({count:S.length,getScrollElement:()=>T.current,initialOffset:S.length>0?99999999:0,getItemKey:C=>{const P=S[C];if(!P)return C;switch(P.type){case"date":return`date-${P.content}`;case"divider":return`div-${C}`;case"spawn":return`spawn-${C}`;case"error":return`err-${C}`;case"message":return Ur(P.content)}},estimateSize:C=>{const P=S[C];if(!P)return 100;switch(P.type){case"date":return 48;case"divider":case"spawn":case"error":return 56;case"message":{const K=P.content.content.length;return P.content.is_from_me?Math.max(80,Math.ceil(K/40)*24+80):Math.max(48,Math.min(200,Math.ceil(K/80)*24+40))}default:return 100}},overscan:window.innerWidth<1024?12:8});g.useEffect(()=>{const C=T.current;if(!C)return;const P=()=>{const{scrollTop:K,scrollHeight:ne,clientHeight:Q}=C,le=ne-K-Q<100,ue=K<50;B.current.autoScroll!==le&&(B.current.autoScroll=le,H(le)),B.current.atTop!==ue&&(B.current.atTop=ue,q(ue)),K<100&&s&&!t&&i()};return C.addEventListener("scroll",P),()=>C.removeEventListener("scroll",P)},[s,t,i,o]),g.useEffect(()=>{I&&e.length>A.current&&requestAnimationFrame(()=>{var C;(C=T.current)==null||C.scrollTo({top:T.current.scrollHeight,behavior:"smooth"})}),A.current=e.length},[e.length,I]),g.useEffect(()=>{r&&r>0&&(H(!0),requestAnimationFrame(()=>{var C;(C=T.current)==null||C.scrollTo({top:T.current.scrollHeight,behavior:"smooth"})}))},[r]);const w=g.useRef(S.length>0);g.useLayoutEffect(()=>{if(!w.current&&S.length>0){w.current=!0,A.current=e.length,y.scrollToIndex(S.length-1,{align:"end"}),T.current&&(T.current.scrollTop=T.current.scrollHeight),H(!0);let C;const P=K=>{C=requestAnimationFrame(()=>{T.current&&(T.current.scrollTop=T.current.scrollHeight),K<3&&P(K+1)})};return P(0),()=>cancelAnimationFrame(C)}},[S.length,y,e.length]),g.useEffect(()=>{if(S.length===0)return;const C=[];for(const P of[50,150,300,500])C.push(window.setTimeout(()=>{const K=T.current;if(!K)return;K.scrollHeight-K.scrollTop-K.clientHeight>100&&(K.scrollTop=K.scrollHeight)},P));return()=>C.forEach(clearTimeout)},[S.length]);const x=V(C=>c?!!C.agentStreaming[c]:!!C.streaming[o??""]);g.useEffect(()=>{if(!I||!x)return;const C=setInterval(()=>{var P;(P=T.current)==null||P.scrollTo({top:T.current.scrollHeight})},100);return()=>clearInterval(C)},[x,I]);const E=g.useCallback(()=>{var C;(C=T.current)==null||C.scrollTo({top:0,behavior:"smooth"})},[]),b=g.useCallback(()=>{const C=T.current;C&&C.scrollTo({top:C.scrollHeight,behavior:"smooth"})},[]),j=e.length>0;return n.jsxs("div",{className:"relative flex-1 overflow-hidden overflow-x-hidden",children:[n.jsx("div",{ref:T,className:"message-scroll-area h-full overflow-y-auto overflow-x-hidden py-6",children:n.jsxs("div",{className:d==="compact"?"mx-auto px-4 min-w-0":"max-w-4xl mx-auto px-4 min-w-0",children:[t&&s&&n.jsx("div",{className:"flex justify-center py-4",children:n.jsx(Be,{className:"animate-spin text-primary",size:24})}),n.jsx("div",{style:{height:`${y.getTotalSize()}px`,width:"100%",position:"relative"},children:y.getVirtualItems().map(C=>{const P=S[C.index];if(!P)return null;if(P.type==="date")return n.jsx("div",{ref:y.measureElement,"data-index":C.index,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${C.start}px)`},children:n.jsx("div",{className:"flex justify-center my-6",children:n.jsx("span",{className:"bg-surface px-4 py-1 rounded-full text-xs text-muted-foreground border border-border",children:P.content})})},C.key);if(P.type==="divider")return n.jsx("div",{ref:y.measureElement,"data-index":C.index,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${C.start}px)`},children:n.jsxs("div",{className:"flex items-center gap-3 my-6 px-4",children:[n.jsx("div",{className:"flex-1 border-t border-amber-300"}),n.jsx("span",{className:"text-xs text-amber-600 whitespace-pre-wrap",children:P.content}),n.jsx("div",{className:"flex-1 border-t border-amber-300"})]})},C.key);if(P.type==="spawn")return n.jsx("div",{ref:y.measureElement,"data-index":C.index,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${C.start}px)`},children:n.jsx("div",{className:"flex items-center gap-2 my-4 px-4",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-violet-50 dark:bg-violet-950/40 text-xs text-violet-600 dark:text-violet-400 border border-violet-200 dark:border-violet-800",children:[n.jsx("span",{children:"⚡"}),n.jsx("span",{className:"font-medium",children:"并行任务"}),n.jsx("span",{className:"text-violet-400 dark:text-violet-500",children:"|"}),n.jsx("span",{className:"max-w-[400px] truncate",children:P.content})]})})},C.key);if(P.type==="error")return n.jsx("div",{ref:y.measureElement,"data-index":C.index,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${C.start}px)`},children:n.jsxs("div",{className:"flex items-center gap-3 my-6 px-4",children:[n.jsx("div",{className:"flex-1 border-t border-red-300"}),n.jsxs("span",{className:"text-xs text-red-600 whitespace-pre-wrap flex items-center gap-1",children:[n.jsx(Xa,{size:14}),P.content]}),n.jsx("div",{className:"flex-1 border-t border-red-300"})]})},C.key);const K=P.content;return n.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${C.start}px)`},ref:y.measureElement,"data-index":C.index,children:n.jsx(mh,{message:K,showTime:!0,thinkingContent:u[Ur(K)],isShared:_})},C.key)})}),e.length===0&&!t&&n.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-6",children:n.jsxs("div",{className:"max-w-lg w-full space-y-8",children:[n.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[n.jsxs("div",{className:"relative w-16 h-16",children:[n.jsx("div",{className:"absolute inset-0 rounded-full bg-brand-200/40 dark:bg-brand-500/20 animate-[breathe_3s_ease-in-out_infinite]"}),n.jsx("div",{className:"absolute inset-[-6px] animate-[orbit_6s_linear_infinite]",children:n.jsx("div",{className:"w-2 h-2 rounded-full bg-brand-400"})}),n.jsx("div",{className:"relative w-16 h-16 animate-[float_4s_ease-in-out_infinite]",children:n.jsx(St,{imageUrl:D,emoji:N,color:L,fallbackChar:k[0],size:"lg",className:"!w-16 !h-16 !text-2xl"})})]}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-2xl font-semibold text-foreground",children:"你好,有什么可以帮你?"}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["我是 ",k,",你的 AI 助手。选择下方话题快速开始,或直接输入你的问题。"]})]})]}),h&&n.jsx("div",{className:"grid grid-cols-2 gap-3",children:vh.map(C=>n.jsxs("button",{onClick:()=>h(C.desc),className:"group text-left p-4 rounded-2xl border border-border/60 bg-muted/30 hover:bg-muted/60 hover:border-border transition-all active:scale-[0.98] cursor-pointer",children:[n.jsx(C.icon,{className:"w-5 h-5 mb-2 text-muted-foreground",strokeWidth:1.75}),n.jsx("span",{className:"text-sm font-medium text-foreground block",children:C.title}),n.jsx("span",{className:"text-xs text-muted-foreground mt-0.5 block",children:C.desc})]},C.title))})]})}),o&&!c&&n.jsx(mi,{groupJid:o,isWaiting:!!a}),o&&c&&n.jsx(mi,{groupJid:o,isWaiting:!!a,agentId:c}),o&&!c&&f.map(C=>n.jsx(mi,{groupJid:o,isWaiting:!0,agentId:C.id,senderName:C.name},C.id))]})}),a&&l&&n.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10",children:n.jsxs("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-xs text-muted-foreground hover:text-red-600 dark:hover:text-red-400 bg-card/90 backdrop-blur-sm hover:bg-red-50 dark:hover:bg-red-950/40 rounded-full border border-border shadow-sm transition-colors cursor-pointer",children:[n.jsx(Nl,{className:"w-3 h-3"}),"中断"]})}),j&&n.jsxs("div",{className:"absolute right-4 bottom-4 flex flex-col gap-1.5",children:[!U&&n.jsx("button",{onClick:E,className:"w-8 h-8 rounded-full bg-foreground/5 backdrop-blur-sm flex items-center justify-center text-muted-foreground/60 hover:text-foreground hover:bg-foreground/10 transition-all cursor-pointer",title:"回到顶部",children:n.jsx(Js,{className:"w-4 h-4"})}),!I&&n.jsx("button",{onClick:b,className:"w-8 h-8 rounded-full bg-foreground/5 backdrop-blur-sm flex items-center justify-center text-muted-foreground/60 hover:text-foreground hover:bg-foreground/10 transition-all cursor-pointer",title:"回到底部",children:n.jsx(ei,{className:"w-4 h-4"})})]})]})}function xh(){const[e,t]=g.useState(0);return g.useEffect(()=>{const s=window.visualViewport;if(!s)return;const i=()=>{const o=Math.max(0,window.innerHeight-s.height);t(o),document.documentElement.style.setProperty("--keyboard-height",`${o}px`)};s.addEventListener("resize",i),s.addEventListener("scroll",i);const r=o=>{const a=o.target;(a instanceof HTMLTextAreaElement||a instanceof HTMLInputElement)&&setTimeout(()=>{a.scrollIntoView({behavior:"smooth",block:"nearest"})},300)};return document.addEventListener("focusin",r),()=>{s.removeEventListener("resize",i),s.removeEventListener("scroll",i),document.removeEventListener("focusin",r)}},[]),{keyboardHeight:e,isKeyboardVisible:e>0}}const bh=5*1024*1024;function hn({onSend:e,groupJid:t,disabled:s=!1,onResetSession:i,onToggleTerminal:r}){const[o,a]=g.useState(""),[l,c]=g.useState(!1),[h,d]=g.useState([]),[u,_]=g.useState([]),[m,f]=g.useState(!1),[p,v]=g.useState(null),k=g.useRef(null),N=g.useRef(null),L=g.useRef(null),D=g.useRef(null),T=g.useRef(void 0),B=g.useRef(t),{uploadFiles:I,uploading:H,uploadProgress:U}=ps(),{drafts:q,saveDraft:A,clearDraft:S}=V(),{mode:y}=gs(),w=y==="compact";xh(),g.useEffect(()=>{if(B.current&&B.current!==t){const W=o.trim();W?A(B.current,W):S(B.current)}B.current=t;const F=t&&q[t]||"";a(F),T.current&&(clearTimeout(T.current),T.current=void 0)},[t]),g.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const x=g.useCallback(F=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{t&&A(t,F.trim())},300)},[t,A]);g.useLayoutEffect(()=>{const F=k.current;if(!F)return;const W=F.style.overflow;F.style.overflow="hidden",F.style.height="0px";const se=F.scrollHeight,oe=24,J=oe*6,ee=Math.max(oe,Math.min(se,J));F.style.height=`${ee}px`,F.style.overflow=ee>=J?"auto":W||""},[o]);const E=g.useRef(!1),b=g.useRef(0),j=F=>{if(!(E.current||F.nativeEvent.isComposing)&&F.key==="Enter"&&!F.shiftKey){if(Date.now()-b.current<100)return;F.preventDefault(),C()}},C=async()=>{const F=o.trim(),W=h.length>0,se=u.length>0;if(!(!F&&!W&&!se)&&!(s||m)){f(!0),v(null);try{let oe=F;if(W){const be=`[我上传了以下文件到工作区,请查看并使用]
|
|
101
|
+
${h.map(qe=>`- ${qe.label}`).join(`
|
|
102
|
+
`)}`;oe=oe?`${be}
|
|
103
|
+
|
|
104
|
+
${oe}`:be,d([])}const J=se?u.map(ee=>({data:ee.data,mimeType:ee.mimeType})):void 0;e(oe,J),Za(),a(""),t&&S(t),T.current&&(clearTimeout(T.current),T.current=void 0),se&&(u.forEach(ee=>URL.revokeObjectURL(ee.preview)),_([]))}catch{v("发送失败,请重试"),setTimeout(()=>v(null),3e3)}finally{f(!1)}}},P=async F=>{if(!t)return;const W=F.target.files;if(W&&W.length>0){const se=Array.from(W);c(!1);const oe=[],J=[];if(se.forEach(ee=>{ee.type.startsWith("image/")?oe.push(ee):J.push(ee)}),oe.length>0){const ee=[];for(const be of oe)try{const qe=await ne(be);ee.push({name:be.name,data:qe,mimeType:be.type,preview:URL.createObjectURL(be)})}catch{}_(be=>[...be,...ee])}if(J.length>0&&await I(t,J)){const be=J.map(qe=>({label:qe.webkitRelativePath||qe.name}));d(qe=>[...qe,...be])}N.current&&(N.current.value="")}},K=async F=>{const W=F.target.files;if(W&&W.length>0){const se=Array.from(W);c(!1);const oe=[];for(const J of se)if(J.type.startsWith("image/"))try{const ee=await ne(J);oe.push({name:J.name,data:ee,mimeType:J.type,preview:URL.createObjectURL(J)})}catch{}_(J=>[...J,...oe]),D.current&&(D.current.value="")}},ne=F=>F.size>bh?Promise.reject(new Error(`图片 ${F.name} 超过 5MB 限制 (${(F.size/1024/1024).toFixed(1)}MB)`)):new Promise((W,se)=>{const oe=new FileReader;oe.onload=()=>{const ee=oe.result.split(",")[1];W(ee)},oe.onerror=se,oe.readAsDataURL(F)}),Q=async F=>{var oe;const W=(oe=F.clipboardData)==null?void 0:oe.items;if(!W)return;const se=[];for(let J=0;J<W.length;J++)W[J].type.startsWith("image/")&&se.push(W[J]);if(se.length>0){F.preventDefault();const J=[];for(const ee of se){const be=ee.getAsFile();if(be)try{const qe=await ne(be);J.push({name:be.name||`pasted-${Date.now()}.png`,data:qe,mimeType:be.type,preview:URL.createObjectURL(be)})}catch{}}_(ee=>[...ee,...J])}},le=async F=>{if(!t)return;const W=F.target.files;if(W&&W.length>0){const se=Array.from(W);if(c(!1),await I(t,se)){const J=se.map(ee=>({label:ee.webkitRelativePath||ee.name}));d(ee=>[...ee,...J])}L.current&&(L.current.value="")}},ue=F=>{d(W=>W.filter((se,oe)=>oe!==F))},Ce=F=>{_(W=>{const se=W[F];return se&&URL.revokeObjectURL(se.preview),W.filter((oe,J)=>J!==F)})},$e=()=>{d([])},Y=()=>{u.forEach(F=>URL.revokeObjectURL(F.preview)),_([])},te=(o.trim().length>0||h.length>0||u.length>0)&&!m,ve=U&&U.totalBytes>0?Math.round(U.uploadedBytes/U.totalBytes*100):0;return n.jsxs("div",{className:"pt-1 pb-3 bg-surface dark:bg-background max-lg:bg-background/60 max-lg:backdrop-blur-xl max-lg:saturate-[1.8] max-lg:border-t max-lg:border-border/40",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px), var(--keyboard-height, 0px))"},children:[n.jsxs("div",{className:w?"mx-auto px-4":"max-w-4xl mx-auto px-4 lg:pl-[60px]",children:[H&&U&&n.jsxs("div",{className:`mb-2 px-4 py-2.5 ${w?"bg-surface border border-border":"bg-surface rounded-xl border border-border shadow-sm"}`,children:[n.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[n.jsx("span",{className:"text-xs text-foreground/70 truncate max-w-[65%]",children:U.currentFile||"完成"}),n.jsxs("span",{className:"text-xs text-muted-foreground",children:[U.completed,"/",U.total," · ",ve,"%"]})]}),n.jsx("div",{className:"w-full h-1.5 bg-muted rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300 ease-out",style:{width:`${ve}%`}})})]}),n.jsxs("div",{className:w?"bg-surface border border-border rounded-lg":"bg-surface rounded-2xl border border-border shadow-sm",children:[p&&n.jsx("div",{className:`px-4 py-2 bg-red-50 dark:bg-red-950/40 text-red-600 dark:text-red-400 text-xs font-medium border-b border-red-100 dark:border-red-800 flex items-center gap-2 ${w?"rounded-t-lg":"rounded-t-2xl"}`,children:n.jsx("span",{children:p})}),u.length>0&&n.jsxs("div",{className:"px-3 pt-2.5 pb-1 border-b border-border",children:[n.jsxs("div",{className:"flex items-center gap-1 mb-1.5",children:[n.jsx(Li,{className:"w-3 h-3 text-muted-foreground"}),n.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["已添加 ",u.length," 张图片"]}),n.jsx("button",{onClick:Y,className:"ml-auto text-[11px] text-muted-foreground hover:text-foreground/70 cursor-pointer",children:"清空"})]}),n.jsx("div",{className:"flex flex-wrap gap-2 pb-1.5",children:u.map((F,W)=>n.jsxs("div",{className:"relative group",children:[n.jsx("img",{src:F.preview,alt:F.name,className:"w-16 h-16 object-cover rounded-lg border border-border"}),n.jsx("button",{onClick:()=>Ce(W),className:"absolute -top-1.5 -right-1.5 w-5 h-5 rounded-full bg-foreground/70 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer hover:bg-foreground/90","aria-label":"移除图片",children:n.jsx(st,{className:"w-3 h-3"})})]},W))})]}),h.length>0&&n.jsxs("div",{className:"px-3 pt-2.5 pb-1 border-b border-border",children:[n.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[n.jsx(Gr,{className:"w-3 h-3 text-muted-foreground"}),n.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["已上传 ",h.length," 个文件,发送时将告知 AI"]}),n.jsx("button",{onClick:$e,className:"ml-auto text-[11px] text-muted-foreground hover:text-foreground/70 cursor-pointer",children:"清空"})]}),n.jsx("div",{className:"flex flex-wrap gap-1 pb-1",children:h.map((F,W)=>n.jsxs("span",{className:"inline-flex items-center gap-1 max-w-[200px] px-2 py-0.5 bg-brand-50 text-primary text-[11px] rounded-md",children:[n.jsx("span",{className:"truncate",children:F.label}),n.jsx("button",{onClick:()=>ue(W),className:"flex-shrink-0 hover:text-primary cursor-pointer p-1 min-w-[28px] min-h-[28px] flex items-center justify-center","aria-label":"移除文件",children:n.jsx(st,{className:"w-3.5 h-3.5"})})]},W))})]}),l&&t&&n.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2.5 pb-1.5 border-b border-border",children:[n.jsxs("button",{onClick:()=>{var F;return(F=D.current)==null?void 0:F.click()},className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-purple-700 dark:text-purple-300 bg-purple-50 dark:bg-purple-950/40 hover:bg-purple-100 dark:hover:bg-purple-900/40 rounded-lg transition-colors cursor-pointer",children:[n.jsx(Li,{className:"w-3.5 h-3.5"}),"添加图片"]}),n.jsxs("button",{onClick:()=>{var F;return(F=N.current)==null?void 0:F.click()},disabled:H,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-primary bg-brand-50 hover:bg-brand-100 rounded-lg transition-colors cursor-pointer disabled:opacity-40",children:[n.jsx(Fl,{className:"w-3.5 h-3.5"}),"上传文件"]}),n.jsxs("button",{onClick:()=>{var F;return(F=L.current)==null?void 0:F.click()},disabled:H,className:"hidden lg:flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-foreground/70 bg-muted hover:bg-muted/80 rounded-lg transition-colors cursor-pointer disabled:opacity-40",children:[n.jsx(Eo,{className:"w-3.5 h-3.5"}),"上传文件夹"]})]}),n.jsx("div",{className:"px-4 pt-3 pb-1",children:n.jsx("textarea",{ref:k,value:o,onChange:F=>{a(F.target.value),x(F.target.value)},onKeyDown:j,onCompositionStart:()=>{E.current=!0},onCompositionEnd:()=>{E.current=!1,b.current=Date.now()},onPaste:Q,placeholder:"输入消息...",disabled:s,className:"w-full text-base leading-6 resize-none focus:outline-none placeholder:text-muted-foreground disabled:opacity-50 disabled:cursor-not-allowed bg-transparent",rows:1,style:{minHeight:"28px",maxHeight:"144px"}})}),n.jsxs("div",{className:"flex items-center px-2 pb-2.5",children:[n.jsxs("div",{className:"flex items-center gap-0.5",children:[t&&n.jsx("button",{type:"button",onClick:()=>c(!l),disabled:H,className:`w-10 h-10 rounded-lg flex items-center justify-center transition-all cursor-pointer ${l?"bg-brand-50 text-primary":"hover:bg-muted text-muted-foreground hover:text-foreground/70"} ${H?"opacity-40 pointer-events-none":""}`,title:"添加文件","aria-label":"添加文件",children:n.jsx(Gr,{className:"w-4.5 h-4.5"})}),i&&n.jsx("button",{type:"button",onClick:i,className:"w-10 h-10 rounded-lg flex items-center justify-center hover:bg-amber-50 dark:hover:bg-amber-950/40 text-muted-foreground hover:text-amber-600 dark:hover:text-amber-400 transition-all cursor-pointer",title:"清除上下文",children:n.jsx(Il,{className:"w-4.5 h-4.5"})}),r&&n.jsx("button",{type:"button",onClick:r,className:"w-10 h-10 rounded-lg flex items-center justify-center hover:bg-brand-50 text-muted-foreground hover:text-primary transition-all cursor-pointer",title:"终端","aria-label":"终端",children:n.jsx(Ul,{className:"w-4.5 h-4.5"})})]}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{onClick:C,disabled:!te||s||m,className:`w-10 h-10 rounded-full flex items-center justify-center transition-all cursor-pointer active:scale-90 ${te&&!s&&!m?"bg-primary text-white hover:bg-primary/90 max-lg:shadow-[0_2px_8px_rgba(249,115,22,0.3)]":"bg-muted text-muted-foreground"}`,children:m?n.jsx(Be,{className:"w-4.5 h-4.5 animate-spin"}):n.jsx(Pl,{className:"w-4.5 h-4.5"})})]})]})]}),n.jsx("input",{ref:D,type:"file",accept:"image/*",multiple:!0,onChange:K,className:"hidden"}),n.jsx("input",{ref:N,type:"file",multiple:!0,onChange:P,className:"hidden",disabled:H}),n.jsx("input",{ref:L,type:"file",webkitdirectory:"",onChange:le,className:"hidden",disabled:H})]})}function Bo(e,t){const s=URL.createObjectURL(e),i=document.createElement("a");i.href=s,i.download=t,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(s),3e3)}async function Sh(e,t){const s=e.startsWith("http")?e:go(e),i=await fetch(s,{credentials:"include"});if(!i.ok)throw new Error(`下载失败: ${i.status}`);const r=await i.blob();Bo(r,t)}async function gf(e,t){const i=await(await fetch(e)).blob();Bo(i,t)}function wh({groupJid:e}){const[t,s]=g.useState(!1),i=g.useRef(null),r=g.useRef(null),{uploadFiles:o,uploading:a,uploadProgress:l}=ps(),c=f=>{f.preventDefault(),f.stopPropagation(),s(!0)},h=f=>{f.preventDefault(),f.stopPropagation(),s(!1)},d=async f=>{f.preventDefault(),f.stopPropagation(),s(!1);const p=f.dataTransfer.files;p.length>0&&await o(e,Array.from(p))},u=async f=>{const p=f.target.files;p&&p.length>0&&(await o(e,Array.from(p)),i.current&&(i.current.value=""))},_=async f=>{const p=f.target.files;p&&p.length>0&&(await o(e,Array.from(p)),r.current&&(r.current.value=""))},m=l&&l.totalBytes>0?Math.round(l.uploadedBytes/l.totalBytes*100):0;return n.jsx("div",{className:"space-y-2",children:n.jsxs("div",{onDragOver:c,onDragLeave:h,onDrop:d,className:`relative border-2 border-dashed rounded-lg p-3 transition-all ${t?"border-primary bg-brand-50":"border-border"} ${a?"pointer-events-none":""}`,children:[n.jsx("input",{ref:i,type:"file",multiple:!0,onChange:u,className:"hidden",disabled:a}),n.jsx("input",{ref:r,type:"file",webkitdirectory:"",onChange:_,className:"hidden",disabled:a}),a&&l?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[n.jsx("span",{className:"truncate max-w-[60%]",children:l.currentFile||"完成"}),n.jsxs("span",{children:[l.completed,"/",l.total," 个文件"]})]}),n.jsx("div",{className:"w-full h-2 bg-muted rounded-full overflow-hidden",children:n.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300 ease-out",style:{width:`${m}%`}})}),n.jsxs("p",{className:"text-[11px] text-muted-foreground text-center",children:[m,"%"]})]}):n.jsxs("div",{className:"flex flex-col items-center gap-2 text-center py-1",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:t?"释放以上传":"拖拽文件到这里,或"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("button",{onClick:()=>{var f;return(f=i.current)==null?void 0:f.click()},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-primary bg-brand-50 hover:bg-brand-100 rounded-md transition-colors cursor-pointer",children:[n.jsx(jl,{className:"w-3.5 h-3.5"}),"上传文件"]}),n.jsxs("button",{onClick:()=>{var f;return(f=r.current)==null?void 0:f.click()},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-foreground bg-muted hover:bg-muted/80 rounded-md transition-colors cursor-pointer",children:[n.jsx(Eo,{className:"w-3.5 h-3.5"}),"上传文件夹"]})]})]})]})})}const Er=new Set(["png","jpg","jpeg","gif","svg","webp","bmp","ico"]),qs=new Set(["txt","md","json","js","ts","jsx","tsx","css","html","xml","py","go","rs","java","c","cpp","h","sh","yaml","yml","toml","ini","conf","log","csv","svg"]),yh=new Set(["js","ts","jsx","tsx","py","go","rs","java","c","cpp","h","sh","css","html","xml","yaml","yml","toml"]),Ch=new Set(["zip","tar","gz","7z","rar","bz2","xz"]);function jr({name:e}){var s;const t=((s=e.split(".").pop())==null?void 0:s.toLowerCase())||"";return Er.has(t)?n.jsx(Li,{className:"w-4 h-4 text-pink-500"}):Ch.has(t)?n.jsx(sl,{className:"w-4 h-4 text-amber-500"}):t==="pdf"?n.jsx(Is,{className:"w-4 h-4 text-red-500"}):t==="json"?n.jsx(Xr,{className:"w-4 h-4 text-yellow-600"}):t==="md"?n.jsx(Is,{className:"w-4 h-4 text-blue-500"}):yh.has(t)?n.jsx(Xr,{className:"w-4 h-4 text-emerald-500"}):qs.has(t)?n.jsx(Is,{className:"w-4 h-4 text-muted-foreground"}):n.jsx(il,{className:"w-4 h-4 text-muted-foreground"})}function Pi(e){var t;return((t=e.split(".").pop())==null?void 0:t.toLowerCase())||""}function kh(e,t){const s=Pi(e);return Er.has(s)||qs.has(s)&&!t}function Nh(e){if(!e||e<=0)return"0 B";const t=1024,s=["B","KB","MB","GB","TB"],i=Math.min(Math.floor(Math.log(e)/Math.log(t)),s.length-1);return`${(e/Math.pow(t,i)).toFixed(1)} ${s[i]}`}function Eh({groupJid:e,file:t,onClose:s}){g.useEffect(()=>{const r=o=>{o.key==="Escape"&&s()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[s]);const i=go(`/api/groups/${encodeURIComponent(e)}/files/preview/${xo(t.path)}`);return Yt.createPortal(n.jsxs("div",{className:"fixed inset-0 z-50 bg-black/80 flex items-center justify-center p-4",onClick:s,children:[n.jsx("button",{className:"absolute top-4 right-4 text-white/70 hover:text-white transition-colors p-2 cursor-pointer z-10",onClick:s,"aria-label":"关闭预览",children:n.jsx(st,{className:"w-8 h-8"})}),n.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white/70 text-sm bg-black/50 px-3 py-1 rounded-full",children:t.name}),n.jsx("img",{src:i,alt:t.name,className:"max-w-full max-h-full object-contain rounded-lg",onClick:r=>r.stopPropagation()})]}),document.body)}function jh({groupJid:e,file:t,onClose:s}){const{getFileContent:i,saveFileContent:r}=ps(),[o,a]=g.useState(""),[l,c]=g.useState(!0),[h,d]=g.useState(!1),[u,_]=g.useState(!1);g.useEffect(()=>{const f=v=>{v.key==="Escape"&&s()},p=v=>{(v.metaKey||v.ctrlKey)&&v.key==="s"&&(v.preventDefault(),m())};return window.addEventListener("keydown",f),window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",f),window.removeEventListener("keydown",p)}},[s,o,u]),g.useEffect(()=>{let f=!1;return(async()=>{c(!0);const p=await i(e,t.path);!f&&p!==null&&a(p),f||c(!1)})(),()=>{f=!0}},[e,t.path,i]);const m=async()=>{if(!u||h)return;d(!0);const f=await r(e,t.path,o);d(!1),f&&_(!1)};return Yt.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-3 lg:p-6",onClick:s,children:n.jsxs("div",{className:"bg-surface rounded-xl shadow-xl w-full max-w-4xl h-[85vh] supports-[height:100dvh]:h-[85dvh] flex flex-col animate-in zoom-in-95 duration-200",onClick:f=>f.stopPropagation(),children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx(jr,{name:t.name}),n.jsx("span",{className:"font-medium text-foreground text-sm truncate",children:t.name}),u&&n.jsx("span",{className:"text-xs text-amber-500 flex-shrink-0",children:"未保存"})]}),n.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[n.jsxs(ye,{size:"sm",onClick:m,disabled:!u||h,children:[h&&n.jsx(Be,{className:"size-4 animate-spin"}),n.jsx(Cr,{className:"w-3.5 h-3.5"}),"保存"]}),n.jsx("button",{onClick:s,className:"text-muted-foreground hover:text-foreground transition-colors p-2 rounded-md hover:bg-muted cursor-pointer","aria-label":"关闭编辑器",children:n.jsx(st,{className:"w-5 h-5"})})]})]}),n.jsx("div",{className:"flex-1 p-3 overflow-hidden",children:l?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."})}):n.jsx(bo,{value:o,onChange:f=>{a(f.target.value),_(!0)},className:"w-full h-full font-mono text-sm text-foreground resize-none bg-muted",spellCheck:!1})}),n.jsx("div",{className:"px-4 py-2 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:"Ctrl/Cmd+S 保存 · Esc 关闭"})]})}),document.body)}function Mh({groupJid:e,file:t,onClose:s}){const{getFileContent:i,saveFileContent:r}=ps(),[o,a]=g.useState(""),[l,c]=g.useState(""),[h,d]=g.useState(!0),[u,_]=g.useState(!1),[m,f]=g.useState(!1),[p,v]=g.useState("preview"),k=g.useRef(null),N=g.useRef(null);g.useEffect(()=>{const I=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=I}},[]),g.useEffect(()=>{const I=U=>{U.key==="Escape"&&s()},H=U=>{(U.metaKey||U.ctrlKey)&&U.key==="s"&&(U.preventDefault(),L())};return window.addEventListener("keydown",I),window.addEventListener("keydown",H),()=>{window.removeEventListener("keydown",I),window.removeEventListener("keydown",H)}},[s,l,m,p]),g.useEffect(()=>{let I=!1;return(async()=>{d(!0);const H=await i(e,t.path);!I&&H!==null&&(a(H),c(H)),I||d(!1)})(),()=>{I=!0}},[e,t.path,i]);const L=async()=>{if(!m||u||p!=="edit")return;_(!0);const I=await r(e,t.path,l);_(!1),I&&(a(l),f(!1))},D=()=>{c(o),v("edit"),requestAnimationFrame(()=>{var I;return(I=k.current)==null?void 0:I.focus()})},T=()=>{m&&a(l),v("preview")},B=g.useCallback(I=>{I.target===I.currentTarget&&s()},[s]);return Yt.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 sm:flex sm:items-center sm:justify-center sm:p-4 lg:p-6",onClick:B,style:{touchAction:"none"},children:n.jsxs("div",{className:"bg-surface w-full h-full sm:rounded-xl sm:shadow-xl sm:max-w-4xl sm:h-[90vh] sm:supports-[height:100dvh]:h-[90dvh] flex flex-col sm:animate-in sm:zoom-in-95 sm:duration-200",style:{maxHeight:"100dvh"},children:[n.jsxs("div",{className:"flex items-center justify-between px-3 sm:px-4 py-2.5 border-b border-border flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n.jsx(jr,{name:t.name}),n.jsx("span",{className:"font-medium text-foreground text-sm truncate",children:t.name}),m&&n.jsx("span",{className:"text-xs text-amber-500 flex-shrink-0",children:"未保存"})]}),n.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center bg-muted rounded-lg p-0.5",children:[n.jsxs("button",{onClick:T,className:`flex items-center gap-1 px-2.5 py-1.5 sm:px-2 sm:py-1 rounded-md text-xs font-medium transition-colors touch-manipulation ${p==="preview"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[n.jsx(rl,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"}),n.jsx("span",{className:"hidden sm:inline",children:"预览"})]}),n.jsxs("button",{onClick:D,className:`flex items-center gap-1 px-2.5 py-1.5 sm:px-2 sm:py-1 rounded-md text-xs font-medium transition-colors touch-manipulation ${p==="edit"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[n.jsx(Hl,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"}),n.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),p==="edit"&&n.jsxs(ye,{size:"sm",onClick:L,disabled:!m||u,className:"touch-manipulation",children:[u&&n.jsx(Be,{className:"size-4 animate-spin"}),n.jsx(Cr,{className:"w-3.5 h-3.5"}),n.jsx("span",{className:"hidden sm:inline",children:"保存"})]}),n.jsx("button",{onClick:s,className:"text-muted-foreground hover:text-foreground transition-colors p-2 rounded-md hover:bg-muted touch-manipulation","aria-label":"关闭",children:n.jsx(st,{className:"w-5 h-5"})})]})]}),n.jsx("div",{className:"flex-1 min-h-0 relative",children:h?n.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:n.jsx(Be,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):p==="preview"?n.jsx("div",{ref:N,className:"absolute inset-0 overflow-y-auto overscroll-y-contain px-4 sm:px-6 py-4 [&_table_td]:!whitespace-normal [&_table_th]:!whitespace-normal",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:n.jsx(us,{content:o,groupJid:e,variant:"docs"})}):n.jsx("div",{className:"absolute inset-0 p-2 sm:p-3",children:n.jsx(bo,{ref:k,value:l,onChange:I=>{c(I.target.value),f(!0)},className:"w-full h-full font-mono text-sm text-foreground resize-none bg-muted",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},spellCheck:!1})})}),n.jsx("div",{className:"px-3 sm:px-4 py-1.5 border-t border-border text-xs text-muted-foreground flex-shrink-0",children:p==="edit"?"Ctrl/Cmd+S 保存 · Esc 关闭":"点击「编辑」修改内容 · Esc 关闭"})]})}),document.body)}function cn({groupJid:e,onClose:t}){const{files:s,currentPath:i,loading:r,loadFiles:o,deleteFile:a,createDirectory:l,navigateTo:c}=ps(),[h,d]=g.useState(!1),[u,_]=g.useState(""),[m,f]=g.useState(!1),[p,v]=g.useState(!1),[k,N]=g.useState(null),[L,D]=g.useState({open:!1,path:"",name:"",isDir:!1}),[T,B]=g.useState(!1),[I,H]=g.useState(null),[U,q]=g.useState(null),[A,S]=g.useState(null),y=V(z=>!!z.streaming[e]),w=Ge(z=>{var te;return((te=z.user)==null?void 0:te.role)==="admin"}),x=g.useRef(!1),E=s[e]||[],b=i[e]||"";g.useEffect(()=>{e&&o(e)},[e]),g.useEffect(()=>{if(y){x.current=!0;const z=setInterval(()=>{o(e,b)},5e3);return()=>clearInterval(z)}x.current&&(x.current=!1,o(e,b))},[y,e,b,o]);const j=g.useMemo(()=>[...E].sort((z,te)=>z.type!==te.type?z.type==="directory"?-1:1:z.name.localeCompare(te.name)),[E]),C=g.useMemo(()=>b?b.split("/").filter(Boolean):[],[b]),P=z=>{z===-1?c(e,""):c(e,C.slice(0,z+1).join("/"))},K=g.useCallback(z=>{if(z.type==="directory"){c(e,z.path);return}const te=Pi(z.name);if(Er.has(te)){H(z);return}if(te==="md"&&!z.isSystem){S(z);return}if(qs.has(te)&&!z.isSystem){q(z);return}},[e,c]),ne=z=>{const te=xo(z.path),ve=`/api/groups/${encodeURIComponent(e)}/files/download/${te}`;Sh(ve,z.name).catch(F=>{console.error("Download failed:",F),dt("下载失败",F instanceof Error?F.message:"文件下载出错,请重试")})},Q=z=>{D({open:!0,path:z.path,name:z.name,isDir:z.type==="directory"})},le=async()=>{B(!0);try{await a(e,L.path)&&D({open:!1,path:"",name:"",isDir:!1})}finally{B(!1)}},ue=()=>{o(e,b)},Ce=async()=>{v(!0),N(null);try{await Ke.post(`/api/groups/${encodeURIComponent(e)}/files/open-directory`,{path:b})}catch(z){z instanceof Error?N(z.message):typeof z=="object"&&z!==null&&"message"in z?N(String(z.message)):N("打开本地文件夹失败")}finally{v(!1)}},$e=()=>{_(""),d(!0)},Y=async()=>{const z=u.trim();if(z){f(!0);try{await l(e,b,z),d(!1)}finally{f(!1)}}};return n.jsxs("div",{className:"w-full h-full border-l border-border bg-background flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[n.jsx("h3",{className:"font-semibold text-foreground text-sm",children:"工作区文件管理"}),n.jsxs("div",{className:"flex items-center gap-1",children:[w&&n.jsx("button",{onClick:Ce,disabled:p,className:"hidden md:inline-flex text-muted-foreground hover:text-foreground transition-colors p-2 rounded-md hover:bg-muted cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"打开工作区文件夹","aria-label":"打开工作区文件夹",children:p?n.jsx(Be,{className:"size-3.5 animate-spin"}):n.jsx(No,{className:"size-3.5"})}),n.jsx("button",{onClick:ue,className:"text-muted-foreground hover:text-foreground transition-colors p-2 rounded-md hover:bg-muted cursor-pointer",title:"刷新","aria-label":"刷新文件列表",children:n.jsx(ti,{className:`w-4 h-4 ${r?"animate-spin":""}`})}),t&&n.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground transition-colors p-2 rounded-md hover:bg-muted cursor-pointer","aria-label":"关闭文件面板",children:n.jsx(st,{className:"w-5 h-5"})})]})]}),n.jsx("div",{className:"px-4 py-2 border-b border-border bg-muted",children:n.jsxs("div",{className:"flex items-center gap-1 text-sm overflow-x-auto",children:[n.jsx("button",{onClick:()=>P(-1),className:"text-primary hover:underline whitespace-nowrap cursor-pointer",children:"根目录"}),C.map((z,te)=>n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(Qa,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),n.jsx("button",{onClick:()=>P(te),className:"text-primary hover:underline whitespace-nowrap cursor-pointer",children:z})]},te))]})}),k&&n.jsx("div",{className:"px-4 py-2 border-b border-red-100 dark:border-red-800 bg-red-50 dark:bg-red-950/40 text-xs text-red-600 dark:text-red-400",children:k}),n.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:r&&E.length===0?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"加载中..."})}):j.length===0?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无文件"})}):n.jsx("div",{className:"space-y-0.5",children:j.map(z=>{const te=z.type==="directory"||kh(z.name,!!z.isSystem);return n.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg transition-colors ${te?"hover:bg-muted cursor-pointer":z.isSystem?"bg-muted/60":"hover:bg-muted/50"}`,onClick:()=>K(z),children:[n.jsx("div",{className:"flex-shrink-0 w-5 flex items-center justify-center",children:z.type==="directory"?n.jsx(Ja,{className:"w-4.5 h-4.5 text-primary"}):n.jsx(jr,{name:z.name})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:`text-sm truncate ${z.isSystem?"text-muted-foreground":"text-foreground"}`,children:z.name}),z.isSystem&&n.jsx(Ml,{variant:"neutral",children:"系统"})]}),z.type==="file"&&n.jsx("p",{className:"text-[11px] text-muted-foreground leading-tight",children:Nh(z.size)})]}),!z.isSystem&&n.jsxs("div",{className:"flex-shrink-0 flex items-center gap-0.5",children:[z.type==="file"&&qs.has(Pi(z.name))&&n.jsx("button",{onClick:ve=>{ve.stopPropagation(),q(z)},className:"p-2.5 rounded hover:bg-brand-100 text-muted-foreground hover:text-primary transition-colors cursor-pointer",title:"编辑","aria-label":"编辑文件",children:n.jsx(vo,{className:"w-3.5 h-3.5"})}),z.type==="file"&&n.jsx("button",{onClick:ve=>{ve.stopPropagation(),ne(z)},className:"p-2.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"下载","aria-label":"下载文件",children:n.jsx(Kr,{className:"w-3.5 h-3.5"})}),n.jsx("button",{onClick:ve=>{ve.stopPropagation(),Q(z)},className:"p-2.5 rounded hover:bg-red-100 dark:hover:bg-red-950/40 text-muted-foreground hover:text-red-600 dark:hover:text-red-400 transition-colors cursor-pointer",title:"删除","aria-label":"删除文件",children:n.jsx(Ct,{className:"w-3.5 h-3.5"})})]}),z.isSystem&&z.type==="file"&&n.jsx("div",{className:"flex-shrink-0",children:n.jsx("button",{onClick:ve=>{ve.stopPropagation(),ne(z)},className:"p-2.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"下载","aria-label":"下载文件",children:n.jsx(Kr,{className:"w-3.5 h-3.5"})})})]},z.path)})})}),n.jsxs("div",{className:"p-3 border-t border-border space-y-2",children:[n.jsxs(ye,{variant:"outline",size:"sm",onClick:$e,className:"w-full",children:[n.jsx(el,{className:"w-4 h-4"}),"新建文件夹"]}),n.jsx(wh,{groupJid:e})]}),n.jsx(br,{open:h,onOpenChange:z=>!z&&d(!1),children:n.jsxs(Sr,{className:"sm:max-w-md",children:[n.jsx(wr,{children:n.jsx(yr,{children:"新建文件夹"})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(tl,{className:"mb-2",children:"文件夹名称"}),n.jsx(Xe,{type:"text",value:u,onChange:z=>_(z.target.value),onKeyDown:z=>{z.key==="Enter"&&Y()},placeholder:"输入文件夹名称",autoFocus:!0})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(ye,{variant:"ghost",onClick:()=>d(!1),disabled:m,children:"取消"}),n.jsxs(ye,{onClick:Y,disabled:m,children:[m&&n.jsx(Be,{className:"size-4 animate-spin"}),"创建"]})]})]})]})}),n.jsx(Xt,{open:L.open,onClose:()=>D({open:!1,path:"",name:"",isDir:!1}),onConfirm:le,title:L.isDir?"删除文件夹":"删除文件",message:L.isDir?`确认删除文件夹「${L.name}」及其所有内容吗?此操作不可恢复。`:`确认删除文件「${L.name}」吗?此操作不可恢复。`,confirmText:"删除",cancelText:"取消",confirmVariant:"danger",loading:T}),I&&n.jsx(Eh,{groupJid:e,file:I,onClose:()=>H(null)}),U&&n.jsx(jh,{groupJid:e,file:U,onClose:()=>q(null)}),A&&n.jsx(Mh,{groupJid:e,file:A,onClose:()=>S(null)})]})}const Dh=So(e=>({configs:{},loading:!1,saving:!1,error:null,loadConfig:async t=>{e({loading:!0,error:null});try{const s=await Ke.get(`/api/groups/${encodeURIComponent(t)}/env`);e(i=>({configs:{...i.configs,[t]:s},loading:!1}))}catch(s){const i=s instanceof Error?s.message:"Failed to load config";console.error("Failed to load container env config:",s),e({loading:!1,error:i})}},saveConfig:async(t,s)=>{e({saving:!0});try{const i=await Ke.put(`/api/groups/${encodeURIComponent(t)}/env`,s);return e(r=>({configs:{...r.configs,[t]:i},saving:!1})),!0}catch(i){const r=i instanceof Error?i.message:"Failed to save config";return console.error("Failed to save container env config:",i),e({saving:!1,error:r}),!1}}})),Ms="ANTHROPIC_MODEL",Rh=["opus[1m]","opus","sonnet[1m]","sonnet","haiku"];function dn({groupJid:e,onClose:t}){const{configs:s,loading:i,saving:r,loadConfig:o,saveConfig:a}=Dh(),l=s[e],[c,h]=g.useState(""),[d,u]=g.useState(""),[_,m]=g.useState(!1),[f,p]=g.useState(""),[v,k]=g.useState([]),[N,L]=g.useState(!1),[D,T]=g.useState(!1),B=g.useRef(void 0);g.useEffect(()=>{e&&o(e)},[e]),g.useEffect(()=>()=>{B.current&&clearTimeout(B.current)},[]),g.useEffect(()=>{if(!l)return;h(l.anthropicBaseUrl||""),u(""),m(!1);const S=Object.entries(l.customEnv||{}).map(([w,x])=>({key:w,value:x})),y=l.customEnv&&l.customEnv[Ms]||"";p(y),k(S.filter(({key:w})=>w!==Ms))},[l]);const I=async()=>{const S={};S.anthropicBaseUrl=c,_&&(S.anthropicAuthToken=d);const y={};for(const{key:E,value:b}of v){const j=E.trim();!j||j===Ms||(y[j]=b)}const w=f.trim();w&&(y[Ms]=w),S.customEnv=y,await a(e,S)&&(L(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>L(!1),2e3),u(""),m(!1))},H=async()=>{if(!window.confirm("确定要清空所有覆盖配置并重建工作区吗?"))return;T(!0);const S=await a(e,{anthropicBaseUrl:"",anthropicAuthToken:"",anthropicApiKey:"",claudeCodeOauthToken:"",customEnv:{}});T(!1),S&&(L(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>L(!1),2e3))},U=()=>{k(S=>[...S,{key:"",value:""}])},q=S=>{k(y=>y.filter((w,x)=>x!==S))},A=(S,y,w)=>{k(x=>x.map((E,b)=>b===S?{...E,[y]:w}:E))};return i&&!l?n.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"加载中..."}):n.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[n.jsx("h3",{className:"font-semibold text-foreground text-sm",children:"工作区环境变量"}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("button",{onClick:()=>o(e),className:"text-muted-foreground hover:text-foreground p-2 rounded-md hover:bg-muted cursor-pointer",title:"刷新",children:n.jsx(ti,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),t&&n.jsx("button",{onClick:t,className:"text-muted-foreground hover:text-foreground p-2 rounded-md hover:bg-muted cursor-pointer",children:n.jsx(st,{className:"w-5 h-5"})})]})]}),n.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3 space-y-4",children:[n.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"覆盖全局 Claude 配置,仅对当前工作区生效。留空则使用全局配置。保存后工作区将自动重建。"}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"ANTHROPIC_BASE_URL"}),n.jsx(Xe,{type:"text",value:c,onChange:S=>h(S.target.value),placeholder:"留空使用全局配置",className:"px-2.5 py-1.5 text-xs h-auto"})]}),n.jsxs("div",{children:[n.jsxs("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:["ANTHROPIC_AUTH_TOKEN",(l==null?void 0:l.hasAnthropicAuthToken)&&n.jsxs("span",{className:"ml-1.5 text-[10px] text-muted-foreground font-normal",children:["(",l.anthropicAuthTokenMasked,")"]})]}),n.jsx(Xe,{type:"password",value:d,onChange:S=>{u(S.target.value),m(!0)},placeholder:l!=null&&l.hasAnthropicAuthToken?"已设置,输入新值覆盖;留空可清除覆盖":"留空使用全局配置",className:"px-2.5 py-1.5 text-xs h-auto"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"模型(ANTHROPIC_MODEL)"}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx(Xe,{type:"text",value:f,onChange:S=>p(S.target.value),placeholder:"opus / sonnet / haiku 或完整模型 ID",className:"px-2.5 py-1.5 text-xs h-auto font-mono",list:"anthropic-model-presets"}),n.jsx("datalist",{id:"anthropic-model-presets",children:Rh.map(S=>n.jsx("option",{value:S},S))}),n.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["留空则回退到全局配置(默认值通常为 ",n.jsx("code",{className:"bg-muted px-1 rounded",children:"opus"}),")。"]})]})]})]}),n.jsx("div",{className:"border-t border-border"}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"自定义环境变量"}),n.jsxs("button",{onClick:U,className:"flex-shrink-0 flex items-center gap-1 text-[11px] text-primary hover:text-primary cursor-pointer",children:[n.jsx(It,{className:"w-3 h-3"}),"添加"]})]}),v.length===0?n.jsx("p",{className:"text-[11px] text-muted-foreground",children:"暂无自定义变量"}):n.jsx("div",{className:"space-y-1.5",children:v.map((S,y)=>n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(Xe,{type:"text",value:S.key,onChange:w=>A(y,"key",w.target.value),placeholder:"KEY",className:"w-[40%] px-2 py-1 text-[11px] font-mono h-auto"}),n.jsx("span",{className:"text-muted-foreground/50 text-xs",children:"="}),n.jsx(Xe,{type:"text",value:S.value,onChange:w=>A(y,"value",w.target.value),placeholder:"value",className:"flex-1 px-2 py-1 text-[11px] font-mono h-auto"}),n.jsx("button",{onClick:()=>q(y),className:"flex-shrink-0 p-1 text-muted-foreground hover:text-red-500 cursor-pointer",children:n.jsx(st,{className:"w-3.5 h-3.5"})})]},y))})]})]}),n.jsxs("div",{className:"flex-shrink-0 p-3 border-t border-border space-y-2",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(ye,{onClick:I,disabled:r||D,className:"flex-1",size:"sm",children:[r&&n.jsx(Be,{className:"size-4 animate-spin"}),n.jsx(Cr,{className:"w-4 h-4"}),N?"已保存":"保存并重建工作区"]}),n.jsxs(ye,{onClick:H,disabled:r||D,variant:"outline",size:"sm",title:"清空所有覆盖配置",children:[D&&n.jsx(Be,{className:"size-4 animate-spin"}),n.jsx(Ct,{className:"w-4 h-4"})]})]}),N&&n.jsx("p",{className:"text-[11px] text-primary text-center",children:"配置已保存,工作区已重建"})]})]})}function un({open:e,title:t,label:s,placeholder:i,defaultValue:r="",confirmText:o="确认",onConfirm:a,onClose:l}){const[c,h]=g.useState(r);g.useEffect(()=>{e&&h(r)},[e,r]);const d=()=>{const u=c.trim();u&&(a(u),l())};return n.jsx(br,{open:e,onOpenChange:u=>!u&&l(),children:n.jsxs(Sr,{className:"sm:max-w-sm",children:[n.jsxs(wr,{children:[n.jsx(yr,{children:t}),n.jsx(nl,{className:"sr-only",children:s||t})]}),n.jsxs("div",{children:[s&&n.jsx("label",{className:"block text-sm font-medium mb-2",children:s}),n.jsx(Xe,{value:c,onChange:u=>h(u.target.value),onKeyDown:u=>{u.key==="Enter"&&d()},placeholder:i,autoFocus:!0})]}),n.jsxs(ol,{children:[n.jsx(ye,{variant:"outline",onClick:l,children:"取消"}),n.jsx(ye,{onClick:d,disabled:!c.trim(),children:o})]})]})})}/**
|
|
105
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
106
|
+
* @license MIT
|
|
107
|
+
*
|
|
108
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
109
|
+
* @license MIT
|
|
110
|
+
*
|
|
111
|
+
* Originally forked from (with the author's permission):
|
|
112
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
113
|
+
* http://bellard.org/jslinux/
|
|
114
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
115
|
+
*/var Ao=Object.defineProperty,Th=Object.getOwnPropertyDescriptor,Lh=(e,t)=>{for(var s in t)Ao(e,s,{get:t[s],enumerable:!0})},ge=(e,t,s,i)=>{for(var r=i>1?void 0:i?Th(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(r=(i?a(t,s,r):a(r))||r);return i&&r&&Ao(t,s,r),r},$=(e,t)=>(s,i)=>t(s,i,e),fn="Terminal input",Ii={get:()=>fn,set:e=>fn=e},mn="Too much output to announce, navigate to rows manually to read",Oi={get:()=>mn,set:e=>mn=e};function Bh(e){return e.replace(/\r?\n/g,"\r")}function Ah(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Ph(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Ih(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Po(r,t,s,i)}}function Po(e,t,s,i){e=Bh(e),e=Ah(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function Io(e,t,s){let i=s.getBoundingClientRect(),r=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function _n(e,t,s,i,r){Io(e,t,s),r&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function bt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function si(e,t=0,s=e.length){let i="";for(let r=t;r<s;++r){let o=e[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var Oh=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=e.charCodeAt(r++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=r;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[i++]=(a-55296)*1024+l-56320+65536:(t[i++]=a,t[i++]=l);continue}a!==65279&&(t[i++]=a)}return i}},zh=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,o,a,l,c=0,h=0;if(this.interim[0]){let _=!1,m=this.interim[0];m&=(m&224)===192?31:(m&240)===224?15:7;let f=0,p;for(;(p=this.interim[++f]&63)&&f<4;)m<<=6,m|=p;let v=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=v-f;for(;h<k;){if(h>=s)return 0;if(p=e[h++],(p&192)!==128){h--,_=!0;break}else this.interim[f++]=p,m<<=6,m|=p&63}_||(v===2?m<128?h--:t[i++]=m:v===3?m<2048||m>=55296&&m<=57343||m===65279||(t[i++]=m):m<65536||m>1114111||(t[i++]=m)),this.interim.fill(0)}let d=s-4,u=h;for(;u<s;){for(;u<d&&!((r=e[u])&128)&&!((o=e[u+1])&128)&&!((a=e[u+2])&128)&&!((l=e[u+3])&128);)t[i++]=r,t[i++]=o,t[i++]=a,t[i++]=l,u+=4;if(r=e[u++],r<128)t[i++]=r;else if((r&224)===192){if(u>=s)return this.interim[0]=r,i;if(o=e[u++],(o&192)!==128){u--;continue}if(c=(r&31)<<6|o&63,c<128){u--;continue}t[i++]=c}else if((r&240)===224){if(u>=s)return this.interim[0]=r,i;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=e[u++],(a&192)!==128){u--;continue}if(c=(r&15)<<12|(o&63)<<6|a&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[i++]=c}else if((r&248)===240){if(u>=s)return this.interim[0]=r,i;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,i;if(a=e[u++],(a&192)!==128){u--;continue}if(u>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=a,i;if(l=e[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(o&63)<<12|(a&63)<<6|l&63,c<65536||c>1114111)continue;t[i++]=c}}return i}},Oo="",wt=" ",vs=class zo{constructor(){this.fg=0,this.bg=0,this.extended=new Vs}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new zo;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Vs=class Ho{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Ho(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},et=class Fo extends vs{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Vs,this.combinedData=""}static fromCharData(t){let s=new Fo;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?bt(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pn="di$target",zi="di$dependencies",_i=new Map;function Hh(e){return e[zi]||[]}function Ae(e){if(_i.has(e))return _i.get(e);let t=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Fh(t,s,r)};return t._id=e,_i.set(e,t),t}function Fh(e,t,s){t[pn]===t?t[zi].push({id:e,index:s}):(t[zi]=[{id:e,index:s}],t[pn]=t)}var Fe=Ae("BufferService"),Wo=Ae("CoreMouseService"),Ht=Ae("CoreService"),Wh=Ae("CharsetService"),Mr=Ae("InstantiationService"),$o=Ae("LogService"),We=Ae("OptionsService"),Uo=Ae("OscLinkService"),$h=Ae("UnicodeService"),xs=Ae("DecorationService"),Hi=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var d;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new et,a=s.getTrimmedLength(),l=-1,c=-1,h=!1;for(let u=0;u<a;u++)if(!(c===-1&&!s.hasContent(u))){if(s.loadCell(u,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=u,l=o.extended.urlId;continue}else h=o.extended.urlId!==l;else c!==-1&&(h=!0);if(h||c!==-1&&u===a-1){let _=(d=this._oscLinkService.getLinkData(l))==null?void 0:d.uri;if(_){let m={start:{x:c+1,y:e},end:{x:u+(!h&&u===a-1?1:0),y:e}},f=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let p=new URL(_);["http:","https:"].includes(p.protocol)||(f=!0)}catch{f=!0}f||i.push({text:_,range:m,activate:(p,v)=>r?r.activate(p,v,m):Uh(p,v),hover:(p,v)=>{var k;return(k=r==null?void 0:r.hover)==null?void 0:k.call(r,p,v,m)},leave:(p,v)=>{var k;return(k=r==null?void 0:r.leave)==null?void 0:k.call(r,p,v,m)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=u,l=o.extended.urlId):(c=-1,l=-1)}}t(i)}};Hi=ge([$(0,Fe),$(1,We),$(2,Uo)],Hi);function Uh(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
116
|
+
|
|
117
|
+
WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var ii=Ae("CharSizeService"),ft=Ae("CoreBrowserService"),Dr=Ae("MouseService"),mt=Ae("RenderService"),Kh=Ae("SelectionService"),Ko=Ae("CharacterJoinerService"),Gt=Ae("ThemeService"),qo=Ae("LinkProviderService"),qh=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?gn.isErrorNoTelemetry(e)?new gn(e.message+`
|
|
118
|
+
|
|
119
|
+
`+e.stack):new Error(e.message+`
|
|
120
|
+
|
|
121
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Vh=new qh;function Os(e){Yh(e)||Vh.onUnexpectedError(e)}var Fi="Canceled";function Yh(e){return e instanceof Xh?!0:e instanceof Error&&e.name===Fi&&e.message===Fi}var Xh=class extends Error{constructor(){super(Fi),this.name=this.message}};function Gh(e){return new Error(`Illegal argument: ${e}`)}var gn=class Wi extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Wi)return t;let s=new Wi;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},$i=class Vo extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Vo.prototype)}};function Ve(e,t=0){return e[e.length-(1+t)]}var Zh;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function r(o){return o===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Zh||(Zh={}));function Qh(e,t){let s=this,i=!1,r;return function(){return i||(i=!0,t||(r=e.apply(s,arguments))),r}}var Yo;(e=>{function t(D){return D&&typeof D=="object"&&typeof D[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(D){yield D}e.single=r;function o(D){return t(D)?D:r(D)}e.wrap=o;function a(D){return D||s}e.from=a;function*l(D){for(let T=D.length-1;T>=0;T--)yield D[T]}e.reverse=l;function c(D){return!D||D[Symbol.iterator]().next().done===!0}e.isEmpty=c;function h(D){return D[Symbol.iterator]().next().value}e.first=h;function d(D,T){let B=0;for(let I of D)if(T(I,B++))return!0;return!1}e.some=d;function u(D,T){for(let B of D)if(T(B))return B}e.find=u;function*_(D,T){for(let B of D)T(B)&&(yield B)}e.filter=_;function*m(D,T){let B=0;for(let I of D)yield T(I,B++)}e.map=m;function*f(D,T){let B=0;for(let I of D)yield*T(I,B++)}e.flatMap=f;function*p(...D){for(let T of D)yield*T}e.concat=p;function v(D,T,B){let I=B;for(let H of D)I=T(I,H);return I}e.reduce=v;function*k(D,T,B=D.length){for(T<0&&(T+=D.length),B<0?B+=D.length:B>D.length&&(B=D.length);T<B;T++)yield D[T]}e.slice=k;function N(D,T=Number.POSITIVE_INFINITY){let B=[];if(T===0)return[B,D];let I=D[Symbol.iterator]();for(let H=0;H<T;H++){let U=I.next();if(U.done)return[B,e.empty()];B.push(U.value)}return[B,{[Symbol.iterator](){return I}}]}e.consume=N;async function L(D){let T=[];for await(let B of D)T.push(B);return Promise.resolve(T)}e.asyncToArray=L})(Yo||(Yo={}));function Ot(e){if(Yo.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Jh(...e){return de(()=>Ot(e))}function de(e){return{dispose:Qh(()=>{e()})}}var Xo=class Go{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ot(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Go.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Xo.DISABLE_DISPOSED_WARNING=!1;var yt=Xo,Z=class{constructor(){this._store=new yt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Z.None=Object.freeze({dispose(){}});var Vt=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ut=typeof window=="object"?window:globalThis,Ui=class Ki{constructor(t){this.element=t,this.next=Ki.Undefined,this.prev=Ki.Undefined}};Ui.Undefined=new Ui(void 0);var me=Ui,vn=class{constructor(){this._first=me.Undefined,this._last=me.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===me.Undefined}clear(){let e=this._first;for(;e!==me.Undefined;){let t=e.next;e.prev=me.Undefined,e.next=me.Undefined,e=t}this._first=me.Undefined,this._last=me.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new me(e);if(this._first===me.Undefined)this._first=s,this._last=s;else if(t){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==me.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==me.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==me.Undefined&&e.next!==me.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===me.Undefined&&e.next===me.Undefined?(this._first=me.Undefined,this._last=me.Undefined):e.next===me.Undefined?(this._last=this._last.prev,this._last.next=me.Undefined):e.prev===me.Undefined&&(this._first=this._first.next,this._first.prev=me.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==me.Undefined;)yield e.element,e=e.next}},ec=globalThis.performance&&typeof globalThis.performance.now=="function",tc=class Zo{static create(t){return new Zo(t)}constructor(t){this._now=ec&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ie;(e=>{e.None=()=>Z.None;function t(S,y){return u(S,()=>{},0,void 0,!0,void 0,y)}e.defer=t;function s(S){return(y,w=null,x)=>{let E=!1,b;return b=S(j=>{if(!E)return b?b.dispose():E=!0,y.call(w,j)},null,x),E&&b.dispose(),b}}e.once=s;function i(S,y,w){return h((x,E=null,b)=>S(j=>x.call(E,y(j)),null,b),w)}e.map=i;function r(S,y,w){return h((x,E=null,b)=>S(j=>{y(j),x.call(E,j)},null,b),w)}e.forEach=r;function o(S,y,w){return h((x,E=null,b)=>S(j=>y(j)&&x.call(E,j),null,b),w)}e.filter=o;function a(S){return S}e.signal=a;function l(...S){return(y,w=null,x)=>{let E=Jh(...S.map(b=>b(j=>y.call(w,j))));return d(E,x)}}e.any=l;function c(S,y,w,x){let E=w;return i(S,b=>(E=y(E,b),E),x)}e.reduce=c;function h(S,y){let w,x={onWillAddFirstListener(){w=S(E.fire,E)},onDidRemoveLastListener(){w==null||w.dispose()}},E=new O(x);return y==null||y.add(E),E.event}function d(S,y){return y instanceof Array?y.push(S):y&&y.add(S),S}function u(S,y,w=100,x=!1,E=!1,b,j){let C,P,K,ne=0,Q,le={leakWarningThreshold:b,onWillAddFirstListener(){C=S(Ce=>{ne++,P=y(P,Ce),x&&!K&&(ue.fire(P),P=void 0),Q=()=>{let $e=P;P=void 0,K=void 0,(!x||ne>1)&&ue.fire($e),ne=0},typeof w=="number"?(clearTimeout(K),K=setTimeout(Q,w)):K===void 0&&(K=0,queueMicrotask(Q))})},onWillRemoveListener(){E&&ne>0&&(Q==null||Q())},onDidRemoveLastListener(){Q=void 0,C.dispose()}},ue=new O(le);return j==null||j.add(ue),ue.event}e.debounce=u;function _(S,y=0,w){return e.debounce(S,(x,E)=>x?(x.push(E),x):[E],y,void 0,!0,void 0,w)}e.accumulate=_;function m(S,y=(x,E)=>x===E,w){let x=!0,E;return o(S,b=>{let j=x||!y(b,E);return x=!1,E=b,j},w)}e.latch=m;function f(S,y,w){return[e.filter(S,y,w),e.filter(S,x=>!y(x),w)]}e.split=f;function p(S,y=!1,w=[],x){let E=w.slice(),b=S(P=>{E?E.push(P):C.fire(P)});x&&x.add(b);let j=()=>{E==null||E.forEach(P=>C.fire(P)),E=null},C=new O({onWillAddFirstListener(){b||(b=S(P=>C.fire(P)),x&&x.add(b))},onDidAddFirstListener(){E&&(y?setTimeout(j):j())},onDidRemoveLastListener(){b&&b.dispose(),b=null}});return x&&x.add(C),C.event}e.buffer=p;function v(S,y){return(w,x,E)=>{let b=y(new N);return S(function(j){let C=b.evaluate(j);C!==k&&w.call(x,C)},void 0,E)}}e.chain=v;let k=Symbol("HaltChainable");class N{constructor(){this.steps=[]}map(y){return this.steps.push(y),this}forEach(y){return this.steps.push(w=>(y(w),w)),this}filter(y){return this.steps.push(w=>y(w)?w:k),this}reduce(y,w){let x=w;return this.steps.push(E=>(x=y(x,E),x)),this}latch(y=(w,x)=>w===x){let w=!0,x;return this.steps.push(E=>{let b=w||!y(E,x);return w=!1,x=E,b?E:k}),this}evaluate(y){for(let w of this.steps)if(y=w(y),y===k)break;return y}}function L(S,y,w=x=>x){let x=(...C)=>j.fire(w(...C)),E=()=>S.on(y,x),b=()=>S.removeListener(y,x),j=new O({onWillAddFirstListener:E,onDidRemoveLastListener:b});return j.event}e.fromNodeEventEmitter=L;function D(S,y,w=x=>x){let x=(...C)=>j.fire(w(...C)),E=()=>S.addEventListener(y,x),b=()=>S.removeEventListener(y,x),j=new O({onWillAddFirstListener:E,onDidRemoveLastListener:b});return j.event}e.fromDOMEventEmitter=D;function T(S){return new Promise(y=>s(S)(y))}e.toPromise=T;function B(S){let y=new O;return S.then(w=>{y.fire(w)},()=>{y.fire(void 0)}).finally(()=>{y.dispose()}),y.event}e.fromPromise=B;function I(S,y){return S(w=>y.fire(w))}e.forward=I;function H(S,y,w){return y(w),S(x=>y(x))}e.runAndSubscribe=H;class U{constructor(y,w){this._observable=y,this._counter=0,this._hasChanged=!1;let x={onWillAddFirstListener:()=>{y.addObserver(this)},onDidRemoveLastListener:()=>{y.removeObserver(this)}};this.emitter=new O(x),w&&w.add(this.emitter)}beginUpdate(y){this._counter++}handlePossibleChange(y){}handleChange(y,w){this._hasChanged=!0}endUpdate(y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function q(S,y){return new U(S,y).emitter.event}e.fromObservable=q;function A(S){return(y,w,x)=>{let E=0,b=!1,j={beginUpdate(){E++},endUpdate(){E--,E===0&&(S.reportChanges(),b&&(b=!1,y.call(w)))},handlePossibleChange(){},handleChange(){b=!0}};S.addObserver(j),S.reportChanges();let C={dispose(){S.removeObserver(j)}};return x instanceof yt?x.add(C):Array.isArray(x)&&x.push(C),C}}e.fromObservableLight=A})(Ie||(Ie={}));var qi=class Vi{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Vi._idPool++}`,Vi.all.add(this)}start(t){this._stopWatch=new tc,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};qi.all=new Set,qi._idPool=0;var sc=qi,ic=-1,Qo=class Jo{constructor(t,s,i=(Jo._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let c=new oc(l,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s<r)&&(t=[i,r],s=r);return t}};Qo._idPool=1;var rc=Qo,nc=class ea{constructor(t){this.value=t}static create(){let t=new Error;return new ea(t.stack??"")}print(){console.warn(this.value.split(`
|
|
122
|
+
`).slice(2).join(`
|
|
123
|
+
`))}},oc=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ac=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},lc=0,pi=class{constructor(e){this.value=e,this.id=lc++}},hc=2,cc,O=class{constructor(t){var s,i,r,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new rc((t==null?void 0:t.onListenerError)??Os,((i=this._options)==null?void 0:i.leakWarningThreshold)??ic):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new sc(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,r;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,c,h,d,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let _=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(_);let m=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],f=new ac(`${_}. HINT: Stack shows most frequent listener (${m[1]}-times)`,m[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Os)(f),Z.None}if(this._disposed)return Z.None;s&&(t=t.bind(s));let r=new pi(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=nc.create(),o=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof pi?(this._deliveryQueue??(this._deliveryQueue=new dc),this._listeners=[this._listeners,r]):this._listeners.push(r):((h=(c=this._options)==null?void 0:c.onWillAddFirstListener)==null||h.call(c,this),this._listeners=r,(u=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||u.call(d,this)),this._size++;let a=de(()=>{o==null||o(),this._removeListener(r)});return i instanceof yt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,c;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(c=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||c.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*hc<=s.length){let h=0;for(let d=0;d<s.length;d++)s[d]?s[h++]=s[d]:r&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=h}}_deliver(t,s){var r;if(!t)return;let i=((r=this._options)==null?void 0:r.onListenerError)||Os;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,r,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof pi)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},dc=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Yi=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Yi.INSTANCE=new Yi;var Rr=Yi;function uc(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}Rr.INSTANCE.onDidChangeZoomLevel;function fc(e){return Rr.INSTANCE.getZoomFactor(e)}Rr.INSTANCE.onDidChangeFullscreen;var Zt=typeof navigator=="object"?navigator.userAgent:"",Xi=Zt.indexOf("Firefox")>=0,mc=Zt.indexOf("AppleWebKit")>=0,Tr=Zt.indexOf("Chrome")>=0,_c=!Tr&&Zt.indexOf("Safari")>=0;Zt.indexOf("Electron/")>=0;Zt.indexOf("Android")>=0;var gi=!1;if(typeof ut.matchMedia=="function"){let e=ut.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ut.matchMedia("(display-mode: fullscreen)");gi=e.matches,uc(ut,e,({matches:s})=>{gi&&t.matches||(gi=s)})}var qt="en",Gi=!1,Zi=!1,zs=!1,ta=!1,Ds,Hs=qt,xn=qt,pc,tt,Pt=globalThis,Pe,mo;typeof Pt.vscode<"u"&&typeof Pt.vscode.process<"u"?Pe=Pt.vscode.process:typeof process<"u"&&typeof((mo=process==null?void 0:process.versions)==null?void 0:mo.node)=="string"&&(Pe=process);var _o,gc=typeof((_o=Pe==null?void 0:Pe.versions)==null?void 0:_o.electron)=="string",vc=gc&&(Pe==null?void 0:Pe.type)==="renderer",po;if(typeof Pe=="object"){Gi=Pe.platform==="win32",Zi=Pe.platform==="darwin",zs=Pe.platform==="linux",zs&&Pe.env.SNAP&&Pe.env.SNAP_REVISION,Pe.env.CI||Pe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ds=qt,Hs=qt;let e=Pe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ds=t.userLocale,xn=t.osLocale,Hs=t.resolvedLanguage||qt,pc=(po=t.languagePack)==null?void 0:po.translationsConfigFile}catch{}ta=!0}else typeof navigator=="object"&&!vc?(tt=navigator.userAgent,Gi=tt.indexOf("Windows")>=0,Zi=tt.indexOf("Macintosh")>=0,(tt.indexOf("Macintosh")>=0||tt.indexOf("iPad")>=0||tt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,zs=tt.indexOf("Linux")>=0,(tt==null?void 0:tt.indexOf("Mobi"))>=0,Hs=globalThis._VSCODE_NLS_LANGUAGE||qt,Ds=navigator.language.toLowerCase(),xn=Ds):console.error("Unable to resolve platform.");var sa=Gi,at=Zi,xc=zs,bn=ta,lt=tt,gt=Hs,bc;(e=>{function t(){return gt}e.value=t;function s(){return gt.length===2?gt==="en":gt.length>=3?gt[0]==="e"&>[1]==="n"&>[2]==="-":!1}e.isDefaultVariant=s;function i(){return gt==="en"}e.isDefault=i})(bc||(bc={}));var Sc=typeof Pt.postMessage=="function"&&!Pt.importScripts;(()=>{if(Sc){let e=[];Pt.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Pt.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var wc=!!(lt&<.indexOf("Chrome")>=0);lt&<.indexOf("Firefox")>=0;!wc&<&<.indexOf("Safari")>=0;lt&<.indexOf("Edg/")>=0;lt&<.indexOf("Android")>=0;var $t=typeof navigator=="object"?navigator:{};bn||document.queryCommandSupported&&document.queryCommandSupported("copy")||$t&&$t.clipboard&&$t.clipboard.writeText,bn||$t&&$t.clipboard&&$t.clipboard.readText;var Lr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},vi=new Lr,Sn=new Lr,wn=new Lr,yc=new Array(230),ia;(e=>{function t(l){return vi.keyCodeToStr(l)}e.toString=t;function s(l){return vi.strToKeyCode(l)}e.fromString=s;function i(l){return Sn.keyCodeToStr(l)}e.toUserSettingsUS=i;function r(l){return wn.keyCodeToStr(l)}e.toUserSettingsGeneral=r;function o(l){return Sn.strToKeyCode(l)||wn.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return vi.keyCodeToStr(l)}e.toElectronAccelerator=a})(ia||(ia={}));var Cc=class ra{constructor(t,s,i,r,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(t){return t instanceof ra&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new kc([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},kc=class{constructor(e){if(e.length===0)throw Gh("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Nc(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return ia.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Xi)switch(t){case 59:return 85;case 60:if(xc)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(at)return 57;break}else if(mc&&(at&&t===93||!at&&t===92))return 57;return yc[t]||0}var Ec=at?256:2048,jc=512,Mc=1024,Dc=at?2048:256,yn=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=Nc(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Ec),this.altKey&&(t|=jc),this.shiftKey&&(t|=Mc),this.metaKey&&(t|=Dc),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Cc(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Cn=new WeakMap;function Rc(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var Tc=class{static getSameOriginWindowChain(e){let t=Cn.get(e);if(!t){t=[],Cn.set(e,t);let s=e,i;do i=Rc(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(e);for(let o of r){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Rs=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Tc.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},kn=class{constructor(e,t=0,s=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(Tr){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?Xi&&!at?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")_c&&sa?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?Xi&&!at?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},na=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Lc;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof Bc?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ie.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:na})})(Lc||(Lc={}));var Bc=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?na:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Br=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new $i("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new $i("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Ac=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new $i("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=de(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Pc;(e=>{async function t(i){let r,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return o}e.settled=t;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Pc||(Pc={}));var Nn=class Qe{static fromArray(t){return new Qe(s=>{s.emitMany(t)})}static fromPromise(t){return new Qe(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Qe(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Qe(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ie.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new Qe(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Qe.map(this,t)}static filter(t,s){return new Qe(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Qe.filter(this,t)}static coalesce(t){return Qe.filter(t,s=>!!s)}coalesce(){return Qe.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Qe.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Nn.EMPTY=Nn.fromArray([]);var{getWindow:ot,getWindowId:Ic,onDidRegisterWindow:Oc}=(function(){let e=new Map,t={window:ut,disposables:new yt};e.set(ut.vscodeWindowId,t);let s=new O,i=new O,r=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return Z.None;let l=new yt,c={window:a,disposables:l.add(new yt)};return e.set(a.vscodeWindowId,c),l.add(de(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(X(a,De.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(c),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var h;let l=a;if((h=l==null?void 0:l.ownerDocument)!=null&&h.defaultView)return l.ownerDocument.defaultView.window;let c=a;return c!=null&&c.view?c.view.window:ut},getDocument(a){return ot(a).document}}})(),zc=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function X(e,t,s,i){return new zc(e,t,s,i)}var En=function(e,t,s,i){return X(e,t,s,i)},Ar,Hc=class extends Ac{constructor(e){super(),this.defaultTarget=e&&ot(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},jn=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Os(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(jn.sort),a.shift().execute();i.set(o,!1)};Ar=(o,a,l=0)=>{let c=Ic(o),h=new jn(a,l),d=e.get(c);return d||(d=[],e.set(c,d)),d.push(h),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>r(c))),h}})();function Fc(e){let t=e.getBoundingClientRect(),s=ot(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var De={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Wc=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Ue(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ue(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ue(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ue(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ue(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ue(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ue(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ue(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ue(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ue(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ue(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Ue(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Ue(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ue(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Ue(e){return typeof e=="number"?`${e}px`:e}function ds(e){return new Wc(e)}var oa=class{constructor(){this._hooks=new yt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=e;try{e.setPointerCapture(t),this._hooks.add(de(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=ot(e)}this._hooks.add(X(o,De.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(X(o,De.POINTER_UP,a=>this.stopMonitoring(!0)))}};function $c(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[o]}}var nt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(nt||(nt={}));var os=class ze extends Z{constructor(){super(),this.dispatched=!1,this.targets=new vn,this.ignoreTargets=new vn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ie.runAndSubscribe(Oc,({window:t,disposables:s})=>{s.add(X(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(X(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(X(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:ut,disposables:this._store}))}static addTarget(t){if(!ze.isTouchDevice())return Z.None;ze.INSTANCE||(ze.INSTANCE=new ze);let s=ze.INSTANCE.targets.push(t);return de(s)}static ignoreTarget(t){if(!ze.isTouchDevice())return Z.None;ze.INSTANCE||(ze.INSTANCE=new ze);let s=ze.INSTANCE.ignoreTargets.push(t);return de(s)}static isTouchDevice(){return"ontouchstart"in ut||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=t.targetTouches.length;i<r;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(nt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],h=Date.now()-c.initialTimeStamp;if(h<ze.HOLD_DELAY&&Math.abs(c.initialPageX-Ve(c.rollingPageX))<30&&Math.abs(c.initialPageY-Ve(c.rollingPageY))<30){let d=this.newGestureEvent(nt.Tap,c.initialTarget);d.pageX=Ve(c.rollingPageX),d.pageY=Ve(c.rollingPageY),this.dispatchEvent(d)}else if(h>=ze.HOLD_DELAY&&Math.abs(c.initialPageX-Ve(c.rollingPageX))<30&&Math.abs(c.initialPageY-Ve(c.rollingPageY))<30){let d=this.newGestureEvent(nt.Contextmenu,c.initialTarget);d.pageX=Ve(c.rollingPageX),d.pageY=Ve(c.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Ve(c.rollingPageX),u=Ve(c.rollingPageY),_=Ve(c.rollingTimestamps)-c.rollingTimestamps[0],m=d-c.rollingPageX[0],f=u-c.rollingPageY[0],p=[...this.targets].filter(v=>c.initialTarget instanceof Node&&v.contains(c.initialTarget));this.inertia(t,p,i,Math.abs(m)/_,m>0?1:-1,d,Math.abs(f)/_,f>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(nt.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===nt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>ze.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===nt.Change||t.type===nt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let r=0,o=t.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,r,o,a,l,c,h){this.handle=Ar(t,()=>{let d=Date.now(),u=d-i,_=0,m=0,f=!0;r+=ze.SCROLL_FRICTION*u,l+=ze.SCROLL_FRICTION*u,r>0&&(f=!1,_=o*r*u),l>0&&(f=!1,m=c*l*u);let p=this.newGestureEvent(nt.Change);p.translationX=_,p.translationY=m,s.forEach(v=>v.dispatchEvent(p)),f||this.inertia(t,s,d,r,o,a+_,l,c,h+m)})}onTouchMove(t){let s=Date.now();for(let i=0,r=t.changedTouches.length;i<r;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(nt.Change,a.initialTarget);l.translationX=o.pageX-Ve(a.rollingPageX),l.translationY=o.pageY-Ve(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};os.SCROLL_FRICTION=-.005,os.HOLD_DELAY=700,os.CLEAR_TAP_COUNT_TIME=400,ge([$c],os,"isTouchDevice",1);var Uc=os,Pr=class extends Z{onclick(e,t){this._register(X(e,De.CLICK,s=>t(new Rs(ot(e),s))))}onmousedown(e,t){this._register(X(e,De.MOUSE_DOWN,s=>t(new Rs(ot(e),s))))}onmouseover(e,t){this._register(X(e,De.MOUSE_OVER,s=>t(new Rs(ot(e),s))))}onmouseleave(e,t){this._register(X(e,De.MOUSE_LEAVE,s=>t(new Rs(ot(e),s))))}onkeydown(e,t){this._register(X(e,De.KEY_DOWN,s=>t(new yn(s))))}onkeyup(e,t){this._register(X(e,De.KEY_UP,s=>t(new yn(s))))}oninput(e,t){this._register(X(e,De.INPUT,t))}onblur(e,t){this._register(X(e,De.BLUR,t))}onfocus(e,t){this._register(X(e,De.FOCUS,t))}onchange(e,t){this._register(X(e,De.CHANGE,t))}ignoreGesture(e){return Uc.ignoreTarget(e)}},Mn=11,Kc=class extends Pr{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Mn+"px",this.domNode.style.height=Mn+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new oa),this._register(En(this.bgDomNode,De.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(En(this.domNode,De.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Hc),this._pointerdownScheduleRepeatTimer=this._register(new Br)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ot(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},qc=class Qi{constructor(t,s,i,r,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Qi(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Qi(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:c}}},Vc=class extends Z{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new qc(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Rn(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Rn.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Dn=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function xi(e,t){let s=t-e;return function(i){return e+s*Gc(i)}}function Yc(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Rn=class Ji{constructor(t,s,i,r){this.from=t,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let r,o;return t<s?(r=t+.75*i,o=s-.75*i):(r=t-.75*i,o=s+.75*i),Yc(xi(t,r),xi(o,s),.33)}return xi(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new Dn(i,r,!1)}return new Dn(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Ji.start(t,s,i)}static start(t,s,i){i=i+10;let r=Date.now()-10;return new Ji(t,s,r,i)}};function Xc(e){return Math.pow(e,3)}function Gc(e){return 1-Xc(1-e)}var Zc=class extends Z{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Br)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},Qc=140,aa=class extends Pr{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Zc(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new oa),this._shouldRender=!0,this.domNode=ds(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(X(this.domNode.domNode,De.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Kc(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=ds(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(X(this.slider.domNode,De.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);s<=r&&r<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let r=Fc(this.domNode.domNode);t=e.pageX-r.left,s=e.pageY-r.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),a=Math.abs(o-s);if(sa&&a>Qc){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},la=class er{constructor(t,s,i,r,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new er(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,r,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),c=r>0&&r>i;if(!c)return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(i*l/r))),d=(l-h)/(r-i),u=o*d;return{computedAvailableSize:Math.round(a),computedIsNeeded:c,computedSliderSize:Math.round(h),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=er._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},Jc=class extends aa{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new la(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},ed=class extends aa{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new la(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},td=500,Tn=50,sd=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},tr=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,r=this._rear;do{let o=r===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(Tr){let s=ot(t.browserEvent),i=fc(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let r=null,o=new sd(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,r)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),c=Math.max(Math.min(r,a),1),h=Math.max(Math.min(o,l),1),d=Math.max(r,a),u=Math.max(o,l);d%c===0&&u%h===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};tr.INSTANCE=new tr;var id=tr,rd=class extends Pr{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=od(t),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new ed(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Jc(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=ds(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=ds(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=ds(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Br),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ot(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,at&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new kn(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ot(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new kn(s))};this._mouseWheelToDispose.push(X(this._listenOnDomNode,De.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=id.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!at&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let c=this._scrollable.getFutureScrollPosition(),h={};if(o){let d=Tn*o,u=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(h,u)}if(a){let d=Tn*a,u=c.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(h,u)}h=this._scrollable.validateScrollPosition(h),(c.scrollLeft!==h.scrollLeft||c.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",r=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),td)}},nd=class extends rd{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function od(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,at&&(t.className+=" mac"),t}var sr=class extends Z{constructor(e,t,s,i,r,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Vc({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Ar(i.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new nd(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ie.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(de(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(de(()=>this._styleElement.remove())),this._register(Ie.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
124
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};sr=ge([$(2,Fe),$(3,ft),$(4,Wo),$(5,Gt),$(6,We),$(7,mt)],sr);var ir=class extends Z{constructor(e,t,s,i,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(de(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};ir=ge([$(1,Fe),$(2,ft),$(3,xs),$(4,mt)],ir);var ad=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},it={full:0,left:0,center:0,right:0},vt={full:0,left:0,center:0,right:0},Jt={full:0,left:0,center:0,right:0},Ys=class extends Z{constructor(e,t,s,i,r,o,a,l){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new ad,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(de(()=>{var d;return(d=this._canvas)==null?void 0:d.remove()}));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);vt.full=this._canvas.width,vt.left=e,vt.center=t,vt.right=e,this._refreshDrawHeightConstants(),Jt.full=1,Jt.left=1,Jt.center=1+vt.left,Jt.right=1+vt.left+vt.center}_refreshDrawHeightConstants(){it.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);it.left=t,it.center=t,it.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*it.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*it.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*it.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*it.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Jt[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-it[e.position||"full"]/2),vt[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+it[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ys=ge([$(2,Fe),$(3,xs),$(4,mt),$(5,We),$(6,Gt),$(7,ft)],Ys);var R;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
125
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(R||(R={}));var Fs;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(Fs||(Fs={}));var ha;(e=>e.ST=`${R.ESC}\\`)(ha||(ha={}));var rr=class{constructor(e,t,s,i,r,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${R.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};rr=ge([$(2,Fe),$(3,We),$(4,Ht),$(5,mt)],rr);var Re=0,Te=0,Le=0,pe=0,Ln={css:"#00000000",rgba:0},we;(e=>{function t(r,o,a,l){return l!==void 0?`#${Rt(r)}${Rt(o)}${Rt(a)}${Rt(l)}`:`#${Rt(r)}${Rt(o)}${Rt(a)}`}e.toCss=t;function s(r,o,a,l=255){return(r<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(r,o,a,l){return{css:e.toCss(r,o,a,l),rgba:e.toRgba(r,o,a,l)}}e.toColor=i})(we||(we={}));var he;(e=>{function t(c,h){if(pe=(h.rgba&255)/255,pe===1)return{css:h.css,rgba:h.rgba};let d=h.rgba>>24&255,u=h.rgba>>16&255,_=h.rgba>>8&255,m=c.rgba>>24&255,f=c.rgba>>16&255,p=c.rgba>>8&255;Re=m+Math.round((d-m)*pe),Te=f+Math.round((u-f)*pe),Le=p+Math.round((_-p)*pe);let v=we.toCss(Re,Te,Le),k=we.toRgba(Re,Te,Le);return{css:v,rgba:k}}e.blend=t;function s(c){return(c.rgba&255)===255}e.isOpaque=s;function i(c,h,d){let u=Ws.ensureContrastRatio(c.rgba,h.rgba,d);if(u)return we.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=i;function r(c){let h=(c.rgba|255)>>>0;return[Re,Te,Le]=Ws.toChannels(h),{css:we.toCss(Re,Te,Le),rgba:h}}e.opaque=r;function o(c,h){return pe=Math.round(h*255),[Re,Te,Le]=Ws.toChannels(c.rgba),{css:we.toCss(Re,Te,Le,pe),rgba:we.toRgba(Re,Te,Le,pe)}}e.opacity=o;function a(c,h){return pe=c.rgba&255,o(c,pe*h/255)}e.multiplyOpacity=a;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=l})(he||(he={}));var _e;(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Re=parseInt(r.slice(1,2).repeat(2),16),Te=parseInt(r.slice(2,3).repeat(2),16),Le=parseInt(r.slice(3,4).repeat(2),16),we.toColor(Re,Te,Le);case 5:return Re=parseInt(r.slice(1,2).repeat(2),16),Te=parseInt(r.slice(2,3).repeat(2),16),Le=parseInt(r.slice(3,4).repeat(2),16),pe=parseInt(r.slice(4,5).repeat(2),16),we.toColor(Re,Te,Le,pe);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let o=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Re=parseInt(o[1]),Te=parseInt(o[2]),Le=parseInt(o[3]),pe=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),we.toColor(Re,Te,Le,pe);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Re,Te,Le,pe]=t.getImageData(0,0,1,1).data,pe!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:we.toRgba(Re,Te,Le,pe),css:r}}e.toColor=i})(_e||(_e={}));var He;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,o){let a=i/255,l=r/255,c=o/255,h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return h*.2126+d*.7152+u*.0722}e.relativeLuminance2=s})(He||(He={}));var Ws;(e=>{function t(a,l){if(pe=(l&255)/255,pe===1)return l;let c=l>>24&255,h=l>>16&255,d=l>>8&255,u=a>>24&255,_=a>>16&255,m=a>>8&255;return Re=u+Math.round((c-u)*pe),Te=_+Math.round((h-_)*pe),Le=m+Math.round((d-m)*pe),we.toRgba(Re,Te,Le)}e.blend=t;function s(a,l,c){let h=He.relativeLuminance(a>>8),d=He.relativeLuminance(l>>8);if(ht(h,d)<c){if(d<h){let m=i(a,l,c),f=ht(h,He.relativeLuminance(m>>8));if(f<c){let p=r(a,l,c),v=ht(h,He.relativeLuminance(p>>8));return f>v?m:p}return m}let u=r(a,l,c),_=ht(h,He.relativeLuminance(u>>8));if(_<c){let m=i(a,l,c),f=ht(h,He.relativeLuminance(m>>8));return _>f?u:m}return u}}e.ensureContrastRatio=s;function i(a,l,c){let h=a>>24&255,d=a>>16&255,u=a>>8&255,_=l>>24&255,m=l>>16&255,f=l>>8&255,p=ht(He.relativeLuminance2(_,m,f),He.relativeLuminance2(h,d,u));for(;p<c&&(_>0||m>0||f>0);)_-=Math.max(0,Math.ceil(_*.1)),m-=Math.max(0,Math.ceil(m*.1)),f-=Math.max(0,Math.ceil(f*.1)),p=ht(He.relativeLuminance2(_,m,f),He.relativeLuminance2(h,d,u));return(_<<24|m<<16|f<<8|255)>>>0}e.reduceLuminance=i;function r(a,l,c){let h=a>>24&255,d=a>>16&255,u=a>>8&255,_=l>>24&255,m=l>>16&255,f=l>>8&255,p=ht(He.relativeLuminance2(_,m,f),He.relativeLuminance2(h,d,u));for(;p<c&&(_<255||m<255||f<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),p=ht(He.relativeLuminance2(_,m,f),He.relativeLuminance2(h,d,u));return(_<<24|m<<16|f<<8|255)>>>0}e.increaseLuminance=r;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Ws||(Ws={}));function Rt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ht(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ld=class extends vs{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Xs=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new et}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),r=0,o=0,a=0,l=t.getFg(0),c=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(h-r>1){let d=this._getJoinedRanges(i,a,o,t,r);for(let u=0;u<d.length;u++)s.push(d[u])}r=h,a=o,l=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||wt.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(i,a,o,t,r);for(let d=0;d<h.length;d++)s.push(h[d])}return s}_getJoinedRanges(e,t,s,i,r){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(o);for(let h=0;h<c.length;h++)Xs._mergeRanges(a,c[h])}catch(c){console.error(c)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(e,t,s){let i=0,r=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let c=t.getWidth(l),h=t.getString(l).length||wt.length;if(c!==0){if(!r&&a[0]<=o&&(a[0]=l,r=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,r=!0):r=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let r=e[i];if(s){if(t[1]<=r[0])return e[i-1][1]=t[1],e;if(t[1]<=r[1])return e[i-1][1]=Math.max(t[1],r[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=r[0])return e.splice(i,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};Xs=ge([$(0,Fe)],Xs);function hd(e){return 57508<=e&&e<=57558}function cd(e){return 9472<=e&&e<=9631}function dd(e){return hd(e)||cd(e)}function ud(){return{css:{canvas:Ts(),cell:Ts()},device:{canvas:Ts(),cell:Ts(),char:{width:0,height:0,left:0,top:0}}}}function Ts(){return{width:0,height:0}}var nr=class{constructor(e,t,s,i,r,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=a,this._workCell=new et,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,r,o,a,l,c,h,d){let u=[],_=this._characterJoinerService.getJoinedCharacters(t),m=this._themeService.colors,f=e.getNoBgTrimmedLength();s&&f<o+1&&(f=o+1);let p,v=0,k="",N=0,L=0,D=0,T=0,B=!1,I=0,H=!1,U=0,q=0,A=[],S=h!==-1&&d!==-1;for(let y=0;y<f;y++){e.loadCell(y,this._workCell);let w=this._workCell.getWidth();if(w===0)continue;let x=!1,E=y>=q,b=y,j=this._workCell;if(_.length>0&&y===_[0][0]&&E){let W=_.shift(),se=this._isCellInSelection(W[0],t);for(N=W[0]+1;N<W[1];N++)E&&(E=se===this._isCellInSelection(N,t));E&&(E=!s||o<W[0]||o>=W[1]),E?(x=!0,j=new ld(this._workCell,e.translateToString(!0,W[0],W[1]),W[1]-W[0]),b=W[1]-1,w=j.getWidth()):q=W[1]}let C=this._isCellInSelection(y,t),P=s&&y===o,K=S&&y>=h&&y<=d,ne=!1;this._decorationService.forEachDecorationAtCell(y,t,void 0,W=>{ne=!0});let Q=j.getChars()||wt;if(Q===" "&&(j.isUnderline()||j.isOverline())&&(Q=" "),U=w*l-c.get(Q,j.isBold(),j.isItalic()),!p)p=this._document.createElement("span");else if(v&&(C&&H||!C&&!H&&j.bg===L)&&(C&&H&&m.selectionForeground||j.fg===D)&&j.extended.ext===T&&K===B&&U===I&&!P&&!x&&!ne&&E){j.isInvisible()?k+=wt:k+=Q,v++;continue}else v&&(p.textContent=k),p=this._document.createElement("span"),v=0,k="";if(L=j.bg,D=j.fg,T=j.extended.ext,B=K,I=U,H=C,x&&o>=y&&o<=b&&(o=y),!this._coreService.isCursorHidden&&P&&this._coreService.isCursorInitialized){if(A.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&A.push("xterm-cursor-blink"),A.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":A.push("xterm-cursor-outline");break;case"block":A.push("xterm-cursor-block");break;case"bar":A.push("xterm-cursor-bar");break;case"underline":A.push("xterm-cursor-underline");break}}if(j.isBold()&&A.push("xterm-bold"),j.isItalic()&&A.push("xterm-italic"),j.isDim()&&A.push("xterm-dim"),j.isInvisible()?k=wt:k=j.getChars()||wt,j.isUnderline()&&(A.push(`xterm-underline-${j.extended.underlineStyle}`),k===" "&&(k=" "),!j.isUnderlineColorDefault()))if(j.isUnderlineColorRGB())p.style.textDecorationColor=`rgb(${vs.toColorRGB(j.getUnderlineColor()).join(",")})`;else{let W=j.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&j.isBold()&&W<8&&(W+=8),p.style.textDecorationColor=m.ansi[W].css}j.isOverline()&&(A.push("xterm-overline"),k===" "&&(k=" ")),j.isStrikethrough()&&A.push("xterm-strikethrough"),K&&(p.style.textDecoration="underline");let le=j.getFgColor(),ue=j.getFgColorMode(),Ce=j.getBgColor(),$e=j.getBgColorMode(),Y=!!j.isInverse();if(Y){let W=le;le=Ce,Ce=W;let se=ue;ue=$e,$e=se}let z,te,ve=!1;this._decorationService.forEachDecorationAtCell(y,t,void 0,W=>{W.options.layer!=="top"&&ve||(W.backgroundColorRGB&&($e=50331648,Ce=W.backgroundColorRGB.rgba>>8&16777215,z=W.backgroundColorRGB),W.foregroundColorRGB&&(ue=50331648,le=W.foregroundColorRGB.rgba>>8&16777215,te=W.foregroundColorRGB),ve=W.options.layer==="top")}),!ve&&C&&(z=this._coreBrowserService.isFocused?m.selectionBackgroundOpaque:m.selectionInactiveBackgroundOpaque,Ce=z.rgba>>8&16777215,$e=50331648,ve=!0,m.selectionForeground&&(ue=50331648,le=m.selectionForeground.rgba>>8&16777215,te=m.selectionForeground)),ve&&A.push("xterm-decoration-top");let F;switch($e){case 16777216:case 33554432:F=m.ansi[Ce],A.push(`xterm-bg-${Ce}`);break;case 50331648:F=we.toColor(Ce>>16,Ce>>8&255,Ce&255),this._addStyle(p,`background-color:#${Bn((Ce>>>0).toString(16),"0",6)}`);break;case 0:default:Y?(F=m.foreground,A.push("xterm-bg-257")):F=m.background}switch(z||j.isDim()&&(z=he.multiplyOpacity(F,.5)),ue){case 16777216:case 33554432:j.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(p,F,m.ansi[le],j,z,void 0)||A.push(`xterm-fg-${le}`);break;case 50331648:let W=we.toColor(le>>16&255,le>>8&255,le&255);this._applyMinimumContrast(p,F,W,j,z,te)||this._addStyle(p,`color:#${Bn(le.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(p,F,m.foreground,j,z,te)||Y&&A.push("xterm-fg-257")}A.length&&(p.className=A.join(" "),A.length=0),!P&&!x&&!ne&&E?v++:p.textContent=k,U!==this.defaultSpacing&&(p.style.letterSpacing=`${U}px`),u.push(p),y=b}return p&&v&&(p.textContent=k),u}_applyMinimumContrast(e,t,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||dd(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=he.ensureContrastRatio(r||t,o||s,c),a.setColor((r||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};nr=ge([$(1,Ko),$(2,We),$(3,ft),$(4,Ht),$(5,xs),$(6,Gt)],nr);function Bn(e,t,s){for(;e.length<s;)e=t+e;return e}var fd=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let r=e;t&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(r,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},md=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,o=t[1]-r,a=s[1]-r,l=Math.max(o,0),c=Math.min(a,e.rows-1);if(l>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function _d(){return new md}var bi="xterm-dom-renderer-owner-",Ze="xterm-rows",Ls="xterm-fg-",An="xterm-bg-",es="xterm-focus",Bs="xterm-selection",pd=1,or=class extends Z{constructor(e,t,s,i,r,o,a,l,c,h,d,u,_,m){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=a,this._charSizeService=c,this._optionsService=h,this._bufferService=d,this._coreService=u,this._coreBrowserService=_,this._themeService=m,this._terminalClass=pd++,this._rowElements=[],this._selectionRenderModel=_d(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ze),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Bs),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=ud(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(nr,document),this._element.classList.add(bi+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(de(()=>{this._element.classList.remove(bi+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new fd(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ze} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ze} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ze} .xterm-dim { color: ${he.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ze}.${es} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ze}.${es} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ze}.${es} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ze} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ze} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ze} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ze} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ze} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Bs} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Bs} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Bs} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${Ls}${o} { color: ${a.css}; }${this._terminalSelector} .${Ls}${o}.xterm-dim { color: ${he.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${An}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${Ls}257 { color: ${he.opaque(e.background).css}; }${this._terminalSelector} .${Ls}257.xterm-dim { color: ${he.multiplyOpacity(he.opaque(e.background),.5).css}; }${this._terminalSelector} .${An}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(es),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(es),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let c=e[0]>t[0];l.appendChild(this._createSelectionElement(o,c?t[0]:e[0],c?e[0]:t[0],a-o+1))}else{let c=i===o?e[0]:0,h=o===r?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,c,h));let d=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,d)),o!==a){let u=r===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${a}px`,r}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let h=c+s.ydisp,d=this._rowElements[c],u=s.lines.get(h);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,h,h===i,a,l,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${bi}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,r,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,h=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let m=s;m<=i;++m){let f=m+l.ydisp,p=this._rowElements[m],v=l.lines.get(f);if(!p||!v)break;p.replaceChildren(...this._rowFactory.createRow(v,f,f===c,u,_,h,d,this.dimensions.css.cell.width,this._widthCache,o?m===s?e:0:-1,o?(m===i?t:r)-1:-1))}}};or=ge([$(7,Mr),$(8,ii),$(9,We),$(10,Fe),$(11,Ht),$(12,ft),$(13,Gt)],or);var ar=class extends Z{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new vd(this._optionsService))}catch{this._measureStrategy=this._register(new gd(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};ar=ge([$(2,We)],ar);var ca=class extends Z{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},gd=class extends ca{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},vd=class extends ca{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},xd=class extends Z{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new bd(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Ie.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(X(this._textarea,"focus",()=>this._isFocused=!0)),this._register(X(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},bd=class extends Z{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Vt),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(de(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=X(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Sd=class extends Z{constructor(){super(),this.linkProviders=[],this._register(de(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Ir(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function wd(e,t,s,i,r,o,a,l,c){if(!o)return;let h=Ir(e,t,s);if(h)return h[0]=Math.ceil((h[0]+(c?a/2:0))/a),h[1]=Math.ceil(h[1]/l),h[0]=Math.min(Math.max(h[0],1),i+(c?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h}var lr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return wd(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=Ir(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};lr=ge([$(0,mt),$(1,ii)],lr);var yd=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},da={};Lh(da,{getSafariVersion:()=>kd,isChromeOS:()=>_a,isFirefox:()=>ua,isIpad:()=>Nd,isIphone:()=>Ed,isLegacyEdge:()=>Cd,isLinux:()=>Or,isMac:()=>Gs,isNode:()=>ri,isSafari:()=>fa,isWindows:()=>ma});var ri=typeof process<"u"&&"title"in process,bs=ri?"node":navigator.userAgent,Ss=ri?"node":navigator.platform,ua=bs.includes("Firefox"),Cd=bs.includes("Edge"),fa=/^((?!chrome|android).)*safari/i.test(bs);function kd(){if(!fa)return 0;let e=bs.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Gs=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ss),Nd=Ss==="iPad",Ed=Ss==="iPhone",ma=["Windows","Win16","Win32","WinCE"].includes(Ss),Or=Ss.indexOf("Linux")>=0,_a=/\bCrOS\b/.test(bs),pa=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),r=e.timeRemaining(),s*1.5>r){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},jd=class extends pa{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Md=class extends pa{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Zs=!ri&&"requestIdleCallback"in window?Md:jd,Dd=class{constructor(){this._queue=new Zs}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},hr=class extends Z{constructor(e,t,s,i,r,o,a,l,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new Vt),this._pausedResizeTask=new Dd,this._observerDisposable=this._register(new Vt),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new yd((h,d)=>this._renderRows(h,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Rd(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(de(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=de(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};hr=ge([$(2,We),$(3,ii),$(4,Ht),$(5,xs),$(6,Fe),$(7,ft),$(8,Gt)],hr);var Rd=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Td(e,t,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return Ad(r,o,e,t,s,i)+ni(o,t,s,i)+Pd(r,o,e,t,s,i);let a;if(o===t)return a=r>e?"D":"C",ms(Math.abs(r-e),fs(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),c=Bd(o>t?e:r,s)+(l-1)*s.cols+1+Ld(o>t?r:e);return ms(c,fs(a,i))}function Ld(e,t){return e-1}function Bd(e,t){return t.cols-e}function Ad(e,t,s,i,r,o){return ni(t,i,r,o).length===0?"":ms(va(e,t,e,t-zt(t,r),!1,r).length,fs("D",o))}function ni(e,t,s,i){let r=e-zt(e,s),o=t-zt(t,s),a=Math.abs(r-o)-Id(e,t,s);return ms(a,fs(ga(e,t),i))}function Pd(e,t,s,i,r,o){let a;ni(t,i,r,o).length>0?a=i-zt(i,r):a=t;let l=i,c=Od(e,t,s,i,r,o);return ms(va(e,a,s,l,c==="C",r).length,fs(c,o))}function Id(e,t,s){var a;let i=0,r=e-zt(e,s),o=t-zt(t,s);for(let l=0;l<Math.abs(r-o);l++){let c=ga(e,t)==="A"?-1:1;(a=s.buffer.lines.get(r+c*l))!=null&&a.isWrapped&&i++}return i}function zt(e,t){let s=0,i=t.buffer.lines.get(e),r=i==null?void 0:i.isWrapped;for(;r&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),r=i==null?void 0:i.isWrapped;return s}function Od(e,t,s,i,r,o){let a;return ni(s,i,r,o).length>0?a=i-zt(i,r):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function ga(e,t){return e>t?"A":"B"}function va(e,t,s,i,r,o){let a=e,l=t,c="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=r?1:-1,r&&a>o.cols-1?(c+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!r&&a<0&&(c+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return c+o.buffer.translateBufferLineToString(l,!1,e,a)}function fs(e,t){let s=t?"O":"[";return R.ESC+s+e}function ms(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var zd=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Pn(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Si=50,Hd=15,Fd=50,Wd=500,$d=" ",Ud=new RegExp($d,"g"),cr=class extends Z{constructor(e,t,s,i,r,o,a,l,c){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new et,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new zd(this._bufferService),this._activeSelectionMode=0,this._register(de(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,r,o);i.push(l)}}else{let r=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],r));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(Ud," ")).join(ma?`\r
|
|
126
|
+
`:`
|
|
127
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Or&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,o;let s=(o=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=Pn(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Ir(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Si),Si),t/=Si,t/Math.abs(t)+Math.round(t*(Hd-1)))}shouldForceSelection(e){return Gs?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Fd)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Gs&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<Wd&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=Td(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(e[1]);if(!o)return;let a=r.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),c=l,h=e[0]-l,d=0,u=0,_=0,m=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;c<a.length&&a.charAt(c+1)===" ";)c++}else{let v=e[0],k=e[0];o.getWidth(v)===0&&(d++,v--),o.getWidth(k)===2&&(u++,k++);let N=o.getString(k).length;for(N>1&&(m+=N-1,c+=N-1);v>0&&l>0&&!this._isCharWordSeparator(o.loadCell(v-1,this._workCell));){o.loadCell(v-1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,v--):L>1&&(_+=L-1,l-=L-1),l--,v--}for(;k<o.length&&c+1<a.length&&!this._isCharWordSeparator(o.loadCell(k+1,this._workCell));){o.loadCell(k+1,this._workCell);let L=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,k++):L>1&&(m+=L-1,c+=L-1),c++,k++}}c++;let f=l+h-d+_,p=Math.min(this._bufferService.cols,c-l+d+u-_-m);if(!(!t&&a.slice(l,c).trim()==="")){if(s&&f===0&&o.getCodePoint(0)!==32){let v=r.lines.get(e[1]-1);if(v&&o.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let N=this._bufferService.cols-k.start;f-=N,p+=N}}}if(i&&f+p===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let v=r.lines.get(e[1]+1);if(v!=null&&v.isWrapped&&v.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(p+=k.length)}}return{start:f,length:p}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Pn(s,this._bufferService.cols)}};cr=ge([$(3,Fe),$(4,Ht),$(5,Dr),$(6,We),$(7,mt),$(8,ft)],cr);var In=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},On=class{constructor(){this._color=new In,this._css=new In}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ke=Object.freeze((()=>{let e=[_e.toColor("#2e3436"),_e.toColor("#cc0000"),_e.toColor("#4e9a06"),_e.toColor("#c4a000"),_e.toColor("#3465a4"),_e.toColor("#75507b"),_e.toColor("#06989a"),_e.toColor("#d3d7cf"),_e.toColor("#555753"),_e.toColor("#ef2929"),_e.toColor("#8ae234"),_e.toColor("#fce94f"),_e.toColor("#729fcf"),_e.toColor("#ad7fa8"),_e.toColor("#34e2e2"),_e.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],o=t[s%6];e.push({css:we.toCss(i,r,o),rgba:we.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:we.toCss(i,i,i),rgba:we.toRgba(i,i,i)})}return e})()),Lt=_e.toColor("#ffffff"),as=_e.toColor("#000000"),zn=_e.toColor("#ffffff"),Hn=as,ts={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Kd=Lt,dr=class extends Z{constructor(e){super(),this._optionsService=e,this._contrastCache=new On,this._halfContrastCache=new On,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Lt,background:as,cursor:zn,cursorAccent:Hn,selectionForeground:void 0,selectionBackgroundTransparent:ts,selectionBackgroundOpaque:he.blend(as,ts),selectionInactiveBackgroundTransparent:ts,selectionInactiveBackgroundOpaque:he.blend(as,ts),scrollbarSliderBackground:he.opacity(Lt,.2),scrollbarSliderHoverBackground:he.opacity(Lt,.4),scrollbarSliderActiveBackground:he.opacity(Lt,.5),overviewRulerBorder:Lt,ansi:ke.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=ae(e.foreground,Lt),t.background=ae(e.background,as),t.cursor=he.blend(t.background,ae(e.cursor,zn)),t.cursorAccent=he.blend(t.background,ae(e.cursorAccent,Hn)),t.selectionBackgroundTransparent=ae(e.selectionBackground,ts),t.selectionBackgroundOpaque=he.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ae(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=he.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ae(e.selectionForeground,Ln):void 0,t.selectionForeground===Ln&&(t.selectionForeground=void 0),he.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=he.opacity(t.selectionBackgroundTransparent,.3)),he.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=he.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ae(e.scrollbarSliderBackground,he.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ae(e.scrollbarSliderHoverBackground,he.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ae(e.scrollbarSliderActiveBackground,he.opacity(t.foreground,.5)),t.overviewRulerBorder=ae(e.overviewRulerBorder,Kd),t.ansi=ke.slice(),t.ansi[0]=ae(e.black,ke[0]),t.ansi[1]=ae(e.red,ke[1]),t.ansi[2]=ae(e.green,ke[2]),t.ansi[3]=ae(e.yellow,ke[3]),t.ansi[4]=ae(e.blue,ke[4]),t.ansi[5]=ae(e.magenta,ke[5]),t.ansi[6]=ae(e.cyan,ke[6]),t.ansi[7]=ae(e.white,ke[7]),t.ansi[8]=ae(e.brightBlack,ke[8]),t.ansi[9]=ae(e.brightRed,ke[9]),t.ansi[10]=ae(e.brightGreen,ke[10]),t.ansi[11]=ae(e.brightYellow,ke[11]),t.ansi[12]=ae(e.brightBlue,ke[12]),t.ansi[13]=ae(e.brightMagenta,ke[13]),t.ansi[14]=ae(e.brightCyan,ke[14]),t.ansi[15]=ae(e.brightWhite,ke[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=ae(e.extendedAnsi[i],ke[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};dr=ge([$(0,We)],dr);function ae(e,t){if(e!==void 0)try{return _e.toColor(e)}catch{}return t}var qd=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Vd=class{constructor(){this._services=new qd,this._services.set(Mr,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=Hh(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let r=s.length>0?s[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},Yd={trace:0,debug:1,info:2,warn:3,error:4,off:5},Xd="xterm.js: ",ur=class extends Z{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Yd[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Xd)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};ur=ge([$(0,We)],ur);var Fn=class extends Z{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},G=3,Se=Object.freeze(new vs),As=0,wi=2,ls=class xa{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*G);let r=s||et.fromCharData([0,Oo,1,0]);for(let o=0;o<t;++o)this.setCell(o,r);this.length=t}get(t){let s=this._data[t*G+0],i=s&2097151;return[this._data[t*G+1],s&2097152?this._combined[t]:i?bt(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*G+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*G+0]=t|2097152|s[2]<<22):this._data[t*G+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*G+0]>>22}hasWidth(t){return this._data[t*G+0]&12582912}getFg(t){return this._data[t*G+1]}getBg(t){return this._data[t*G+2]}hasContent(t){return this._data[t*G+0]&4194303}getCodePoint(t){let s=this._data[t*G+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*G+0]&2097152}getString(t){let s=this._data[t*G+0];return s&2097152?this._combined[t]:s&2097151?bt(s&2097151):""}isProtected(t){return this._data[t*G+2]&536870912}loadCell(t,s){return As=t*G,s.content=this._data[As+0],s.fg=this._data[As+1],s.bg=this._data[As+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*G+0]=s.content,this._data[t*G+1]=s.fg,this._data[t*G+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*G+0]=s|i<<22,this._data[t*G+1]=r.fg,this._data[t*G+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*G+0];r&2097152?this._combined[t]+=bt(s):r&2097151?(this._combined[t]=bt(r&2097151)+bt(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*G+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let r=new et;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,r));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let r=new et;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*wi<this._data.buffer.byteLength;let i=t*G;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let a=0;a<r.length;a++){let l=parseInt(r[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*wi<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*wi<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new xa(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*G+0]&4194303)return t+(this._data[t*G+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*G+0]&4194303||this._data[t*G+2]&50331648)return t+(this._data[t*G+0]>>22);return 0}copyCellsFrom(t,s,i,r,o){let a=t._data;if(o)for(let c=r-1;c>=0;c--){for(let h=0;h<G;h++)this._data[(i+c)*G+h]=a[(s+c)*G+h];a[(s+c)*G+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}else for(let c=0;c<r;c++){for(let h=0;h<G;h++)this._data[(i+c)*G+h]=a[(s+c)*G+h];a[(s+c)*G+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}let l=Object.keys(t._combined);for(let c=0;c<l.length;c++){let h=parseInt(l[c],10);h>=s&&(this._combined[h-s+i]=t._combined[h])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let a=this._data[s*G+0],l=a&2097151,c=a&2097152?this._combined[s]:l?bt(l):wt;if(o+=c,r)for(let h=0;h<c.length;++h)r.push(s);s+=a>>22||1}return r&&r.push(s),o}};function Gd(e,t,s,i,r,o){let a=[];for(let l=0;l<e.length-1;l++){let c=l,h=e.get(++c);if(!h.isWrapped)continue;let d=[e.get(l)];for(;c<e.length&&h.isWrapped;)d.push(h),h=e.get(++c);if(!o&&i>=l&&i<c){l+=d.length-1;continue}let u=0,_=_s(d,u,t),m=1,f=0;for(;m<d.length;){let v=_s(d,m,t),k=v-f,N=s-_,L=Math.min(k,N);d[u].copyCellsFrom(d[m],f,_,L,!1),_+=L,_===s&&(u++,_=0),f+=L,f===v&&(m++,f=0),_===0&&u!==0&&d[u-1].getWidth(s-1)===2&&(d[u].copyCellsFrom(d[u-1],s-1,_++,1,!1),d[u-1].setCell(s-1,r))}d[u].replaceCells(_,s,r);let p=0;for(let v=d.length-1;v>0&&(v>u||d[v].getTrimmedLength()===0);v--)p++;p>0&&(a.push(l+d.length-p),a.push(p)),l+=d.length-1}return a}function Zd(e,t){let s=[],i=0,r=t[i],o=0;for(let a=0;a<e.length;a++)if(r===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,r=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function Qd(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function Jd(e,t,s){let i=[],r=e.map((c,h)=>_s(e,h,t)).reduce((c,h)=>c+h),o=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}o+=s;let c=_s(e,a,t);o>c&&(o-=c,a++);let h=e[a].getWidth(o-1)===2;h&&o--;let d=h?s-1:s;i.push(d),l+=d}return i}function _s(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}var ba=class Sa{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=Sa._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ot(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};ba._nextId=1;var eu=ba,Ee={},Bt=Ee.B;Ee[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Ee.A={"#":"£"};Ee.B=void 0;Ee[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ee.C=Ee[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ee.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ee.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ee.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ee.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ee.E=Ee[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ee.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ee.H=Ee[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ee["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Wn=4294967295,$n=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Se.clone(),this.savedCharset=Bt,this.markers=[],this._nullCell=et.fromCharData([0,Oo,1,0]),this._whitespaceCell=et.fromCharData([0,wt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Zs,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Fn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Vs),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Vs),this._whitespaceCell}getBlankLine(e,t){return new ls(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Wn?Wn:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Se);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Fn(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Se),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ls(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ls(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let a=this.lines.length-r;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=Gd(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Se),s);if(i.length>0){let r=Zd(this.lines,i);Qd(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Se),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ls(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Se),r=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),c.unshift(l);if(!s){let L=this.ybase+this.y;if(L>=a&&L<a+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=Jd(c,this._cols,e),u=d.length-c.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+u):_=Math.max(0,this.lines.length-this.lines.maxLength+u);let m=[];for(let L=0;L<u;L++){let D=this.getBlankLine(Se,!0);m.push(D)}m.length>0&&(r.push({start:a+c.length+o,newLines:m}),o+=m.length),c.push(...m);let f=d.length-1,p=d[f];p===0&&(f--,p=d[f]);let v=c.length-u-1,k=h;for(;v>=0;){let L=Math.min(k,p);if(c[f]===void 0)break;if(c[f].copyCellsFrom(c[v],k-L,p-L,L,!0),p-=L,p===0&&(f--,p=d[f]),k-=L,k===0){v--;let D=Math.max(v,0);k=_s(c,D,this._cols)}}for(let L=0;L<c.length;L++)d[L]<e&&c[L].setCell(d[L],i);let N=u-_;for(;N-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(r.length>0){let a=[],l=[];for(let p=0;p<this.lines.length;p++)l.push(this.lines.get(p));let c=this.lines.length,h=c-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let _=0;for(let p=Math.min(this.lines.maxLength-1,c+o-1);p>=0;p--)if(u&&u.start>h+_){for(let v=u.newLines.length-1;v>=0;v--)this.lines.set(p--,u.newLines[v]);p++,a.push({index:h+1,amount:u.newLines.length}),_+=u.newLines.length,u=r[++d]}else this.lines.set(p,l[h--]);let m=0;for(let p=a.length-1;p>=0;p--)a[p].index+=m,this.lines.onInsertEmitter.fire(a[p]),m+=a[p].amount;let f=Math.max(0,c+o-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new eu(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},tu=class extends Z{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new $n(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new $n(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},wa=2,ya=1,fr=class extends Z{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,wa),this.rows=Math.max(e.rawOptions.rows||0,ya),this.buffers=this._register(new tu(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};fr=ge([$(0,We)],fr);var Ut={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Gs,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},su=["normal","bold","100","200","300","400","500","600","700","800","900"],iu=class extends Z{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...Ut};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(de(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in Ut))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in Ut))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ut[e]),!ru(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ut[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=su.includes(t)?t:Ut[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function ru(e){return e==="block"||e==="underline"||e==="bar"}function hs(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&hs(e[i],t-1);return s}var Un=Object.freeze({insertMode:!1}),Kn=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),mr=class extends Z{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=hs(Un),this.decPrivateModes=hs(Kn)}reset(){this.modes=hs(Un),this.decPrivateModes=hs(Kn)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};mr=ge([$(0,Fe),$(1,$o),$(2,We)],mr);var qn={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function yi(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var Ci=String.fromCharCode,Vn={DEFAULT:e=>{let t=[yi(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Ci(t[0])}${Ci(t[1])}${Ci(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yi(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${yi(e,!0)};${e.x};${e.y}${t}`}},_r=class extends Z{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(qn))this.addProtocol(i,qn[i]);for(let i of Object.keys(Vn))this.addEncoding(i,Vn[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};_r=ge([$(0,Fe),$(1,Ht),$(2,We)],_r);var ki=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],nu=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ne;function ou(e,t){let s=0,i=t.length-1,r;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e<t[r][0])i=r-1;else return!0;return!1}var au=class{constructor(){if(this.version="6",!Ne){Ne=new Uint8Array(65536),Ne.fill(1),Ne[0]=0,Ne.fill(0,1,32),Ne.fill(0,127,160),Ne.fill(2,4352,4448),Ne[9001]=2,Ne[9002]=2,Ne.fill(2,11904,42192),Ne[12351]=1,Ne.fill(2,44032,55204),Ne.fill(2,63744,64256),Ne.fill(2,65040,65050),Ne.fill(2,65072,65136),Ne.fill(2,65280,65377),Ne.fill(2,65504,65511);for(let e=0;e<ki.length;++e)Ne.fill(0,ki[e][0],ki[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ne[e]:ou(e,nu)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=At.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return At.createPropertyValue(0,s,i)}},At=class $s{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new au;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,r=t.length;for(let o=0;o<r;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=r)return s+this.wcwidth(a);let h=t.charCodeAt(o);56320<=h&&h<=57343?a=(a-55296)*1024+h-56320+65536:s+=this.wcwidth(h)}let l=this.charProperties(a,i),c=$s.extractWidth(l);$s.extractShouldJoin(l)&&(c-=$s.extractWidth(i)),s+=c,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},lu=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Yn(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var ss=2147483647,hu=256,Ca=class pr{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>hu)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new pr;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let r=t[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let t=new pr(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ss?ss:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>ss?ss:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,ss):t}},is=[],cu=class{constructor(){this._state=0,this._active=is,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=is}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=is,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||is,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",si(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=is,this._id=-1,this._state=0}}},Ye=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=si(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},rs=[],du=class{constructor(){this._handlers=Object.create(null),this._active=rs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=rs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=rs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||rs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",si(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=rs,this._ident=0}},cs=new Ca;cs.addParam(0);var Xn=class{constructor(e){this._handler=e,this._data="",this._params=cs,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():cs,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=si(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=cs,this._data="",this._hitLimit=!1,s));return this._params=cs,this._data="",this._hitLimit=!1,t}},uu=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=s<<4|i}},Je=160,fu=(function(){let e=new uu(4095),t=Array.apply(null,Array(256)).map((l,c)=>c),s=(l,c)=>t.slice(l,c),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Je,0,2,0),e.add(Je,8,5,8),e.add(Je,6,0,6),e.add(Je,11,0,11),e.add(Je,13,13,13),e})(),mu=class extends Z{constructor(e=fu){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new Ca,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(de(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new cu),this._dcsParser=this._register(new du),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let o=e.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(a=l[c](),a!==!0);c--)if(a instanceof Promise)return this._parseStack.handlerPos=c,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],r=this._transitions.table[this.currentState<<8|(i<160?i:Je)],r>>4){case 2:for(let _=l+1;;++_){if(_>=t||(i=e[_])<32||i>126&&i<Je){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(i=e[_])<32||i>126&&i<Je){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(i=e[_])<32||i>126&&i<Je){this._printHandler(e,l,_),l=_-1;break}if(++_>=t||(i=e[_])<32||i>126&&i<Je){this._printHandler(e,l,_),l=_-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|i],h=c?c.length-1:-1;for(;h>=0&&(a=c[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._preserveStack(3,c,h,r,l),a;h<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let d=this._escHandlers[this._collect<<8|i],u=d?d.length-1:-1;for(;u>=0&&(a=d[u](),a!==!0);u--)if(a instanceof Promise)return this._preserveStack(4,d,u,r,l),a;u<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let _=l+1;;++_)if(_>=t||(i=e[_])===24||i===26||i===27||i>127&&i<Je){this._dcsParser.put(e,l,_),l=_-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=l+1;;_++)if(_>=t||(i=e[_])<32||i>127&&i<Je){this._oscParser.put(e,l,_),l=_-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},_u=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,pu=/^[\da-f]+$/;function Gn(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=_u.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),pu.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(t.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Ni(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function gu(e,t=16){let[s,i,r]=e;return`rgb:${Ni(s,t)}/${Ni(i,t)}/${Ni(r,t)}`}var vu={"(":0,")":1,"*":2,"+":3,"-":1,".":2},xt=131072,Zn=10;function Qn(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Jn=5e3,eo=0,xu=class extends Z{constructor(e,t,s,i,r,o,a,l,c=new mu){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Oh,this._utf8Decoder=new zh,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Se.clone(),this._eraseAttrDataInternal=Se.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new gr(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:d.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:d,data:u})}),this._parser.setDcsHandlerFallback((h,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:d,payload:u})}),this._parser.setPrintHandler((h,d,u)=>this.print(h,d,u)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(R.BEL,()=>this.bell()),this._parser.setExecuteHandler(R.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(R.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(R.BS,()=>this.backspace()),this._parser.setExecuteHandler(R.HT,()=>this.tab()),this._parser.setExecuteHandler(R.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(R.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Fs.IND,()=>this.index()),this._parser.setExecuteHandler(Fs.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Fs.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ye(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new Ye(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new Ye(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new Ye(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new Ye(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new Ye(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new Ye(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new Ye(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new Ye(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new Ye(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new Ye(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new Ye(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Ee)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new Xn((h,d)=>this.requestStatusString(h,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Jn))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Jn} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>xt&&(o=this._parseStack.position+xt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<xt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,xt))),a||this._dirtyRowTracker.clearRange(),e.length>xt)for(let h=o;h<e.length;h+=xt){let d=h+xt<e.length?h+xt:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(h,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,d),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,u))return this._preserveStack(i,r,u,h),this._logSlowResolvingAsync(s),s}else if(!a){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,h))return this._preserveStack(i,r,h,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,r,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let _=this._parser.precedingJoinState;for(let m=t;m<s;++m){if(i=e[m],i<127&&o){let k=o[String.fromCharCode(i)];k&&(i=k.charCodeAt(0))}let f=this._unicodeService.charProperties(i,_);r=At.extractWidth(f);let p=At.extractShouldJoin(f),v=p?At.extractWidth(_):0;if(_=f,a&&this._onA11yChar.fire(bt(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-v>l){if(c){let k=u,N=this._activeBuffer.x-v;for(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&u instanceof ls&&u.copyCellsFrom(k,N,0,v,!1);N<l;)k.setCellFromCodepoint(N++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(p&&this._activeBuffer.x){let k=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-k,i,r);for(let N=r-v;--N>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,r-v,this._activeBuffer.getNullCell(d)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,i,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=_,this._activeBuffer.x<l&&s-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>Qn(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new Xn(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ye(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Se));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=At.extractWidth(t),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(o.length*s),l=0;for(let h=0;h<o.length;){let d=o.codePointAt(h)||0;a[l++]=d,h+=d>65535?2:1}let c=l;for(let h=1;h<s;++h)a.copyWithin(c,0,l),c+=l;return this.print(a,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(R.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(R.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(R.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(R.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(R.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Bt),this._charsetService.setgCharset(1,Bt),this._charsetService.setgCharset(2,Bt),this._charsetService.setgCharset(3,Bt);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(p=>(p[p.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",p[p.SET=1]="SET",p[p.RESET=2]="RESET",p[p.PERMANENTLY_SET=3]="PERMANENTLY_SET",p[p.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:h,alt:d}=l,u=this._optionsService.rawOptions,_=(p,v)=>(a.triggerDataEvent(`${R.ESC}[${t?"":"?"}${p};${v}$y`),!0),m=p=>p?1:2,f=e.params[0];return t?f===2?_(f,4):f===4?_(f,m(a.modes.insertMode)):f===12?_(f,3):f===20?_(f,m(u.convertEol)):_(f,0):f===1?_(f,m(i.applicationCursorKeys)):f===3?_(f,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):f===6?_(f,m(i.origin)):f===7?_(f,m(i.wraparound)):f===8?_(f,3):f===9?_(f,m(r==="X10")):f===12?_(f,m(u.cursorBlink)):f===25?_(f,m(!a.isCursorHidden)):f===45?_(f,m(i.reverseWraparound)):f===66?_(f,m(i.applicationKeypad)):f===67?_(f,4):f===1e3?_(f,m(r==="VT200")):f===1002?_(f,m(r==="DRAG")):f===1003?_(f,m(r==="ANY")):f===1004?_(f,m(i.sendFocus)):f===1005?_(f,4):f===1006?_(f,m(o==="SGR")):f===1015?_(f,4):f===1016?_(f,m(o==="SGR_PIXELS")):f===1048?_(f,1):f===47||f===1047||f===1049?_(f,m(h===d)):f===2004?_(f,m(i.bracketedPasteMode)):f===2026?_(f,m(i.synchronizedOutput)):_(f,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=vs.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(r=1),i[o+l+1+r]=a[l];while(++l<a.length&&l+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+t<e.length&&o+r<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Se.fg,e.bg=Se.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let r=0;r<t;r++)s=e.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Se.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Se.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Se.fg&16777215,i.bg&=-67108864,i.bg|=Se.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${R.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Se.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Qn(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${R.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Zn&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Zn&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(to(o))if(r==="?")t.push({type:0,index:o});else{let a=Gn(r);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=Gn(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);to(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Bt),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(vu[e[0]],Ee[e[1]]||Bt),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Se.clone(),this._eraseAttrDataInternal=Se.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new et;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${R.ESC}${a}${R.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},gr=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(eo=e,e=t,t=eo),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};gr=ge([$(0,Fe)],gr);function to(e){return 0<=e&&e<256}var bu=5e7,so=12,Su=50,wu=class extends Z{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>bu)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let a=l=>performance.now()-s>=so?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=so)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Su&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},vr=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),c={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};vr=ge([$(0,Fe)],vr);var io=!1,yu=class extends Z{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Vt),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new Vd,this.optionsService=this._register(new iu(e)),this._instantiationService.setService(We,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(fr)),this._instantiationService.setService(Fe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ur)),this._instantiationService.setService($o,this._logService),this.coreService=this._register(this._instantiationService.createInstance(mr)),this._instantiationService.setService(Ht,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(_r)),this._instantiationService.setService(Wo,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(At)),this._instantiationService.setService($h,this.unicodeService),this._charsetService=this._instantiationService.createInstance(lu),this._instantiationService.setService(Wh,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(vr),this._instantiationService.setService(Uo,this._oscLinkService),this._inputHandler=this._register(new xu(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ie.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ie.forward(this._bufferService.onResize,this._onResize)),this._register(Ie.forward(this.coreService.onData,this._onData)),this._register(Ie.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new wu((t,s)=>this._inputHandler.parse(t,s))),this._register(Ie.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!io&&(this._logService.warn("writeSync is unreliable and will be removed soon."),io=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,wa),t=Math.max(t,ya),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Yn.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Yn(this._bufferService),!1))),this._windowsWrappingHeuristics.value=de(()=>{for(let t of e)t.dispose()})}}},Cu={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function ku(e,t,s,i){var a;let r={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=R.ESC+"OA":r.key=R.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=R.ESC+"OD":r.key=R.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=R.ESC+"OC":r.key=R.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=R.ESC+"OB":r.key=R.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":R.DEL,e.altKey&&(r.key=R.ESC+r.key);break;case 9:if(e.shiftKey){r.key=R.ESC+"[Z";break}r.key=R.HT,r.cancel=!0;break;case 13:r.key=e.altKey?R.ESC+R.CR:R.CR,r.cancel=!0;break;case 27:r.key=R.ESC,e.altKey&&(r.key=R.ESC+R.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;o?r.key=R.ESC+"[1;"+(o+1)+"D":t?r.key=R.ESC+"OD":r.key=R.ESC+"[D";break;case 39:if(e.metaKey)break;o?r.key=R.ESC+"[1;"+(o+1)+"C":t?r.key=R.ESC+"OC":r.key=R.ESC+"[C";break;case 38:if(e.metaKey)break;o?r.key=R.ESC+"[1;"+(o+1)+"A":t?r.key=R.ESC+"OA":r.key=R.ESC+"[A";break;case 40:if(e.metaKey)break;o?r.key=R.ESC+"[1;"+(o+1)+"B":t?r.key=R.ESC+"OB":r.key=R.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=R.ESC+"[2~");break;case 46:o?r.key=R.ESC+"[3;"+(o+1)+"~":r.key=R.ESC+"[3~";break;case 36:o?r.key=R.ESC+"[1;"+(o+1)+"H":t?r.key=R.ESC+"OH":r.key=R.ESC+"[H";break;case 35:o?r.key=R.ESC+"[1;"+(o+1)+"F":t?r.key=R.ESC+"OF":r.key=R.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=R.ESC+"[5;"+(o+1)+"~":r.key=R.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=R.ESC+"[6;"+(o+1)+"~":r.key=R.ESC+"[6~";break;case 112:o?r.key=R.ESC+"[1;"+(o+1)+"P":r.key=R.ESC+"OP";break;case 113:o?r.key=R.ESC+"[1;"+(o+1)+"Q":r.key=R.ESC+"OQ";break;case 114:o?r.key=R.ESC+"[1;"+(o+1)+"R":r.key=R.ESC+"OR";break;case 115:o?r.key=R.ESC+"[1;"+(o+1)+"S":r.key=R.ESC+"OS";break;case 116:o?r.key=R.ESC+"[15;"+(o+1)+"~":r.key=R.ESC+"[15~";break;case 117:o?r.key=R.ESC+"[17;"+(o+1)+"~":r.key=R.ESC+"[17~";break;case 118:o?r.key=R.ESC+"[18;"+(o+1)+"~":r.key=R.ESC+"[18~";break;case 119:o?r.key=R.ESC+"[19;"+(o+1)+"~":r.key=R.ESC+"[19~";break;case 120:o?r.key=R.ESC+"[20;"+(o+1)+"~":r.key=R.ESC+"[20~";break;case 121:o?r.key=R.ESC+"[21;"+(o+1)+"~":r.key=R.ESC+"[21~";break;case 122:o?r.key=R.ESC+"[23;"+(o+1)+"~":r.key=R.ESC+"[23~";break;case 123:o?r.key=R.ESC+"[24;"+(o+1)+"~":r.key=R.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=R.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=R.DEL:e.keyCode===219?r.key=R.ESC:e.keyCode===220?r.key=R.FS:e.keyCode===221&&(r.key=R.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=Cu[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)r.key=R.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let c=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(c);e.shiftKey&&(h=h.toUpperCase()),r.key=R.ESC+h}else if(e.keyCode===32)r.key=R.ESC+(e.ctrlKey?R.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let c=e.code.slice(3,4);e.shiftKey||(c=c.toLowerCase()),r.key=R.ESC+c,r.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=R.US),e.key==="@"&&(r.key=R.NUL));break}return r}var xe=0,Nu=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Zs,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Zs,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,o)=>this._getKey(r)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(xe=this._search(t),xe===-1)||this._getKey(this._array[xe])!==t)return!1;do if(this._array[xe]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(xe),!0;while(++xe<this._array.length&&this._getKey(this._array[xe])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,o)=>r-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xe=this._search(e),!(xe<0||xe>=this._array.length)&&this._getKey(this._array[xe])===e))do yield this._array[xe];while(++xe<this._array.length&&this._getKey(this._array[xe])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xe=this._search(e),!(xe<0||xe>=this._array.length)&&this._getKey(this._array[xe])===e))do t(this._array[xe]);while(++xe<this._array.length&&this._getKey(this._array[xe])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Ei=0,ro=0,Eu=class extends Z{constructor(){super(),this._decorations=new Nu(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(de(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new ju(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,r=i+(o.options.width??1),e>=i&&e<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,r=>{Ei=r.options.x??0,ro=Ei+(r.options.width??1),e>=Ei&&e<ro&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},ju=class extends yt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=_e.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=_e.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Mu=1e3,Du=class{constructor(e,t=Mu){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},no=20,Qs=class extends Z{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Du(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
128
|
+
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(X(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(de(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<no+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
129
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===no+1&&(this._liveRegion.textContent+=Oi.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=e;r<=t;r++){let o=s.lines.get(s.ydisp+r),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",c=(s.ydisp+r+1).toString(),h=this._rowElements[r];h&&(l.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=l,this._rowColumns.set(h,a)),h.setAttribute("aria-posinset",c),h.setAttribute("aria-setsize",i),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let r=({node:c,offset:h})=>{let d=c instanceof Text?c.parentNode:c,u=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(d);if(!_)return console.warn("columns is null. Race condition?"),null;let m=h<_.length?_[h]:_.slice(-1)[0]+1;return m>=this._terminal.cols&&(++u,m=0),{row:u,column:m}},o=r(t),a=r(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var r,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};Qs=ge([$(1,Mr),$(2,ft),$(3,mt)],Qs);var xr=class extends Z{constructor(e,t,s,i,r){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(de(()=>{var o;Ot(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(X(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(X(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(X(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(X(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,r;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var h,d;if(this._isMouseOut)return;let c=l==null?void 0:l.map(u=>({link:u}));(h=this._activeProviderReplies)==null||h.set(o,c),s=this._checkLinkProviderResult(o,e,s),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let r=t.get(i);if(r)for(let o=0;o<r.length;o++){let a=r[o],l=a.link.range.start.y<e?0:a.link.range.start.x,c=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let h=l;h<=c;h++){if(s.has(h)){r.splice(o--,1);break}s.add(h)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),r=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(r=!0);if(!r&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(c=>this._linkAtPosition(c.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Ru(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ot(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,r,o;(i=this._currentLink)!=null&&i.state&&((o=(r=this._currentLink)==null?void 0:r.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return s<=r&&r<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,r){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};xr=ge([$(1,Dr),$(2,mt),$(3,Fe),$(4,qo)],xr);function Ru(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Tu=class extends yu{constructor(e={}){super(e),this._linkifier=this._register(new Vt),this.browser=da,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Vt),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(Eu),this._instantiationService.setService(xs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Sd),this._instantiationService.setService(qo,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Hi)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ie.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ie.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ie.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ie.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(de(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let r=he.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${R.ESC}]${i};${gu(r)}${ha.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=we.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=we.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Qs,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(X(this.element,"copy",t=>{this.hasSelection()&&Ph(t,this._selectionService)}));let e=t=>Ih(t,this.textarea,this.coreService,this.optionsService);this._register(X(this.textarea,"paste",e)),this._register(X(this.element,"paste",e)),ua?this._register(X(this.element,"mousedown",t=>{t.button===2&&_n(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(X(this.element,"contextmenu",t=>{_n(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Or&&this._register(X(this.element,"auxclick",t=>{t.button===1&&Io(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(X(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(X(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(X(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(X(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(X(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(X(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(X(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(X(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Ii.get()),_a||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(xd,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(ft,this._coreBrowserService),this._register(X(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(X(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ar,this._document,this._helperContainer),this._instantiationService.setService(ii,this._charSizeService),this._themeService=this._instantiationService.createInstance(dr),this._instantiationService.setService(Gt,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Xs),this._instantiationService.setService(Ko,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(hr,this.rows,this.screenElement)),this._instantiationService.setService(mt,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(rr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lr),this._instantiationService.setService(Dr,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(xr,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(sr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(cr,this.element,this.screenElement,i)),this._instantiationService.setService(Kh,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Ie.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(ir,this.screenElement)),this._register(X(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Qs,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ys,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ys,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(or,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var h,d,u,_,m;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,l=o.button<3?o.button:3;break;case"mousedown":c=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let f=o.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(o,(_=(u=(d=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:d.device)==null?void 0:u.cell)==null?void 0:_.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return!1;c=f<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(t.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(X(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(X(t,"wheel",o=>{var a,l,c,h,d;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(c=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:c.cell)==null?void 0:h.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(o,!0);let u=R.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Po(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=ku(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===R.ETX||s.key===R.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Lu(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Se));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(R.ESC+"[I"):this.coreService.triggerDataEvent(R.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${R.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${R.ESC}[6;${r};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Lu(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var Bu=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Au=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new et)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},oo=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Au(t)}getNullCell(){return new et}},Pu=class extends Z{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new oo(this._core.buffers.normal,"normal"),this._alternate=new oo(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},Iu=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Ou=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},zu=["cols","rows"],rt=0,Hu=class extends Z{constructor(e){super(),this._core=this._register(new Tu(e)),this._addonManager=this._register(new Bu),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(e){if(zu.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new Iu(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Ou(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new Pu(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
130
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Ii.get()},set promptLabel(e){Ii.set(e)},get tooMuchOutput(){return Oi.get()},set tooMuchOutput(e){Oi.set(e)}}}_verifyIntegers(...e){for(rt of e)if(rt===1/0||isNaN(rt)||rt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(rt of e)if(rt&&(rt===1/0||isNaN(rt)||rt%1!==0||rt<0))throw new Error("This API only accepts positive integers")}};/**
|
|
131
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
132
|
+
* @license MIT
|
|
133
|
+
*
|
|
134
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
135
|
+
* @license MIT
|
|
136
|
+
*
|
|
137
|
+
* Originally forked from (with the author's permission):
|
|
138
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
139
|
+
* http://bellard.org/jslinux/
|
|
140
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
141
|
+
*/var Fu=2,Wu=1,$u=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var u;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((u=this._terminal.options.overviewRuler)==null?void 0:u.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,c=a.right+a.left,h=i-l,d=r-c-t;return{cols:Math.max(Fu,Math.floor(d/e.css.cell.width)),rows:Math.max(Wu,Math.floor(h/e.css.cell.height))}}};/**
|
|
142
|
+
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
143
|
+
* @license MIT
|
|
144
|
+
*
|
|
145
|
+
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
|
146
|
+
* @license MIT
|
|
147
|
+
*
|
|
148
|
+
* Originally forked from (with the author's permission):
|
|
149
|
+
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
150
|
+
* http://bellard.org/jslinux/
|
|
151
|
+
* Copyright (c) 2011 Fabrice Bellard
|
|
152
|
+
*/var Uu=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=qu.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:r}=t;this._options.hover(s,i,r)}},t))}};function Ku(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var qu=class Us{static computeLink(t,s,i,r){let o=new RegExp(s.source,(s.flags||"")+"g"),[a,l]=Us._getWindowedLineStrings(t-1,i),c=a.join(""),h,d=[];for(;h=o.exec(c);){let u=h[0];if(!Ku(u))continue;let[_,m]=Us._mapStrIdx(i,l,0,h.index),[f,p]=Us._mapStrIdx(i,_,m,u.length);if(_===-1||m===-1||f===-1||p===-1)continue;let v={start:{x:m+1,y:_+1},end:{x:p,y:f+1}};d.push({range:v,text:u,activate:r})}return d}static _getWindowedLineStrings(t,s){let i,r=t,o=t,a=0,l="",c=[];if(i=s.buffer.active.getLine(t)){let h=i.translateToString(!0);if(i.isWrapped&&h[0]!==" "){for(a=0;(i=s.buffer.active.getLine(--r))&&a<2048&&(l=i.translateToString(!0),a+=l.length,c.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););c.reverse()}for(c.push(h),a=0;(i=s.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,c.push(l),l.indexOf(" ")===-1););}return[c,r]}static _mapStrIdx(t,s,i,r){let o=t.buffer.active,a=o.getNullCell(),l=i;for(;r;){let c=o.getLine(s);if(!c)return[-1,-1];for(let h=l;h<c.length;++h){c.getCell(h,a);let d=a.getChars();if(a.getWidth()&&(r-=d.length||1,h===c.length-1&&d==="")){let u=o.getLine(s+1);u&&u.isWrapped&&(u.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[s,h]}s++,l=0}return[s,l]}},Vu=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Yu(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var Xu=class{constructor(e=Yu,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,s=t.urlRegex||Vu;this._linkProvider=this._terminal.registerLinkProvider(new Uu(this._terminal,s,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};function ao({groupJid:e,visible:t,onHide:s,onDelete:i}){const r=g.useRef(null),o=g.useRef(null),a=g.useRef(null),l=g.useRef(t),[c,h]=g.useState("idle"),d=g.useRef("idle"),u=_=>{d.current=_,h(_)};return g.useEffect(()=>{if(l.current=t,!t)return;const _=setTimeout(()=>{if(!(!a.current||!o.current)&&(a.current.fit(),o.current.focus(),d.current==="connected")){const{cols:m,rows:f}=o.current;ce.send({type:"terminal_resize",chatJid:e,cols:m,rows:f})}},300);return()=>clearTimeout(_)},[t,e]),g.useEffect(()=>{var w;if(!r.current)return;const _=new Hu({cursorBlink:!0,fontSize:14,lineHeight:1.15,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, monospace",scrollback:5e3,convertEol:!0,theme:{background:"#1a1b26",foreground:"#a9b1d6",cursor:"#c0caf5",selectionBackground:"#33467c",black:"#32344a",red:"#f7768e",green:"#9ece6a",yellow:"#e0af68",blue:"#7aa2f7",magenta:"#ad8ee6",cyan:"#449dab",white:"#787c99",brightBlack:"#444b6a",brightRed:"#ff7a93",brightGreen:"#b9f27c",brightYellow:"#ff9e64",brightBlue:"#7da6ff",brightMagenta:"#bb9af7",brightCyan:"#0db9d7",brightWhite:"#acb0d0"}}),m=new $u,f=new Xu;_.loadAddon(m),_.loadAddon(f),_.open(r.current),o.current=_,a.current=m,setTimeout(()=>{m.fit()},100);const p=()=>{const x=_.cols,E=_.rows;ce.send({type:"terminal_start",chatJid:e,cols:x,rows:E})},v=()=>{u("connecting"),ce.isConnected()?p():ce.connect()},k=ce.on("terminal_output",x=>{x.chatJid===e&&_.write(x.data)}),N=ce.on("terminal_started",x=>{x.chatJid===e&&u("connected")}),L=ce.on("terminal_stopped",x=>{x.chatJid===e&&(u("disconnected"),_.write(`\r
|
|
153
|
+
\x1B[33m[${x.reason||"终端已断开"}]\x1B[0m\r
|
|
154
|
+
`),x.reason!=="用户关闭终端"&&(_.write(`\x1B[33m[3 秒后自动重连...]\x1B[0m\r
|
|
155
|
+
`),setTimeout(()=>{d.current==="disconnected"&&ce.isConnected()&&v()},3e3)))}),D=ce.on("terminal_error",x=>{var E,b;x.chatJid===e&&(u("disconnected"),(E=x.error)!=null&&E.includes("工作区未运行")||(b=x.error)!=null&&b.includes("工作区启动中")?(_.write(`\r
|
|
156
|
+
\x1B[33m[工作区启动中,5 秒后自动重连...]\x1B[0m\r
|
|
157
|
+
`),setTimeout(()=>{d.current==="disconnected"&&ce.isConnected()&&v()},5e3)):_.write(`\r
|
|
158
|
+
\x1B[31m[错误: ${x.error}]\x1B[0m\r
|
|
159
|
+
`))}),T=ce.on("connected",()=>{d.current!=="connected"&&(u("connecting"),p())}),B=ce.on("disconnected",()=>{u("disconnected"),_.write(`\r
|
|
160
|
+
\x1B[33m[WebSocket 已断开,等待重连]\x1B[0m\r
|
|
161
|
+
`)});let I=!1;const H=(w=r.current)==null?void 0:w.querySelector("textarea"),U=()=>{I=!0},q=()=>{setTimeout(()=>{I=!1},50)};H&&(H.addEventListener("compositionstart",U),H.addEventListener("compositionend",q));const A=_.onData(x=>{I||d.current==="connected"&&ce.send({type:"terminal_input",chatJid:e,data:x})});let S=null;const y=new ResizeObserver(()=>{l.current&&(S&&clearTimeout(S),S=setTimeout(()=>{if(S=null,a.current&&o.current&&(a.current.fit(),d.current==="connected")){const{cols:x,rows:E}=o.current;ce.send({type:"terminal_resize",chatJid:e,cols:x,rows:E})}},150))});return y.observe(r.current),v(),()=>{S&&clearTimeout(S),y.disconnect(),H&&(H.removeEventListener("compositionstart",U),H.removeEventListener("compositionend",q)),A.dispose(),k(),N(),L(),D(),T(),B(),ce.isConnected()&&ce.send({type:"terminal_stop",chatJid:e}),_.dispose(),o.current=null,a.current=null}},[e]),n.jsxs("div",{className:"h-full flex flex-col terminal-panel",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[#1a1b26] border-b border-[#2a2b36] text-xs",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${c==="connected"?"bg-green-400":c==="connecting"?"bg-yellow-400 animate-pulse":"bg-neutral-500"}`}),n.jsx("span",{className:"text-neutral-400",children:c==="connected"?"已连接":c==="connecting"?"连接中...":c==="disconnected"?"已断开":"空闲"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[c==="disconnected"&&n.jsx("button",{onClick:()=>{var _,m;if(u("connecting"),ce.isConnected()){const f=((_=o.current)==null?void 0:_.cols)||80,p=((m=o.current)==null?void 0:m.rows)||24;ce.send({type:"terminal_start",chatJid:e,cols:f,rows:p})}else ce.connect()},className:"text-brand-400 hover:text-brand-300 transition-colors cursor-pointer",children:"重新连接"}),s&&n.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-[#2a2b36] text-neutral-400 hover:text-neutral-200 transition-colors cursor-pointer","aria-label":"隐藏终端",title:"隐藏终端",children:n.jsx(al,{className:"w-3.5 h-3.5"})}),i&&n.jsx("button",{onClick:i,className:"p-1 rounded hover:bg-red-900/30 text-neutral-400 hover:text-red-300 transition-colors cursor-pointer","aria-label":"删除终端",title:"删除终端",children:n.jsx(Ct,{className:"w-3.5 h-3.5"})})]})]}),n.jsx("div",{ref:r,className:"flex-1 min-h-0 overflow-hidden bg-[#1a1b26]"})]})}function lo({groupJid:e}){const t=kr(),s=V(S=>S.groups[e]),i=Ge(S=>S.user),r=Tt(S=>S.members[e]),o=Tt(S=>S.membersLoading),a=r??[],[l,c]=g.useState(""),[h,d]=g.useState([]),[u,_]=g.useState(!1),[m,f]=g.useState(!1),[p,v]=g.useState(null),[k,N]=g.useState(null),[L,D]=g.useState(!1),T=(s==null?void 0:s.member_role)==="owner",B=(i==null?void 0:i.role)==="admin",I=T||B,H=g.useRef(null);g.useEffect(()=>{H.current!==e&&(H.current=e,Tt.getState().loadMembers(e).catch(()=>{}))},[e]),g.useEffect(()=>{if(!l.trim()){d([]);return}const S=setTimeout(async()=>{_(!0);try{const y=await Ke.get(`/api/groups/${encodeURIComponent(e)}/members/search?q=${encodeURIComponent(l.trim())}`),w=new Set(a.map(x=>x.user_id));d(y.users.filter(x=>!w.has(x.id)))}catch{d([])}finally{_(!1)}},300);return()=>clearTimeout(S)},[l,a]);const U=async S=>{f(!0),N(null);try{await Tt.getState().addMember(e,S),c(""),d([]),D(!1)}catch(y){N(y instanceof Error?y.message:"添加成员失败")}finally{f(!1)}},q=async S=>{v(S),N(null);try{await Tt.getState().removeMember(e,S)}catch(y){N(y instanceof Error?y.message:"移除成员失败")}finally{v(null)}},A=async()=>{if(i&&confirm("确定要退出该工作区吗?退出后将无法访问此工作区的消息和文件。")){v(i.id),N(null);try{await Tt.getState().removeMember(e,i.id),t("/chat")}catch(S){N(S instanceof Error?S.message:"退出失败")}finally{v(null)}}};return o&&a.length===0?n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:"加载中..."}):n.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[k&&n.jsx("div",{className:"px-4 py-2 bg-red-50 dark:bg-red-950/40 text-red-600 dark:text-red-400 text-xs border-b border-red-100 dark:border-red-800",children:k}),I&&n.jsx("div",{className:"px-4 pt-3 pb-2 border-b border-border",children:L?n.jsxs("div",{className:"space-y-2",children:[n.jsx("input",{type:"text",value:l,onChange:S=>c(S.target.value),placeholder:"搜索用户名...",className:"w-full px-3 py-1.5 text-sm border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-brand-500/30 focus:border-brand-400",autoFocus:!0}),u&&n.jsx("div",{className:"text-xs text-muted-foreground px-1",children:"搜索中..."}),h.length>0&&n.jsx("div",{className:"max-h-40 overflow-y-auto border border-border rounded-lg divide-y divide-border",children:h.map(S=>n.jsxs("button",{onClick:()=>U(S.id),disabled:m,className:"w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-muted/50 transition-colors cursor-pointer disabled:opacity-50 text-left",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"font-medium text-foreground truncate",children:S.display_name||S.username}),S.display_name&&n.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["@",S.username]})]}),n.jsx(qr,{className:"w-4 h-4 text-brand-500 flex-shrink-0"})]},S.id))}),l.trim()&&!u&&h.length===0&&n.jsx("div",{className:"text-xs text-muted-foreground px-1",children:"未找到可添加的用户"}),n.jsx("button",{onClick:()=>{D(!1),c(""),d([])},className:"text-xs text-muted-foreground hover:text-foreground cursor-pointer",children:"取消"})]}):n.jsxs("button",{onClick:()=>D(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-brand-600 hover:bg-brand-50 rounded-lg transition-colors cursor-pointer",children:[n.jsx(qr,{className:"w-4 h-4"}),"添加成员"]})}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:a.length===0?n.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:"暂无成员"}):n.jsx("div",{className:"divide-y divide-border",children:a.map(S=>{const y=S.user_id===(i==null?void 0:i.id),w=S.role==="owner";return n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[n.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground flex-shrink-0",children:(S.display_name||S.username).charAt(0).toUpperCase()}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:S.display_name||S.username}),y&&n.jsx("span",{className:"text-[10px] text-muted-foreground",children:"(我)"}),w&&n.jsx(zl,{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0"})]}),n.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["@",S.username]})]}),!w&&n.jsxs(n.Fragment,{children:[I&&!y&&n.jsx("button",{onClick:()=>q(S.user_id),disabled:p===S.user_id,className:"p-1.5 rounded-md hover:bg-red-50 dark:hover:bg-red-950/40 text-muted-foreground hover:text-red-500 dark:hover:text-red-400 transition-colors cursor-pointer disabled:opacity-50",title:"移除成员",children:n.jsx(Ct,{className:"w-3.5 h-3.5"})}),y&&!I&&n.jsxs("button",{onClick:A,disabled:p===S.user_id,className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-red-50 dark:hover:bg-red-950/40 hover:text-red-500 dark:hover:text-red-400 transition-colors cursor-pointer disabled:opacity-50",children:[n.jsx(wo,{className:"w-3.5 h-3.5"}),"退出"]})]})]},S.user_id)})})})]})}function ct(e){return`/api/groups/${encodeURIComponent(e)}/workspace-config`}const ka=So((e,t)=>({skills:[],skillsLoading:!1,skillsError:null,skillsInstalling:!1,loadWorkspaceSkills:async s=>{e({skills:[],skillsLoading:!0,skillsError:null});try{const i=await Ke.get(`${ct(s)}/skills`);e({skills:i.skills,skillsLoading:!1,skillsError:null})}catch(i){e({skillsLoading:!1,skillsError:pt(i)})}},installWorkspaceSkill:async(s,i)=>{e({skillsInstalling:!0,skillsError:null});try{await Ke.post(`${ct(s)}/skills/install`,{package:i},6e4),await t().loadWorkspaceSkills(s)}catch(r){throw e({skillsError:(r==null?void 0:r.message)||"安装失败"}),r}finally{e({skillsInstalling:!1})}},toggleWorkspaceSkill:async(s,i,r)=>{try{await Ke.patch(`${ct(s)}/skills/${encodeURIComponent(i)}`,{enabled:r}),await t().loadWorkspaceSkills(s)}catch(o){e({skillsError:pt(o)})}},deleteWorkspaceSkill:async(s,i)=>{try{await Ke.delete(`${ct(s)}/skills/${encodeURIComponent(i)}`),await t().loadWorkspaceSkills(s)}catch(r){throw e({skillsError:pt(r)}),r}},mcpServers:[],mcpLoading:!1,mcpError:null,loadWorkspaceMcp:async s=>{e({mcpServers:[],mcpLoading:!0,mcpError:null});try{const i=await Ke.get(`${ct(s)}/mcp-servers`);e({mcpServers:i.servers,mcpLoading:!1,mcpError:null})}catch(i){e({mcpLoading:!1,mcpError:pt(i)})}},addWorkspaceMcp:async(s,i)=>{try{await Ke.post(`${ct(s)}/mcp-servers`,i),e({mcpError:null}),await t().loadWorkspaceMcp(s)}catch(r){throw e({mcpError:pt(r)}),r}},updateWorkspaceMcp:async(s,i,r)=>{try{await Ke.patch(`${ct(s)}/mcp-servers/${encodeURIComponent(i)}`,r),e({mcpError:null}),await t().loadWorkspaceMcp(s)}catch(o){throw e({mcpError:pt(o)}),o}},toggleWorkspaceMcp:async(s,i,r)=>{try{await Ke.patch(`${ct(s)}/mcp-servers/${encodeURIComponent(i)}`,{enabled:r}),e({mcpError:null}),await t().loadWorkspaceMcp(s)}catch(o){e({mcpError:pt(o)})}},deleteWorkspaceMcp:async(s,i)=>{try{await Ke.delete(`${ct(s)}/mcp-servers/${encodeURIComponent(i)}`),e({mcpError:null}),await t().loadWorkspaceMcp(s)}catch(r){throw e({mcpError:pt(r)}),r}}}));function ho({groupJid:e,onClose:t}){const{skills:s,skillsLoading:i,skillsError:r,skillsInstalling:o,loadWorkspaceSkills:a,installWorkspaceSkill:l,toggleWorkspaceSkill:c,deleteWorkspaceSkill:h}=ka(),[d,u]=g.useState(""),[_,m]=g.useState(!1),[f,p]=g.useState(null);g.useEffect(()=>{a(e)},[e,a]);const v=async()=>{if(d.trim())try{await l(e,d.trim()),u(""),m(!1)}catch{}},k=async()=>{if(f){try{await h(e,f)}catch{}p(null)}};return n.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border flex-shrink-0",children:[n.jsx("h3",{className:"text-sm font-medium text-foreground",children:"工作区 Skills"}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>a(e),disabled:i,className:"h-7 w-7 p-0",children:n.jsx(ti,{className:`w-3.5 h-3.5 ${i?"animate-spin":""}`})}),n.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>m(!_),className:"h-7 w-7 p-0",children:n.jsx(It,{className:"w-3.5 h-3.5"})})]})]}),_&&n.jsxs("div",{className:"px-4 py-2 border-b border-border flex-shrink-0",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsx(Xe,{value:d,onChange:N=>u(N.target.value),placeholder:"owner/repo 或 URL",className:"h-8 text-sm",onKeyDown:N=>N.key==="Enter"&&v()}),n.jsx(ye,{size:"sm",onClick:v,disabled:o||!d.trim(),className:"h-8 px-3",children:o?n.jsx(Be,{className:"w-3.5 h-3.5 animate-spin"}):"安装"})]}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:"安装 skills.sh 上的技能到当前工作区"})]}),r&&n.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs flex-shrink-0",children:r}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:i&&s.length===0?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(Be,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):s.length===0?n.jsx(yo,{icon:Co,title:"无工作区 Skills",description:"当前工作区 .claude/skills/ 下没有自定义技能",action:n.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[n.jsx(It,{className:"w-3.5 h-3.5 mr-1"}),"安装技能"]})}):n.jsx("div",{className:"divide-y divide-border",children:s.map(N=>n.jsx(Gu,{skill:N,onToggle:L=>c(e,N.id,L),onDelete:()=>p(N.id)},N.id))})}),n.jsx(Xt,{open:!!f,onClose:()=>p(null),onConfirm:k,title:"删除技能",message:`确定要从工作区删除技能 "${f}" 吗?此操作不可撤销。`,confirmText:"删除",confirmVariant:"danger"})]})}function Gu({skill:e,onToggle:t,onDelete:s}){return n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-accent/50 transition-colors",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.name}),!e.enabled&&n.jsx("span",{className:"text-[10px] text-muted-foreground bg-muted px-1 py-px rounded",children:"已禁用"})]}),e.description&&n.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:e.description})]}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsx("button",{onClick:()=>t(!e.enabled),className:"p-1 rounded hover:bg-accent transition-colors cursor-pointer",title:e.enabled?"禁用":"启用",children:e.enabled?n.jsx(Do,{className:"w-4 h-4 text-emerald-500"}):n.jsx(Mo,{className:"w-4 h-4 text-muted-foreground"})}),n.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-destructive transition-colors cursor-pointer",title:"删除",children:n.jsx(Ct,{className:"w-3.5 h-3.5"})})]})]})}function co({groupJid:e,onClose:t}){const{mcpServers:s,mcpLoading:i,mcpError:r,loadWorkspaceMcp:o,addWorkspaceMcp:a,toggleWorkspaceMcp:l,deleteWorkspaceMcp:c}=ka(),[h,d]=g.useState(!1),[u,_]=g.useState(null),[m,f]=g.useState(""),[p,v]=g.useState("stdio"),[k,N]=g.useState(""),[L,D]=g.useState(""),[T,B]=g.useState(""),[I,H]=g.useState(""),[U,q]=g.useState(!1);g.useEffect(()=>{o(e)},[e,o]);const A=()=>{f(""),N(""),D(""),B(""),H(""),v("stdio")},S=async()=>{if(m.trim()){q(!0);try{p==="http"?await a(e,{id:m.trim(),type:"sse",url:T.trim(),description:I.trim()||void 0}):await a(e,{id:m.trim(),command:k.trim(),args:L.trim()?L.trim().split(/\s+/):void 0,description:I.trim()||void 0}),A(),d(!1)}catch{}finally{q(!1)}}},y=async()=>{if(u){try{await c(e,u)}catch{}_(null)}};return n.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border flex-shrink-0",children:[n.jsx("h3",{className:"text-sm font-medium text-foreground",children:"工作区 MCP"}),n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>o(e),disabled:i,className:"h-7 w-7 p-0",children:n.jsx(ti,{className:`w-3.5 h-3.5 ${i?"animate-spin":""}`})}),n.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>d(!h),className:"h-7 w-7 p-0",children:n.jsx(It,{className:"w-3.5 h-3.5"})})]})]}),h&&n.jsxs("div",{className:"px-4 py-2 border-b border-border space-y-2 flex-shrink-0",children:[n.jsx(Xe,{value:m,onChange:w=>f(w.target.value),placeholder:"Server ID(如 my-server)",className:"h-8 text-sm"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:()=>v("stdio"),className:`text-xs px-2 py-1 rounded cursor-pointer ${p==="stdio"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:"stdio"}),n.jsx("button",{onClick:()=>v("http"),className:`text-xs px-2 py-1 rounded cursor-pointer ${p==="http"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:"http/sse"})]}),p==="stdio"?n.jsxs(n.Fragment,{children:[n.jsx(Xe,{value:k,onChange:w=>N(w.target.value),placeholder:"command(如 npx)",className:"h-8 text-sm"}),n.jsx(Xe,{value:L,onChange:w=>D(w.target.value),placeholder:"args(空格分隔)",className:"h-8 text-sm"})]}):n.jsx(Xe,{value:T,onChange:w=>B(w.target.value),placeholder:"URL(如 http://localhost:3001/sse)",className:"h-8 text-sm"}),n.jsx(Xe,{value:I,onChange:w=>H(w.target.value),placeholder:"描述(可选)",className:"h-8 text-sm"}),n.jsx(ye,{size:"sm",onClick:S,disabled:U||!m.trim()||(p==="stdio"?!k.trim():!T.trim()),className:"w-full h-8",children:U?n.jsx(Be,{className:"w-3.5 h-3.5 animate-spin"}):"添加"})]}),r&&n.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs flex-shrink-0",children:r}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:i&&s.length===0?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx(Be,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):s.length===0?n.jsx(yo,{icon:ko,title:"无工作区 MCP Servers",description:"当前工作区 .claude/settings.json 中没有 MCP 配置",action:n.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[n.jsx(It,{className:"w-3.5 h-3.5 mr-1"}),"添加 MCP Server"]})}):n.jsx("div",{className:"divide-y divide-border",children:s.map(w=>n.jsx(Zu,{server:w,onToggle:x=>l(e,w.id,x),onDelete:()=>_(w.id)},w.id))})}),n.jsx(Xt,{open:!!u,onClose:()=>_(null),onConfirm:y,title:"删除 MCP Server",message:`确定要从工作区删除 MCP Server "${u}" 吗?`,confirmText:"删除",confirmVariant:"danger"})]})}function Zu({server:e,onToggle:t,onDelete:s}){var o;const i=e.type==="http"||e.type==="sse",r=i?e.url||"":e.command?`${e.command}${(o=e.args)!=null&&o.length?" "+e.args.join(" "):""}`:"";return n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-accent/50 transition-colors",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:e.id}),n.jsx("span",{className:"text-[10px] text-muted-foreground bg-muted px-1 py-px rounded",children:i?e.type||"http":"stdio"}),!e.enabled&&n.jsx("span",{className:"text-[10px] text-muted-foreground bg-muted px-1 py-px rounded",children:"已禁用"})]}),(e.description||r)&&n.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:e.description||r})]}),n.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[n.jsx("button",{onClick:()=>t(!e.enabled),className:"p-1 rounded hover:bg-accent transition-colors cursor-pointer",title:e.enabled?"禁用":"启用",children:e.enabled?n.jsx(Do,{className:"w-4 h-4 text-emerald-500"}):n.jsx(Mo,{className:"w-4 h-4 text-muted-foreground"})}),n.jsx("button",{onClick:s,className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-destructive transition-colors cursor-pointer",title:"删除",children:n.jsx(Ct,{className:"w-3.5 h-3.5"})})]})]})}const uo=e=>`flex-shrink-0 px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer ${e?"border-border bg-accent text-accent-foreground":"border-border/40 text-muted-foreground hover:border-border hover:bg-accent/60 hover:text-foreground"}`;function Qu({menu:e,onRename:t,onDelete:s,onClose:i}){const r=g.useRef(null),o=g.useRef(i);return o.current=i,g.useEffect(()=>{const a=l=>{r.current&&!r.current.contains(l.target)&&o.current()};return document.addEventListener("mousedown",a),document.addEventListener("touchstart",a),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("touchstart",a)}},[]),n.jsxs("div",{ref:r,className:"fixed z-50 min-w-[120px] rounded-md border border-border bg-popover p-1 shadow-md animate-in fade-in-0 zoom-in-95",style:{left:e.x,top:e.y},children:[t&&n.jsxs("button",{onClick:t,className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground cursor-pointer",children:[n.jsx(vo,{className:"w-3.5 h-3.5"}),"重命名"]}),n.jsxs("button",{onClick:s,className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/30 cursor-pointer",children:[n.jsx(Ct,{className:"w-3.5 h-3.5"}),"删除"]})]})}function Ju({agents:e,activeTab:t,onSelectTab:s,onDeleteAgent:i,onRenameAgent:r,onCreateConversation:o,onBindIm:a,onBindMainIm:l}){const c=g.useMemo(()=>e.filter(v=>v.kind==="conversation"),[e]),[h,d]=g.useState(null),u=g.useRef(null);if(g.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]),c.length===0&&!o)return null;const _=(v,k,N,L)=>{const B=Math.min(N,window.innerWidth-140),I=Math.min(L,window.innerHeight-80);d({agentId:v,agentName:k,x:B,y:I})},m=(v,k)=>{v.preventDefault(),v.stopPropagation(),_(k.id,k.name,v.clientX,v.clientY)},f=(v,k)=>{const N=k.touches[0],L=N.clientX,D=N.clientY;u.current=setTimeout(()=>{u.current=null,_(v.id,v.name,L,D)},500)},p=()=>{u.current&&(clearTimeout(u.current),u.current=null)};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-1 px-4 pt-1 pb-2 border-b border-border/40 overflow-x-auto select-none",children:[n.jsxs("div",{className:`${uo(t===null)} flex items-center gap-1.5 group`,onClick:()=>s(null),children:[n.jsx("span",{children:"主对话"}),l&&n.jsx("button",{onClick:v=>{v.stopPropagation(),l()},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-accent transition-all cursor-pointer",title:"绑定 IM 群组",children:n.jsx(Ti,{className:"w-3 h-3"})})]}),c.map(v=>{const k=v.linked_im_groups&&v.linked_im_groups.length>0;return n.jsxs("div",{className:`${uo(t===v.id)} flex items-center gap-1.5 group`,onClick:()=>s(v.id),onContextMenu:N=>m(N,v),onTouchStart:N=>f(v,N),onTouchEnd:p,onTouchMove:p,children:[v.status==="running"&&n.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-teal-500 animate-pulse flex-shrink-0"}),k&&n.jsx("span",{title:`已绑定: ${v.linked_im_groups.map(N=>N.name).join(", ")}`,children:n.jsx(Ks,{className:"w-3 h-3 text-teal-500 flex-shrink-0"})}),n.jsx("span",{className:"truncate max-w-[120px]",children:v.name}),a&&n.jsx("button",{onClick:N=>{N.stopPropagation(),a(v.id)},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-accent transition-all cursor-pointer",title:"绑定 IM 群组",children:n.jsx(Ti,{className:"w-3 h-3"})}),n.jsx("button",{onClick:N=>{N.stopPropagation(),i(v.id)},className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-accent transition-all cursor-pointer",title:"关闭对话",children:n.jsx(st,{className:"w-3 h-3"})})]},v.id)}),o&&n.jsx("button",{onClick:o,className:"flex-shrink-0 flex items-center gap-0.5 px-2 py-1 rounded-md text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors cursor-pointer",title:"新建对话",children:n.jsx(It,{className:"w-3.5 h-3.5"})})]}),h&&n.jsx(Qu,{menu:h,onRename:r?()=>{r(h.agentId,h.agentName),d(null)}:void 0,onDelete:()=>{i(h.agentId),d(null)},onClose:()=>d(null)})]})}const fo=[{value:"always",label:"始终响应"},{value:"when_mentioned",label:"仅 @mention"}];function ef({open:e,groupJid:t,agentId:s,agent:i,onClose:r}){const[o,a]=g.useState([]),[l,c]=g.useState(!1),[h,d]=g.useState(null),[u,_]=g.useState(""),[m,f]=g.useState(null),[p,v]=g.useState({}),k=V(b=>b.loadAvailableImGroups),N=V(b=>b.bindImGroup),L=V(b=>b.unbindImGroup),D=V(b=>b.bindMainImGroup),T=V(b=>b.unbindMainImGroup),B=s===null;g.useEffect(()=>{if(!e){c(!1),d(null),_(""),f(null),v({});return}d(null),f(null),v({}),c(!0),_(""),k(t).then(b=>{a(b);const j={};for(const C of b)C.channel_type==="feishu"&&C.activation_mode&&C.activation_mode!=="auto"&&(j[C.jid]=C.activation_mode);v(j),c(!1)})},[e,t,s,k]);const I=g.useMemo(()=>{if(!u.trim())return o;const b=u.trim().toLowerCase();return o.filter(j=>j.name.toLowerCase().includes(b)||j.jid.toLowerCase().includes(b))},[o,u]),H=b=>B?b.bound_main_jid===t:b.bound_agent_id===s,U=b=>H(b)?!1:!!b.bound_agent_id||!!b.bound_main_jid,q=async()=>{try{const b=await k(t);a(b)}catch{}},A=async b=>{d(b);try{let j;if(B){const C=o.find(K=>K.jid===b),P=(C==null?void 0:C.channel_type)==="feishu"?p[b]||"always":void 0;j=await D(t,b,!1,P)}else j=await N(t,s,b);j?await q():dt("绑定失败")}catch{dt("绑定失败")}d(null)},S=async b=>{d(b);try{let j;B?j=await T(t,b):j=await L(t,s,b),j?await q():dt("解绑失败")}catch{dt("解绑失败")}d(null)},y=g.useCallback(async(b,j)=>{v(C=>({...C,[b]:j}));try{await D(t,b,!0,j),await q()}catch{dt("更新触发模式失败")}},[t,D]),w=b=>b.bound_agent_id&&b.bound_target_name?b.bound_workspace_name&&b.bound_workspace_name!==b.bound_target_name?`Agent「${b.bound_workspace_name} / ${b.bound_target_name}」`:`Agent「${b.bound_target_name}」`:b.bound_main_jid&&b.bound_target_name?`工作区「${b.bound_target_name}」`:"其他对话",x=async()=>{if(!m)return;const{imJid:b,group:j}=m;f(null),d(b);try{let C;if(B){const P=j.channel_type==="feishu"?p[b]||"always":void 0;C=await D(t,b,!0,P)}else C=await N(t,s,b,!0);C?await q():dt("换绑失败")}catch{dt("换绑失败")}d(null)},E=B?"绑定 IM 渠道 — 主对话":`绑定 IM 渠道${i?` — ${i.name}`:""}`;return n.jsxs(n.Fragment,{children:[n.jsx(br,{open:e,onOpenChange:b=>!b&&r(),children:n.jsxs(Sr,{className:"sm:max-w-md",children:[n.jsx(wr,{children:n.jsxs(yr,{className:"flex items-center gap-2",children:[n.jsx(Ks,{className:"w-4 h-4"}),E]})}),!l&&o.length>0&&n.jsx(ll,{value:u,onChange:_,placeholder:"搜索群组...",debounce:150}),n.jsxs("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:[l&&n.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[n.jsx(Be,{className:"w-4 h-4 animate-spin mr-2"}),"加载中..."]}),!l&&o.length===0&&n.jsxs("div",{className:"text-center py-8 text-muted-foreground text-sm",children:["暂无群聊可绑定。请先在飞书/Telegram 群中向 Bot 发送消息,群聊会自动出现在此列表中。",n.jsx("br",{}),n.jsx("span",{className:"text-xs opacity-70",children:"私聊不支持绑定到子对话。"})]}),!l&&o.length>0&&I.length===0&&n.jsx("div",{className:"text-center py-6 text-muted-foreground text-sm",children:"没有匹配的群组"}),!l&&I.map(b=>{const j=H(b),C=U(b),P=h===b.jid;return n.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg border ${j?"border-primary/30 bg-brand-50/50 dark:bg-brand-700/10":C?"border-amber-200/50 dark:border-amber-800/30":"border-border hover:border-border/80"}`,children:[b.avatar?n.jsx("img",{src:b.avatar,alt:"",className:"w-10 h-10 rounded-lg flex-shrink-0 object-cover"}):n.jsx("div",{className:"w-10 h-10 rounded-lg flex-shrink-0 bg-muted flex items-center justify-center",children:n.jsx(Ks,{className:"w-5 h-5 text-muted-foreground"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"text-sm font-medium truncate",children:b.name}),n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[n.jsx(Dl,{channelType:b.channel_type}),b.member_count!=null&&n.jsxs("span",{className:"flex items-center gap-0.5",children:[n.jsx(Nr,{className:"w-3 h-3"}),b.member_count]}),C&&n.jsxs("span",{className:"text-amber-500 truncate",children:["已绑定",b.bound_agent_id?" Agent":"",b.bound_target_name&&`「${b.bound_workspace_name&&b.bound_workspace_name!==b.bound_target_name?`${b.bound_workspace_name} / ${b.bound_target_name}`:b.bound_target_name}」`]})]})]}),B&&b.channel_type==="feishu"&&!j&&!C&&n.jsx("select",{value:p[b.jid]||"always",onChange:K=>v(ne=>({...ne,[b.jid]:K.target.value})),className:"flex-shrink-0 text-xs px-1.5 py-1 rounded border border-border bg-background text-foreground",children:fo.map(K=>n.jsx("option",{value:K.value,children:K.label},K.value))}),j?n.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[B&&b.channel_type==="feishu"&&n.jsx("select",{value:p[b.jid]||b.activation_mode||"always",onChange:K=>y(b.jid,K.target.value),className:"text-xs px-1.5 py-1 rounded border border-border bg-background text-foreground",children:fo.map(K=>n.jsx("option",{value:K.value,children:K.label},K.value))}),n.jsxs(ye,{size:"sm",variant:"outline",onClick:()=>S(b.jid),disabled:P,children:[P?n.jsx(Be,{className:"w-3 h-3 animate-spin"}):n.jsx(Rl,{className:"w-3 h-3 mr-1"}),"解绑"]})]}):C?n.jsxs(ye,{size:"sm",variant:"outline",onClick:()=>f({imJid:b.jid,group:b}),disabled:P,className:"flex-shrink-0 text-amber-600 border-amber-300 hover:bg-amber-50 dark:text-amber-400 dark:border-amber-700 dark:hover:bg-amber-950/30",children:[P?n.jsx(Be,{className:"w-3 h-3 animate-spin"}):n.jsx(Tl,{className:"w-3 h-3 mr-1"}),"换绑"]}):n.jsxs(ye,{size:"sm",onClick:()=>A(b.jid),disabled:P,className:"flex-shrink-0",children:[P?n.jsx(Be,{className:"w-3 h-3 animate-spin"}):n.jsx(hl,{className:"w-3 h-3 mr-1"}),"绑定"]})]},b.jid)})]})]})}),n.jsx(Xt,{open:!!m,onClose:()=>f(null),onConfirm:x,title:"确认换绑",message:m?`该群组当前已绑定到${w(m.group)},确认换绑到当前${B?"主对话":"Agent"}吗?`:"",confirmText:"换绑"})]})}const ji="__main__",tf=[{id:"files",icon:No,label:"文件管理"},{id:"env",icon:ql,label:"环境变量"},{id:"skills",icon:Co,label:"工作区 Skills"},{id:"mcp",icon:ko,label:"工作区 MCP"},{id:"members",icon:Nr,label:"成员"}],sf=2e3,rf=150,nf=300,of=.7,af=[];function lf({groupJid:e,onBack:t,headerLeft:s}){const{mode:i,toggle:r}=gs(),{theme:o,toggle:a}=cl(),[l,c]=g.useState(null),[h,d]=g.useState("files"),[u,_]=g.useState(!1),[m,f]=g.useState(!1),[p,v]=g.useState(!1),[k,N]=g.useState(null),[L,D]=g.useState(!1),[T,B]=g.useState(!1),[I,H]=g.useState(nf),[U,q]=g.useState(!1),[A,S]=g.useState(!1),[y,w]=g.useState(null),[x,E]=g.useState(!1),[b,j]=g.useState(null),[C,P]=g.useState(null),[K,ne]=g.useState(()=>localStorage.getItem("im-banner-dismissed")==="1"),Q=kr(),le=g.useRef(null),ue=g.useRef(!1),Ce=g.useRef(0),$e=g.useRef(0),Y=V(M=>M.groups[e]),z=V(M=>M.messages[e]),te=V(M=>!!M.waiting[e]),ve=V(M=>!!M.hasMore[e]),F=V(M=>M.loading),W=V(M=>M.loadMessages),se=V(M=>M.refreshMessages),oe=V(M=>M.sendMessage),J=V(M=>M.interruptQuery),ee=V(M=>M.resetSession),be=V(M=>M.handleStreamEvent),qe=V(M=>M.handleWsNewMessage),oi=V(M=>M.handleStreamSnapshot),ws=V(M=>M.agents[e]??af),Me=V(M=>M.activeAgentTab[e]??null),zr=V(M=>M.setActiveAgentTab),ai=V(M=>M.loadAgents),Na=V(M=>M.deleteAgentAction),Ea=V(M=>M.agentStreaming),ja=V(M=>M.createConversation),Ma=V(M=>M.renameConversation),li=V(M=>M.loadAgentMessages),Da=V(M=>M.refreshAgentMessages),Ra=V(M=>M.sendAgentMessage),hi=V(M=>M.agentMessages),Ta=V(M=>M.agentWaiting),La=V(M=>M.agentHasMore),Ft=Ge(M=>M.user),kt=(Y==null?void 0:Y.execution_mode)!=="host",Qt=g.useRef(void 0),Nt=(Y==null?void 0:Y.agent_type)==="codex",ci=!!(Y!=null&&Y.is_home),ys=(!!(Y!=null&&Y.is_shared)||(Y==null?void 0:Y.member_role)==="owner")&&!ci,Ba=tf.filter(M=>M.id==="members"?ys:!(Nt&&(M.id==="env"||M.id==="skills")));g.useEffect(()=>{h==="members"&&!ys&&d("files")},[h,ys]),g.useEffect(()=>{Nt&&(h==="env"||h==="skills")&&d("files"),Nt&&(l==="env"||l==="skills")&&c("files")},[Nt,l,h]);const Cs=ci&&(!!(Y!=null&&Y.created_by)&&Y.created_by===(Ft==null?void 0:Ft.id)||(Ft==null?void 0:Ft.role)==="admin"&&(Y==null?void 0:Y.folder)==="main");g.useEffect(()=>{if(!Cs){P(null);return}let M=!0;const ie=()=>{Ke.get("/api/config/user-im/status").then(Oe=>{M&&P(Oe)}).catch(()=>{})};ie();const fe=setInterval(ie,3e4);return()=>{M=!1,clearInterval(fe)}},[Cs]);const Aa=!!z;g.useEffect(()=>{e&&W(e)},[e,Aa,W]),g.useEffect(()=>{let M=!0;const ie=()=>{!M||document.hidden||(Qt.current=setTimeout(fe,sf))},fe=async()=>{if(M){try{await se(e)}catch{}ie()}},Oe=()=>{!document.hidden&&M&&(Qt.current&&clearTimeout(Qt.current),fe())};return document.addEventListener("visibilitychange",Oe),ie(),()=>{M=!1,document.removeEventListener("visibilitychange",Oe),Qt.current&&clearTimeout(Qt.current)}},[e]);const Hr=V(M=>M.restoreActiveState);g.useEffect(()=>{Hr();const M=ce.on("connected",()=>{Hr(),ai(e);const ie=V.getState(),fe=ie.activeAgentTab[e];if(fe){const Oe=(ie.agents[e]||[]).find(_t=>_t.id===fe);(Oe==null?void 0:Oe.kind)==="conversation"&&Da(e,fe)}});return()=>{M()}},[e]);const di=Me?ws.find(M=>M.id===Me):null,ui=(di==null?void 0:di.kind)==="conversation";g.useEffect(()=>{ai(e)},[e,ai]),g.useEffect(()=>{Me&&ui&&(hi[Me]||li(e,Me))},[Me,ui,e,li,hi]),g.useEffect(()=>{const M=ce.on("stream_event",re=>{re.chatJid===e&&be(e,re.event,re.agentId)}),ie=ce.on("new_message",re=>{re.chatJid===e&&re.message&&(qe(e,re.message,re.agentId,re.source),Y!=null&&Y.is_home&&re.message.chat_jid&&re.message.chat_jid!==e&&se(e))}),fe=ce.on("ws_error",re=>{(!re.chatJid||re.chatJid===e)&&dt("发送失败",re.error||"消息格式无效",4e3)}),Oe=e+"#agent:",_t=ce.on("stream_snapshot",re=>{if(re.snapshot){if(re.chatJid===e)oi(e,re.snapshot);else if(typeof re.chatJid=="string"&&re.chatJid.startsWith(Oe)){const fi=re.chatJid.slice(Oe.length);oi(e,re.snapshot,fi)}}});return()=>{M(),ie(),fe(),_t()}},[Y==null?void 0:Y.is_home,e,be,qe,oi,se]);const[Fr,Wr]=g.useState(0),$r=async(M,ie)=>{await oe(e,M,ie),Wr(fe=>fe+1)},Pa=()=>{ve&&!F&&W(e,!0)},Ia=async()=>{v(!0),await ee(e,k??void 0),v(!1),f(!1),N(null)},ks=g.useCallback(M=>{ue.current=!0,Ce.current=M,$e.current=I;const ie=re=>{const fi=Ce.current-re,$a=le.current?le.current.clientHeight*of:600;return Math.min($a,Math.max(rf,$e.current+fi))},fe=re=>{ue.current&&H(ie(re.clientY))},Oe=re=>{ue.current&&H(ie(re.touches[0].clientY))},_t=()=>{ue.current=!1,document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",_t),document.removeEventListener("touchmove",Oe),document.removeEventListener("touchend",_t),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",fe),document.addEventListener("mouseup",_t),document.addEventListener("touchmove",Oe,{passive:!0}),document.addEventListener("touchend",_t),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},[I]),Oa=g.useCallback(M=>{M.preventDefault(),ks(M.clientY)},[ks]),za=g.useCallback(M=>{ks(M.touches[0].clientY)},[ks]),Ha=g.useCallback(()=>{kt&&(window.matchMedia("(min-width: 1024px)").matches?T?D(M=>!M):(B(!0),D(!0)):q(!0))},[kt,T]);g.useEffect(()=>{D(!1),B(!1),q(!1)},[e]),g.useEffect(()=>{kt||(D(!1),B(!1),q(!1))},[kt]);const Fa=()=>{S(!1),c("files")},Wa=()=>{Nt||(S(!1),c("env"))};return Y?n.jsxs("div",{ref:le,className:"h-full flex flex-col bg-surface dark:bg-background max-lg:rounded-none lg:rounded-t-2xl lg:rounded-b-none lg:mr-5 lg:ml-3 lg:overflow-hidden",children:[n.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 max-lg:px-4 max-lg:py-2.5 max-lg:bg-background/60 max-lg:backdrop-blur-xl max-lg:saturate-[1.8] max-lg:border-border/40",children:[t&&n.jsx("button",{onClick:t,className:"lg:hidden p-2 -ml-2 hover:bg-muted rounded-lg transition-colors cursor-pointer","aria-label":"返回",children:n.jsx(dl,{className:"w-5 h-5 text-foreground/70"})}),s,n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("h2",{className:"font-semibold text-foreground text-[15px] truncate",children:Y.name}),n.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsx("span",{children:te?"正在思考...":Y.is_home?"主 Agent":"Agent"}),!te&&Y.is_shared&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/40",children:"·"}),n.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[n.jsx(Nr,{className:"w-3 h-3"}),Y.member_count??0," 人协作"]})]}),!te&&Y.execution_mode&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/40",children:"·"}),n.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium border ${Y.execution_mode==="host"?"bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-950/30 dark:text-amber-300 dark:border-amber-800":"bg-sky-50 text-sky-700 border-sky-200 dark:bg-sky-950/30 dark:text-sky-300 dark:border-sky-800"}`,children:Y.execution_mode==="host"?"宿主机":"Docker"})]}),!te&&Y.agent_type&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/40",children:"·"}),n.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-[10px] font-medium border ${Y.agent_type==="codex"?"bg-emerald-50 text-emerald-700 border-emerald-200 dark:bg-emerald-950/30 dark:text-emerald-300 dark:border-emerald-800":"bg-violet-50 text-violet-700 border-violet-200 dark:bg-violet-950/30 dark:text-violet-300 dark:border-violet-800"}`,children:Y.agent_type==="codex"?"Codex":"Claude"})]}),Cs&&C&&(C.feishu||C.telegram)&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-muted-foreground/40",children:"·"}),C.feishu&&n.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[n.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"飞书"]}),C.telegram&&n.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[n.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500"}),"Telegram"]})]})]})]}),n.jsx("button",{onClick:a,className:"hidden lg:flex p-2 rounded-lg hover:bg-accent text-muted-foreground transition-colors cursor-pointer",title:o==="light"?"切换到暗色模式":o==="dark"?"跟随系统":"切换到亮色模式","aria-label":o==="light"?"切换到暗色模式":o==="dark"?"跟随系统":"切换到亮色模式",children:o==="light"?n.jsx(Ll,{className:"w-5 h-5"}):o==="dark"?n.jsx(ul,{className:"w-5 h-5"}):n.jsx(Bl,{className:"w-5 h-5"})}),n.jsx("button",{onClick:r,className:"hidden lg:flex p-2 rounded-lg hover:bg-accent text-muted-foreground transition-colors cursor-pointer",title:i==="chat"?"紧凑模式":"对话模式","aria-label":i==="chat"?"切换到紧凑模式":"切换到对话模式",children:i==="chat"?n.jsx(Kl,{className:"w-5 h-5"}):n.jsx(Ks,{className:"w-5 h-5"})}),n.jsx("button",{onClick:()=>_(M=>!M),className:"hidden lg:flex p-2 rounded-lg hover:bg-accent text-muted-foreground transition-colors cursor-pointer",title:u?"收起面板":"展开面板","aria-label":u?"收起面板":"展开面板",children:u?n.jsx(Wl,{className:"w-5 h-5"}):n.jsx($l,{className:"w-5 h-5"})}),n.jsx("div",{className:"lg:hidden",children:n.jsx("button",{onClick:()=>S(!0),className:"p-2 rounded-lg hover:bg-accent text-muted-foreground transition-colors cursor-pointer",title:"更多操作","aria-label":"更多操作",children:n.jsx(Ps,{className:"w-5 h-5"})})})]}),Cs&&C&&!C.feishu&&!C.telegram&&!K&&n.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-950/40 border-b border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-300 text-sm",children:[n.jsx(Ti,{className:"w-4 h-4 flex-shrink-0"}),n.jsx("span",{className:"flex-1 min-w-0",children:"未配置 IM 渠道,飞书 / Telegram 消息无法与主工作区互通"}),n.jsx("button",{onClick:()=>Q("/setup/channels"),className:"flex-shrink-0 px-3 py-1 text-xs font-medium rounded-md bg-amber-600 text-white hover:bg-amber-700 transition-colors cursor-pointer",children:"去配置"}),n.jsx("button",{onClick:()=>{ne(!0),localStorage.setItem("im-banner-dismissed","1")},className:"flex-shrink-0 p-0.5 rounded hover:bg-amber-200/60 transition-colors cursor-pointer","aria-label":"关闭",children:n.jsx(st,{className:"w-4 h-4"})})]}),n.jsx(Ju,{agents:ws,activeTab:Me,onSelectTab:M=>zr(e,M),onDeleteAgent:M=>{const ie=ws.find(fe=>fe.id===M);if(ie!=null&&ie.linked_im_groups&&ie.linked_im_groups.length>0){const fe=ie.linked_im_groups.map(Oe=>Oe.name).join("、");alert(`该对话已绑定 IM 渠道(${fe}),请先解绑后再删除。`),w(M);return}Na(e,M)},onRenameAgent:(M,ie)=>j({agentId:M,name:ie}),onCreateConversation:()=>E(!0),onBindIm:w,onBindMainIm:ci?void 0:()=>w(ji)}),n.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[n.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-x-hidden",children:Me&&ui?n.jsxs(n.Fragment,{children:[n.jsx(ln,{messages:hi[Me]||[],loading:!1,hasMore:!!La[Me],onLoadMore:()=>li(e,Me,!0),scrollTrigger:Fr,groupJid:e,isWaiting:!!Ta[Me]||!!Ea[Me],onInterrupt:()=>J(`${e}#agent:${Me}`),agentId:Me},`conv-${Me}`),n.jsx(hn,{onSend:async(M,ie)=>{Ra(e,Me,M,ie),Wr(fe=>fe+1)},groupJid:e,onResetSession:()=>{N(Me),f(!0)}})]}):n.jsxs(n.Fragment,{children:[n.jsx(ln,{messages:z||[],loading:F,hasMore:ve,onLoadMore:Pa,scrollTrigger:Fr,groupJid:e,isWaiting:te,onInterrupt:()=>J(e),onSend:M=>$r(M)},`main-${e}`),n.jsx(hn,{onSend:$r,groupJid:e,onResetSession:()=>{N(null),f(!0)},onToggleTerminal:kt?Ha:void 0})]})}),n.jsxs("div",{className:Di("hidden lg:flex lg:flex-col flex-shrink-0 border-l border-border bg-surface dark:bg-background transition-[width] duration-200",u?"w-80":"w-0 overflow-hidden border-l-0"),children:[n.jsx(fl,{delayDuration:300,children:n.jsx("div",{className:"flex border-b border-border",children:Ba.map(M=>{const ie=M.icon,fe=h===M.id;return n.jsxs(ml,{children:[n.jsx(_l,{asChild:!0,children:n.jsx("button",{onClick:()=>d(M.id),className:Di("flex-1 flex items-center justify-center py-2.5 transition-colors cursor-pointer",fe?"text-primary border-b-2 border-primary":"text-muted-foreground hover:text-foreground"),children:n.jsx(ie,{className:"w-4 h-4"})})}),n.jsx(pl,{side:"bottom",className:"text-xs",children:M.label})]},M.id)})})}),n.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:h==="files"?n.jsx(cn,{groupJid:e}):h==="env"?n.jsx(dn,{groupJid:e}):h==="skills"?n.jsx(ho,{groupJid:e}):h==="mcp"?n.jsx(co,{groupJid:e}):n.jsx(lo,{groupJid:e})})]})]}),kt&&T&&n.jsxs(n.Fragment,{children:[L&&n.jsx("div",{onMouseDown:Oa,onTouchStart:za,className:"hidden lg:flex h-1 bg-muted hover:bg-brand-400 cursor-row-resize items-center justify-center transition-colors group",children:n.jsx("div",{className:"w-8 h-0.5 rounded-full bg-muted-foreground group-hover:bg-primary transition-colors"})}),n.jsx("div",{className:`hidden lg:block flex-shrink-0 overflow-hidden transition-[height] duration-200 ${L?"border-t border-border":"border-t-0"}`,style:{height:L?I:0},children:n.jsx(ao,{groupJid:e,visible:L,onHide:()=>D(!1),onDelete:()=>{D(!1),B(!1)}})})]}),n.jsx(Et,{open:l==="files",onOpenChange:M=>!M&&c(null),children:n.jsxs(jt,{side:"bottom",className:"h-[80dvh] p-0",children:[n.jsx(Mt,{className:"px-4 pt-4 pb-2",children:n.jsx(Dt,{children:"工作区文件管理"})}),n.jsx("div",{className:"flex-1 overflow-hidden h-[calc(80dvh-56px)]",children:n.jsx(cn,{groupJid:e,onClose:()=>c(null)})})]})}),n.jsx(Et,{open:l==="env",onOpenChange:M=>!M&&c(null),children:n.jsxs(jt,{side:"bottom",className:"h-[80dvh] p-0",children:[n.jsx(Mt,{className:"px-4 pt-4 pb-2",children:n.jsx(Dt,{children:"工作区环境变量"})}),n.jsx("div",{className:"flex-1 overflow-hidden h-[calc(80dvh-56px)]",children:n.jsx(dn,{groupJid:e,onClose:()=>c(null)})})]})}),n.jsx(Et,{open:l==="skills",onOpenChange:M=>!M&&c(null),children:n.jsxs(jt,{side:"bottom",className:"h-[80dvh] p-0",children:[n.jsx(Mt,{className:"px-4 pt-4 pb-2",children:n.jsx(Dt,{children:"工作区 Skills"})}),n.jsx("div",{className:"flex-1 overflow-hidden h-[calc(80dvh-56px)]",children:n.jsx(ho,{groupJid:e,onClose:()=>c(null)})})]})}),n.jsx(Et,{open:l==="mcp",onOpenChange:M=>!M&&c(null),children:n.jsxs(jt,{side:"bottom",className:"h-[80dvh] p-0",children:[n.jsx(Mt,{className:"px-4 pt-4 pb-2",children:n.jsx(Dt,{children:"工作区 MCP Servers"})}),n.jsx("div",{className:"flex-1 overflow-hidden h-[calc(80dvh-56px)]",children:n.jsx(co,{groupJid:e,onClose:()=>c(null)})})]})}),n.jsx(Et,{open:l==="members",onOpenChange:M=>!M&&c(null),children:n.jsxs(jt,{side:"bottom",className:"h-[80dvh] p-0",children:[n.jsx(Mt,{className:"px-4 pt-4 pb-2",children:n.jsx(Dt,{children:"成员管理"})}),n.jsx("div",{className:"flex-1 overflow-hidden h-[calc(80dvh-56px)]",children:n.jsx(lo,{groupJid:e})})]})}),n.jsx(Et,{open:U,onOpenChange:M=>!M&&q(!1),children:n.jsxs(jt,{side:"bottom",className:"h-[85dvh] p-0",children:[n.jsx(Mt,{className:"px-4 pt-4 pb-2",children:n.jsx(Dt,{children:"终端"})}),n.jsx("div",{className:"flex-1 overflow-hidden h-[calc(85dvh-56px)]",children:n.jsx(ao,{groupJid:e,visible:!0,onHide:()=>q(!1),onDelete:()=>q(!1)})})]})}),n.jsx(Et,{open:A,onOpenChange:M=>!M&&S(!1),children:n.jsxs(jt,{side:"bottom",className:"pb-[env(safe-area-inset-bottom)]",children:[n.jsx(Mt,{children:n.jsx(Dt,{children:"工作区操作"})}),n.jsxs("div",{className:"space-y-2 pt-2",children:[n.jsx("button",{onClick:Fa,className:"w-full text-left px-4 py-3 rounded-lg border border-border hover:bg-accent transition-colors cursor-pointer text-foreground text-sm",children:"工作区文件"}),!Nt&&n.jsx("button",{onClick:Wa,className:"w-full text-left px-4 py-3 rounded-lg border border-border hover:bg-accent transition-colors cursor-pointer text-foreground text-sm",children:"环境变量"}),!Nt&&n.jsx("button",{onClick:()=>{S(!1),c("skills")},className:"w-full text-left px-4 py-3 rounded-lg border border-border hover:bg-accent transition-colors cursor-pointer text-foreground text-sm",children:"工作区 Skills"}),n.jsx("button",{onClick:()=>{S(!1),c("mcp")},className:"w-full text-left px-4 py-3 rounded-lg border border-border hover:bg-accent transition-colors cursor-pointer text-foreground text-sm",children:"工作区 MCP"}),ys&&n.jsx("button",{onClick:()=>{S(!1),c("members")},className:"w-full text-left px-4 py-3 rounded-lg border border-border hover:bg-accent transition-colors cursor-pointer text-foreground text-sm",children:"成员管理"}),kt&&n.jsx("button",{onClick:()=>{S(!1),q(!0)},className:"w-full text-left px-4 py-3 rounded-lg border border-border hover:bg-accent transition-colors cursor-pointer text-foreground text-sm",children:"终端"})]})]})}),n.jsx(Xt,{open:m,onClose:()=>f(!1),onConfirm:Ia,title:"清除上下文",message:k?"将清除该子对话的 Claude 会话上下文,下次发送消息时将开始全新会话。聊天记录不受影响。":"将清除 Claude 会话上下文并停止运行中的工作区进程,下次发送消息时将开始全新会话。聊天记录不受影响。",confirmText:"清除",confirmVariant:"danger",loading:p}),y&&n.jsx(ef,{open:!!y,groupJid:e,agentId:y===ji?null:y,agent:y!==ji?ws.find(M=>M.id===y):void 0,onClose:()=>w(null)}),n.jsx(un,{open:x,title:"新建对话",label:"对话名称",placeholder:"输入对话名称",onConfirm:M=>{ja(e,M).then(ie=>{ie&&zr(e,ie.id)})},onClose:()=>E(!1)}),n.jsx(un,{open:b!==null,title:"重命名对话",label:"对话名称",placeholder:"输入新名称",defaultValue:(b==null?void 0:b.name)??"",onConfirm:M=>{b&&Ma(e,b.agentId,M)},onClose:()=>j(null)})]}):n.jsx("div",{className:"h-full flex items-center justify-center bg-background",children:n.jsx("div",{className:"text-center",children:n.jsx("p",{className:"text-muted-foreground",children:"群组不存在"})})})}function hf(e,t,s={}){const{edgeWidth:i=20,threshold:r=.4}=s,o=Vr("(max-width: 1023px)"),a=Vr("(display-mode: standalone)"),l=g.useRef({startX:0,startY:0,active:!1,currentX:0,isHorizontal:null}),c=g.useRef(null),h=g.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),d=g.useCallback(()=>{const v=e.current;v&&(v.style.transform="",v.style.transition="",v.style.willChange="")},[e]),u=g.useCallback(()=>{const v=e.current;v&&(v.style.transition="transform 250ms cubic-bezier(0.4, 0, 0.2, 1)",v.style.transform="translateX(0)",h(),c.current=setTimeout(()=>{d()},250))},[e,h,d]),_=g.useCallback(v=>{const k=v.target instanceof Element?v.target:null;if(k!=null&&k.closest('[data-swipe-back-ignore="true"]'))return;const N=v.touches[0];N.clientX<i&&(l.current={startX:N.clientX,startY:N.clientY,active:!0,currentX:0,isHorizontal:null})},[i]),m=g.useCallback(v=>{if(!l.current.active)return;const k=v.touches[0],N=k.clientX-l.current.startX,L=k.clientY-l.current.startY;if(l.current.isHorizontal===null){if(Math.abs(N)<8&&Math.abs(L)<8)return;if(l.current.isHorizontal=Math.abs(N)>Math.abs(L)*1.2,!l.current.isHorizontal){l.current.active=!1,d();return}}N>0&&e.current&&(l.current.currentX=N,e.current.style.transition="none",e.current.style.transform=`translateX(${N}px)`,e.current.style.willChange="transform")},[e,d]),f=g.useCallback(()=>{if(!l.current.active)return;l.current.active=!1;const v=l.current.isHorizontal===!0;l.current.isHorizontal=null;const k=e.current;if(!k)return;if(!v){d();return}const N=l.current.currentX,L=window.innerWidth;N>L*r?(k.style.transition="transform 250ms cubic-bezier(0.4, 0, 0.2, 1)",k.style.transform=`translateX(${L}px)`,h(),c.current=setTimeout(()=>{d(),t()},250)):u()},[e,r,t,h,d,u]),p=g.useCallback(()=>{!l.current.active&&l.current.currentX<=0||(l.current.active=!1,l.current.currentX=0,l.current.isHorizontal=null,u())},[u]);g.useEffect(()=>{const v=e.current;if(!(!v||!o||!a))return v.addEventListener("touchstart",_,{passive:!0}),v.addEventListener("touchmove",m,{passive:!0}),v.addEventListener("touchend",f),v.addEventListener("touchcancel",p),()=>{v.removeEventListener("touchstart",_),v.removeEventListener("touchmove",m),v.removeEventListener("touchend",f),v.removeEventListener("touchcancel",p),h(),d()}},[e,o,a,_,m,f,p,h,d])}function cf(){const{groupFolder:e}=gl(),t=kr(),{groups:s,currentGroup:i,selectGroup:r,loadGroups:o}=V(),{clearState:a,clearLoading:l,openClear:c,closeClear:h,handleClearConfirm:d}=vl(),[u,_]=g.useState(!1),[m,f]=g.useState({open:!1,jid:""}),p=Ge(w=>w.user),v=Ge(w=>w.appearance),k=((p==null?void 0:p.display_name)||(p==null?void 0:p.username)||"?")[0].toUpperCase(),N=g.useMemo(()=>{if(!e)return null;const w=Object.entries(s).find(([x,E])=>E.folder===e&&x.startsWith("web:")&&!!E.is_home)||Object.entries(s).find(([x,E])=>E.folder===e&&x.startsWith("web:"))||Object.entries(s).find(([x,E])=>E.folder===e);return(w==null?void 0:w[0])||null},[e,s]),L=Tt(w=>w.runnerStates),D=Object.keys(s).length>0,{mainGroup:T,pinnedGroups:B,mySections:I,collabSections:H}=g.useMemo(()=>{let w=null;const x=[];for(const[C,P]of Object.entries(s)){const K={jid:C,...P};P.is_my_home?w=K:x.push(K)}x.sort(xl);const E=[],b=[],j=[];return x.forEach(C=>{C.pinned_at?E.push(C):C.is_shared&&(C.member_count??0)>=2?j.push(C):b.push(C)}),E.sort((C,P)=>(C.pinned_at||"").localeCompare(P.pinned_at||"")),{mainGroup:w,pinnedGroups:E,mySections:Yr(b),collabSections:Yr(j)}},[s]),U=T||B.length>0||I.length>0||H.length>0;g.useEffect(()=>{if(e){if(N&&i!==N){r(N);return}D&&!N&&o().then(()=>{const w=V.getState().groups,x=Object.entries(w).find(([E,b])=>b.folder===e&&E.startsWith("web:"));x?r(x[0]):t("/chat",{replace:!0})})}},[e,N,D,i,r,t,o]);const q=e?N:i,A=g.useRef(null),S=m.jid?s[m.jid]:void 0,y=()=>{t("/chat")};return hf(A,y),n.jsxs("div",{className:"h-full flex bg-muted/30",children:[!e&&n.jsxs("div",{className:"block lg:hidden w-full overflow-y-auto",children:[n.jsxs("div",{className:"flex items-center gap-3 px-4 pt-5 pb-3",children:[n.jsx("img",{src:"/icons/logo-text.svg",alt:(v==null?void 0:v.appName)||"cli-claw",className:"h-8"}),n.jsx("div",{className:"flex-1"}),n.jsx("button",{onClick:()=>_(!0),className:"w-9 h-9 rounded-lg flex items-center justify-center hover:bg-accent text-muted-foreground hover:text-foreground transition-colors cursor-pointer","aria-label":"新工作区",children:n.jsx(It,{className:"w-5 h-5"})}),n.jsxs(bl,{children:[n.jsx(Sl,{asChild:!0,children:n.jsx("button",{className:"rounded-full hover:ring-2 hover:ring-brand-200 transition-all cursor-pointer","aria-label":"用户菜单",children:n.jsx(St,{emoji:p==null?void 0:p.avatar_emoji,color:p==null?void 0:p.avatar_color,fallbackChar:k,size:"md",className:"w-8 h-8"})})}),n.jsxs(wl,{side:"bottom",align:"end",className:"w-44 p-1",children:[n.jsx("div",{className:"px-3 py-2 text-xs font-medium text-muted-foreground truncate border-b border-border mb-1",children:(p==null?void 0:p.display_name)||(p==null?void 0:p.username)}),n.jsxs("button",{onClick:()=>t("/settings?tab=profile"),className:"w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-accent text-foreground cursor-pointer",children:[n.jsx(yl,{className:"w-4 h-4"})," 个人设置"]}),n.jsxs("button",{onClick:async()=>{await Ge.getState().logout(),t("/login")},className:"w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-destructive/10 text-destructive cursor-pointer",children:[n.jsx(wo,{className:"w-4 h-4"})," 退出登录"]})]})]})]}),U?n.jsxs("div",{className:"px-2 pb-nav-safe",children:[T&&n.jsxs("div",{className:"mb-1",children:[n.jsx("div",{className:"px-2 pt-1 pb-1",children:n.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"主工作区"})}),n.jsx(Ns,{jid:T.jid,name:T.name,folder:T.folder,lastMessage:T.lastMessage,isActive:i===T.jid,isHome:!0,isRunning:L[T.jid]==="running",editable:!0,onRuntimeSettings:w=>f({open:!0,jid:w}),onSelect:(w,x)=>{r(w),t(`/chat/${x}`)},onClearHistory:c})]}),B.length>0&&n.jsxs("div",{className:"mb-1",children:[n.jsx("div",{className:"px-2 pt-2 pb-1",children:n.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"已固定"})}),B.map(w=>n.jsx(Ns,{jid:w.jid,name:w.name,folder:w.folder,lastMessage:w.lastMessage,isActive:i===w.jid,isHome:!1,isPinned:!0,isRunning:L[w.jid]==="running",editable:w.editable,onRuntimeSettings:x=>f({open:!0,jid:x}),onSelect:(x,E)=>{r(x),t(`/chat/${E}`)},onClearHistory:c},w.jid))]}),I.length>0&&n.jsxs("div",{className:"mb-1",children:[n.jsx("div",{className:"px-2 pt-2 pb-1",children:n.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"我的工作区"})}),I.map(w=>n.jsxs("div",{className:"mb-1",children:[n.jsx("div",{className:"px-2 pt-1 pb-1",children:n.jsx("span",{className:"text-[10px] text-muted-foreground/70 tracking-wide",children:w.label})}),w.items.map(x=>n.jsx(Ns,{jid:x.jid,name:x.name,folder:x.folder,lastMessage:x.lastMessage,isActive:i===x.jid,isHome:!1,isRunning:L[x.jid]==="running",editable:x.editable,onRuntimeSettings:E=>f({open:!0,jid:E}),onSelect:(E,b)=>{r(E),t(`/chat/${b}`)},onClearHistory:c},x.jid))]},w.label))]}),H.length>0&&n.jsxs("div",{className:"mb-1",children:[n.jsx("div",{className:"px-2 pt-2 pb-1",children:n.jsx("span",{className:"text-[10px] font-bold text-muted-foreground uppercase tracking-wider",children:"协作工作区"})}),H.map(w=>n.jsxs("div",{className:"mb-1",children:[n.jsx("div",{className:"px-2 pt-1 pb-1",children:n.jsx("span",{className:"text-[10px] text-muted-foreground/70 tracking-wide",children:w.label})}),w.items.map(x=>n.jsx(Ns,{jid:x.jid,name:x.name,folder:x.folder,lastMessage:x.lastMessage,isShared:x.is_shared,memberRole:x.member_role,memberCount:x.member_count,isActive:i===x.jid,isHome:!1,isRunning:L[x.jid]==="running",editable:x.editable,onRuntimeSettings:E=>f({open:!0,jid:E}),onSelect:(E,b)=>{r(E),t(`/chat/${b}`)},onClearHistory:c},x.jid))]},w.label))]})]}):n.jsxs("div",{className:"flex flex-col items-center justify-center h-64 px-4",children:[n.jsx("img",{src:"/icons/logo-text.svg",alt:(v==null?void 0:v.appName)||"cli-claw",className:"h-12 mb-6"}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"暂无工作区"})]})]}),q?n.jsx("div",{ref:A,className:`${e?"flex-1 min-w-0 h-full overflow-hidden lg:pt-4":"hidden lg:block flex-1 min-w-0 h-full overflow-hidden lg:pt-4"}`,children:n.jsx(lf,{groupJid:q,onBack:y})}):n.jsx("div",{className:"hidden lg:flex flex-1 items-center justify-center bg-background rounded-t-3xl rounded-b-none mt-5 mr-5 mb-0 ml-3 relative",children:n.jsxs("div",{className:"text-center max-w-sm",children:[n.jsx("div",{className:"w-16 h-16 rounded-2xl overflow-hidden mx-auto mb-6",children:n.jsx("img",{src:"/icons/icon-192.png",alt:"cli-claw",className:"w-full h-full object-cover"})}),n.jsxs("h2",{className:"text-xl font-semibold text-foreground mb-2",children:["欢迎使用 ",(v==null?void 0:v.appName)||"cli-claw"]}),n.jsx("p",{className:"text-muted-foreground text-sm",children:"从左侧选择一个工作区开始对话"})]})}),n.jsx(Xt,{open:a.open,onClose:h,onConfirm:d,title:"重建工作区",message:`确认重建工作区「${a.name}」吗?这会清除全部聊天记录、上下文,并删除工作目录中的所有文件。此操作不可撤销。`,confirmText:"确认重建",cancelText:"取消",confirmVariant:"danger",loading:l}),n.jsx(Cl,{open:u,onClose:()=>_(!1),onCreated:(w,x)=>{r(w),t(`/chat/${x}`)}}),S&&n.jsx(kl,{open:m.open,jid:m.jid,name:S.name,isHome:!!S.is_home,currentAgentType:S.agent_type||"claude",currentExecutionMode:S.execution_mode||"container",onClose:()=>f({open:!1,jid:""})})]})}const Sf=Object.freeze(Object.defineProperty({__proto__:null,ChatPage:cf},Symbol.toStringTag,{value:"Module"}));export{Sf as C,gf as d};
|