@kingsoftcloud/ksadk-web 0.2.10 → 0.2.11
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/CHANGELOG.md +11 -0
- package/dist-ksadk/assets/{ArtifactsPanel-DWKSsYb9.js → ArtifactsPanel-BF4v3fIu.js} +1 -1
- package/dist-ksadk/assets/{CodeBlock-CTxzE2VS.js → CodeBlock-MkPxZeyx.js} +1 -1
- package/dist-ksadk/assets/{MathMessageMarkdown-BQEjyzo5.js → MathMessageMarkdown-BtAniUMT.js} +1 -1
- package/dist-ksadk/assets/{MermaidBlock-CDmk7TDv.js → MermaidBlock-B7_vB2SD.js} +6 -6
- package/dist-ksadk/assets/NativeTerminalPanel-DKuFni1-.js +1 -0
- package/dist-ksadk/assets/{arc-DsDFn-pM.js → arc-DcxNT_so.js} +1 -1
- package/dist-ksadk/assets/architecture-7EHR7CIX-BHyTI6bf.js +1 -0
- package/dist-ksadk/assets/{architectureDiagram-3BPJPVTR-CXQLDPo9.js → architectureDiagram-3BPJPVTR-BrLH3CLV.js} +1 -1
- package/dist-ksadk/assets/{blockDiagram-GPEHLZMM-ByJsJcrt.js → blockDiagram-GPEHLZMM-D4lvcIrU.js} +1 -1
- package/dist-ksadk/assets/{c4Diagram-AAUBKEIU-D5eKWwvF.js → c4Diagram-AAUBKEIU-v644IW0m.js} +1 -1
- package/dist-ksadk/assets/channel-BH5WJ3h3.js +1 -0
- package/dist-ksadk/assets/{chunk-2J33WTMH-CmLQ3DD9.js → chunk-2J33WTMH-CI4vAXF2.js} +1 -1
- package/dist-ksadk/assets/{chunk-4BX2VUAB-BhRYlJwh.js → chunk-4BX2VUAB-B7f3Nw20.js} +1 -1
- package/dist-ksadk/assets/{chunk-55IACEB6-B60wcTiu.js → chunk-55IACEB6-Ba9KW173.js} +1 -1
- package/dist-ksadk/assets/{chunk-727SXJPM-BGlb7ll1.js → chunk-727SXJPM-CBkuHlWy.js} +1 -1
- package/dist-ksadk/assets/{chunk-AQP2D5EJ-C5QUv7XG.js → chunk-AQP2D5EJ-cWD88O0R.js} +1 -1
- package/dist-ksadk/assets/{chunk-FMBD7UC4-Du4tdup0.js → chunk-FMBD7UC4-BUrLnsHX.js} +1 -1
- package/dist-ksadk/assets/{chunk-ND2GUHAM-BsLG8760.js → chunk-ND2GUHAM-B_uYv3IA.js} +1 -1
- package/dist-ksadk/assets/chunk-QZHKN3VN-yZAr1Dj8.js +1 -0
- package/dist-ksadk/assets/classDiagram-4FO5ZUOK-Cav8Io0V.js +1 -0
- package/dist-ksadk/assets/classDiagram-v2-Q7XG4LA2-Cav8Io0V.js +1 -0
- package/dist-ksadk/assets/{cose-bilkent-S5V4N54A-JMKU0kQi.js → cose-bilkent-S5V4N54A-Ob1AOX07.js} +1 -1
- package/dist-ksadk/assets/{dagre-BM42HDAG-P3phXbyY.js → dagre-BM42HDAG-Cw2ELnlF.js} +1 -1
- package/dist-ksadk/assets/{diagram-2AECGRRQ-C6ifXc81.js → diagram-2AECGRRQ-BIR6If7W.js} +1 -1
- package/dist-ksadk/assets/{diagram-5GNKFQAL-BLkF21oh.js → diagram-5GNKFQAL-CaECh3Vg.js} +1 -1
- package/dist-ksadk/assets/{diagram-KO2AKTUF-A9gkeGco.js → diagram-KO2AKTUF-D3V-rrkc.js} +1 -1
- package/dist-ksadk/assets/{diagram-LMA3HP47-Bqa8UV5s.js → diagram-LMA3HP47-BzEyff8c.js} +1 -1
- package/dist-ksadk/assets/{diagram-OG6HWLK6-GRe4pokR.js → diagram-OG6HWLK6-Bgthbllv.js} +1 -1
- package/dist-ksadk/assets/{dist-CNP2pf7G.js → dist-B4yXtSg3.js} +1 -1
- package/dist-ksadk/assets/{dist-D2JPG7pC.js → dist-B8ZWpW4i.js} +1 -1
- package/dist-ksadk/assets/{dist-4wlqrTld.js → dist-BE76hYy3.js} +1 -1
- package/dist-ksadk/assets/{dist-DpijsPsZ.js → dist-BI5M27-4.js} +1 -1
- package/dist-ksadk/assets/{dist-BVtcRB6j.js → dist-BZzeSVME.js} +1 -1
- package/dist-ksadk/assets/{dist-Cy6uew5t.js → dist-BbsQ32yZ.js} +1 -1
- package/dist-ksadk/assets/{dist-CQy3m9R-.js → dist-Br4tabXH.js} +1 -1
- package/dist-ksadk/assets/{dist-Cybdu3nb.js → dist-C1FbzTlR.js} +1 -1
- package/dist-ksadk/assets/{dist-CIwg1HaJ.js → dist-CJVD8Qen.js} +1 -1
- package/dist-ksadk/assets/{dist-Bb2GBx-1.js → dist-CQj_mZtX.js} +1 -1
- package/dist-ksadk/assets/{dist-CejVKm1n.js → dist-CltMulHu.js} +1 -1
- package/dist-ksadk/assets/{dist-DBDWFC2P.js → dist-CprtF_Yw.js} +1 -1
- package/dist-ksadk/assets/{dist-f5z7EOt1.js → dist-Cs_CrFvx.js} +1 -1
- package/dist-ksadk/assets/{dist-DjQKJaGi.js → dist-CtpPIyFY.js} +1 -1
- package/dist-ksadk/assets/{dist-DIe_LuNr.js → dist-DNQ5Xgkl.js} +1 -1
- package/dist-ksadk/assets/{dist-BicfrzOs.js → dist-DhwceB_X.js} +1 -1
- package/dist-ksadk/assets/{dist-Bg1jewnS.js → dist-FWZSQYuG.js} +1 -1
- package/dist-ksadk/assets/{dist-DELPkMrm.js → dist-FgO6dUv_.js} +1 -1
- package/dist-ksadk/assets/{dist-Q6a4_tgv.js → dist-SOaE0trD.js} +1 -1
- package/dist-ksadk/assets/{dist-CTVErq35.js → dist-loAWb-yY.js} +1 -1
- package/dist-ksadk/assets/{dist-CJmGJ-_Y.js → dist-qmkcKPdJ.js} +1 -1
- package/dist-ksadk/assets/{dist-DqTi4q3N.js → dist-xjcaveNh.js} +1 -1
- package/dist-ksadk/assets/{erDiagram-TEJ5UH35-B8oH_MaS.js → erDiagram-TEJ5UH35-C_N1U6ND.js} +1 -1
- package/dist-ksadk/assets/eventmodeling-FCH6USID-D4JVqRuD.js +1 -0
- package/dist-ksadk/assets/{flowDiagram-I6XJVG4X-BhXAWO91.js → flowDiagram-I6XJVG4X-Cu2-GdOp.js} +1 -1
- package/dist-ksadk/assets/{ganttDiagram-6RSMTGT7-BHNcInuv.js → ganttDiagram-6RSMTGT7-CFMrfxGE.js} +1 -1
- package/dist-ksadk/assets/gitGraph-WXDBUCRP-Dhb2APoT.js +1 -0
- package/dist-ksadk/assets/{gitGraphDiagram-PVQCEYII-B82aMrtH.js → gitGraphDiagram-PVQCEYII-DMfMwZL3.js} +1 -1
- package/dist-ksadk/assets/{index-DZFhFnmx.js → index-NDLr6qy9.js} +5 -5
- package/dist-ksadk/assets/info-J43DQDTF-Bd0FU_kK.js +1 -0
- package/dist-ksadk/assets/{infoDiagram-5YYISTIA-b_Hi36OA.js → infoDiagram-5YYISTIA-cBZXniHy.js} +1 -1
- package/dist-ksadk/assets/{ishikawaDiagram-YF4QCWOH-CpiHSyNA.js → ishikawaDiagram-YF4QCWOH-Byt-LQw-.js} +1 -1
- package/dist-ksadk/assets/{journeyDiagram-JHISSGLW-BHxHdRl7.js → journeyDiagram-JHISSGLW-BtY3m69h.js} +1 -1
- package/dist-ksadk/assets/{kanban-definition-UN3LZRKU-kTk8cylz.js → kanban-definition-UN3LZRKU-C6iN0sWn.js} +1 -1
- package/dist-ksadk/assets/{katex-D_Tkj1sg.js → katex-DJ8K3DD_.js} +1 -1
- package/dist-ksadk/assets/{linear-Dc1T6HuL.js → linear-CUfNl6zg.js} +1 -1
- package/dist-ksadk/assets/{mermaid-parser.core-Cfv6TRDT.js → mermaid-parser.core-xgL8Vh_R.js} +2 -2
- package/dist-ksadk/assets/{mindmap-definition-RKZ34NQL-BsWFIVwR.js → mindmap-definition-RKZ34NQL-BkGzz7Z2.js} +1 -1
- package/dist-ksadk/assets/packet-YPE3B663-BLs1Uxy0.js +1 -0
- package/dist-ksadk/assets/pie-LRSECV5Y-DwzfGu6H.js +1 -0
- package/dist-ksadk/assets/{pieDiagram-4H26LBE5-CAMt3yXs.js → pieDiagram-4H26LBE5-BIH7P3Lx.js} +1 -1
- package/dist-ksadk/assets/{quadrantDiagram-W4KKPZXB-D-fXOUis.js → quadrantDiagram-W4KKPZXB-C2xbbI2c.js} +1 -1
- package/dist-ksadk/assets/radar-GUYGQ44K-eGejGVHG.js +1 -0
- package/dist-ksadk/assets/{requirementDiagram-4Y6WPE33-on5TsZ__.js → requirementDiagram-4Y6WPE33-ByFUrTNV.js} +1 -1
- package/dist-ksadk/assets/{sankeyDiagram-5OEKKPKP-DJVzeVPc.js → sankeyDiagram-5OEKKPKP-vGZbAxiz.js} +1 -1
- package/dist-ksadk/assets/{sequenceDiagram-3UESZ5HK-DHLjjUuy.js → sequenceDiagram-3UESZ5HK-ZkwUIiu3.js} +1 -1
- package/dist-ksadk/assets/{stateDiagram-AJRCARHV-CS1svOV-.js → stateDiagram-AJRCARHV-BdbKWYq8.js} +1 -1
- package/dist-ksadk/assets/stateDiagram-v2-BHNVJYJU-DiPVQ0cz.js +1 -0
- package/dist-ksadk/assets/{timeline-definition-PNZ67QCA-CzEM0jEl.js → timeline-definition-PNZ67QCA-B5QfJdJp.js} +1 -1
- package/dist-ksadk/assets/treeView-BLDUP644-C6UbCLlZ.js +1 -0
- package/dist-ksadk/assets/treemap-LRROVOQU-Bk3Xcttl.js +1 -0
- package/dist-ksadk/assets/{vennDiagram-CIIHVFJN-CX4PRvMt.js → vennDiagram-CIIHVFJN-zcCHPgCd.js} +1 -1
- package/dist-ksadk/assets/wardley-L42UT6IY-DpJI-Lu5.js +1 -0
- package/dist-ksadk/assets/{wardleyDiagram-YWT4CUSO-C_uFCiox.js → wardleyDiagram-YWT4CUSO-CUTRM1sP.js} +1 -1
- package/dist-ksadk/assets/{xychartDiagram-2RQKCTM6-C0jIrQJj.js → xychartDiagram-2RQKCTM6-gvfSgBXS.js} +1 -1
- package/dist-ksadk/index.html +1 -1
- package/dist-lib/App.d.ts.map +1 -1
- package/dist-lib/{ArtifactsPanel-Bwj57S63.js → ArtifactsPanel-yLxSIEFw.js} +1 -1
- package/dist-lib/{CodeBlock-CqZR-NBE.js → CodeBlock-CKy7sFkN.js} +1 -1
- package/dist-lib/{MathMessageMarkdown-D-CXaxIx.js → MathMessageMarkdown-D0fGt004.js} +2 -2
- package/dist-lib/{NativeTerminalPanel-DASBHcE0.js → NativeTerminalPanel-Bzdmm_Au.js} +94 -79
- package/dist-lib/{WorkspacePanelContainer-DLWLtZRG.js → WorkspacePanelContainer-BTxXY3RS.js} +4 -3
- package/dist-lib/components/chat/ChatHeader.d.ts.map +1 -1
- package/dist-lib/components/native/NativeTerminalPanel.d.ts +2 -1
- package/dist-lib/components/native/NativeTerminalPanel.d.ts.map +1 -1
- package/dist-lib/components.js +2 -2
- package/dist-lib/runtime.js +3 -2
- package/dist-lib/utils/terminal-session.d.ts +1 -0
- package/dist-lib/utils/terminal-session.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist-ksadk/assets/NativeTerminalPanel-DEfOlZBW.js +0 -1
- package/dist-ksadk/assets/architecture-7EHR7CIX-DXMaR0JR.js +0 -1
- package/dist-ksadk/assets/channel-Be4GcfhN.js +0 -1
- package/dist-ksadk/assets/chunk-QZHKN3VN-D07X2ALj.js +0 -1
- package/dist-ksadk/assets/classDiagram-4FO5ZUOK-CcD88kyq.js +0 -1
- package/dist-ksadk/assets/classDiagram-v2-Q7XG4LA2-CcD88kyq.js +0 -1
- package/dist-ksadk/assets/eventmodeling-FCH6USID-Dl1-sbst.js +0 -1
- package/dist-ksadk/assets/gitGraph-WXDBUCRP-BH52bHVm.js +0 -1
- package/dist-ksadk/assets/info-J43DQDTF-DpbRzclW.js +0 -1
- package/dist-ksadk/assets/packet-YPE3B663-DCpFrt65.js +0 -1
- package/dist-ksadk/assets/pie-LRSECV5Y-BcSHuNj-.js +0 -1
- package/dist-ksadk/assets/radar-GUYGQ44K-DR1bSSMx.js +0 -1
- package/dist-ksadk/assets/stateDiagram-v2-BHNVJYJU-BXQTiPGY.js +0 -1
- package/dist-ksadk/assets/treeView-BLDUP644-94CTmjJu.js +0 -1
- package/dist-ksadk/assets/treemap-LRROVOQU-Cjv6ruUS.js +0 -1
- package/dist-ksadk/assets/wardley-L42UT6IY-B-RIUQEs.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MathMessageMarkdown-BtAniUMT.js","./CodeBlock-MkPxZeyx.js","./MermaidBlock-B7_vB2SD.js","./katex-DJ8K3DD_.js","./MathMessageMarkdown-DeYh8QPr.css","./NativeTerminalPanel-DKuFni1-.js","./NativeTerminalPanel-CHOd7Rch.css","./dist-B8ZWpW4i.js","./dist-CJVD8Qen.js","./dist-CtpPIyFY.js","./dist-C1FbzTlR.js","./dist-xjcaveNh.js","./dist-SOaE0trD.js","./dist-CprtF_Yw.js","./dist-CQj_mZtX.js","./dist-BZzeSVME.js","./dist-DNQ5Xgkl.js","./dist-BI5M27-4.js","./dist-loAWb-yY.js","./dist-BE76hYy3.js","./dist-qmkcKPdJ.js","./dist-BbsQ32yZ.js","./dist-DhwceB_X.js","./dist-CltMulHu.js","./dist-Br4tabXH.js","./dist-Cs_CrFvx.js","./dist-FWZSQYuG.js","./dockerfile-BLkNEvjs.js","./simple-mode-DRpGK0lJ.js","./factor-D7LVTn2l.js","./nsis-AQ_alPln.js","./pug-Bugr-47h.js","./javascript-9Tg8ixDm.js","./dist-FgO6dUv_.js","./dist-B4yXtSg3.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-T<w)}function E(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(E)};else if(typeof MessageChannel<`u`){var O=new MessageChannel,te=O.port2;O.port1.onmessage=E,D=function(){te.postMessage(null)}}else D=function(){_(E,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function ee(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function E(e,t){return ee(e.type,t,e.props)}function D(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function O(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?O(``+e.key):t.toString(36)}function re(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ie(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ie(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),ie(o,r,i,``,function(e){return e})):o!=null&&(D(o)&&(o=E(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ne(a,u),c+=ie(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ne(a,u++),c+=ie(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ie(re(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ae(e,t,n){if(e==null)return e;var r=[],i=0;return ie(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function oe(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var k=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},A={map:ae,forEach:function(e,t,n){ae(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ae(e,function(){t++}),t},toArray:function(e){return ae(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=A,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return ee(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return ee(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=D,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:oe}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,k)}catch(e){k(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=d(),n=p(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),ee=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function re(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var ie=Symbol.for(`react.client.reference`);function ae(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case ee:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?ae(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return ae(e(t))}catch{}}return null}var oe=Array.isArray,k=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se={pending:!1,data:null,method:null,action:null},ce=[],le=-1;function ue(e){return{current:e}}function j(e){0>le||(e.current=ce[le],ce[le]=null,le--)}function de(e,t){le++,ce[le]=e.current,e.current=t}var fe=ue(null),pe=ue(null),me=ue(null),he=ue(null);function ge(e,t){switch(de(me,t),de(pe,e),de(fe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Zd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Zd(t),e=Qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}j(fe),de(fe,e)}function _e(){j(fe),j(pe),j(me)}function ve(e){e.memoizedState!==null&&de(he,e);var t=fe.current,n=Qd(t,e.type);t!==n&&(de(pe,e),de(fe,n))}function ye(e){pe.current===e&&(j(fe),j(pe)),he.current===e&&(j(he),cp._currentValue=se)}var M,be;function xe(e){if(M===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);M=t&&t[1]||``,be=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+M+e+be}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -115,10 +115,10 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
|
115
115
|
`:i||a?`
|
|
116
116
|
`:r})}function Uy(e){if(!e)return e;let t=String(e).replace(/\r\n/g,`
|
|
117
117
|
`).replace(/\r/g,`
|
|
118
|
-
`).trim();return t=jy(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),Hy(t.split("```")).join("```").trim()}var Wy=`modulepreload`,Gy=function(e,t){return new URL(e,t).href},Ky={},W=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Gy(t,n),t in Ky)return;Ky[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Wy,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},qy=b.lazy(()=>W(()=>import(`./CodeBlock-
|
|
118
|
+
`).trim();return t=jy(t),(t.match(/```/g)||[]).length%2==1&&(t=`${t}\n\`\`\``),Hy(t.split("```")).join("```").trim()}var Wy=`modulepreload`,Gy=function(e,t){return new URL(e,t).href},Ky={},W=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Gy(t,n),t in Ky)return;Ky[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Wy,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},qy=b.lazy(()=>W(()=>import(`./CodeBlock-MkPxZeyx.js`).then(e=>({default:e.CodeBlock})),[],import.meta.url)),Jy=b.lazy(()=>W(()=>import(`./MermaidBlock-B7_vB2SD.js`).then(e=>({default:e.MermaidBlock})),[],import.meta.url)),Yy=b.lazy(()=>W(()=>import(`./MathMessageMarkdown-BtAniUMT.js`).then(e=>({default:e.MathMessageMarkdown})),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function Xy(e){return/\$[^$]+\$|\$\$[^$]+\$\$/.test(e)}var Zy={code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e||``),i=String(t??``);if(!r&&!i.includes(`
|
|
119
119
|
`))return(0,L.jsx)(`code`,{className:`bg-slate-100 dark:bg-slate-800 px-1.5 py-0.5 rounded-md text-[13.5px] font-mono text-slate-800 dark:text-slate-200 before:content-none after:content-none border border-slate-200 dark:border-slate-700`,...n,children:t});let a=r?r[1]:``;return a===`mermaid`?(0,L.jsx)(b.Suspense,{fallback:(0,L.jsx)(`div`,{className:`h-32 animate-pulse bg-slate-100 dark:bg-slate-800 rounded`}),children:(0,L.jsx)(Jy,{chart:i})}):(0,L.jsx)(b.Suspense,{fallback:(0,L.jsx)(`pre`,{className:`p-4 text-sm`,children:i}),children:(0,L.jsx)(qy,{language:a,value:i})})},table({children:e,...t}){return(0,L.jsx)(`div`,{className:`overflow-x-auto my-4 border border-slate-200 dark:border-slate-700 rounded-lg`,children:(0,L.jsx)(`table`,{className:`w-full text-sm text-left my-0`,...t,children:e})})},th({children:e,...t}){return(0,L.jsx)(`th`,{className:`bg-slate-50 dark:bg-slate-800/50 px-4 py-2 font-semibold border-b border-slate-200 dark:border-slate-700`,...t,children:e})},td({children:e,...t}){return(0,L.jsx)(`td`,{className:`px-4 py-2 border-b border-slate-100 dark:border-slate-800 last:border-0`,...t,children:e})},a({children:e,href:t,...n}){return(0,L.jsx)(`a`,{href:t,className:`text-blue-600 dark:text-blue-400 hover:underline`,target:`_blank`,rel:`noopener noreferrer`,...n,children:e})}},Qy=b.memo(({content:e})=>{let t=Uy(e);return(0,L.jsx)(`div`,{className:`prose prose-slate dark:prose-invert max-w-none break-words text-[15px] leading-7 prose-headings:mb-3 prose-headings:mt-6 prose-headings:font-semibold prose-headings:text-slate-900 dark:prose-headings:text-slate-50 prose-h1:text-[1.95rem] prose-h1:leading-tight prose-h1:tracking-[-0.02em] prose-h2:text-[1.55rem] prose-h2:leading-tight prose-h2:tracking-[-0.015em] prose-h3:text-[1.2rem] prose-h3:leading-snug prose-p:my-3 prose-p:leading-7 prose-strong:text-slate-900 dark:prose-strong:text-slate-100 prose-ol:my-3 prose-ul:my-3 prose-li:my-1.5 prose-li:leading-7 prose-hr:my-5 prose-hr:border-slate-200 dark:prose-hr:border-slate-700 prose-pre:m-0 prose-pre:bg-transparent prose-pre:p-0 [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,L.jsx)(Eg,{remarkPlugins:[Ay],components:Zy,children:t})})}),$y=b.memo(({content:e})=>Xy(e)?(0,L.jsx)(b.Suspense,{fallback:(0,L.jsx)(Qy,{content:e}),children:(0,L.jsx)(Yy,{content:e})}):(0,L.jsx)(Qy,{content:e}));async function eb(e,t=globalThis){let n=String(e??``),r=t?.navigator;if(r?.clipboard?.writeText)try{return await r.clipboard.writeText(n),!0}catch{}let i=t?.document,a=i?.body;if(!i?.createElement||!a?.appendChild||!a?.removeChild)return!1;let o=i.createElement(`textarea`);o.value=n,o.setAttribute?.(`readonly`,``),o.style&&(o.style.position=`fixed`,o.style.top=`0`,o.style.left=`-9999px`,o.style.opacity=`0`,o.style.pointerEvents=`none`);let s=i.activeElement;a.appendChild(o),o.focus?.(),o.select?.(),o.setSelectionRange?.(0,n.length);try{return typeof i.execCommand==`function`?!!i.execCommand(`copy`):!1}finally{a.removeChild(o),s?.focus?.()}}function tb(e,t,n){return Math.max(t,Math.min(n,e))}function nb({items:e=[],scrollTop:t=0,viewportHeight:n=0,overscan:r=4,defaultItemHeight:i=120,measuredHeights:a=new Map,getItemKey:o=(e,t)=>e?.id||String(t)}={}){let s=Math.max(0,Number(n)||0),c=Math.max(0,Number(t)||0),l=Math.max(0,Number(r)||0),u=Math.max(1,Number(i)||120);if(!e.length)return{startIndex:0,endIndex:0,offsetTop:0,totalHeight:0,visibleItems:[]};let d=e.map((e,t)=>{let n=o(e,t),r=Number(a.get(n));return Number.isFinite(r)&&r>0?r:u}),f=Array(e.length),p=0;for(let t=0;t<e.length;t+=1)f[t]=p,p+=d[t];let m=p,h=c+s,g=0;for(;g<e.length&&f[g]+d[g]<=c;)g+=1;let _=g;for(;_<e.length&&f[_]<h;)_+=1;return g=tb(g-l,0,e.length),_=tb(Math.max(g+1,_+l),0,e.length),{startIndex:g,endIndex:_,offsetTop:f[g]||0,totalHeight:m,visibleItems:e.slice(g,_).map((e,t)=>{let n=g+t;return{index:n,item:e,top:f[n]||0,height:d[n]||u}})}}var rb=140,ib=4;function ab(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n<=0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function ob(e){return e<1e3?`刚刚`:e<6e4?`${Math.floor(e/1e3)} 秒前`:`${Math.floor(e/6e4)} 分钟前`}function sb(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0`:t<1e3?String(Math.round(t)):t<1e6?`${Math.round(t/100)/10}k`:`${Math.round(t/1e5)/10}m`}function cb({contextIndicator:e}){let t=e?.usedTokens,n=e?.contextWindowTokens;return!t||!n?null:(0,L.jsxs)(`span`,{className:`token-count-pulse hidden font-mono text-slate-400 dark:text-slate-500 sm:inline`,title:`估算 token:${Math.round(t)} / ${Math.round(n)}`,children:[`估算 token `,sb(t),` / `,sb(n)]},Math.round(t))}function lb({activity:e,contextIndicator:t,onStopGeneration:n,onCancelRemote:r}){let[i,a]=(0,b.useState)(()=>Date.now());(0,b.useEffect)(()=>{let e=window.setInterval(()=>a(Date.now()),1e3);return()=>window.clearInterval(e)},[]);let o=e.status===`connecting`||e.status===`running`||e.status===`waiting`,s=i-e.lastEventAt<2e4;return(0,L.jsxs)(`div`,{className:`inline-flex max-w-full items-center gap-2 rounded-full border border-slate-200/70 bg-white/90 px-2.5 py-1 text-[11px] leading-4 text-slate-500 shadow-sm shadow-slate-900/5 backdrop-blur dark:border-slate-700/60 dark:bg-slate-900/90 dark:text-slate-400`,children:[e.status===`failed`?(0,L.jsx)(Gr,{className:`h-3 w-3 text-rose-500`}):e.status===`completed`?(0,L.jsx)(Ur,{className:`h-3 w-3 text-emerald-500`}):e.status===`stopped`?(0,L.jsx)(yi,{className:`h-3 w-3 text-amber-500`}):(0,L.jsx)(mi,{className:`h-3 w-3 animate-spin text-slate-400`}),(0,L.jsx)(`span`,{className:`max-w-[16rem] truncate text-slate-600 dark:text-slate-300`,title:e.detail||e.phase,children:e.phase}),(0,L.jsxs)(`span`,{children:[e.source===`restore`?`恢复`:`运行`,` `,ab(i-e.startedAt)]}),o?(0,L.jsx)(`span`,{className:I(`inline-block h-1.5 w-1.5 flex-shrink-0 rounded-full`,s?`bg-emerald-400`:`bg-slate-300 dark:bg-slate-600`),title:s?`连接存活`:`连接超时`}):null,(0,L.jsxs)(`span`,{className:`text-slate-400 dark:text-slate-500`,children:[e.eventCount,` ev`]}),(0,L.jsx)(cb,{contextIndicator:t}),(0,L.jsx)(`span`,{className:`hidden text-slate-400 dark:text-slate-500 sm:inline`,children:ob(i-e.lastEventAt)}),o&&(n||r)?(0,L.jsxs)(`div`,{className:`flex flex-shrink-0 gap-1`,children:[n?(0,L.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-slate-100 hover:text-slate-700 dark:text-slate-500 dark:hover:bg-slate-800 dark:hover:text-slate-200`,children:[(0,L.jsx)(Gr,{className:`h-3 w-3`}),`停止`]}):null,r?(0,L.jsxs)(`button`,{type:`button`,"aria-label":`取消运行并保留恢复点`,title:`取消运行并保留最近 checkpoint`,onClick:r,className:`flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[11px] text-slate-400 transition hover:bg-rose-50 hover:text-rose-600 dark:text-slate-500 dark:hover:bg-rose-950/30 dark:hover:text-rose-300`,children:[(0,L.jsx)(Kr,{className:`h-3 w-3`}),`取消`]}):null]}):null]})}function ub({agentName:e}){return(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[50vh] px-4`,children:[(0,L.jsx)(`div`,{className:`mb-6 h-16 w-16 rounded-2xl bg-gradient-to-br from-blue-500 to-indigo-600
|
|
120
120
|
flex items-center justify-center shadow-lg shadow-blue-500/20`,children:(0,L.jsx)(Hr,{className:`h-8 w-8 text-white`})}),(0,L.jsx)(`h2`,{className:`text-xl font-semibold text-slate-900 dark:text-slate-50`,children:`有什么我可以帮您的吗?`}),(0,L.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500`,children:[`我是 `,e,`,由 Ksyun AgentEngine 驱动`]})]})}function db(e){let t=String(e||``).trim();return t?{stream:`流式执行中`,running:`运行中`,interrupted:`已中断`,cancelled:`已取消`,completed:`已完成`,before_tool:`工具执行前`,after_tool:`工具执行后`}[t]||t:`保存运行状态`}function fb(e){return{completed:`已完成`,checkpointed:`已保存`,running:`执行中`,ready_to_resume:`可恢复`,cancelled:`已取消`,canceled:`已取消`,failed:`失败`,pending:`等待中`}[String(e||``).trim().toLowerCase()]||``}function pb(e,t){return t.stage?t.stage:t.phase&&![`stream`,`running`,`interrupted`,`cancelled`,`completed`,`before_tool`,`after_tool`].includes(t.phase)?t.phase:e===0?`最新状态快照`:`状态快照 #${e+1}`}function mb(e,t){return`第 ${Math.max(1,t-e)}/${Math.max(1,t)} 阶段`}function hb(e,t=8,n=4){let r=String(e||``).trim();return r?r.length<=t+n+1?r:`${r.slice(0,t)}...${r.slice(-n)}`:``}function gb({checkpoints:e,isStreaming:t,onResumeCheckpoint:n}){if(!e.length||!n)return null;let r=e.filter(e=>{let t=String(e.status||``).trim().toLowerCase();return t===`completed`||t===`checkpointed`||t===`ready_to_resume`}).length;return(0,L.jsxs)(`div`,{className:`mb-4 rounded-lg border border-slate-200 bg-white px-3 py-3 text-xs text-slate-600 shadow-sm shadow-slate-900/[0.04] dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-300`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`font-medium text-slate-800 dark:text-slate-100`,children:`会话恢复区`}),(0,L.jsx)(`div`,{className:`mt-0.5 text-[11px] text-slate-400`,children:`选择 LangGraph 状态快照,从对应图状态继续`})]}),(0,L.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[r>0?(0,L.jsxs)(`span`,{className:`rounded-full bg-emerald-50 px-2 py-1 text-[11px] font-medium text-emerald-700 ring-1 ring-emerald-100 dark:bg-emerald-950/25 dark:text-emerald-300 dark:ring-emerald-900/50`,children:[`已捕获 `,r,` 个快照`]}):null,(0,L.jsxs)(`span`,{className:`rounded-full bg-white px-2 py-1 text-[11px] font-medium text-slate-500 ring-1 ring-slate-200 dark:bg-slate-950/40 dark:text-slate-300 dark:ring-slate-700`,children:[`共 `,e.length,` 个`]})]})]}),(0,L.jsx)(`div`,{className:`custom-scrollbar flex max-h-[24rem] flex-col gap-1.5 overflow-y-auto pr-1`,children:e.map((r,i)=>{let a=t||!r.sessionId,o=mb(i,e.length),s=pb(i,r),c=db(r.phase),l=fb(r.status)||(i===0?`推荐`:``),u=hb(r.checkpointId),d=hb(r.runId,10,4);return(0,L.jsxs)(`div`,{className:`grid min-h-[4.35rem] grid-cols-[1.75rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md border border-slate-200/70 bg-slate-50/70 px-2.5 py-2 transition hover:border-blue-200 hover:bg-blue-50/40 dark:border-slate-700/70 dark:bg-slate-950/30 dark:hover:border-blue-800 dark:hover:bg-blue-950/20`,title:[r.timestamp?`时间:${Ul(r.timestamp)}`:``,u?`checkpoint:${r.checkpointId}`:``,d?`run:${r.runId}`:``].filter(Boolean).join(`
|
|
121
|
-
`)||void 0,children:[(0,L.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-white text-emerald-600 ring-1 ring-slate-200 dark:bg-slate-900 dark:text-emerald-300 dark:ring-slate-700`,children:(0,L.jsx)(Ur,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-600 dark:bg-blue-950/40 dark:text-blue-300`,children:o}),i===0?(0,L.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-white px-2 py-0.5 text-[11px] font-medium text-blue-600 ring-1 ring-blue-100 dark:bg-slate-950/40 dark:text-blue-300 dark:ring-blue-900/50`,children:`最新`}):null,l?(0,L.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-600 dark:bg-emerald-950/30 dark:text-emerald-300`,children:l}):null,(0,L.jsx)(`span`,{className:`truncate font-medium text-slate-800 dark:text-slate-100`,children:s})]}),r.summary?(0,L.jsx)(`div`,{className:`mt-1 truncate text-[12px] leading-5 text-slate-600 dark:text-slate-300`,children:r.summary}):(0,L.jsx)(`div`,{className:`mt-1 text-[12px] leading-5 text-slate-500 dark:text-slate-400`,children:c}),(0,L.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-slate-400`,children:[r.nextAction?(0,L.jsxs)(`span`,{className:`truncate text-blue-600 dark:text-blue-300`,children:[`恢复后阶段:`,r.nextAction]}):(0,L.jsx)(`span`,{className:`truncate`,children:c}),r.timestamp?(0,L.jsx)(`span`,{className:`hidden flex-shrink-0 sm:inline`,children:Ul(r.timestamp)}):null]})]}),(0,L.jsxs)(`button`,{type:`button`,"aria-label":`恢复到${o}`,disabled:a,title:a?`当前会话正在运行,暂不能恢复`:`从该 LangGraph checkpoint 恢复`,onClick:()=>{r.sessionId&&n({sessionId:r.sessionId,runId:r.runId,checkpointId:r.checkpointId})},className:`inline-flex h-8 flex-shrink-0 items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 text-[11px] font-medium text-slate-600 transition hover:border-blue-300 hover:text-blue-600 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300 dark:hover:border-blue-500 dark:hover:text-blue-300`,children:[(0,L.jsx)(mi,{className:`h-3 w-3`}),`恢复`]})]},r.checkpointId)})})]})}function _b({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,L.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,L.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:I(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,L.jsx)(`img`,{src:e.url,alt:e.name,className:I(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,L.jsx)(`div`,{className:I(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,L.jsxs)(`div`,{className:I(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,L.jsx)(ui,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`truncate text-sm text-slate-700 hover:underline dark:text-slate-300`,title:e.name,children:e.name}):(0,L.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function vb({message:e}){return(0,L.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,L.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-2xl border border-amber-200/80 bg-amber-50/80 px-4 py-3 text-sm text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,L.jsx)(mi,{className:`h-4 w-4 animate-spin text-amber-600 dark:text-amber-300`}):e.status===`failed`?(0,L.jsx)(Gr,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,L.jsx)(Ur,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,L.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,L.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,L.jsxs)(`details`,{className:`mt-3 rounded-xl border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-900/60 dark:bg-slate-950/40`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-amber-800 dark:text-amber-200`,children:`查看压缩摘要`}),(0,L.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,L.jsx)($y,{content:e.summary})})]}):null]})})}function yb({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=jn(n);(0,b.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await eb(a)?`copied`:`failed`)};return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,L.jsx)(`div`,{className:I(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{o()},className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,children:[r===`copied`?(0,L.jsx)(Ur,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,L.jsx)(Jr,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,L.jsx)(`div`,{className:`custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]`,children:a})]})}function bb({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i}){let[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(n.feedback?.comment||``),l=mr(n,t,e),u=!!n.feedback?.pending,d=n.feedback?.rating;return l?(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-slate-500 dark:text-slate-400`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,L.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>i({message:n,rating:`up`,comment:``}),className:I(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`up`?`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900/70 dark:bg-emerald-950/30 dark:text-emerald-200`:`border-slate-200 bg-white text-slate-600 hover:border-emerald-200 hover:text-emerald-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-emerald-900/70 dark:hover:text-emerald-200`),children:[(0,L.jsx)(Si,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,L.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{c(n.feedback?.comment||``),o(e=>!e)},className:I(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`down`?`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-200`:`border-slate-200 bg-white text-slate-600 hover:border-rose-200 hover:text-rose-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-rose-900/70 dark:hover:text-rose-200`),children:[(0,L.jsx)(xi,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,L.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>r(n),className:`inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200`,children:[(0,L.jsx)(Ci,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,u?(0,L.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),a?(0,L.jsxs)(`div`,{className:`max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20`,children:[(0,L.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`可以补充哪里不准确、缺失或不符合预期。`,className:`min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950`}),(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{i({message:n,rating:`down`,comment:s}),o(!1)},className:`rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60`,children:`提交点踩`})]})]}):d===`down`&&n.feedback?.comment?(0,L.jsxs)(`div`,{className:`max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`,children:[`反馈:`,n.feedback.comment]}):null,n.feedback?.error?(0,L.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function xb({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,message:i,onDeleteFeedback:a,onOpenAttachmentPreview:o,onRespondToApproval:s,onSubmitFeedback:c}){return i.role===`user`?(0,L.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,L.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-sm bg-blue-600 px-3.5 py-2.5 text-[14px] leading-relaxed text-white dark:bg-blue-500`,children:[i.attachments?.length?(0,L.jsx)(_b,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.content]})}):(0,L.jsxs)(`div`,{className:`mb-3 max-w-none`,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-slate-400`,children:[(0,L.jsx)(Hr,{className:`w-3.5 h-3.5`}),(0,L.jsx)(`span`,{children:e})]}),i.attachments?.length?(0,L.jsx)(_b,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.reasoning?(0,L.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-lg border border-emerald-200/70 bg-emerald-50/40 text-sm text-slate-600 transition-colors open:bg-white dark:border-emerald-900/50 dark:bg-emerald-950/10 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,L.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 border-l-2 border-emerald-400 px-3 py-2 font-medium outline-none marker:hidden dark:border-emerald-500`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n&&r&&!i.content?(0,L.jsx)(mi,{className:`h-4 w-4 animate-spin text-emerald-500`}):(0,L.jsx)(Ur,{className:`h-4 w-4 text-emerald-500`}),(0,L.jsx)(`span`,{className:`truncate`,children:`思考过程`}),(0,L.jsx)(`span`,{className:`rounded-full bg-emerald-100 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:n&&r&&!i.content?`生成中`:`已完成`})]}),(0,L.jsx)(Wr,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,L.jsx)(`div`,{className:`border-t border-emerald-100/80 bg-white/70 dark:border-emerald-950 dark:bg-slate-950/20`,children:(0,L.jsx)(`div`,{className:`custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2`,children:(0,L.jsx)($y,{content:i.reasoning})})})]}):null,i.tools?Object.values(i.tools).map((e,t)=>(0,L.jsxs)(`details`,{open:e.status===`paused`?!0:void 0,className:I(`group/details mb-3 rounded-xl border px-3 py-2.5 text-sm transition-all`,e.status===`paused`?`border-amber-200 bg-amber-50/50 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-200`:e.status===`error`?`border-rose-200 bg-rose-50/40 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`:`border-blue-200 bg-blue-50/30 text-blue-600 dark:border-blue-900/50 dark:bg-blue-950/20 dark:text-blue-400`),children:[(0,L.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 font-medium`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,L.jsx)(mi,{className:`h-4 w-4 animate-spin text-blue-500`}):e.status===`paused`?(0,L.jsx)(yi,{className:`h-4 w-4 text-amber-500`}):e.status===`error`?(0,L.jsx)(Kr,{className:`h-4 w-4 text-rose-500`}):(0,L.jsx)(Ur,{className:`h-4 w-4 text-emerald-500`}),(0,L.jsxs)(`span`,{children:[e.status===`paused`?`等待审批:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,L.jsxs)(`div`,{className:I(`mx-1 mt-3 flex flex-col gap-3 border-l-2 py-1 pl-4 font-mono text-[13px] leading-relaxed opacity-90`,e.status===`paused`?`border-amber-200 dark:border-amber-800`:e.status===`error`?`border-rose-200 dark:border-rose-800`:`border-blue-200 dark:border-blue-800`),children:[e.status===`paused`&&e.approvalRequestId?(0,L.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-white/75 p-3 font-sans text-sm text-amber-900 shadow-sm dark:border-amber-900/70 dark:bg-slate-950/40 dark:text-amber-100`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:`该工具调用需要人工确认后继续。`}),e.serverLabel?(0,L.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,L.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,L.jsx)(Ur,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,L.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl border border-rose-200 bg-white px-3 py-1.5 text-xs font-semibold text-rose-600 shadow-sm transition hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-55 dark:border-rose-900/70 dark:bg-slate-950 dark:text-rose-300 dark:hover:bg-rose-950/30`,children:[(0,L.jsx)(Kr,{className:`h-3.5 w-3.5`}),`拒绝`]})]})]}):null,e.args?(0,L.jsx)(yb,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,L.jsx)(yb,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,(0,L.jsx)(`div`,{className:`w-full break-words`,children:i.content?(0,L.jsx)($y,{content:i.content}):n&&r&&!i.reasoning&&!i.tools?(0,L.jsx)(`span`,{className:`ml-1 mt-2 inline-block h-4 w-2 animate-pulse rounded-sm bg-emerald-500 align-middle opacity-80 shadow-sm`}):null}),(0,L.jsx)(bb,{isLastMessage:r,isStreaming:n,message:i,onDeleteFeedback:a,onSubmitFeedback:c})]})}function Sb({agentName:e,isMobile:t,isStreaming:n,activity:r,contextIndicator:i,messages:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l,onStopGeneration:u,onCancelRemote:d,checkpoints:f=[],onResumeCheckpoint:p,scrollRef:m}){let[h,g]=(0,b.useState)(0),[_,v]=(0,b.useState)(0),[y,x]=(0,b.useState)(new Map);(0,b.useLayoutEffect)(()=>{let e=m.current;if(!e)return;let t=()=>{g(e.scrollTop),v(e.clientHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),()=>n.disconnect()},[m]);let S=(0,b.useMemo)(()=>nb({items:a,scrollTop:h,viewportHeight:_,overscan:ib,defaultItemHeight:rb,measuredHeights:y,getItemKey:(e,t)=>e?.id||String(t)}),[y,a,h,_]),C=S.visibleItems,w=(e,t)=>{!e||!Number.isFinite(t)||t<=0||x(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})};return(0,L.jsxs)(`div`,{ref:m,onScroll:e=>g(e.currentTarget.scrollTop),className:I(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,t?`px-3 py-3`:`px-4 py-5`),children:[(0,L.jsxs)(`div`,{className:I(`mx-auto flex w-full max-w-[64rem] flex-col`,r?`pb-10 sm:pb-10`:`pb-6 sm:pb-8`),children:[(0,L.jsx)(gb,{checkpoints:f,isStreaming:n,onResumeCheckpoint:p}),a.length===0?(0,L.jsx)(ub,{agentName:e}):(0,L.jsx)(`div`,{style:{height:S.totalHeight},className:`relative`,children:C.map(r=>(0,L.jsx)(`div`,{ref:e=>{e&&w(r.item.id||String(r.index),e.offsetHeight)},style:{position:`absolute`,top:r.top,left:0,right:0},children:r.item.role===`system`?(0,L.jsx)(vb,{message:r.item}):(0,L.jsx)(xb,{agentName:e,isMobile:t,isStreaming:n,isLastMessage:r.index===a.length-1,message:r.item,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l})},r.item.id||r.index))})]}),r?(0,L.jsx)(`div`,{className:`sticky bottom-1 z-20 mx-auto flex w-full max-w-[64rem] justify-end`,children:(0,L.jsx)(lb,{activity:r,contextIndicator:i,onStopGeneration:u,onCancelRemote:d})}):null]})}var Cb=Cl,wb=wl,Tb=b.forwardRef(({className:e,...t},n)=>(0,L.jsx)(Tl,{ref:n,className:I(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Tb.displayName=Tl.displayName;var Eb=b.forwardRef(({className:e,children:t,...n},r)=>(0,L.jsxs)(wb,{children:[(0,L.jsx)(Tb,{}),(0,L.jsxs)(El,{ref:r,className:I(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,L.jsxs)(kl,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,L.jsx)(Ti,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Eb.displayName=El.displayName;var Db=({className:e,...t})=>(0,L.jsx)(`div`,{className:I(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});Db.displayName=`DialogHeader`;var Ob=({className:e,...t})=>(0,L.jsx)(`div`,{className:I(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Ob.displayName=`DialogFooter`;var kb=b.forwardRef(({className:e,...t},n)=>(0,L.jsx)(Dl,{ref:n,className:I(`text-lg font-semibold leading-none tracking-tight`,e),...t}));kb.displayName=Dl.displayName;var Ab=b.forwardRef(({className:e,...t},n)=>(0,L.jsx)(Ol,{ref:n,className:I(`text-sm text-muted-foreground`,e),...t}));Ab.displayName=Ol.displayName;function jb(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function Mb(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function Nb({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,L.jsx)(Cb,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,L.jsxs)(Eb,{className:I(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:Mb(t,n),children:[(0,L.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,L.jsx)(kb,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,L.jsx)(`div`,{className:I(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,L.jsx)(`img`,{src:e.url,alt:e.name,className:I(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:jb(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,L.jsx)(`iframe`,{src:e.url,title:e.name,className:`h-full min-h-[24rem] w-full rounded-xl border border-slate-800 bg-white`}):null})]})})}function Pb(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return null}function Fb(e){return/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]/u.test(e)}function Ib(e){let t=String(e||``).trim();if(!t)return 0;let n=0,r=0;for(let e of t){if(Fb(e)){n+=1;continue}r+=1}return Math.max(1,n+Math.ceil(r/4))}function Lb(e){if(!e)return 0;if(e.role===`system`)return e.eventType===`context_checkpoint`?Ib(e.summary||``):0;let t=Ib(e.content||``);return e.tools&&(t+=Object.values(e.tools).reduce((e,t)=>e+Ib(t?.name||``)+Ib(t?.args||``)+Ib(t?.output||``),0)),t}function Rb(e){return e?Pb(e.context_window_tokens)??Pb(e?.limits?.context_window_tokens):null}function zb(e){return e?Pb(e.auto_compact_threshold_percentage)??84:84}function Bb({messages:e,draftInput:t,selectedModel:n}){let r=Rb(n);if(!r)return null;let i=[...e||[]].reverse().find(e=>e?.role===`system`&&e?.eventType===`context_checkpoint`&&e?.status===`running`);if(i){let e=Lb(i);return{label:`正在压缩上下文…`,phase:`compressing`,usedTokens:e,contextWindowTokens:r,percent:Math.min(100,Math.max(0,Math.round(e/r*100)))}}let a=(e||[]).reduce((e,t)=>e+Lb(t),0)+Ib(t||``);if(a<=0)return null;let o=Math.min(100,Math.max(0,Math.round(a/r*100)));return o>=zb(n)?{label:`估算上下文 ${o}% · 即将压缩`,phase:`warning`,percent:o,usedTokens:a,contextWindowTokens:r}:{label:`估算上下文 ${o}%`,phase:`normal`,percent:o,usedTokens:a,contextWindowTokens:r}}function Vb({agentName:e,isMobile:t,onDeleteFeedback:n,onSubmitFeedback:r,onRespondToApproval:i,onStopGeneration:a,onCancelRemote:o,checkpointResumeEnabled:s=!1,onResumeCheckpoint:c,onLoadOlderSessionEvents:l}){let u=Tt(e=>e.messages),d=M(e=>e.currentSessionId),f=j(e=>!!(e.getSessionActivity(d)&&e.isSessionStreaming(d))),p=j(e=>e.getSessionActivity(d)),m=bn(e=>e.getSessionCheckpoints(d)),h=M(e=>d?e.eventCache[d]:null),g=E(e=>e.input),_=le(e=>e.availableModels),v=le(e=>e.selectedModel),y=E(e=>e.previewAttachment),x=E(e=>e.previewImageSize),S=(0,b.useRef)(null),C=(0,b.useRef)(!0),w=(0,b.useRef)(!1),T=(0,b.useRef)(0),ee=(0,b.useRef)(f),D=(0,b.useRef)(!1),O=(0,b.useMemo)(()=>_.find(e=>e.id===v)||null,[_,v]),te=(0,b.useMemo)(()=>Bb({messages:u,draftInput:g,selectedModel:O}),[g,u,O]);return(0,b.useEffect)(()=>{ee.current=f},[f]),(0,b.useEffect)(()=>{let e=S.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<T.current-2;if(T.current=e.scrollTop,e.scrollTop<200&&d&&h&&h.offset>0&&!h.isLoadingOlder&&!D.current&&l){let t=e.scrollHeight;D.current=!0,l(d).then(()=>{requestAnimationFrame(()=>{let e=S.current;if(!e)return;let n=e.scrollHeight-t;e.scrollTop+=n,T.current=e.scrollTop})}).finally(()=>{D.current=!1})}if(ee.current&&n){w.current=!0,C.current=!1;return}if(w.current){let e=t<=12;w.current=!e,C.current=e;return}C.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[h,d,l]),(0,b.useEffect)(()=>{let e=S.current;!e||!C.current||(e.scrollTop=e.scrollHeight,T.current=e.scrollTop)},[u,f]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Sb,{agentName:e,isMobile:t,isStreaming:f,activity:p,contextIndicator:te,messages:u,onDeleteFeedback:n,onOpenAttachmentPreview:e=>{E.getState().setPreviewAttachment(e),E.getState().setPreviewImageSize(null)},onRespondToApproval:i,onSubmitFeedback:r,onStopGeneration:a,onCancelRemote:o,checkpoints:s?m:[],onResumeCheckpoint:c,scrollRef:S}),(0,L.jsx)(Nb,{attachment:y,isMobile:t,previewImageSize:x,onClose:()=>{E.getState().setPreviewAttachment(null),E.getState().setPreviewImageSize(null)},onImageLoad:e=>E.getState().setPreviewImageSize(e)})]})}function Hb({attachments:e,composerContextIndicator:t,composerMaxHeight:n,fileInputRef:r,input:i,isMobile:a,isStreaming:o,queuedDrafts:s,onAppendAttachments:c,onInputChange:l,onPaste:u,onRemoveAttachment:d,onStopGeneration:f,onCancelRemote:p,onSubmit:m,textareaRef:h}){let g=a?`发送消息...`:`发送消息... (Shift + Enter 换行)`,_=p?`保留恢复点并结束本次执行`:`停止生成`;return(0,L.jsx)(`div`,{className:`relative z-10 flex-shrink-0 bg-white/95 px-3 py-3 backdrop-blur dark:bg-slate-900/95 sm:px-4 sm:py-3`,children:(0,L.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[s.length>0?(0,L.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-amber-200/80 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,s.length]}),(0,L.jsx)(`span`,{className:`text-amber-700/75 dark:text-amber-200/75`,children:`当前回复完成后依次发送`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-white/70 px-2 py-1.5 dark:bg-slate-950/35`,children:[(0,L.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-amber-100 font-mono text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:t+1}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200`,children:n}),e.attachments.length>0?(0,L.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),s.length>3?(0,L.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80`,children:[`还有 `,s.length-3,` 条等待发送`]}):null]})]}):null,(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),o){p?p():f();return}let n=i.trim();!n&&e.length===0||m(n,e)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files&&e.dataTransfer.files.length>0&&c(Array.from(e.dataTransfer.files))},className:`relative flex min-w-0 flex-1 flex-col rounded-[1.25rem] border border-slate-200 bg-white p-1.5 shadow-[0_8px_22px_rgba(15,23,42,0.07)] transition-all focus-within:border-slate-300 focus-within:ring-1 focus-within:ring-slate-300 dark:border-slate-700 dark:bg-slate-900 dark:focus-within:border-slate-600 dark:focus-within:ring-slate-600`,children:[e.length>0?(0,L.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2 px-1.5 pt-1.5`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:I(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-1.5 text-xs text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,a?`max-w-full`:``),children:[(0,L.jsx)(`span`,{className:`max-w-[10rem] truncate font-medium sm:max-w-[12rem]`,children:e.name}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>d(t),className:`text-slate-400 transition hover:text-red-500`,"aria-label":`移除附件 ${e.name}`,children:`×`})]},`${e.name}-${e.size}-${t}`))}):null,(0,L.jsxs)(`div`,{className:`flex w-full items-end gap-2`,children:[(0,L.jsxs)(`label`,{className:`relative flex h-9 w-9 flex-shrink-0 items-center justify-center overflow-hidden rounded-xl text-slate-400 transition hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-slate-800 dark:hover:text-slate-200`,title:`上传附件`,children:[(0,L.jsx)(`input`,{ref:r,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(c(Array.from(e.target.files)),e.target.value=``)}}),(0,L.jsx)(ui,{className:`h-5 w-5`})]}),(0,L.jsx)(`textarea`,{ref:h,rows:1,value:i,onChange:l,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:u,placeholder:g,className:I(`custom-scrollbar min-h-[38px] w-full resize-none border-0 bg-transparent px-2 py-1.5 text-[15px] leading-6 outline-none placeholder:text-slate-400 dark:text-slate-100 dark:placeholder:text-slate-500`,a?`text-[16px]`:`text-[15px]`),style:{maxHeight:`${n}px`,overflowY:`auto`}}),(0,L.jsx)(`button`,{type:`submit`,disabled:!o&&!i.trim()&&e.length===0,className:I(`flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl transition-all`,o||i.trim()||e.length>0?`bg-slate-900 text-white hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white`:`bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-600`),title:o?_:`发送消息`,children:o?(0,L.jsx)(Gr,{className:`h-4 w-4`}):(0,L.jsx)(vi,{className:`ml-0.5 h-4 w-4`})})]})]}),t?(0,L.jsxs)(`div`,{className:I(`hidden flex-shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-right text-[11px] leading-5 transition-colors sm:inline-flex`,t.phase===`compressing`?`bg-amber-50 text-amber-600 dark:bg-amber-950/30 dark:text-amber-300`:t.phase===`warning`?`bg-rose-50 text-rose-600 dark:bg-rose-950/30 dark:text-rose-300`:`bg-slate-50 text-slate-400 dark:bg-slate-800/50 dark:text-slate-500`),children:[(0,L.jsx)(yi,{className:`h-3 w-3`}),t.label]}):null]})]})})}function Ub(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function Wb(e,t){let n=new Map;for(let t of e)n.set(Ub(t),t);for(let e of t)n.set(Ub(e),e);return Array.from(n.values())}function Gb(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function Kb({composerMaxHeight:e,submitDraft:t,stopGeneration:n,cancelRemote:r,isMobile:i}){let a=E(e=>e.input),o=E(e=>e.attachments),s=M(e=>e.currentSessionId),c=j(e=>!!(e.getSessionActivity(s)&&e.isSessionStreaming(s))),l=E(e=>e.queuedDrafts),u=Tt(e=>e.messages),d=le(e=>e.availableModels),f=le(e=>e.selectedModel),p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useMemo)(()=>d.find(e=>e.id===f)||null,[d,f]),g=(0,b.useMemo)(()=>Bb({messages:u,draftInput:a,selectedModel:h}),[a,u,h]),_=(0,b.useCallback)((e,n)=>{!e&&n.length===0||(E.getState().setInput(``),E.getState().setAttachments([]),t(e,n))},[t]);(0,b.useEffect)(()=>{m.current&&(m.current.style.height=`auto`,m.current.style.height=`${Math.min(m.current.scrollHeight,e)}px`)},[a,e]);let v=t=>{E.getState().setInput(t.target.value),t.target.style.height=`auto`,t.target.style.height=`${Math.min(t.target.scrollHeight,e)}px`},y=e=>{e.length&&E.getState().setAttachments(t=>Wb(t,e))};return(0,L.jsx)(Hb,{attachments:o,composerContextIndicator:g,composerMaxHeight:e,fileInputRef:p,input:a,isMobile:i,isStreaming:c,queuedDrafts:l,onAppendAttachments:y,onInputChange:v,onPaste:e=>{let t=Gb(e);t.length&&(e.preventDefault(),e.stopPropagation(),y(t))},onRemoveAttachment:e=>E.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:n,onCancelRemote:r,onSubmit:_,textareaRef:m})}var qb=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-DEfOlZBW.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Jb({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=I(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,L.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,L.jsx)(`span`,{className:I(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,L.jsx)(`span`,{className:`truncate`,children:r})}):(0,L.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,L.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:I(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,L.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,L.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,L.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,L.jsxs)(`div`,{className:I(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function Yb({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:v,nativeManagementLink:y,nativeTerminal:x,nativeLauncherMode:S=!1}){let[C,w]=(0,b.useState)(!1),T=!!x?.Enabled,ee=n?i?(0,L.jsx)(ci,{className:`h-5 w-5`}):(0,L.jsx)(li,{className:`h-5 w-5`}):r?(0,L.jsx)(ci,{className:`h-5 w-5`}):(0,L.jsx)(li,{className:`h-5 w-5`});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`header`,{className:I(`flex flex-shrink-0 items-center justify-between border-b border-slate-200/30 bg-white/95 px-3 py-2 backdrop-blur dark:border-slate-800 dark:bg-slate-900/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-14`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":n?`打开历史记录`:`切换侧边栏`,children:ee}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,L.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,L.jsx)(`button`,{type:`button`,onClick:()=>g(!0),className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":`打开会话操作`,children:(0,L.jsx)(Xr,{className:`h-5 w-5`})}):(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y?(0,L.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Zr,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:y.label})]}):null,_?(0,L.jsxs)(`button`,{type:`button`,onClick:v,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(ti,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:`Workspace`})]}):null,T?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,L.jsx)(bi,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:`TUI`})]}):null,S?null:(0,L.jsx)(Jb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m}),!S&&t?(0,L.jsxs)(`span`,{className:`rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800`,children:[`ID: `,t.slice(0,8)]}):null]})]}),n?(0,L.jsx)(Nl,{open:h,onOpenChange:g,children:(0,L.jsxs)(Ll,{side:`bottom`,className:`rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsxs)(Rl,{className:`text-left`,children:[(0,L.jsx)(Bl,{children:`会话设置`}),(0,L.jsx)(Vl,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,L.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),v()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(ti,{className:`h-4 w-4`}),`工作区文件`]}):null,T?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),w(!0)},className:`inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,L.jsx)(bi,{className:`h-4 w-4`}),`原生 TUI`]}):null,y?(0,L.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Zr,{className:`h-4 w-4`}),y.label]}):null,S?(0,L.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:`当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,L.jsx)(Jb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,L.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:t?(0,L.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&C?(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(qb,{capability:x,open:C,onClose:()=>w(!1)})}):null]})}var Xb=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-DEfOlZBW.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Zb({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,b.useState)(!1);return(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8`,children:[(0,L.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30`,children:[(0,L.jsxs)(`div`,{className:`border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8`,children:[(0,L.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300`,children:[(0,L.jsx)(yi,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,L.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,L.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base`,children:`当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。`})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,L.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950`,children:(0,L.jsx)(ai,{className:`h-5 w-5`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,L.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,title:t.title,className:`mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white`,children:[(0,L.jsx)(Zr,{className:`h-4 w-4`}),`打开`,t.label]}):(0,L.jsx)(`div`,{className:`mt-5 rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,L.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300`,children:(0,L.jsx)(ti,{className:`h-5 w-5`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,L.jsxs)(`button`,{type:`button`,onClick:i,className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700`,children:[(0,L.jsx)(ti,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,L.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。`})]}),(0,L.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:(0,L.jsx)(bi,{className:`h-5 w-5`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,L.jsx)(bi,{className:`h-4 w-4`}),`打开 TUI`]}):(0,L.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前运行时未声明可用的浏览器 TUI 能力。`})]})]})]})}),n&&o?(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(Xb,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var Qb=[],$b=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?$b:Qb).push(n+=e[t])})();function ex(e){if(e<768)return!1;for(let t=0,n=Qb.length;;){let r=t+n>>1;if(e<Qb[r])n=r;else if(e>=$b[r])t=r+1;else return!0;if(t==n)return!1}}function tx(e){return e>=127462&&e<=127487}var nx=8205;function rx(e,t,n=!0,r=!0){return(n?ix:ax)(e,t,r)}function ix(e,t,n){if(t==e.length)return t;t&&sx(e.charCodeAt(t))&&cx(e.charCodeAt(t-1))&&t--;let r=ox(e,t);for(t+=lx(r);t<e.length;){let i=ox(e,t);if(r==nx||i==nx||n&&ex(i))t+=lx(i),r=i;else if(tx(i)){let n=0,r=t-2;for(;r>=0&&tx(ox(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function ax(e,t,n){for(;t>0;){let r=ix(e,t-2,n);if(r<t)return r;t--}return 0}function ox(e,t){let n=e.charCodeAt(t);if(!cx(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return sx(r)?(n-55296<<10)+(r-56320)+65536:n}function sx(e){return e>=56320&&e<57344}function cx(e){return e>=55296&&e<56320}function lx(e){return e<65536?1:2}var ux=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=bx(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),fx.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=bx(this,e,t);let n=[];return this.decompose(e,t,n,0),fx.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new gx(this),i=new gx(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new gx(this,e)}iterRange(e,t=this.length){return new _x(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new vx(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new dx(t):fx.from(dx.split(t,[]))}},dx=class e extends ux{constructor(e,t=px(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new yx(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(hx(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=mx(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=bx(this,t,n);let i=mx(this.text,mx(r.text,hx(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):fx.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
121
|
+
`)||void 0,children:[(0,L.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-white text-emerald-600 ring-1 ring-slate-200 dark:bg-slate-900 dark:text-emerald-300 dark:ring-slate-700`,children:(0,L.jsx)(Ur,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-600 dark:bg-blue-950/40 dark:text-blue-300`,children:o}),i===0?(0,L.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-white px-2 py-0.5 text-[11px] font-medium text-blue-600 ring-1 ring-blue-100 dark:bg-slate-950/40 dark:text-blue-300 dark:ring-blue-900/50`,children:`最新`}):null,l?(0,L.jsx)(`span`,{className:`flex-shrink-0 rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-600 dark:bg-emerald-950/30 dark:text-emerald-300`,children:l}):null,(0,L.jsx)(`span`,{className:`truncate font-medium text-slate-800 dark:text-slate-100`,children:s})]}),r.summary?(0,L.jsx)(`div`,{className:`mt-1 truncate text-[12px] leading-5 text-slate-600 dark:text-slate-300`,children:r.summary}):(0,L.jsx)(`div`,{className:`mt-1 text-[12px] leading-5 text-slate-500 dark:text-slate-400`,children:c}),(0,L.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5 text-[11px] leading-4 text-slate-400`,children:[r.nextAction?(0,L.jsxs)(`span`,{className:`truncate text-blue-600 dark:text-blue-300`,children:[`恢复后阶段:`,r.nextAction]}):(0,L.jsx)(`span`,{className:`truncate`,children:c}),r.timestamp?(0,L.jsx)(`span`,{className:`hidden flex-shrink-0 sm:inline`,children:Ul(r.timestamp)}):null]})]}),(0,L.jsxs)(`button`,{type:`button`,"aria-label":`恢复到${o}`,disabled:a,title:a?`当前会话正在运行,暂不能恢复`:`从该 LangGraph checkpoint 恢复`,onClick:()=>{r.sessionId&&n({sessionId:r.sessionId,runId:r.runId,checkpointId:r.checkpointId})},className:`inline-flex h-8 flex-shrink-0 items-center gap-1 rounded-md border border-slate-200 bg-white px-2.5 text-[11px] font-medium text-slate-600 transition hover:border-blue-300 hover:text-blue-600 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300 dark:hover:border-blue-500 dark:hover:text-blue-300`,children:[(0,L.jsx)(mi,{className:`h-3 w-3`}),`恢复`]})]},r.checkpointId)})})]})}function _b({attachments:e,isMobile:t,onOpenAttachmentPreview:n}){return(0,L.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-3`,children:e.map((e,r)=>e.type.startsWith(`image/`)?e.url?(0,L.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:I(`group relative overflow-hidden rounded-xl border border-slate-200 shadow-sm dark:border-slate-700`,t?`w-full max-w-full`:`max-w-[200px]`),children:(0,L.jsx)(`img`,{src:e.url,alt:e.name,className:I(`object-cover transition group-hover:scale-[1.02]`,t?`max-h-[16rem] w-full max-w-full`:`max-h-[200px] max-w-[200px]`)})},`${e.name}-${r}`):(0,L.jsx)(`div`,{className:I(`flex items-center justify-center rounded-xl border border-dashed border-slate-300 bg-slate-50 px-4 text-sm text-slate-500 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-400`,t?`h-28 w-full`:`h-[120px] w-[200px]`),children:e.name},`${e.name}-${r}`):(0,L.jsxs)(`div`,{className:I(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 shadow-sm dark:border-slate-700 dark:bg-slate-800`,t?`w-full max-w-full`:`w-max max-w-full`),children:[(0,L.jsx)(ui,{className:`h-4 w-4 flex-shrink-0 text-blue-500`}),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`truncate text-sm text-slate-700 hover:underline dark:text-slate-300`,title:e.name,children:e.name}):(0,L.jsx)(`span`,{className:`truncate text-sm text-slate-700 dark:text-slate-300`,title:e.name,children:e.name})]},`${e.name}-${r}`))})}function vb({message:e}){return(0,L.jsx)(`div`,{className:`w-full px-0 py-2 sm:px-4`,children:(0,L.jsxs)(`div`,{className:`mx-auto max-w-3xl rounded-2xl border border-amber-200/80 bg-amber-50/80 px-4 py-3 text-sm text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.status===`running`?(0,L.jsx)(mi,{className:`h-4 w-4 animate-spin text-amber-600 dark:text-amber-300`}):e.status===`failed`?(0,L.jsx)(Gr,{className:`h-4 w-4 text-rose-600 dark:text-rose-400`}):(0,L.jsx)(Ur,{className:`h-4 w-4 text-emerald-600 dark:text-emerald-400`}),(0,L.jsx)(`span`,{children:e.content})]}),e.compactedUntilSeqId?(0,L.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`已折叠到会话事件 #`,e.compactedUntilSeqId]}):null,e.summary?(0,L.jsxs)(`details`,{className:`mt-3 rounded-xl border border-amber-200/80 bg-white/70 px-3 py-2 dark:border-amber-900/60 dark:bg-slate-950/40`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-amber-800 dark:text-amber-200`,children:`查看压缩摘要`}),(0,L.jsx)(`div`,{className:`mt-2 text-[13px] leading-relaxed text-slate-700 dark:text-slate-200`,children:(0,L.jsx)($y,{content:e.summary})})]}):null]})})}function yb({label:e,tone:t,value:n}){let[r,i]=(0,b.useState)(`idle`),a=jn(n);(0,b.useEffect)(()=>{if(r===`idle`)return;let e=window.setTimeout(()=>i(`idle`),1600);return()=>window.clearTimeout(e)},[r]);let o=async()=>{i(await eb(a)?`copied`:`failed`)};return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,L.jsx)(`div`,{className:I(`text-xs font-semibold uppercase`,t===`input`?`text-blue-500`:t===`error`?`text-rose-500`:`text-emerald-500`),children:e}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{o()},className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-[11px] font-medium text-slate-500 transition hover:bg-white hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,children:[r===`copied`?(0,L.jsx)(Ur,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,L.jsx)(Jr,{className:`h-3.5 w-3.5`}),r===`copied`?`已复制`:r===`failed`?`复制失败`:`复制`]})]}),(0,L.jsx)(`div`,{className:`custom-scrollbar max-h-[220px] overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-slate-200/30 bg-white/70 p-3 text-slate-600 shadow-sm dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 sm:max-h-[300px]`,children:a})]})}function bb({isLastMessage:e,isStreaming:t,message:n,onDeleteFeedback:r,onSubmitFeedback:i}){let[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(n.feedback?.comment||``),l=mr(n,t,e),u=!!n.feedback?.pending,d=n.feedback?.rating;return l?(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-slate-500 dark:text-slate-400`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`本次回复有帮助吗?`}),(0,L.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>i({message:n,rating:`up`,comment:``}),className:I(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`up`?`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900/70 dark:bg-emerald-950/30 dark:text-emerald-200`:`border-slate-200 bg-white text-slate-600 hover:border-emerald-200 hover:text-emerald-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-emerald-900/70 dark:hover:text-emerald-200`),children:[(0,L.jsx)(Si,{className:`h-3.5 w-3.5`}),`有帮助`]}),(0,L.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{c(n.feedback?.comment||``),o(e=>!e)},className:I(`inline-flex items-center gap-1 rounded-full border px-2.5 py-1 font-medium transition disabled:cursor-not-allowed disabled:opacity-60`,d===`down`?`border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-900/70 dark:bg-rose-950/30 dark:text-rose-200`:`border-slate-200 bg-white text-slate-600 hover:border-rose-200 hover:text-rose-700 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-300 dark:hover:border-rose-900/70 dark:hover:text-rose-200`),children:[(0,L.jsx)(xi,{className:`h-3.5 w-3.5`}),`需改进`]}),n.feedback?(0,L.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>r(n),className:`inline-flex items-center gap-1 rounded-full border border-transparent px-2 py-1 font-medium text-slate-400 transition hover:border-slate-200 hover:text-slate-700 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:border-slate-800 dark:hover:text-slate-200`,children:[(0,L.jsx)(Ci,{className:`h-3.5 w-3.5`}),`删除反馈`]}):null,u?(0,L.jsx)(`span`,{className:`text-slate-400`,children:`提交中…`}):null]}),a?(0,L.jsxs)(`div`,{className:`max-w-xl rounded-2xl border border-rose-100 bg-rose-50/60 p-3 shadow-sm dark:border-rose-900/60 dark:bg-rose-950/20`,children:[(0,L.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`可以补充哪里不准确、缺失或不符合预期。`,className:`min-h-[84px] w-full resize-y rounded-xl border border-rose-100 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition placeholder:text-slate-400 focus:border-rose-300 focus:ring-2 focus:ring-rose-100 dark:border-rose-900/70 dark:bg-slate-950 dark:text-slate-100 dark:focus:border-rose-700 dark:focus:ring-rose-950`}),(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`rounded-xl px-3 py-1.5 text-xs font-semibold text-slate-500 transition hover:bg-white hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-950 dark:hover:text-slate-100`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{i({message:n,rating:`down`,comment:s}),o(!1)},className:`rounded-xl bg-rose-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-rose-500 disabled:cursor-not-allowed disabled:opacity-60`,children:`提交点踩`})]})]}):d===`down`&&n.feedback?.comment?(0,L.jsxs)(`div`,{className:`max-w-xl rounded-xl border border-rose-100 bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`,children:[`反馈:`,n.feedback.comment]}):null,n.feedback?.error?(0,L.jsx)(`div`,{className:`text-xs text-rose-600 dark:text-rose-300`,children:n.feedback.error}):null]}):null}function xb({agentName:e,isMobile:t,isStreaming:n,isLastMessage:r,message:i,onDeleteFeedback:a,onOpenAttachmentPreview:o,onRespondToApproval:s,onSubmitFeedback:c}){return i.role===`user`?(0,L.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,L.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-sm bg-blue-600 px-3.5 py-2.5 text-[14px] leading-relaxed text-white dark:bg-blue-500`,children:[i.attachments?.length?(0,L.jsx)(_b,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.content]})}):(0,L.jsxs)(`div`,{className:`mb-3 max-w-none`,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-xs text-slate-400`,children:[(0,L.jsx)(Hr,{className:`w-3.5 h-3.5`}),(0,L.jsx)(`span`,{children:e})]}),i.attachments?.length?(0,L.jsx)(_b,{attachments:i.attachments,isMobile:t,onOpenAttachmentPreview:o}):null,i.reasoning?(0,L.jsxs)(`details`,{className:`group/details mb-3 overflow-hidden rounded-lg border border-emerald-200/70 bg-emerald-50/40 text-sm text-slate-600 transition-colors open:bg-white dark:border-emerald-900/50 dark:bg-emerald-950/10 dark:text-slate-300 dark:open:bg-slate-950/30`,children:[(0,L.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 border-l-2 border-emerald-400 px-3 py-2 font-medium outline-none marker:hidden dark:border-emerald-500`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[n&&r&&!i.content?(0,L.jsx)(mi,{className:`h-4 w-4 animate-spin text-emerald-500`}):(0,L.jsx)(Ur,{className:`h-4 w-4 text-emerald-500`}),(0,L.jsx)(`span`,{className:`truncate`,children:`思考过程`}),(0,L.jsx)(`span`,{className:`rounded-full bg-emerald-100 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:n&&r&&!i.content?`生成中`:`已完成`})]}),(0,L.jsx)(Wr,{className:`h-4 w-4 flex-shrink-0 text-slate-400 transition-transform group-open/details:rotate-180`})]}),(0,L.jsx)(`div`,{className:`border-t border-emerald-100/80 bg-white/70 dark:border-emerald-950 dark:bg-slate-950/20`,children:(0,L.jsx)(`div`,{className:`custom-scrollbar max-h-[min(46vh,28rem)] overflow-y-auto px-4 py-3 text-[14px] leading-7 text-slate-600 dark:text-slate-300 [&_p]:my-2 [&_pre]:my-2`,children:(0,L.jsx)($y,{content:i.reasoning})})})]}):null,i.tools?Object.values(i.tools).map((e,t)=>(0,L.jsxs)(`details`,{open:e.status===`paused`?!0:void 0,className:I(`group/details mb-3 rounded-xl border px-3 py-2.5 text-sm transition-all`,e.status===`paused`?`border-amber-200 bg-amber-50/50 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-200`:e.status===`error`?`border-rose-200 bg-rose-50/40 text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-200`:`border-blue-200 bg-blue-50/30 text-blue-600 dark:border-blue-900/50 dark:bg-blue-950/20 dark:text-blue-400`),children:[(0,L.jsx)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 font-medium`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`running`?(0,L.jsx)(mi,{className:`h-4 w-4 animate-spin text-blue-500`}):e.status===`paused`?(0,L.jsx)(yi,{className:`h-4 w-4 text-amber-500`}):e.status===`error`?(0,L.jsx)(Kr,{className:`h-4 w-4 text-rose-500`}):(0,L.jsx)(Ur,{className:`h-4 w-4 text-emerald-500`}),(0,L.jsxs)(`span`,{children:[e.status===`paused`?`等待审批:`:e.status===`error`?`工具调用失败:`:`工具调用:`,e.name]})]})}),(0,L.jsxs)(`div`,{className:I(`mx-1 mt-3 flex flex-col gap-3 border-l-2 py-1 pl-4 font-mono text-[13px] leading-relaxed opacity-90`,e.status===`paused`?`border-amber-200 dark:border-amber-800`:e.status===`error`?`border-rose-200 dark:border-rose-800`:`border-blue-200 dark:border-blue-800`),children:[e.status===`paused`&&e.approvalRequestId?(0,L.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-white/75 p-3 font-sans text-sm text-amber-900 shadow-sm dark:border-amber-900/70 dark:bg-slate-950/40 dark:text-amber-100`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:`该工具调用需要人工确认后继续。`}),e.serverLabel?(0,L.jsxs)(`div`,{className:`mt-1 text-xs text-amber-700/80 dark:text-amber-200/80`,children:[`MCP Server: `,e.serverLabel]}):null,(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,L.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!0,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl bg-emerald-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-55`,children:[(0,L.jsx)(Ur,{className:`h-3.5 w-3.5`}),`批准并继续`]}),(0,L.jsxs)(`button`,{type:`button`,disabled:e.approvalStatus===`approved`||e.approvalStatus===`rejected`,onClick:()=>s({approvalRequestId:e.approvalRequestId||``,approve:!1,previousResponseId:e.previousResponseId}),className:`inline-flex items-center gap-1.5 rounded-xl border border-rose-200 bg-white px-3 py-1.5 text-xs font-semibold text-rose-600 shadow-sm transition hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-55 dark:border-rose-900/70 dark:bg-slate-950 dark:text-rose-300 dark:hover:bg-rose-950/30`,children:[(0,L.jsx)(Kr,{className:`h-3.5 w-3.5`}),`拒绝`]})]})]}):null,e.args?(0,L.jsx)(yb,{label:`入参 (Args)`,tone:`input`,value:e.args}):null,e.output?(0,L.jsx)(yb,{label:`输出 (Output)`,tone:e.status===`error`?`error`:`output`,value:e.output}):null]})]},`${e.name}-${t}`)):null,(0,L.jsx)(`div`,{className:`w-full break-words`,children:i.content?(0,L.jsx)($y,{content:i.content}):n&&r&&!i.reasoning&&!i.tools?(0,L.jsx)(`span`,{className:`ml-1 mt-2 inline-block h-4 w-2 animate-pulse rounded-sm bg-emerald-500 align-middle opacity-80 shadow-sm`}):null}),(0,L.jsx)(bb,{isLastMessage:r,isStreaming:n,message:i,onDeleteFeedback:a,onSubmitFeedback:c})]})}function Sb({agentName:e,isMobile:t,isStreaming:n,activity:r,contextIndicator:i,messages:a,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l,onStopGeneration:u,onCancelRemote:d,checkpoints:f=[],onResumeCheckpoint:p,scrollRef:m}){let[h,g]=(0,b.useState)(0),[_,v]=(0,b.useState)(0),[y,x]=(0,b.useState)(new Map);(0,b.useLayoutEffect)(()=>{let e=m.current;if(!e)return;let t=()=>{g(e.scrollTop),v(e.clientHeight)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t());return n.observe(e),()=>n.disconnect()},[m]);let S=(0,b.useMemo)(()=>nb({items:a,scrollTop:h,viewportHeight:_,overscan:ib,defaultItemHeight:rb,measuredHeights:y,getItemKey:(e,t)=>e?.id||String(t)}),[y,a,h,_]),C=S.visibleItems,w=(e,t)=>{!e||!Number.isFinite(t)||t<=0||x(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})};return(0,L.jsxs)(`div`,{ref:m,onScroll:e=>g(e.currentTarget.scrollTop),className:I(`custom-scrollbar relative min-h-0 flex-1 overflow-y-auto scroll-smooth`,t?`px-3 py-3`:`px-4 py-5`),children:[(0,L.jsxs)(`div`,{className:I(`mx-auto flex w-full max-w-[64rem] flex-col`,r?`pb-10 sm:pb-10`:`pb-6 sm:pb-8`),children:[(0,L.jsx)(gb,{checkpoints:f,isStreaming:n,onResumeCheckpoint:p}),a.length===0?(0,L.jsx)(ub,{agentName:e}):(0,L.jsx)(`div`,{style:{height:S.totalHeight},className:`relative`,children:C.map(r=>(0,L.jsx)(`div`,{ref:e=>{e&&w(r.item.id||String(r.index),e.offsetHeight)},style:{position:`absolute`,top:r.top,left:0,right:0},children:r.item.role===`system`?(0,L.jsx)(vb,{message:r.item}):(0,L.jsx)(xb,{agentName:e,isMobile:t,isStreaming:n,isLastMessage:r.index===a.length-1,message:r.item,onDeleteFeedback:o,onOpenAttachmentPreview:s,onRespondToApproval:c,onSubmitFeedback:l})},r.item.id||r.index))})]}),r?(0,L.jsx)(`div`,{className:`sticky bottom-1 z-20 mx-auto flex w-full max-w-[64rem] justify-end`,children:(0,L.jsx)(lb,{activity:r,contextIndicator:i,onStopGeneration:u,onCancelRemote:d})}):null]})}var Cb=Cl,wb=wl,Tb=b.forwardRef(({className:e,...t},n)=>(0,L.jsx)(Tl,{ref:n,className:I(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Tb.displayName=Tl.displayName;var Eb=b.forwardRef(({className:e,children:t,...n},r)=>(0,L.jsxs)(wb,{children:[(0,L.jsx)(Tb,{}),(0,L.jsxs)(El,{ref:r,className:I(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,L.jsxs)(kl,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,L.jsx)(Ti,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Eb.displayName=El.displayName;var Db=({className:e,...t})=>(0,L.jsx)(`div`,{className:I(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});Db.displayName=`DialogHeader`;var Ob=({className:e,...t})=>(0,L.jsx)(`div`,{className:I(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Ob.displayName=`DialogFooter`;var kb=b.forwardRef(({className:e,...t},n)=>(0,L.jsx)(Dl,{ref:n,className:I(`text-lg font-semibold leading-none tracking-tight`,e),...t}));kb.displayName=Dl.displayName;var Ab=b.forwardRef(({className:e,...t},n)=>(0,L.jsx)(Ol,{ref:n,className:I(`text-sm text-muted-foreground`,e),...t}));Ab.displayName=Ol.displayName;function jb(e,t){if(!(!t||e))return{width:`min(${t.width}px, calc(100vw - 5rem))`,height:`min(${t.height}px, calc(100vh - 9rem))`}}function Mb(e,t){if(!(!t||e))return{width:`min(${t.width+32}px, calc(100vw - 3rem))`}}function Nb({attachment:e,isMobile:t,previewImageSize:n,onClose:r,onImageLoad:i}){return(0,L.jsx)(Cb,{open:!!e?.url,onOpenChange:e=>!e&&r(),children:(0,L.jsxs)(Eb,{className:I(`gap-0 overflow-hidden border-slate-700 bg-slate-950 p-0 text-slate-100 shadow-2xl [&>button]:right-3 [&>button]:top-3 [&>button]:rounded-md [&>button]:border [&>button]:border-slate-700 [&>button]:bg-slate-900/70 [&>button]:p-1.5 [&>button]:text-slate-200 [&>button]:opacity-100`,t?`left-0 top-0 h-[var(--app-height)] max-h-[var(--app-height)] w-screen max-w-none translate-x-0 translate-y-0 rounded-none border-0`:`max-h-[calc(100vh-2rem)] max-w-[calc(100vw-2rem)] rounded-2xl`),style:Mb(t,n),children:[(0,L.jsx)(`div`,{className:`flex items-center gap-3 border-b border-slate-800 px-4 py-3 pr-16`,children:(0,L.jsx)(kb,{className:`truncate text-sm font-medium`,children:e?.name||`附件预览`})}),(0,L.jsx)(`div`,{className:I(`flex items-center justify-center overflow-auto bg-slate-950`,t?`h-full p-4 pb-[calc(var(--safe-area-bottom)+1rem)]`:`max-h-[calc(100vh-7rem)] p-4`),children:e?e.type.startsWith(`image/`)?(0,L.jsx)(`img`,{src:e.url,alt:e.name,className:I(`object-contain`,t?`h-auto max-h-full w-full max-w-full`:`h-auto w-auto max-h-[calc(100vh-9rem)] max-w-[calc(100vw-5rem)]`),style:jb(t,n),onLoad:e=>{let t=e.currentTarget;i({width:t.naturalWidth,height:t.naturalHeight})}}):(0,L.jsx)(`iframe`,{src:e.url,title:e.name,className:`h-full min-h-[24rem] w-full rounded-xl border border-slate-800 bg-white`}):null})]})})}function Pb(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>0)return t}return null}function Fb(e){return/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]/u.test(e)}function Ib(e){let t=String(e||``).trim();if(!t)return 0;let n=0,r=0;for(let e of t){if(Fb(e)){n+=1;continue}r+=1}return Math.max(1,n+Math.ceil(r/4))}function Lb(e){if(!e)return 0;if(e.role===`system`)return e.eventType===`context_checkpoint`?Ib(e.summary||``):0;let t=Ib(e.content||``);return e.tools&&(t+=Object.values(e.tools).reduce((e,t)=>e+Ib(t?.name||``)+Ib(t?.args||``)+Ib(t?.output||``),0)),t}function Rb(e){return e?Pb(e.context_window_tokens)??Pb(e?.limits?.context_window_tokens):null}function zb(e){return e?Pb(e.auto_compact_threshold_percentage)??84:84}function Bb({messages:e,draftInput:t,selectedModel:n}){let r=Rb(n);if(!r)return null;let i=[...e||[]].reverse().find(e=>e?.role===`system`&&e?.eventType===`context_checkpoint`&&e?.status===`running`);if(i){let e=Lb(i);return{label:`正在压缩上下文…`,phase:`compressing`,usedTokens:e,contextWindowTokens:r,percent:Math.min(100,Math.max(0,Math.round(e/r*100)))}}let a=(e||[]).reduce((e,t)=>e+Lb(t),0)+Ib(t||``);if(a<=0)return null;let o=Math.min(100,Math.max(0,Math.round(a/r*100)));return o>=zb(n)?{label:`估算上下文 ${o}% · 即将压缩`,phase:`warning`,percent:o,usedTokens:a,contextWindowTokens:r}:{label:`估算上下文 ${o}%`,phase:`normal`,percent:o,usedTokens:a,contextWindowTokens:r}}function Vb({agentName:e,isMobile:t,onDeleteFeedback:n,onSubmitFeedback:r,onRespondToApproval:i,onStopGeneration:a,onCancelRemote:o,checkpointResumeEnabled:s=!1,onResumeCheckpoint:c,onLoadOlderSessionEvents:l}){let u=Tt(e=>e.messages),d=M(e=>e.currentSessionId),f=j(e=>!!(e.getSessionActivity(d)&&e.isSessionStreaming(d))),p=j(e=>e.getSessionActivity(d)),m=bn(e=>e.getSessionCheckpoints(d)),h=M(e=>d?e.eventCache[d]:null),g=E(e=>e.input),_=le(e=>e.availableModels),v=le(e=>e.selectedModel),y=E(e=>e.previewAttachment),x=E(e=>e.previewImageSize),S=(0,b.useRef)(null),C=(0,b.useRef)(!0),w=(0,b.useRef)(!1),T=(0,b.useRef)(0),ee=(0,b.useRef)(f),D=(0,b.useRef)(!1),O=(0,b.useMemo)(()=>_.find(e=>e.id===v)||null,[_,v]),te=(0,b.useMemo)(()=>Bb({messages:u,draftInput:g,selectedModel:O}),[g,u,O]);return(0,b.useEffect)(()=>{ee.current=f},[f]),(0,b.useEffect)(()=>{let e=S.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight,n=e.scrollTop<T.current-2;if(T.current=e.scrollTop,e.scrollTop<200&&d&&h&&h.offset>0&&!h.isLoadingOlder&&!D.current&&l){let t=e.scrollHeight;D.current=!0,l(d).then(()=>{requestAnimationFrame(()=>{let e=S.current;if(!e)return;let n=e.scrollHeight-t;e.scrollTop+=n,T.current=e.scrollTop})}).finally(()=>{D.current=!1})}if(ee.current&&n){w.current=!0,C.current=!1;return}if(w.current){let e=t<=12;w.current=!e,C.current=e;return}C.current=t<96};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[h,d,l]),(0,b.useEffect)(()=>{let e=S.current;!e||!C.current||(e.scrollTop=e.scrollHeight,T.current=e.scrollTop)},[u,f]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Sb,{agentName:e,isMobile:t,isStreaming:f,activity:p,contextIndicator:te,messages:u,onDeleteFeedback:n,onOpenAttachmentPreview:e=>{E.getState().setPreviewAttachment(e),E.getState().setPreviewImageSize(null)},onRespondToApproval:i,onSubmitFeedback:r,onStopGeneration:a,onCancelRemote:o,checkpoints:s?m:[],onResumeCheckpoint:c,scrollRef:S}),(0,L.jsx)(Nb,{attachment:y,isMobile:t,previewImageSize:x,onClose:()=>{E.getState().setPreviewAttachment(null),E.getState().setPreviewImageSize(null)},onImageLoad:e=>E.getState().setPreviewImageSize(e)})]})}function Hb({attachments:e,composerContextIndicator:t,composerMaxHeight:n,fileInputRef:r,input:i,isMobile:a,isStreaming:o,queuedDrafts:s,onAppendAttachments:c,onInputChange:l,onPaste:u,onRemoveAttachment:d,onStopGeneration:f,onCancelRemote:p,onSubmit:m,textareaRef:h}){let g=a?`发送消息...`:`发送消息... (Shift + Enter 换行)`,_=p?`保留恢复点并结束本次执行`:`停止生成`;return(0,L.jsx)(`div`,{className:`relative z-10 flex-shrink-0 bg-white/95 px-3 py-3 backdrop-blur dark:bg-slate-900/95 sm:px-4 sm:py-3`,children:(0,L.jsxs)(`div`,{className:`mx-auto w-full max-w-[64rem]`,children:[s.length>0?(0,L.jsxs)(`div`,{className:`mb-2 rounded-2xl border border-amber-200/80 bg-amber-50/80 px-3 py-2 text-xs text-amber-900 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-100`,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`span`,{className:`font-semibold`,children:[`发送队列 · `,s.length]}),(0,L.jsx)(`span`,{className:`text-amber-700/75 dark:text-amber-200/75`,children:`当前回复完成后依次发送`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[s.slice(0,3).map((e,t)=>{let n=e.text.trim()||(e.attachments.length>0?`仅附件消息`:`空消息`);return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-white/70 px-2 py-1.5 dark:bg-slate-950/35`,children:[(0,L.jsx)(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-full bg-amber-100 font-mono text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:t+1}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200`,children:n}),e.attachments.length>0?(0,L.jsxs)(`span`,{className:`flex-shrink-0 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] text-amber-700 dark:bg-amber-900/50 dark:text-amber-100`,children:[e.attachments.length,` 附件`]}):null]},`${t}-${n}-${e.attachments.length}`)}),s.length>3?(0,L.jsxs)(`div`,{className:`px-2 pt-0.5 text-[11px] text-amber-700/80 dark:text-amber-200/80`,children:[`还有 `,s.length-3,` 条等待发送`]}):null]})]}):null,(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),o){p?p():f();return}let n=i.trim();!n&&e.length===0||m(n,e)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer.files&&e.dataTransfer.files.length>0&&c(Array.from(e.dataTransfer.files))},className:`relative flex min-w-0 flex-1 flex-col rounded-[1.25rem] border border-slate-200 bg-white p-1.5 shadow-[0_8px_22px_rgba(15,23,42,0.07)] transition-all focus-within:border-slate-300 focus-within:ring-1 focus-within:ring-slate-300 dark:border-slate-700 dark:bg-slate-900 dark:focus-within:border-slate-600 dark:focus-within:ring-slate-600`,children:[e.length>0?(0,L.jsx)(`div`,{className:`mb-1.5 flex flex-wrap gap-2 px-1.5 pt-1.5`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:I(`flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-100 px-3 py-1.5 text-xs text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,a?`max-w-full`:``),children:[(0,L.jsx)(`span`,{className:`max-w-[10rem] truncate font-medium sm:max-w-[12rem]`,children:e.name}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>d(t),className:`text-slate-400 transition hover:text-red-500`,"aria-label":`移除附件 ${e.name}`,children:`×`})]},`${e.name}-${e.size}-${t}`))}):null,(0,L.jsxs)(`div`,{className:`flex w-full items-end gap-2`,children:[(0,L.jsxs)(`label`,{className:`relative flex h-9 w-9 flex-shrink-0 items-center justify-center overflow-hidden rounded-xl text-slate-400 transition hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-slate-800 dark:hover:text-slate-200`,title:`上传附件`,children:[(0,L.jsx)(`input`,{ref:r,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&e.target.files.length>0&&(c(Array.from(e.target.files)),e.target.value=``)}}),(0,L.jsx)(ui,{className:`h-5 w-5`})]}),(0,L.jsx)(`textarea`,{ref:h,rows:1,value:i,onChange:l,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},onPaste:u,placeholder:g,className:I(`custom-scrollbar min-h-[38px] w-full resize-none border-0 bg-transparent px-2 py-1.5 text-[15px] leading-6 outline-none placeholder:text-slate-400 dark:text-slate-100 dark:placeholder:text-slate-500`,a?`text-[16px]`:`text-[15px]`),style:{maxHeight:`${n}px`,overflowY:`auto`}}),(0,L.jsx)(`button`,{type:`submit`,disabled:!o&&!i.trim()&&e.length===0,className:I(`flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-xl transition-all`,o||i.trim()||e.length>0?`bg-slate-900 text-white hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white`:`bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-600`),title:o?_:`发送消息`,children:o?(0,L.jsx)(Gr,{className:`h-4 w-4`}):(0,L.jsx)(vi,{className:`ml-0.5 h-4 w-4`})})]})]}),t?(0,L.jsxs)(`div`,{className:I(`hidden flex-shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1 text-right text-[11px] leading-5 transition-colors sm:inline-flex`,t.phase===`compressing`?`bg-amber-50 text-amber-600 dark:bg-amber-950/30 dark:text-amber-300`:t.phase===`warning`?`bg-rose-50 text-rose-600 dark:bg-rose-950/30 dark:text-rose-300`:`bg-slate-50 text-slate-400 dark:bg-slate-800/50 dark:text-slate-500`),children:[(0,L.jsx)(yi,{className:`h-3 w-3`}),t.label]}):null]})]})})}function Ub(e){return[e.name,e.size,e.lastModified,e.type].join(`:`)}function Wb(e,t){let n=new Map;for(let t of e)n.set(Ub(t),t);for(let e of t)n.set(Ub(e),e);return Array.from(n.values())}function Gb(e){return Array.from(e.clipboardData.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)}function Kb({composerMaxHeight:e,submitDraft:t,stopGeneration:n,cancelRemote:r,isMobile:i}){let a=E(e=>e.input),o=E(e=>e.attachments),s=M(e=>e.currentSessionId),c=j(e=>!!(e.getSessionActivity(s)&&e.isSessionStreaming(s))),l=E(e=>e.queuedDrafts),u=Tt(e=>e.messages),d=le(e=>e.availableModels),f=le(e=>e.selectedModel),p=(0,b.useRef)(null),m=(0,b.useRef)(null),h=(0,b.useMemo)(()=>d.find(e=>e.id===f)||null,[d,f]),g=(0,b.useMemo)(()=>Bb({messages:u,draftInput:a,selectedModel:h}),[a,u,h]),_=(0,b.useCallback)((e,n)=>{!e&&n.length===0||(E.getState().setInput(``),E.getState().setAttachments([]),t(e,n))},[t]);(0,b.useEffect)(()=>{m.current&&(m.current.style.height=`auto`,m.current.style.height=`${Math.min(m.current.scrollHeight,e)}px`)},[a,e]);let v=t=>{E.getState().setInput(t.target.value),t.target.style.height=`auto`,t.target.style.height=`${Math.min(t.target.scrollHeight,e)}px`},y=e=>{e.length&&E.getState().setAttachments(t=>Wb(t,e))};return(0,L.jsx)(Hb,{attachments:o,composerContextIndicator:g,composerMaxHeight:e,fileInputRef:p,input:a,isMobile:i,isStreaming:c,queuedDrafts:l,onAppendAttachments:y,onInputChange:v,onPaste:e=>{let t=Gb(e);t.length&&(e.preventDefault(),e.stopPropagation(),y(t))},onRemoveAttachment:e=>E.getState().setAttachments(t=>t.filter((t,n)=>n!==e)),onStopGeneration:n,onCancelRemote:r,onSubmit:_,textareaRef:m})}var qb=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-DKuFni1-.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Jb({availableModels:e,selectedModel:t,onSelectModel:n,selectedModelLabel:r,modelCatalogLoaded:i,modelSource:a,thinkingEnabled:o,thinkingMode:s,onSelectThinkingMode:c,compact:l=!1}){let u=I(`rounded-full border border-slate-200 bg-white px-3 py-2 text-sm text-slate-700 outline-none transition-colors focus:ring-1 focus:ring-blue-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-300`,l?`w-full`:`max-w-[13rem]`),d=e.length>1?(0,L.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:u,children:e.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.display_name||e.id},e.id))}):r?(0,L.jsx)(`span`,{className:I(u,`inline-flex max-w-full items-center`,l?`justify-start`:``),title:a||r,children:(0,L.jsx)(`span`,{className:`truncate`,children:r})}):(0,L.jsx)(`span`,{className:`text-sm text-slate-400`,children:i?`未配置模型`:`Loading models...`}),f=o?(0,L.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:I(u,l?``:`max-w-[9rem]`),title:`控制模型 thinking/reasoning 参数`,children:[(0,L.jsx)(`option`,{value:`auto`,children:`思考自动`}),(0,L.jsx)(`option`,{value:`enabled`,children:`开启思考`}),(0,L.jsx)(`option`,{value:`disabled`,children:`关闭思考`})]}):null;return(0,L.jsxs)(`div`,{className:I(`flex min-w-0 gap-2`,l?`w-full flex-col`:`items-center`),children:[d,f]})}function Yb({agentName:e,currentSessionId:t,isMobile:n,sidebarOpen:r,mobileSidebarOpen:i,onToggleSidebar:a,availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,mobileActionsOpen:h,onMobileActionsOpenChange:g,workspaceEnabled:_,onOpenWorkspace:v,nativeManagementLink:y,nativeTerminal:x,nativeLauncherMode:S=!1}){let[C,w]=(0,b.useState)(!1),T=!!x?.Enabled,ee=n?i?(0,L.jsx)(ci,{className:`h-5 w-5`}):(0,L.jsx)(li,{className:`h-5 w-5`}):r?(0,L.jsx)(ci,{className:`h-5 w-5`}):(0,L.jsx)(li,{className:`h-5 w-5`});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`header`,{className:I(`flex flex-shrink-0 items-center justify-between border-b border-slate-200/30 bg-white/95 px-3 py-2 backdrop-blur dark:border-slate-800 dark:bg-slate-900/95 sm:px-4`,n?`pt-[calc(var(--safe-area-top)+0.5rem)]`:`h-14`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[S?null:(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":n?`打开历史记录`:`切换侧边栏`,children:ee}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100 sm:text-base`,children:e}),(0,L.jsx)(`div`,{className:`text-[11px] text-slate-400 dark:text-slate-500`,children:S?`原生运行时入口`:`智能体`})]})]}),n?(0,L.jsx)(`button`,{type:`button`,onClick:()=>g(!0),className:`rounded-lg p-2 text-slate-500 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800`,"aria-label":`打开会话操作`,children:(0,L.jsx)(Xr,{className:`h-5 w-5`})}):(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[y?(0,L.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Zr,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:y.label})]}):null,_?(0,L.jsxs)(`button`,{type:`button`,onClick:v,className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm font-medium leading-none text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(ti,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:`Workspace`})]}):null,T?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`inline-flex flex-shrink-0 items-center gap-1.5 whitespace-nowrap rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm font-medium leading-none text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,L.jsx)(bi,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:`TUI`})]}):null,S?null:(0,L.jsx)(Jb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m}),!S&&t?(0,L.jsxs)(`span`,{className:`rounded bg-slate-50 px-2 py-1 text-xs font-mono text-slate-400 dark:bg-slate-800`,children:[`ID: `,t.slice(0,8)]}):null]})]}),n?(0,L.jsx)(Nl,{open:h,onOpenChange:g,children:(0,L.jsxs)(Ll,{side:`bottom`,className:`rounded-t-[1.75rem] border-slate-200 bg-white px-4 pb-[calc(var(--safe-area-bottom)+1rem)] pt-6 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsxs)(Rl,{className:`text-left`,children:[(0,L.jsx)(Bl,{children:`会话设置`}),(0,L.jsx)(Vl,{className:`sr-only`,children:`调整当前会话的模型和 Workspace 操作。`})]}),(0,L.jsxs)(`div`,{className:`mt-6 flex flex-col gap-4`,children:[_?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),v()},className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(ti,{className:`h-4 w-4`}),`工作区文件`]}):null,T?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),w(!0)},className:`inline-flex items-center gap-2 rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,L.jsx)(bi,{className:`h-4 w-4`}),`原生 TUI`]}):null,y?(0,L.jsxs)(`a`,{href:y.href,target:`_blank`,rel:`noreferrer`,title:y.title,onClick:()=>g(!1),className:`inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm font-medium text-slate-700 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Zr,{className:`h-4 w-4`}),y.label]}):null,S?(0,L.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm leading-6 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:`当前运行时对话在原生管理台中进行;这里保留管理入口和 Workspace 文件操作。`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`模型`}),(0,L.jsx)(Jb,{availableModels:o,selectedModel:s,onSelectModel:c,selectedModelLabel:l,modelCatalogLoaded:u,modelSource:d,thinkingEnabled:f,thinkingMode:p,onSelectThinkingMode:m,compact:!0})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-slate-400 dark:text-slate-500`,children:`当前会话`}),(0,L.jsx)(`div`,{className:`rounded-2xl border border-slate-200 bg-slate-50 px-3 py-3 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300`,children:t?(0,L.jsx)(`span`,{className:`break-all font-mono`,children:t}):`新对话尚未创建会话 ID`})]})]})]})]})}):null,x&&C?(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(qb,{capability:x,open:C,sessionId:t,onClose:()=>w(!1)})}):null]})}var Xb=(0,b.lazy)(()=>W(()=>import(`./NativeTerminalPanel-DKuFni1-.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Zb({productLabel:e=`原生运行时`,nativeManagementLink:t,nativeTerminal:n,workspaceEnabled:r,onOpenWorkspace:i}){let a=!!n?.Enabled,[o,s]=(0,b.useState)(!1);return(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.12),transparent_34%),linear-gradient(135deg,#f8fafc_0%,#ffffff_48%,#f1f5f9_100%)] px-4 py-8 dark:bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_34%),linear-gradient(135deg,#020617_0%,#0f172a_52%,#111827_100%)] sm:px-8`,children:[(0,L.jsx)(`div`,{className:`mx-auto flex w-full max-w-5xl flex-col justify-center`,children:(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-[2rem] border border-slate-200/80 bg-white/90 shadow-xl shadow-slate-200/60 backdrop-blur dark:border-slate-800 dark:bg-slate-900/85 dark:shadow-black/30`,children:[(0,L.jsxs)(`div`,{className:`border-b border-slate-200/80 bg-slate-50/80 px-6 py-5 dark:border-slate-800 dark:bg-slate-950/40 sm:px-8`,children:[(0,L.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-medium text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/50 dark:text-sky-300`,children:[(0,L.jsx)(yi,{className:`h-3.5 w-3.5`}),e,` native runtime`]}),(0,L.jsx)(`h1`,{className:`mt-5 text-2xl font-semibold tracking-tight text-slate-950 dark:text-slate-50 sm:text-3xl`,children:`对话请使用原生管理台`}),(0,L.jsx)(`p`,{className:`mt-3 max-w-2xl text-sm leading-6 text-slate-600 dark:text-slate-300 sm:text-base`,children:`当前运行时的对话状态由原生管理台承载。AgentEngine Hosted UI 在这里保留统一入口和 Workspace 文件管理,不重复实现运行时内部已有的复杂对话状态机。`})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 p-6 md:grid-cols-3 sm:p-8`,children:[(0,L.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-slate-950 text-white dark:bg-slate-100 dark:text-slate-950`,children:(0,L.jsx)(ai,{className:`h-5 w-5`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生管理台`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`使用原生管理台处理对话、工具卡片、思考流、审批、中断和运行时历史,避免跨状态机不一致。`}),t?(0,L.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,title:t.title,className:`mt-5 inline-flex items-center gap-2 rounded-2xl bg-slate-950 px-4 py-2.5 text-sm font-medium text-white transition hover:bg-slate-800 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white`,children:[(0,L.jsx)(Zr,{className:`h-4 w-4`}),`打开`,t.label]}):(0,L.jsx)(`div`,{className:`mt-5 rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm leading-6 text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-200`,children:`当前访问模式不开放原生管理入口。需要完整对话体验时,请使用 owner/private 链接或 CLI。`})]}),(0,L.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-300`,children:(0,L.jsx)(ti,{className:`h-5 w-5`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`Workspace 文件管理`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`文件浏览、上传、预览仍由 Hosted UI 提供,和原生管理台组合使用覆盖对话与工作区。`}),r?(0,L.jsxs)(`button`,{type:`button`,onClick:i,className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-2.5 text-sm font-medium text-slate-800 transition hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700`,children:[(0,L.jsx)(ti,{className:`h-4 w-4`}),`打开 Workspace`]}):(0,L.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前链接未开放 Workspace 文件管理。Owner 或 private 链接可使用该能力。`})]}),(0,L.jsxs)(`div`,{className:`rounded-3xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900`,children:[(0,L.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-2xl bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300`,children:(0,L.jsx)(bi,{className:`h-5 w-5`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-slate-950 dark:text-slate-50`,children:`原生 TUI`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-600 dark:text-slate-300`,children:`如果运行时暴露安全的 ks-terminal.v1 通道,可以在这里进入原生终端 UI;share 链接不会开放该入口。`}),a?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`mt-5 inline-flex items-center gap-2 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-2.5 text-sm font-medium text-emerald-800 transition hover:bg-emerald-100 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-200`,children:[(0,L.jsx)(bi,{className:`h-4 w-4`}),`打开 TUI`]}):(0,L.jsx)(`div`,{className:`mt-5 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm leading-6 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400`,children:`当前运行时未声明可用的浏览器 TUI 能力。`})]})]})]})}),n&&o?(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(Xb,{capability:n,open:o,onClose:()=>s(!1)})}):null]})}var Qb=[],$b=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?$b:Qb).push(n+=e[t])})();function ex(e){if(e<768)return!1;for(let t=0,n=Qb.length;;){let r=t+n>>1;if(e<Qb[r])n=r;else if(e>=$b[r])t=r+1;else return!0;if(t==n)return!1}}function tx(e){return e>=127462&&e<=127487}var nx=8205;function rx(e,t,n=!0,r=!0){return(n?ix:ax)(e,t,r)}function ix(e,t,n){if(t==e.length)return t;t&&sx(e.charCodeAt(t))&&cx(e.charCodeAt(t-1))&&t--;let r=ox(e,t);for(t+=lx(r);t<e.length;){let i=ox(e,t);if(r==nx||i==nx||n&&ex(i))t+=lx(i),r=i;else if(tx(i)){let n=0,r=t-2;for(;r>=0&&tx(ox(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function ax(e,t,n){for(;t>0;){let r=ix(e,t-2,n);if(r<t)return r;t--}return 0}function ox(e,t){let n=e.charCodeAt(t);if(!cx(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return sx(r)?(n-55296<<10)+(r-56320)+65536:n}function sx(e){return e>=56320&&e<57344}function cx(e){return e>=55296&&e<56320}function lx(e){return e<65536?1:2}var ux=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=bx(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),fx.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=bx(this,e,t);let n=[];return this.decompose(e,t,n,0),fx.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new gx(this),i=new gx(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new gx(this,e)}iterRange(e,t=this.length){return new _x(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new vx(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new dx(t):fx.from(dx.split(t,[]))}},dx=class e extends ux{constructor(e,t=px(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new yx(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(hx(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=mx(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=bx(this,t,n);let i=mx(this.text,mx(r.text,hx(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):fx.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
122
122
|
`){[e,t]=bx(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},fx=class e extends ux{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=bx(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
123
123
|
`){[e,t]=bx(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new dx(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof dx&&c&&(n=u[u.length-1])instanceof dx&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new dx(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};ux.empty=new dx([``],0);function px(e){let t=-1;for(let n of e)t+=n.length+1;return t}function mx(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function hx(e,t,n){return mx(e,[``],t,n)}var gx=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof dx?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof dx?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
124
124
|
`,this;e--}else if(r instanceof dx){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof dx?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},_x=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new gx(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},vx=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(ux.prototype[Symbol.iterator]=function(){return this.iter()},gx.prototype[Symbol.iterator]=_x.prototype[Symbol.iterator]=vx.prototype[Symbol.iterator]=function(){return this});var yx=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function bx(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function xx(e,t,n=!0,r=!0){return rx(e,t,n,r)}function Sx(e){return e>=56320&&e<57344}function Cx(e){return e>=55296&&e<56320}function wx(e,t){let n=e.charCodeAt(t);if(!Cx(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Sx(r)?(n-55296<<10)+(r-56320)+65536:n}function Tx(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Ex(e){return e<65536?1:2}var Dx=/\r\n?|\n/,Ox=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(Ox||={}),kx=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){Nx(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:Fx(this,e)}mapDesc(e,t=!1){return e.empty?this:Px(this,e,t)}mapPos(e,t=-1,n=Ox.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=Ox.Simple&&c>=e&&(n==Ox.TrackDel&&r<e&&c>e||n==Ox.TrackBefore&&r<e||n==Ox.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},Ax=class e extends kx{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return Nx(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return Px(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(ux.empty);r.push(a?t.slice(i,i+a):ux.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Fx(this,e,!0)}map(e,t=!1){return e.empty?this:Px(this,e,t,!0)}iterChanges(e,t=!1){Nx(this,e,t)}get desc(){return kx.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new Ix(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);jx(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;jx(n,e,t),t>0&&Mx(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);jx(n,e,-1),jx(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:kx.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&jx(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?ux.of(l.split(r||Dx)):l:ux.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&jx(i,e-o,-1),jx(i,s-e,d),Mx(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(ux.empty);r[e]=ux.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function jx(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function Mx(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(ux.empty);e.push(n)}}function Nx(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=ux.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function Px(e,t,n,r=!1){let i=[],a=r?[]:null,o=new Ix(e),s=new Ix(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);jx(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(jx(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(jx(i,0,o.ins),a&&Mx(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;jx(i,t,e<o.i?o.ins:0),a&&e<o.i&&Mx(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?Ax.createSet(i,a):kx.create(i);else throw Error(`Mismatched change set lengths`)}function Fx(e,t,n=!1){let r=[],i=n?[]:null,a=new Ix(e),o=new Ix(t);for(let e=!1;;)if(a.done&&o.done)return i?Ax.createSet(r,i):kx.create(r);else if(a.ins==0)jx(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)jx(r,0,o.ins,e),i&&Mx(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;jx(r,t,n,e),i&&n&&Mx(i,r,o.text)}else o.ins==-1?(jx(r,a.off?0:a.len,t,e),i&&Mx(i,r,a.textBit(t))):(jx(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&Mx(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var Ix=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?ux.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ux.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Lx=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return G.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return G.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return G.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},G=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Lx.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Lx.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?Lx.create(t,e,48|a):Lx.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Rx(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var zx=0,K=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=zx++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Bx),!!t.static,t.enables)}of(e){return new Vx([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Vx(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Vx(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Bx(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Vx=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=zx++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Ux(e,c)){let r=t(e);if(a?!Hx(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=nS(o,c);if(this.dependencies.every(t=>t instanceof K?o.facet(t)===e.facet(t):t instanceof Kx?o.field(t,!1)==e.field(t,!1):!0)||(a?Hx(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Hx(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Ux(e,t){let n=!1;for(let r of t)tS(e,r)&1&&(n=!0);return n}function Wx(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=nS(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)tS(e,t);return e.values[o]=s(e),1},update(e,n){if(!Ux(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=Ux(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Bx(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var Gx=K.define({static:!0}),Kx=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(zx++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Gx).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Gx),i=n.facet(Gx),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Gx.of({field:this,create:e})]}get extension(){return this}},qx={lowest:4,low:3,default:2,high:1,highest:0};function Jx(e){return t=>new Xx(t,e)}var Yx={highest:Jx(qx.highest),high:Jx(qx.high),default:Jx(qx.default),low:Jx(qx.low),lowest:Jx(qx.lowest)},Xx=class{constructor(e,t){this.inner=e,this.prec=t}},Zx=class e{of(e){return new Qx(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Qx=class{constructor(e,t){this.compartment=e,this.inner=t}},$x=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of eS(t,n,o))e instanceof Kx?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,Bx(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Wx(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function eS(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Qx&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Qx){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Xx)a(e.inner,e.prec);else if(e instanceof Kx)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Vx)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,qx.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,qx.default),r.reduce((e,t)=>e.concat(t))}function tS(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function nS(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var rS=K.define(),iS=K.define({combine:e=>e.some(e=>e),static:!0}),aS=K.define({combine:e=>e.length?e[0]:void 0,static:!0}),oS=K.define(),sS=K.define(),cS=K.define(),lS=K.define({combine:e=>e.length?e[0]:!1}),uS=class{constructor(e,t){this.type=e,this.value=t}static define(){return new dS}},dS=class{of(e){return new uS(this,e)}},fS=class{constructor(e){this.map=e}of(e){return new pS(this,e)}},pS=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new fS(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};pS.reconfigure=pS.define(),pS.appendConfig=pS.define();var mS=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Rx(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};mS.time=uS.define(),mS.userEvent=uS.define(),mS.addToHistory=uS.define(),mS.remote=uS.define();function hS(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function gS(e,t,n){let r,i,a;return n?(r=t.changes,i=Ax.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:pS.mapEffects(e.effects,r).concat(pS.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function _S(e,t,n){let r=t.selection,i=SS(t.annotations);return t.userEvent&&(i=i.concat(mS.userEvent.of(t.userEvent))),{changes:t.changes instanceof Ax?t.changes:Ax.of(t.changes||[],n,e.facet(aS)),selection:r&&(r instanceof G?r:G.single(r.anchor,r.head)),effects:SS(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function vS(e,t,n){let r=_S(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=gS(r,_S(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=mS.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return bS(n?yS(i):i)}function yS(e){let t=e.startState,n=!0;for(let r of t.facet(oS)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:hS(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=Ax.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=mS.create(t,r,e.selection&&e.selection.map(i),pS.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(sS);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof mS?i:Array.isArray(i)&&i.length==1&&i[0]instanceof mS?i[0]:vS(t,SS(i),!1)}return e}function bS(e){let t=e.startState,n=t.facet(cS),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=gS(r,_S(t,a,e.changes.newLength),!0))}return r==e?e:mS.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var xS=[];function SS(e){return e==null?xS:Array.isArray(e)?e:[e]}var CS=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(CS||={}),wS=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,TS;try{TS=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function ES(e){if(TS)return TS.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||wS.test(n)))return!0}return!1}function DS(e){return t=>{if(!/\S/.test(t))return CS.Space;if(ES(t))return CS.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return CS.Word;return CS.Other}}var OS=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)tS(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return tS(this,n),nS(this,n)}update(...e){return vS(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Zx.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(pS.reconfigure)?(n=null,r=e.value):e.is(pS.appendConfig)&&(n=null,r=SS(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=$x.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(iS)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:G.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=SS(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=pS.mapEffects(a,c).concat(pS.mapEffects(SS(o.effects),l))}return{changes:r,selection:G.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof Ax?t:Ax.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return ux.of(t.split(this.facet(e.lineSeparator)||Dx))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(tS(this,t),nS(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Kx&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:G.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=$x.resolve(t.extensions||[],new Map),r=t.doc instanceof ux?t.doc:ux.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||Dx)),i=t.selection?t.selection instanceof G?t.selection:G.single(t.selection.anchor,t.selection.head):G.single(0);return Rx(i,r.length),n.staticFacet(iS)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
@@ -130,7 +130,7 @@ $2`),t=t.replace(/([。;;::\.])\s*-(?!-)\s*/g,`$1
|
|
|
130
130
|
`))};if((q.mac||q.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:ux.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);xE(e,u,G.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(J.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:qw.of(J.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=RC(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},Y=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||iw(e.parent)||document,this.viewState=new FD(this,e.state||OS.create(e)),e.scrollTo&&e.scrollTo.is(Kw)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Zw).map(e=>new $w(e));for(let e of this.plugins)e.update(this);this.observer=new tO(this),this.inputState=new DE(this),this.inputState.ensureHandlers(this.plugins),this.docView=new VT(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof mS?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(aD))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=oD(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(OS.phrases)!=this.state.facet(OS.phrases))return this.setState(a);i=fT.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new Gw(t.empty?t:G.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Kw)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=cO.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(uT)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(GD)!=i.state.facet(GD)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(Lw))try{e(i)}catch(e){Jw(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!bE(this,u)&&l.force&&rw(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new FD(this,e),this.plugins=e.facet(Zw).map(e=>new $w(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new VT(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Zw),n=e.state.facet(Zw);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new $w(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){Jw(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(ow(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return Jw(this.state,e),sO}}),l=fT.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=sO)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){Jw(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(Lw))e(t)}get themeClasses(){return qD+` `+(this.state.facet(KD)?YD:JD)+` `+this.state.facet(GD)}updateAttrs(){let e=lO(this,eT,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Yw)?`true`:`false`,class:`cm-content`,style:`${q.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),lO(this,tT,t);let n=this.observer.ignore(()=>{let n=DC(this.contentDOM,this.contentAttrs,t),r=DC(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(uT);let t=this.state.facet(e.cspNonce);eC.mount(this.root,this.styleModules.concat(QD).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return lE(this,e,iE(this,e,t,n))}moveByGroup(e,t){return lE(this,e,iE(this,e,t,t=>aE(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return G.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return rE(this,e,t,n)}moveVertically(e,t,n){return lE(this,e,oE(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=dE(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),dE(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[bw.find(i,e-r.from,-1,t)];return qC(n,a.dir==uw.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Hw)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>oO)return kw(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||xw(r.isolates,n=sT(this,e))))return r.order;n||=sT(this,e);let r=Ow(e.text,t,n);return this.bidiCache.push(new cO(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||q.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ew(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Kw.of(new Gw(typeof e==`number`?G.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Kw.of(new Gw(G.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Qw.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Qw.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=eC.newName(),r=[GD.of(n),uT.of(ZD(`.${n}`,e))];return t&&t.dark&&r.push(KD.of(!0)),r}static baseTheme(e){return Yx.lowest(uT.of(ZD(`.`+qD,e,XD)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&mT.get(t)||mT.get(e))?.root?.view||null}};Y.styleModule=uT,Y.inputHandler=Rw,Y.clipboardInputFilter=Bw,Y.clipboardOutputFilter=Vw,Y.scrollHandler=Ww,Y.focusChangeEffect=zw,Y.perLineTextDirection=Hw,Y.exceptionSink=Iw,Y.updateListener=Lw,Y.editable=Yw,Y.mouseSelectionStyle=Fw,Y.dragMovesSelection=Pw,Y.clickAddsSelectionRange=Nw,Y.decorations=nT,Y.blockWrappers=rT,Y.outerDecorations=iT,Y.atomicRanges=aT,Y.bidiIsolatedRanges=oT,Y.cursorScrollMargin=K.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),Y.scrollMargins=cT,Y.darkTheme=KD,Y.cspNonce=K.define({combine:e=>e.length?e[0]:``}),Y.contentAttributes=tT,Y.editorAttributes=eT,Y.lineWrapping=Y.contentAttributes.of({class:`cm-lineWrapping`}),Y.announce=pS.define();var oO=4096,sO={},cO=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:uw.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function lO(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&CC(a,n)}return n}var uO=q.mac?`mac`:q.windows?`win`:q.linux?`linux`:`key`;function dO(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function fO(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var pO=Yx.default(Y.domEventHandlers({keydown(e,t){return SO(gO(t.state),e,t,`editor`)}})),mO=K.define({enables:pO}),hO=new WeakMap;function gO(e){let t=e.facet(mO),n=hO.get(t);return n||hO.set(t,n=bO(t.reduce((e,t)=>e.concat(t),[]))),n}function _O(e,t,n){return SO(gO(e.state),t,e,n)}var vO=null,yO=4e3;function bO(e,t=uO){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>dO(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=vO={view:t,prefix:n,scope:e};return setTimeout(()=>{vO==r&&(vO=null)},yO),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,xO))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var xO=null;function SO(e,t,n,r){xO=t;let i=lC(t),a=Ex(wx(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;vO&&vO.view==n&&vO.scope==r&&(o=vO.prefix+` `,ME.indexOf(t.keyCode)<0&&(c=!0,vO=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+fO(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(q.windows&&t.ctrlKey&&t.altKey)&&!(q.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=rC[t.keyCode])&&p!=i?(d(f[o+fO(p,t,!0)])||t.shiftKey&&(m=iC[t.keyCode])!=i&&m!=p&&d(f[o+fO(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+fO(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),xO=null,s}var CO=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className?(this.adjust(e),!0):!1}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=wO(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return EO(t,n,r)}};function wO(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==uw.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function TO(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function EO(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==uw.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=wO(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=nE(e,r,1),m=nE(e,i,-1),h=p.type==AC.Text?p:null,g=m.type==AC.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=TO(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=TO(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):b(p,!1),r=g?y(null,n.to,g):b(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==AC.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new CO(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==uw.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function b(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function DO(e,t){return e.constructor==t.constructor&&e.eq(t)}var OO=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(kO)!=e.state.facet(kO)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(kO);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!DO(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,q.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},kO=K.define();function AO(e){return[Qw.define(t=>new OO(t,e)),kO.of(e)]}var jO=K.define({combine(e){return kS(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function MO(e={}){return[jO.of(e),PO,IO,LO,Uw.of(!0)]}function NO(e){return e.startState.facet(jO)!=e.state.facet(jO)}var PO=AO({above:!0,markers(e){let{state:t}=e,n=t.facet(jO),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&q.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:G.cursor(i.head,i.assoc);for(let i of CO.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=NO(e);return n&&FO(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){FO(t.state,e)},class:`cm-cursorLayer`});function FO(e,t){t.style.animationDuration=e.facet(jO).cursorBlinkRate+`ms`}var IO=AO({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of CO.forRange(e,`cm-selectionBackground`,n))t.push(r);if(q.ios&&!n.empty&&e.state.facet(jO).iosSelectionHandles){for(let r of CO.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,G.cursor(n.from,1)))t.push(r);for(let r of CO.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,G.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||NO(e)},class:`cm-selectionLayer`}),LO=Yx.highest(Y.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}})),RO=pS.define({map(e,t){return e==null?null:t.mapPos(e)}}),zO=Kx.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(RO)?t.value:e,e)}}),BO=Qw.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(zO);n==null?this.cursor!=null&&((t=this.cursor)==null||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.cursor.className=`cm-dropCursor`),(e.startState.field(zO)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(zO),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+`px`,this.cursor.style.top=e.top/n+`px`,this.cursor.style.height=e.height/n+`px`):this.cursor.style.left=`-100000px`}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(zO)!=e&&this.view.dispatch({effects:RO.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function VO(){return[zO,BO]}/x/.unicode;function HO(){return WO}var UO=J.line({class:`cm-activeLine`}),WO=Qw.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(UO.range(i.from)),t=i.from)}return J.set(n)}},{decorations:e=>e.decorations}),GO=2e3;function KO(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>GO||n.off>GO||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(G.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=YS(n.text,o,e.tabSize,!0);if(r<0)a.push(G.cursor(n.to));else{let t=YS(n.text,s,e.tabSize);a.push(G.range(n.from+r,n.from+t))}}}return a}function qO(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function JO(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>GO?-1:i==r.length?qO(e,t.clientX):JS(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function YO(e,t){let n=JO(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=JO(e,t);if(!o)return r;let s=KO(e.state,n,o);return s.length?a?G.create(s.concat(r.ranges)):G.create(s):r}}:null}function XO(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return Y.mouseSelectionStyle.of((e,n)=>t(n)?YO(e,n):null)}var ZO={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},QO={style:`cursor: crosshair`};function $O(e={}){let[t,n]=ZO[e.key||`Alt`],r=Qw.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,Y.contentAttributes.of(e=>e.plugin(r)?.isDown?QO:null)]}var ek=`-10000px`,tk=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function nk(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var rk=K.define({combine:e=>({position:q.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||nk})}),ik=new WeakMap,ak=Qw.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(rk);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new tk(e,lk,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(rk);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=ek,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(q.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=lT(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(rk).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=ek;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=ik.get(c)??d.bottom-d.top,g=c.offset||ck,_=this.view.textDirection==uw.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=ek;continue}ik.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,ok(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,ok(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=ek}},{eventObservers:{scroll(){this.maybeMeasure()}}});function ok(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var sk=Y.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),ck={x:0,y:0},lk=K.define({enables:[ak,sk]});function uk(e,t){let n=e.plugin(ak);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var dk=K.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function fk(e,t){let n=e.plugin(pk),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var pk=Qw.fromClass(class{constructor(e){this.input=e.state.facet(gk),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(dk);this.top=new mk(e,!0,t.topContainer),this.bottom=new mk(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(dk);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new mk(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new mk(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(gk);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Y.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),mk=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`,this.dom.style[this.top?`top`:`bottom`]=`0`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=hk(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=hk(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function hk(e){let t=e.nextSibling;return e.remove(),t}var gk=K.define({enables:pk});function _k(e,t){let n,r=new Promise(e=>n=e),i=e=>xk(e,t,n);e.state.field(vk,!1)?e.dispatch({effects:yk.of(i)}):e.dispatch({effects:pS.appendConfig.of(vk.init(()=>[i]))});let a=bk.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(vk).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var vk=Kx.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(yk)?e=[n.value].concat(e):n.is(bk)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>gk.computeN([e],t=>t.field(e))}),yk=pS.define(),bk=pS.define();function xk(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=uC(`form`),t.input){let e=uC(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(uC(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(uC(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=uC(`div`,r,uC(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var Sk=class extends AS{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Sk.prototype.elementClass=``,Sk.prototype.toDOM=void 0,Sk.prototype.mapMode=Ox.TrackBefore,Sk.prototype.startSide=Sk.prototype.endSide=-1,Sk.prototype.point=!0;var Ck=K.define(),wk=K.define(),Tk={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>FS.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},Ek=K.define();function Dk(e){return[kk(),Ek.of({...Tk,...e})]}var Ok=K.define({combine:e=>e.some(e=>e)});function kk(e){let t=[Ak];return e&&e.fixed===!1&&t.push(Ok.of(!0)),t}var Ak=Qw.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(Ek).map(t=>new Pk(e,t)),this.fixed=!e.state.facet(Ok);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Ok)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=FS.iter(this.view.state.facet(Ck),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Nk(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==AC.Text&&t){Mk(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==AC.Text){Mk(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Ek),n=e.state.facet(Ek),r=e.docChanged||e.heightChanged||e.viewportChanged||!FS.eq(e.startState.facet(Ck),e.state.facet(Ck),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Pk(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Y.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==uw.LTR?{left:r,right:i}:{right:r,left:i}})});function jk(e){return Array.isArray(e)?e:[e]}function Mk(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var Nk=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=FS.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Fk(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Mk(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(wk)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Pk=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=jk(t.markers(e)),t.initialSpacer&&(this.spacer=new Fk(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=jk(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!FS.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Fk=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),Ik(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Ik(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var Lk=K.define(),Rk=K.define(),zk=K.define({combine(e){return kS(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),Bk=class extends Sk{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Vk(e,t){return e.state.facet(zk).formatNumber(t,e.state)}var Hk=Ek.compute([zk],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Lk)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Bk(Vk(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Rk)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(zk)!=e.state.facet(zk),initialSpacer(e){return new Bk(Vk(e,Wk(e.state.doc.lines)))},updateSpacer(e,t){let n=Vk(t.view,Wk(t.view.state.doc.lines));return n==e.number?e:new Bk(n)},domEventHandlers:e.facet(zk).domEventHandlers,side:`before`}));function Uk(e={}){return[zk.of(e),kk(),Hk]}function Wk(e){let t=9;for(;t<e;)t=t*10+9;return t}var Gk=new class extends Sk{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},Kk=Ck.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Gk.range(i)))}return FS.of(t)});function qk(){return Kk}var Jk=1024,Yk=0,Xk=class{constructor(e,t){this.from=e,this.to=t}},Zk=class{constructor(e={}){this.id=Yk++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=eA.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Zk.closedBy=new Zk({deserialize:e=>e.split(` `)}),Zk.openedBy=new Zk({deserialize:e=>e.split(` `)}),Zk.group=new Zk({deserialize:e=>e.split(` `)}),Zk.isolate=new Zk({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),Zk.contextHash=new Zk({perNode:!0}),Zk.lookAhead=new Zk({perNode:!0}),Zk.mounted=new Zk({perNode:!0});var Qk=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Zk.mounted.id]}},$k=Object.create(null),eA=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):$k,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(Zk.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(Zk.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};eA.none=new eA(``,Object.create(null),0,8);var tA=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new eA(e.name,r,e.id,e.flags):e)}return new e(n)}},nA=new WeakMap,rA=new WeakMap,iA;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(iA||={});var aA=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=Qk.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new yA(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new yA(nA.get(this)||this.topNode);return r.moveTo(e,t),nA.set(this,r._tree),r}get topNode(){return new dA(this,0,0,null)}resolve(e,t=0){let n=lA(nA.get(this)||this.topNode,e,t,!1);return nA.set(this,n),n}resolveInner(e,t=0){let n=lA(rA.get(this)||this.topNode,e,t,!0);return rA.set(this,n),n}resolveStack(e,t=0){return vA(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&iA.IncludeAnonymous)>0;for(let e=this.cursor(a|iA.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:wA(eA.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(eA.none,t,n,r)))}static build(e){return xA(e)}};aA.empty=new aA(eA.none,[],[],0);var oA=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},sA=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return eA.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(cA(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function cA(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function lA(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof dA&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:iA.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof dA&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var uA=class{cursor(e=0){return new yA(this,e)}getChild(e,t=null,n=null){let r=fA(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return fA(this,e,t,n)}resolve(e,t=0){return lA(this,e,t,!1)}resolveInner(e,t=0){return lA(this,e,t,!0)}matchContext(e){return pA(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},dA=class e extends uA{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&iA.EnterBracketed&&l instanceof aA&&(d=Qk.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!cA(i,r,u,u+l.length))){if(l instanceof sA){if(a&iA.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new hA(new mA(o,l,t,u),null,e)}else if(a&iA.IncludeAnonymous||!l.type.isAnonymous||bA(l)){let s;if(!(a&iA.IgnoreMounts)&&(s=Qk.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&iA.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&iA.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&iA.IgnoreOverlays)&&(i=Qk.get(this._tree))&&i.overlay){let a=t-this.from,o=r&iA.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function fA(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function pA(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var mA=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},hA=class e extends uA{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&iA.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new aA(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function gA(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof dA&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new _A(i,n)}var _A=class{constructor(e,t){this.heads=e,this.node=t}get next(){return gA(this.heads)}};function vA(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof dA?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=Qk.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new dA(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(lA(o,t,n,!1))}}return i?gA(i):r}var yA=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~iA.EnterBracketed,e instanceof dA)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof dA?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&iA.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&iA.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&iA.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&iA.IncludeAnonymous||e instanceof sA||!e.type.isAnonymous||bA(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new hA(this.buffer,t,this.stack[e]);return this.bufferNode=new hA(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return pA(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return pA(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function bA(e){return e.children.some(e=>e instanceof sA||!e.type.isAnonymous||bA(e))}function xA(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Jk,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new oA(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,ee=c;if(w<0)if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(w==-3){c=x;return}else if(w==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${w}`);let E=s[x],D,O,te=S-e;if(C-S<=r&&(O=h(o.pos-t,y))){let t=new Uint16Array(O.size-O.skip),r=o.pos-O.size,i=t.length;for(;o.pos>r;)i=g(O.start,t,i);D=new sA(t,C-O.start,n),te=O.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,ee),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,ee),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(E,ee);D=wA(E,t,n,0,t.length,0,C-S,e,e)}else D=m(E,t,n,C-S,T-C,ee)}_.push(D),v.push(te)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new sA(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof aA){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(Zk.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[Zk.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[Zk.lookAhead,i];o=o?[e].concat(o):[e]}return new aA(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new aA(s[e.topID],_.reverse(),v.reverse(),y)}var SA=new WeakMap;function CA(e,t){if(!e.isAnonymous||t instanceof sA||t.type!=e)return 1;let n=SA.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof aA)){n=1;break}n+=CA(e,r)}SA.set(t,n)}return n}function wA(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=CA(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=CA(e,t[s]);for(s++;s<i;s++){let n=CA(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(wA(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var TA=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof hA?this.setBuffer(e.context.buffer,e.index,t):e instanceof dA&&this.map.set(e.tree,t)}get(e){return e instanceof hA?this.getBuffer(e.context.buffer,e.index):e instanceof dA?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},EA=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},DA=class{startParse(e,t,n){return typeof e==`string`&&(e=new OA(e)),n=n?n.length?n.map(e=>new Xk(e.from,e.to)):[new Xk(0,0)]:[new Xk(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},OA=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function kA(e){return(t,n,r,i)=>new PA(t,e,n,r,i)}var AA=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function jA(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var MA=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},NA=new Zk({perNode:!0}),PA=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new aA(e.type,e.children,e.positions,e.length,e.propValues.concat([[NA,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[Zk.mounted.id]=new Qk(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new zA(this.fragments),t=null,n=null,r=new yA(new dA(this.baseTree,this.ranges[0].from,0,null),iA.IncludeAnonymous|iA.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=FA(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||(LA(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new MA(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=BA(this.ranges,i.overlay||(r.from<r.to?[new Xk(r.from,r.to)]:[]));e.length&&jA(e),(e.length||!i.overlay)&&this.inner.push(new AA(i.parser,e.length?i.parser.startParse(this.input,HA(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new Xk(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new Xk(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=BA(this.ranges,t.ranges);e.length&&(jA(e),this.inner.splice(t.index,0,new AA(t.parser,t.parser.startParse(this.input,HA(t.mounts,e),e),t.ranges.map(e=>new Xk(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function FA(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function IA(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function LA(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];IA(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),IA(o,s[f+3],r,p,m,a),new aA(i,p,m,u)}i.children[a]=l(0,s.length,eA.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new dA(n,r+e.from,t,e._tree))}}var RA=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(iA.IncludeAnonymous|iA.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=e&&t.enter(n,1,iA.IgnoreOverlays|iA.ExcludeBuffers)))if(t.to<=e)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof aA)t=t.children[0];else break}return!1}},zA=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(NA)??t.to,this.inner=new RA(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(NA)??e.to,this.inner=new RA(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(Zk.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function BA(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new Xk(e.from,o),e.to>s&&n.splice(a+1,0,new Xk(s,e.to))):e.to>s?n[a--]=new Xk(s,e.to):n.splice(a--,1))}}return r}function VA(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new Xk(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function HA(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=VA(t,i.overlay.map(e=>new Xk(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new EA(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new EA(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var UA=0,WA=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=UA++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new KA(e);return e=>e.modified.indexOf(t)>-1?e:KA.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},GA=0,KA=class e{constructor(e){this.name=e,this.instances=[],this.id=GA++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&qA(n,e.modified));if(r)return r;let i=[],a=new WA(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=JA(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function qA(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function JA(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function YA(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new ZA(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return XA.add(t)}var XA=new Zk({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new ZA(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),ZA=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};ZA.empty=new ZA([],2,null);function QA(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function $A(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function ej(e,t,n,r=0,i=e.length){let a=new tj(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var tj=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=nj(e)||ZA.empty,u=$A(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(Zk.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function nj(e){let t=e.type.prop(XA);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=WA.define,rj=X(),ij=X(),aj=X(ij),oj=X(ij),sj=X(),cj=X(sj),lj=X(sj),uj=X(),dj=X(uj),fj=X(),pj=X(),mj=X(),hj=X(mj),gj=X(),Z={comment:rj,lineComment:X(rj),blockComment:X(rj),docComment:X(rj),name:ij,variableName:X(ij),typeName:aj,tagName:X(aj),propertyName:oj,attributeName:X(oj),className:X(ij),labelName:X(ij),namespace:X(ij),macroName:X(ij),literal:sj,string:cj,docString:X(cj),character:X(cj),attributeValue:X(cj),number:lj,integer:X(lj),float:X(lj),bool:X(sj),regexp:X(sj),escape:X(sj),color:X(sj),url:X(sj),keyword:fj,self:X(fj),null:X(fj),atom:X(fj),unit:X(fj),modifier:X(fj),operatorKeyword:X(fj),controlKeyword:X(fj),definitionKeyword:X(fj),moduleKeyword:X(fj),operator:pj,derefOperator:X(pj),arithmeticOperator:X(pj),logicOperator:X(pj),bitwiseOperator:X(pj),compareOperator:X(pj),updateOperator:X(pj),definitionOperator:X(pj),typeOperator:X(pj),controlOperator:X(pj),punctuation:mj,separator:X(mj),bracket:hj,angleBracket:X(hj),squareBracket:X(hj),paren:X(hj),brace:X(hj),content:uj,heading:dj,heading1:X(dj),heading2:X(dj),heading3:X(dj),heading4:X(dj),heading5:X(dj),heading6:X(dj),contentSeparator:X(uj),list:X(uj),quote:X(uj),emphasis:X(uj),strong:X(uj),link:X(uj),monospace:X(uj),strikethrough:X(uj),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:gj,documentMeta:X(gj),annotation:X(gj),processingInstruction:X(gj),definition:WA.defineModifier(`definition`),constant:WA.defineModifier(`constant`),function:WA.defineModifier(`function`),standard:WA.defineModifier(`standard`),local:WA.defineModifier(`local`),special:WA.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof WA&&(t.name=e)}QA([{tag:Z.link,class:`tok-link`},{tag:Z.heading,class:`tok-heading`},{tag:Z.emphasis,class:`tok-emphasis`},{tag:Z.strong,class:`tok-strong`},{tag:Z.keyword,class:`tok-keyword`},{tag:Z.atom,class:`tok-atom`},{tag:Z.bool,class:`tok-bool`},{tag:Z.url,class:`tok-url`},{tag:Z.labelName,class:`tok-labelName`},{tag:Z.inserted,class:`tok-inserted`},{tag:Z.deleted,class:`tok-deleted`},{tag:Z.literal,class:`tok-literal`},{tag:Z.string,class:`tok-string`},{tag:Z.number,class:`tok-number`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:`tok-string2`},{tag:Z.variableName,class:`tok-variableName`},{tag:Z.local(Z.variableName),class:`tok-variableName tok-local`},{tag:Z.definition(Z.variableName),class:`tok-variableName tok-definition`},{tag:Z.special(Z.variableName),class:`tok-variableName2`},{tag:Z.definition(Z.propertyName),class:`tok-propertyName tok-definition`},{tag:Z.typeName,class:`tok-typeName`},{tag:Z.namespace,class:`tok-namespace`},{tag:Z.className,class:`tok-className`},{tag:Z.macroName,class:`tok-macroName`},{tag:Z.propertyName,class:`tok-propertyName`},{tag:Z.operator,class:`tok-operator`},{tag:Z.comment,class:`tok-comment`},{tag:Z.meta,class:`tok-meta`},{tag:Z.invalid,class:`tok-invalid`},{tag:Z.punctuation,class:`tok-punctuation`}]);var _j=new Zk;function vj(e){return K.define({combine:e?t=>t.concat(e):void 0})}var yj=new Zk,bj=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,OS.prototype.hasOwnProperty(`tree`)||Object.defineProperty(OS.prototype,"tree",{get(){return Cj(this)}}),this.parser=t,this.extension=[Mj.of(this),OS.languageData.of((e,t,n)=>{let r=xj(e,t,n),i=r.type.prop(_j);if(!i)return[];let a=e.facet(i),o=r.type.prop(yj);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return xj(e,t,n).type.prop(_j)==this.data}findRegions(e){let t=e.facet(Mj);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(_j)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(Zk.mounted);if(i){if(i.tree.prop(_j)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof aA&&r(i,e.positions[n]+t)}};return r(Cj(e),0),n}get allowsNesting(){return!0}};bj.setState=pS.define();function xj(e,t,n){let r=e.facet(Mj),i=Cj(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,iA.ExcludeBuffers|iA.EnterBracketed))e.type.isTop&&(i=e);return i}var Sj=class e extends bj{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=vj(t.languageData);return new e(n,t.parser.configure({props:[_j.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Cj(e){let t=e.field(bj.state,!1);return t?t.tree:aA.empty}var wj=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Tj=null,Ej=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],aA.empty,0,r,[],null)}startParse(){return this.parser.startParse(new wj(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=aA.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(EA.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(EA.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Tj;Tj=this;try{return e()}finally{Tj=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Dj(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=EA.applyChanges(r,e),i=aA.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=Dj(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends DA{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Tj;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new aA(eA.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Tj}};function Dj(e,t,n){return EA.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Oj=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Ej.create(t.facet(Mj).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};bj.state=Kx.define({create:Oj.init,update(e,t){for(let e of t.effects)if(e.is(bj.setState))return e.value;return t.startState.facet(Mj)==t.state.facet(Mj)?e.apply(t):Oj.init(t.state)}});var kj=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(kj=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Aj=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,jj=Qw.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(bj.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(bj.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=kj(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(bj.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Aj?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>Aj&&Aj()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:bj.setState.of(new Oj(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Jw(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Mj=K.define({combine(e){return e.length?e[0]:null},enables:e=>[bj.state,jj,Y.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Nj=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Q=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},Pj=K.define(),Fj=K.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function Ij(e){let t=e.facet(Fj);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Lj(e,t){let n=``,r=e.tabSize,i=e.facet(Fj)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function Rj(e,t){e instanceof OS&&(e=new zj(e));for(let n of e.state.facet(Pj)){let r=n(e,t);if(r!==void 0)return r}let n=Cj(e.state);return n.length>=t?Vj(e,n,t):null}var zj=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ij(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return JS(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Bj=new Zk;function Vj(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return Hj(r,e,n)}function Hj(e,t,n){for(let r=e;r;r=r.next){let e=Wj(r.node);if(e)return e(Kj.create(t,n,r))}return 0}function Uj(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Wj(e){let t=e.type.prop(Bj);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Zk.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Xj(e,!0,1,void 0,n&&!Uj(e)?t.from:void 0)}return e.parent==null?Gj:null}function Gj(){return 0}var Kj=class e extends zj{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(qj(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Hj(this.context.next,this.base,this.pos)}};function qj(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Jj(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function Yj({closing:e,align:t=!0,units:n=1}){return r=>Xj(r,t,n,e)}function Xj(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?Jj(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Zj=e=>e.baseIndent;function Qj({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var $j=200;function eM(){return OS.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+$j)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=Rj(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=Lj(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var tM=K.define(),nM=new Zk;function rM(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function iM(e,t,n){let r=Cj(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(nM);if(s&&(i.to<r.length-50||r.length==e.doc.length||!aM(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function aM(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function oM(e,t,n){for(let r of e.facet(tM)){let i=r(e,t,n);if(i)return i}return iM(e,t,n)}function sM(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var cM=pS.define({map:sM}),lM=pS.define({map:sM});function uM(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var dM=Kx.define({create(){return J.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=fM(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(cM)&&!mM(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(xM),i=r?J.replace({widget:new TM(r(t.state,n.value))}):wM;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(lM)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=fM(e,t.selection.main.head)),e},provide:e=>Y.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(wM.range(r,i))}return J.set(t,!0)}});function fM(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function pM(e,t,n){var r;let i=null;return(r=e.field(dM,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function mM(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function hM(e,t){return e.field(dM,!1)?t:t.concat(pS.appendConfig.of(SM()))}var gM=e=>{for(let t of uM(e)){let n=oM(e.state,t.from,t.to);if(n)return e.dispatch({effects:hM(e.state,[cM.of(n),vM(e,n)])}),!0}return!1},_M=e=>{if(!e.state.field(dM,!1))return!1;let t=[];for(let n of uM(e)){let r=pM(e.state,n.from,n.to);r&&t.push(lM.of(r),vM(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function vM(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Y.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var yM=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:gM},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:_M},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=oM(t,i.from,i.to);a&&n.push(cM.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:hM(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(dM,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(lM.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],bM={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},xM=K.define({combine(e){return kS(e,bM)}});function SM(e){let t=[dM,kM];return e&&t.push(xM.of(e)),t}function CM(e,t){let{state:n}=e,r=n.facet(xM),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=pM(e.state,n.from,n.to);r&&e.dispatch({effects:lM.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var wM=J.replace({widget:new class extends kC{toDOM(e){return CM(e,null)}}}),TM=class extends kC{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return CM(e,this.value)}},EM={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},DM=class extends Sk{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function OM(e={}){let t={...EM,...e},n=new DM(t,!0),r=new DM(t,!1),i=Qw.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(Mj)!=e.state.facet(Mj)||e.startState.field(dM,!1)!=e.state.field(dM,!1)||Cj(e.startState)!=Cj(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new LS;for(let i of e.viewportLineBlocks){let a=pM(e.state,i.from,i.to)?r:oM(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,Dk({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||FS.empty},initialSpacer(){return new DM(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=pM(e.state,t.from,t.to);if(r)return e.dispatch({effects:lM.of(r)}),!0;let i=oM(e.state,t.from,t.to);return i?(e.dispatch({effects:cM.of(i)}),!0):!1}}}),SM()]}var kM=Y.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),AM=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=eC.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof bj?e=>e.prop(_j)==a.data:a?e=>e==a:void 0,this.style=QA(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new eC(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},jM=K.define(),MM=K.define({combine(e){return e.length?[e[0]]:null}});function NM(e){let t=e.facet(jM);return t.length?t:e.facet(MM)}function PM(e,t){let n=[IM],r;return e instanceof AM&&(e.module&&n.push(Y.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(MM.of(e)):r?n.push(jM.computeN([Y.darkTheme],t=>t.facet(Y.darkTheme)==(r==`dark`)?[e]:[])):n.push(jM.of(e)),n}var FM=class{constructor(e){this.markCache=Object.create(null),this.tree=Cj(e.state),this.decorations=this.buildDeco(e,NM(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Cj(e.state),n=NM(e.state),r=n!=NM(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return J.none;let n=new LS;for(let{from:r,to:i}of e.visibleRanges)ej(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=J.mark({class:r})))},r,i);return n.finish()}},IM=Yx.high(Qw.fromClass(FM,{decorations:e=>e.decorations})),LM=AM.define([{tag:Z.meta,color:`#404740`},{tag:Z.link,textDecoration:`underline`},{tag:Z.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strong,fontWeight:`bold`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.keyword,color:`#708`},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:`#219`},{tag:[Z.literal,Z.inserted],color:`#164`},{tag:[Z.string,Z.deleted],color:`#a11`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:`#e40`},{tag:Z.definition(Z.variableName),color:`#00f`},{tag:Z.local(Z.variableName),color:`#30a`},{tag:[Z.typeName,Z.namespace],color:`#085`},{tag:Z.className,color:`#167`},{tag:[Z.special(Z.variableName),Z.macroName],color:`#256`},{tag:Z.definition(Z.propertyName),color:`#00c`},{tag:Z.comment,color:`#940`},{tag:Z.invalid,color:`#f00`}]),RM=Y.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),zM=1e4,BM=`()[]{}`,VM=K.define({combine(e){return kS(e,{afterCursor:!0,brackets:BM,maxScanDistance:zM,renderMatch:WM})}}),HM=J.mark({class:`cm-matchingBracket`}),UM=J.mark({class:`cm-nonmatchingBracket`});function WM(e){let t=[],n=e.matched?HM:UM;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function GM(e){let t=[],n=e.facet(VM);for(let r of e.selection.ranges){if(!r.empty)continue;let i=ZM(e,r.head,-1,n)||r.head>0&&ZM(e,r.head-1,1,n)||n.afterCursor&&(ZM(e,r.head,1,n)||r.head<e.doc.length&&ZM(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return J.set(t,!0)}var KM=[Qw.fromClass(class{constructor(e){this.paused=!1,this.decorations=GM(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=GM(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),RM];function qM(e={}){return[VM.of(e),KM]}var JM=new Zk;function YM(e,t,n){let r=e.prop(t<0?Zk.openedBy:Zk.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function XM(e){let t=e.type.prop(JM);return t?t(e.node):e}function ZM(e,t,n,r={}){let i=r.maxScanDistance||zM,a=r.brackets||BM,o=Cj(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=YM(r.type,n,a);if(i&&r.from<r.to){let o=XM(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return QM(e,t,n,r,o,i,a)}}return $M(e,t,n,o,s.type,i,a)}function QM(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=XM(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(YM(u.type,n,o))l++;else if(YM(u.type,-n,o)){if(l==0){let e=XM(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function $M(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function eN(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var tN=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=eN(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??eN(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}};function nN(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||rN,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||dN,mergeTokens:e.mergeTokens!==!1}}function rN(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var iN=new WeakMap,aN=class e extends bj{constructor(e){let t=vj(e.languageData),n=nN(e),r,i=new class extends DA{createParse(e,t,n){return new lN(r,e,t,n)}};super(t,i,[],e.name),this.topNode=xN(t,this),r=this,this.streamParser=n,this.stateAfter=new Zk({perNode:!0}),this.tokenTable=e.tokenTable?new _N(n.tokenTable):vN}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=iN.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=oN(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new tN(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)uN(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&iN.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function oN(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof aA&&s<i&&oN(e,o,s,r,i);if(c)return c}return null}function sN(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof aA){if(!(c=sN(e,s,n-o,r-o,i)))break;return i?new aA(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function cN(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&oN(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=sN(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?Ij(i):4),tree:aA.empty}}var lN=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=Ej.get(),a=r[0].from,{state:o,tree:s}=cN(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(Ij(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=Ej.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
131
131
|
`&&(t=``);else{let e=t.indexOf(`
|
|
132
132
|
`);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new tN(t,e?e.state.tabSize:4,e?Ij(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=uN(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=aA.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:pN,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new aA(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new aA(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function uN(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var dN=Object.create(null),fN=[eA.none],pN=new tA(fN),mN=[],hN=Object.create(null),gN=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])gN[e]=bN(dN,t);var _N=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),gN)}resolve(e){return e?this.table[e]||(this.table[e]=bN(this.extra,e)):0}},vN=new _N(dN);function yN(e,t){mN.indexOf(e)>-1||(mN.push(e),console.warn(t))}function bN(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Z[n];r?typeof r==`function`?t.length?t=t.map(r):yN(n,`Modifier ${n} used at start of tag`):t.length?yN(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:yN(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=hN[i];if(a)return a.id;let o=hN[i]=eA.define({id:fN.length,name:r,props:[YA({[r]:n})]});return fN.push(o),o.id}function xN(e,t){let n=eA.define({id:fN.length,name:`Document`,props:[_j.add(()=>e),Bj.add(()=>e=>t.getIndent(e))],top:!0});return fN.push(n),n}uw.RTL,uw.LTR;var SN=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=DN(e.state,n.from);return r.line?wN(e):r.block?EN(e):!1};function CN(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var wN=CN(MN,0),TN=CN(jN,0),EN=CN((e,t)=>jN(e,t,AN(t)),0);function DN(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var ON=50;function kN(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-ON,r),o=e.sliceDoc(i,i+ON),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*ON?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+ON),d=e.sliceDoc(i-ON,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function AN(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function jN(e,t,n=t.selection.ranges){let r=n.map(e=>DN(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>kN(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function MN(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=DN(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var NN=uS.define(),PN=uS.define(),FN=K.define(),IN=K.define({combine(e){return kS(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),LN=Kx.define({create(){return nP.empty},update(e,t){let n=t.state.facet(IN),r=t.annotation(NN);if(r){let i=WN.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?GN(o,o.length,n.minDepth,i):ZN(o,t.startState.selection),new nP(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(PN);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(mS.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=WN.fromTransaction(t),o=t.annotation(mS.time),s=t.annotation(mS.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new nP(e.done.map(WN.fromJSON),e.undone.map(WN.fromJSON))}});function RN(e={}){return[LN,IN.of(e),Y.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?BN:e.inputType==`historyRedo`?VN:null;return n?(e.preventDefault(),n(t)):!1}})]}function zN(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(LN,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var BN=zN(0,!1),VN=zN(1,!1),HN=zN(0,!0),UN=zN(1,!0),WN=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Ax.fromJSON(t.changes),[],t.mapped&&kx.fromJSON(t.mapped),t.startSelection&&G.fromJSON(t.startSelection),t.selectionsAfter.map(G.fromJSON))}static fromTransaction(t,n){let r=YN;for(let e of t.startState.facet(FN)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,YN)}static selection(t){return new e(void 0,YN,void 0,void 0,t)}};function GN(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function KN(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function qN(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function JN(e,t){return e.length?t.length?e.concat(t):e:t}var YN=[],XN=200;function ZN(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-XN));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),GN(e,e.length-1,1e9,n.setSelAfter(r)))}else return[WN.selection([t])]}function QN(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function $N(e,t){if(!e.length)return e;let n=e.length,r=YN;for(;n;){let i=eP(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[WN.selection(r)]:YN}function eP(e,t,n){let r=JN(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):YN,n);if(!e.changes)return WN.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new WN(i,pS.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var tP=/^(input\.type|delete)($|\.)/,nP=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||tP.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,KN(s.changes,t.changes))||r==`input.type.compose`)?GN(o,o.length-1,i.minDepth,new WN(t.changes.compose(s.changes),JN(pS.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,YN)):GN(o,o.length,i.minDepth,t),new e(o,YN,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:YN;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&qN(a[a.length-1],t)?this:new e(ZN(this.done,t),this.undone,n,r)}addMapping(t){return new e($N(this.done,t),$N(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:NN.of({side:e,rest:QN(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?YN:r.slice(0,r.length-1);return i.mapped&&(n=$N(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:NN.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};nP.empty=new nP(YN,YN);var rP=[{key:`Mod-z`,run:BN,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:VN,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:VN,preventDefault:!0},{key:`Mod-u`,run:HN,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:UN,preventDefault:!0}];function iP(e,t){return G.create(e.ranges.map(t),e.mainIndex)}function aP(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function oP({state:e,dispatch:t},n){let r=iP(e.selection,n);return r.eq(e.selection,!0)?!1:(t(aP(e,r)),!0)}function sP(e,t){return G.cursor(t?e.to:e.from)}function cP(e,t){return oP(e,n=>n.empty?e.moveByChar(n,t):sP(n,t))}function lP(e){return e.textDirectionAt(e.state.selection.main.head)==uw.LTR}var uP=e=>cP(e,!lP(e)),dP=e=>cP(e,lP(e));function fP(e,t){return oP(e,n=>n.empty?e.moveByGroup(n,t):sP(n,t))}var pP=e=>fP(e,!lP(e)),mP=e=>fP(e,lP(e));typeof Intl<`u`&&Intl.Segmenter;function hP(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function gP(e,t,n){let r=Cj(e).resolveInner(t.head),i=n?Zk.closedBy:Zk.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;hP(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?ZM(e,r.from,1):ZM(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,G.cursor(s,n?-1:1)}var _P=e=>oP(e,t=>gP(e.state,t,!lP(e))),vP=e=>oP(e,t=>gP(e.state,t,lP(e)));function yP(e,t){return oP(e,n=>{if(!n.empty)return sP(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var bP=e=>yP(e,!1),xP=e=>yP(e,!0);function SP(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(Y.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function CP(e,t){let n=SP(e),{state:r}=e,i=iP(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):sP(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=Y.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(aP(r,i),{effects:a}),!0}var wP=e=>CP(e,!1),TP=e=>CP(e,!0);function EP(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=G.cursor(r.from+n))}return i}var DP=e=>oP(e,t=>EP(e,t,!0)),OP=e=>oP(e,t=>EP(e,t,!1)),kP=e=>oP(e,t=>EP(e,t,!lP(e))),AP=e=>oP(e,t=>EP(e,t,lP(e))),jP=e=>oP(e,t=>G.cursor(e.lineBlockAt(t.head).from,1)),MP=e=>oP(e,t=>G.cursor(e.lineBlockAt(t.head).to,-1));function NP(e,t,n){let r=!1,i=iP(e.selection,t=>{let i=ZM(e,t.head,-1)||ZM(e,t.head,1)||t.head>0&&ZM(e,t.head-1,1)||t.head<e.doc.length&&ZM(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?G.range(t.anchor,a):G.cursor(a)});return r?(t(aP(e,i)),!0):!1}var PP=({state:e,dispatch:t})=>NP(e,t,!1);function FP(e,t){let n=iP(e.state.selection,e=>{let n=t(e);return G.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(aP(e.state,n)),!0)}function IP(e,t){return FP(e,n=>e.moveByChar(n,t))}var LP=e=>IP(e,!lP(e)),RP=e=>IP(e,lP(e));function zP(e,t){return FP(e,n=>e.moveByGroup(n,t))}var BP=e=>zP(e,!lP(e)),VP=e=>zP(e,lP(e)),HP=e=>FP(e,t=>gP(e.state,t,!lP(e))),UP=e=>FP(e,t=>gP(e.state,t,lP(e)));function WP(e,t){return FP(e,n=>e.moveVertically(n,t))}var GP=e=>WP(e,!1),KP=e=>WP(e,!0);function qP(e,t){return FP(e,n=>e.moveVertically(n,t,SP(e).height))}var JP=e=>qP(e,!1),YP=e=>qP(e,!0),XP=e=>FP(e,t=>EP(e,t,!0)),ZP=e=>FP(e,t=>EP(e,t,!1)),QP=e=>FP(e,t=>EP(e,t,!lP(e))),$P=e=>FP(e,t=>EP(e,t,lP(e))),eF=e=>FP(e,t=>G.cursor(e.lineBlockAt(t.head).from)),tF=e=>FP(e,t=>G.cursor(e.lineBlockAt(t.head).to)),nF=({state:e,dispatch:t})=>(t(aP(e,{anchor:0})),!0),rF=({state:e,dispatch:t})=>(t(aP(e,{anchor:e.doc.length})),!0),iF=({state:e,dispatch:t})=>(t(aP(e,{anchor:e.selection.main.anchor,head:0})),!0),aF=({state:e,dispatch:t})=>(t(aP(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),oF=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),sF=({state:e,dispatch:t})=>{let n=EF(e).map(({from:t,to:n})=>G.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:G.create(n),userEvent:`select`})),!0},cF=({state:e,dispatch:t})=>{let n=iP(e.selection,t=>{let n=Cj(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return G.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(aP(e,n)),!0)};function lF(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(aP(n,G.create(i,i.length-1))),!0)}var uF=e=>lF(e,!1),dF=e=>lF(e,!0),fF=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=G.create([n.main]):n.main.empty||(r=G.create([G.cursor(n.main.head)])),r?(t(aP(e,r)),!0):!1};function pF(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=mF(e,o,!1)):o>i&&(n=`delete.forward`,o=mF(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=mF(e,i,!1),a=mF(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:G.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?Y.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function mF(e,t,n){if(e instanceof Y)for(let r of e.state.facet(Y.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var hF=(e,t,n)=>pF(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=JS(s,a.tabSize)%Ij(a)||Ij(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=xx(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=xx(o.text,c-o.from,!1,!1)+o.from);return c}),gF=e=>hF(e,!1,!0),_F=e=>hF(e,!0,!1),vF=(e,t)=>pF(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=xx(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),yF=e=>vF(e,!1),bF=e=>vF(e,!0),xF=e=>pF(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),SF=e=>pF(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),CF=e=>pF(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),wF=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:ux.of([``,``])},range:G.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},TF=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:xx(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:xx(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:G.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function EF(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function DF(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of EF(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(G.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(G.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:G.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var OF=({state:e,dispatch:t})=>DF(e,t,!1),kF=({state:e,dispatch:t})=>DF(e,t,!0);function AF(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of EF(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var jF=({state:e,dispatch:t})=>AF(e,t,!1),MF=({state:e,dispatch:t})=>AF(e,t,!0),NF=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(EF(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=iP(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function PF(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Cj(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Zk.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var FF=LF(!1),IF=LF(!0);function LF(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&PF(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new zj(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Rj(s,r);for(c??=JS(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Lj(t,c)];return o&&l.push(Lj(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:ux.of(l)},range:G.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function RF(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:G.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var zF=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new zj(e,{overrideIndentation:e=>n[e]??-1}),i=RF(e,(t,i,a)=>{let o=Rj(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Lj(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},BF=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(RF(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Fj)})}),{userEvent:`input.indent`})),!0),VF=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(RF(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=JS(r,e.tabSize),a=0,o=Lj(e,Math.max(0,i-Ij(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),HF=e=>(e.setTabFocusMode(),!0),UF=[{key:`Ctrl-b`,run:uP,shift:LP,preventDefault:!0},{key:`Ctrl-f`,run:dP,shift:RP},{key:`Ctrl-p`,run:bP,shift:GP},{key:`Ctrl-n`,run:xP,shift:KP},{key:`Ctrl-a`,run:jP,shift:eF},{key:`Ctrl-e`,run:MP,shift:tF},{key:`Ctrl-d`,run:_F},{key:`Ctrl-h`,run:gF},{key:`Ctrl-k`,run:xF},{key:`Ctrl-Alt-h`,run:yF},{key:`Ctrl-o`,run:wF},{key:`Ctrl-t`,run:TF},{key:`Ctrl-v`,run:TP}],WF=[{key:`ArrowLeft`,run:uP,shift:LP,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:pP,shift:BP,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:kP,shift:QP,preventDefault:!0},{key:`ArrowRight`,run:dP,shift:RP,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:mP,shift:VP,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:AP,shift:$P,preventDefault:!0},{key:`ArrowUp`,run:bP,shift:GP,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:nF,shift:iF},{mac:`Ctrl-ArrowUp`,run:wP,shift:JP},{key:`ArrowDown`,run:xP,shift:KP,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:rF,shift:aF},{mac:`Ctrl-ArrowDown`,run:TP,shift:YP},{key:`PageUp`,run:wP,shift:JP},{key:`PageDown`,run:TP,shift:YP},{key:`Home`,run:OP,shift:ZP,preventDefault:!0},{key:`Mod-Home`,run:nF,shift:iF},{key:`End`,run:DP,shift:XP,preventDefault:!0},{key:`Mod-End`,run:rF,shift:aF},{key:`Enter`,run:FF,shift:FF},{key:`Mod-a`,run:oF},{key:`Backspace`,run:gF,shift:gF,preventDefault:!0},{key:`Delete`,run:_F,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:yF,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:bF,preventDefault:!0},{mac:`Mod-Backspace`,run:SF,preventDefault:!0},{mac:`Mod-Delete`,run:CF,preventDefault:!0}].concat(UF.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),GF=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:_P,shift:HP},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:vP,shift:UP},{key:`Alt-ArrowUp`,run:OF},{key:`Shift-Alt-ArrowUp`,run:jF},{key:`Alt-ArrowDown`,run:kF},{key:`Shift-Alt-ArrowDown`,run:MF},{key:`Mod-Alt-ArrowUp`,run:uF},{key:`Mod-Alt-ArrowDown`,run:dF},{key:`Escape`,run:fF},{key:`Mod-Enter`,run:IF},{key:`Alt-l`,mac:`Ctrl-l`,run:sF},{key:`Mod-i`,run:cF,preventDefault:!0},{key:`Mod-[`,run:VF},{key:`Mod-]`,run:BF},{key:`Mod-Alt-\\`,run:zF},{key:`Shift-Mod-k`,run:NF},{key:`Shift-Mod-\\`,run:PP},{key:`Mod-/`,run:SN},{key:`Alt-A`,run:TN},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:HF}].concat(WF),KF={key:`Tab`,run:BF,shift:VF},qF=`#e5c07b`,JF=`#e06c75`,YF=`#56b6c2`,XF=`#ffffff`,ZF=`#abb2bf`,QF=`#7d8799`,$F=`#61afef`,eI=`#98c379`,tI=`#d19a66`,nI=`#c678dd`,rI=`#21252b`,iI=`#2c313a`,aI=`#282c34`,oI=`#353a42`,sI=`#3E4451`,cI=`#528bff`,lI=[Y.theme({"&":{color:ZF,backgroundColor:aI},".cm-content":{caretColor:cI},".cm-cursor, .cm-dropCursor":{borderLeftColor:cI},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:sI},".cm-panels":{backgroundColor:rI,color:ZF},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:aI,color:QF,border:`none`},".cm-activeLineGutter":{backgroundColor:iI},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:oI},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:oI,borderBottomColor:oI},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:iI,color:ZF}}},{dark:!0}),PM(AM.define([{tag:Z.keyword,color:nI},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:JF},{tag:[Z.function(Z.variableName),Z.labelName],color:$F},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:tI},{tag:[Z.definition(Z.name),Z.separator],color:ZF},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:qF},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:YF},{tag:[Z.meta,Z.comment],color:QF},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:QF,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:JF},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:tI},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:eI},{tag:Z.invalid,color:XF}]))],uI=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,dI=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(uI(e)):uI,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return wx(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Tx(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Ex(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(dI.prototype[Symbol.iterator]=function(){return this});var fI={from:-1,to:-1,match:/.*/.exec(``),precise:!0},pI=`gm`+(/x/.unicode==null?``:`u`),mI=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=fI,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new _I(e,t,n,r,i);this.re=new RegExp(t,pI+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=yI(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=yI(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},hI=new WeakMap,gI=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=hI.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return hI.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),hI.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},_I=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=fI,this.matchPos=yI(e,r),this.re=new RegExp(t,pI+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=gI.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=yI(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=gI.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(mI.prototype[Symbol.iterator]=_I.prototype[Symbol.iterator]=function(){return this});function vI(e){try{return new RegExp(e,pI),!0}catch{return!1}}function yI(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var bI=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=_k(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=G.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,Y.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},xI={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},SI=K.define({combine(e){return kS(e,xI,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function CI(e){let t=[kI,OI];return e&&t.push(SI.of(e)),t}var wI=J.mark({class:`cm-selectionMatch`}),TI=J.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function EI(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=CS.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=CS.Word)}function DI(e,t,n,r){return e(t.sliceDoc(n,n+1))==CS.Word&&e(t.sliceDoc(r-1,r))==CS.Word}var OI=Qw.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(SI),{state:n}=e,r=n.selection;if(r.ranges.length>1)return J.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return J.none;let e=n.wordAt(i.head);if(!e)return J.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return J.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(EI(o,n,i.from,i.to)&&DI(o,n,i.from,i.to)))return J.none}else if(a=n.sliceDoc(i.from,i.to),!a)return J.none}let s=[];for(let r of e.visibleRanges){let e=new dI(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||EI(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(TI.range(r,a)):(r>=i.to||a<=i.from)&&s.push(wI.range(r,a)),s.length>t.maxMatches))return J.none}}return J.set(s)}},{decorations:e=>e.decorations}),kI=Y.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),AI=({state:e,dispatch:t})=>{let{selection:n}=e,r=G.create(n.ranges.map(t=>e.wordAt(t.head)||G.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function jI(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new dI(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new dI(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var MI=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return AI({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=jI(e,r);return i?(t(e.update({selection:e.selection.addRange(G.range(i.from,i.to),!1),effects:Y.scrollIntoView(i.to)})),!0):!1},NI=K.define({combine(e){return kS(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new pL(e),scrollToMatch:e=>Y.scrollIntoView(e)})}}),PI=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||vI(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
133
|
-
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new GI(this):new zI(this)}getCursor(e,t=0,n){let r=e.doc?e:OS.create({doc:e});return n??=r.doc.length,this.regexp?VI(this,r,t,n):LI(this,r,t,n)}},FI=class{constructor(e){this.spec=e}};function II(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function LI(e,t,n,r){let i;return e.wholeWord&&(i=RI(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=II(e.test,t,i)),new dI(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function RI(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(HI(i,n-a))!=CS.Word||t(UI(i,n-a))!=CS.Word)&&(t(UI(i,r-a))!=CS.Word||t(HI(i,r-a))!=CS.Word))}var zI=class extends FI{constructor(e){super(e)}nextMatch(e,t,n){let r=LI(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=LI(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=LI(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=LI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=LI(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function BI(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function VI(e,t,n,r){let i;return e.wholeWord&&(i=WI(t.charCategorizer(t.selection.main.head))),e.test&&(i=BI(e.test,t,i)),new mI(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function HI(e,t){return e.slice(xx(e,t,!1),t)}function UI(e,t){return e.slice(t,xx(e,t))}function WI(e){return(t,n,r)=>!r[0].length||(e(HI(r.input,r.index))!=CS.Word||e(UI(r.input,r.index))!=CS.Word)&&(e(UI(r.input,r.index+r[0].length))!=CS.Word||e(HI(r.input,r.index+r[0].length))!=CS.Word)}var GI=class extends FI{nextMatch(e,t,n){let r=VI(this.spec,e,n,e.doc.length).next();return r.done&&(r=VI(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=VI(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=VI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=VI(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},KI=pS.define(),qI=pS.define(),JI=Kx.define({create(e){return new YI(sL(e).create(),null)},update(e,t){for(let n of t.effects)n.is(KI)?e=new YI(n.value.create(),e.panel):n.is(qI)&&(e=new YI(e.query,n.value?oL:null));return e},provide:e=>gk.from(e,e=>e.panel)}),YI=class{constructor(e,t){this.query=e,this.panel=t}},XI=J.mark({class:`cm-searchMatch`}),ZI=J.mark({class:`cm-searchMatch cm-searchMatch-selected`}),QI=Qw.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(JI))}update(e){let t=e.state.field(JI);(t!=e.startState.field(JI)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return J.none;let{view:n}=this,r=new LS;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?ZI:XI)})}return r.finish()}},{decorations:e=>e.decorations});function $I(e){return t=>{let n=t.state.field(JI,!1);return n&&n.query.spec.valid?e(t,n):uL(t)}}var eL=$I((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(NI);return e.dispatch({selection:i,effects:[_L(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),lL(e),!0}),tL=$I((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(NI);return e.dispatch({selection:a,effects:[_L(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),lL(e),!0}),nL=$I((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),rL=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new dI(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},iL=$I((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(Y.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(_L(e,o)),u.push(n.facet(NI).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),aL=$I((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:Y.announce.of(r),userEvent:`input.replace.all`}),!0});function oL(e){return e.state.facet(NI).createPanel(e)}function sL(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(NI);return new PI({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function cL(e){let t=fk(e,oL);return t&&t.dom.querySelector(`[main-field]`)}function lL(e){let t=cL(e);t&&t==e.root.activeElement&&t.select()}var uL=e=>{let t=e.state.field(JI,!1);if(t&&t.panel){let n=cL(e);if(n&&n!=e.root.activeElement){let r=sL(e.state,t.query.spec);r.valid&&e.dispatch({effects:KI.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[qI.of(!0),t?KI.of(sL(e.state,t.query.spec)):pS.appendConfig.of(yL)]});return!0},dL=e=>{let t=e.state.field(JI,!1);if(!t||!t.panel)return!1;let n=fk(e,oL);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:qI.of(!1)}),!0},fL=[{key:`Mod-f`,run:uL,scope:`editor search-panel`},{key:`F3`,run:eL,shift:tL,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:eL,shift:tL,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:dL,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:rL},{key:`Mod-Alt-g`,run:bI},{key:`Mod-d`,run:MI,preventDefault:!0}],pL=class{constructor(e){this.view=e;let t=this.query=e.state.field(JI).query.spec;this.commit=this.commit.bind(this),this.searchField=uC(`input`,{value:t.search,placeholder:mL(e,`Find`),"aria-label":mL(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=uC(`input`,{value:t.replace,placeholder:mL(e,`Replace`),"aria-label":mL(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=uC(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=uC(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=uC(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return uC(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=uC(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>eL(e),[mL(e,`next`)]),n(`prev`,()=>tL(e),[mL(e,`previous`)]),n(`select`,()=>nL(e),[mL(e,`all`)]),uC(`label`,null,[this.caseField,mL(e,`match case`)]),uC(`label`,null,[this.reField,mL(e,`regexp`)]),uC(`label`,null,[this.wordField,mL(e,`by word`)]),...e.state.readOnly?[]:[uC(`br`),this.replaceField,n(`replace`,()=>iL(e),[mL(e,`replace`)]),n(`replaceAll`,()=>aL(e),[mL(e,`replace all`)])],uC(`button`,{name:`close`,onclick:()=>dL(e),"aria-label":mL(e,`close`),type:`button`},[`×`])])}commit(){let e=new PI({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:KI.of(e)}))}keydown(e){_O(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?tL:eL)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),iL(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(KI)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(NI).top}};function mL(e,t){return e.state.phrase(t)}var hL=30,gL=/[\s\.,:;?!]/;function _L(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-hL),o=Math.min(i,n+hL),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<hL;e++)if(!gL.test(s[e+1])&&gL.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-hL;e--)if(!gL.test(s[e-1])&&gL.test(s[e])){s=s.slice(0,e);break}}return Y.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var vL=Y.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),yL=[JI,Yx.low(QI),vL],bL=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Cj(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(DL(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function xL(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function SL(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=xL(t)+xL(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function CL(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:SL(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function wL(e,t){return n=>{for(let t=Cj(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var TL=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function EL(e){return e.selection.main.from}function DL(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var OL=uS.define();function kL(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:G.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var AL=new WeakMap;function jL(e){if(!Array.isArray(e))return e;let t=AL.get(e);return t||AL.set(e,t=CL(e)),t}var ML=pS.define(),NL=pS.define(),PL=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=wx(e,t),r=Ex(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(wx(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=wx(e,0),i=Ex(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=wx(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=Ex(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=wx(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=Tx(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=Ex(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?Ex(wx(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},FL=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},IL=K.define({combine(e){return kS(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:RL,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>LL(e(n),t(n)),optionClass:(e,t)=>n=>LL(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function LL(e,t){return e?t?e+` `+t:e:t}function RL(e,t,n,r,i,a){let o=e.textDirection==uw.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var zL=pS.define();function BL(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function VL(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var HL=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(IL);this.optionContent=BL(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=VL(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:zL.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(IL).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:NL.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=VL(r.length,i,e.state.facet(IL).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=VL(t.options.length,t.selected,this.view.state.facet(IL).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>Jw(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&WL(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(IL).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function UL(e,t){return n=>new HL(n,e,t)}function WL(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function GL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function KL(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(IL);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new TL(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new FL(n):new PL(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new TL(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):GL(e.completion)>GL(c)&&(s[s.length-1]=e),c=e.completion}return s}var qL=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,QL(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=KL(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(IL).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,QL(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:sR,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},JL=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e($L,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(IL),i=(r.override||n.languageDataAt(`autocomplete`,EL(n)).map(jL)).map(e=>(this.active.find(t=>t.source==e)||new tR(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(iR));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!YL(i,this.active)||o?a=qL.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new tR(e.source,0):e));for(let e of t.effects)e.is(zL)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?XL:ZL}};function YL(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var XL={"aria-autocomplete":`list`},ZL={};function QL(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var $L=[];function eR(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(OL);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var tR=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=eR(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(ML))i=new e(i.source,1,n.value);else if(n.is(NL))i=new e(i.source,0);else if(n.is(iR))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(EL(e.state))}},nR=class e extends tR{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=EL(t.state);if(o>a||!r||n&2&&(EL(t.startState)==this.from||o<this.limit))return new tR(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return rR(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new bL(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??EL(t.state)):new tR(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new tR(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function rR(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):DL(e,!0).test(i)}var iR=pS.define({map(e,t){return e.map(e=>e.map(t))}}),aR=Kx.define({create(){return JL.start()},update(e,t){return e.update(t)},provide:e=>[lk.from(e,e=>e.tooltip),Y.contentAttributes.from(e,e=>e.attrs)]});function oR(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(aR).active.find(e=>e.source==t.source);return r instanceof nR?(typeof n==`string`?e.dispatch({...kL(e.state,n,r.from,r.to),annotations:OL.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var sR=UL(aR,oR);function cR(e,t=`option`){return n=>{let r=n.state.field(aR,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(IL).interactionDelay)return!1;let i=1,a;t==`page`&&(a=uk(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:zL.of(s)}),!0}}var lR=e=>{let t=e.state.field(aR,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(IL).interactionDelay?!1:oR(e,t.open.options[t.open.selected])},uR=e=>e.state.field(aR,!1)?(e.dispatch({effects:ML.of(!0)}),!0):!1,dR=e=>{let t=e.state.field(aR,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:NL.of(null)}),!0)},fR=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},pR=50,mR=1e3,hR=Qw.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(aR).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(aR),n=e.state.facet(IL);if(!e.selectionSet&&!e.docChanged&&e.startState.field(aR)==t)return;let r=e.transactions.some(e=>{let t=eR(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>pR&&Date.now()-n.time>mR){for(let e of n.context.abortListeners)try{e()}catch(e){Jw(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(ML)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(aR);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(IL).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new bL(t,EL(t),e.explicit,this.view),r=new fR(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:NL.of(null)}),Jw(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(IL).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(IL),n=this.view.state.field(aR);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=EL(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new nR(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new tR(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:iR.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(aR,!1);if(t&&t.tooltip&&this.view.state.facet(IL).closeOnBlur){let n=t.open&&uk(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:NL.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ML.of(!1)}),20),this.composing=0}}}),gR=typeof navigator==`object`&&/Win/.test(navigator.platform),_R=Yx.highest(Y.domEventHandlers({keydown(e,t){let n=t.state.field(aR,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(gR&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&oR(t,r),!1}})),vR=Y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),yR=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},bR=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,Ox.TrackDel),r=t.mapPos(this.to,1,Ox.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},xR=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(Fj);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new bR(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new yR(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},SR=J.widget({widget:new class extends kC{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),CR=J.mark({class:`cm-snippetField`}),wR=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=J.set(e.map(e=>(e.from==e.to?SR:CR).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},TR=pS.define({map(e,t){return e&&e.map(t)}}),ER=pS.define(),DR=Kx.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(TR))return n.value;if(n.is(ER)&&e)return new wR(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Y.decorations.from(e,e=>e?e.deco:J.none)});function OR(e,t){return G.create(e.filter(e=>e.field==t).map(e=>G.range(e.from,e.to)))}function kR(e){let t=xR.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:ux.of(a)},scrollIntoView:!0,annotations:n?[OL.of(n),mS.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=OR(o,0)),o.some(e=>e.field>0)){let t=new wR(o,0),n=c.effects=[TR.of(t)];e.state.field(DR,!1)===void 0&&n.push(pS.appendConfig.of([DR,NR,FR,vR]))}e.dispatch(e.state.update(c))}}function AR(e){return({state:t,dispatch:n})=>{let r=t.field(DR,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:OR(r.ranges,i),effects:TR.of(a?null:new wR(r.ranges,i)),scrollIntoView:!0})),!0}}var jR=[{key:`Tab`,run:AR(1),shift:AR(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(DR,!1)?(t(e.update({effects:TR.of(null)})),!0):!1}],MR=K.define({combine(e){return e.length?e[0]:jR}}),NR=Yx.highest(mO.compute([MR],e=>e.facet(MR)));function PR(e,t){return{...t,apply:kR(e)}}var FR=Y.domEventHandlers({mousedown(e,t){let n=t.state.field(DR,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:OR(n.ranges,i.field),effects:TR.of(n.ranges.some(e=>e.field>i.field)?new wR(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),IR={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},LR=pS.define({map(e,t){return t.mapPos(e,-1,Ox.TrackAfter)??void 0}}),RR=new class extends AS{};RR.startSide=1,RR.endSide=-1;var zR=Kx.define({create(){return FS.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(LR)&&(e=e.update({add:[RR.range(n.value,n.value+1)]}));return e}});function BR(){return[GR,zR]}var VR=`()[]{}<>«»»«[]{}`;function HR(e){for(let t=0;t<16;t+=2)if(VR.charCodeAt(t)==e)return VR.charAt(t+1);return Tx(e<128?e:e+1)}function UR(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||IR}var WR=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),GR=Y.inputHandler.of((e,t,n,r)=>{if((WR?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Ex(wx(r,0))==1||t!=i.from||n!=i.to)return!1;let a=qR(e.state,r);return a?(e.dispatch(a),!0):!1}),KR=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=UR(e,e.selection.main.head).brackets||IR.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=XR(e.doc,t.head);for(let i of n)if(i==r&&YR(e.doc,t.head)==HR(wx(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:G.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function qR(e,t){let n=UR(e,e.selection.main.head),r=n.brackets||IR.brackets;for(let i of r){let a=HR(wx(i,0));if(t==i)return a==i?$R(e,i,r.indexOf(i+i+i)>-1,n):ZR(e,i,a,n.before||IR.before);if(t==a&&JR(e,e.selection.main.from))return QR(e,i,a)}return null}function JR(e,t){let n=!1;return e.field(zR).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function YR(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Ex(wx(n,0)))}function XR(e,t){let n=e.sliceString(t-2,t);return Ex(wx(n,0))==n.length?n:n.slice(1)}function ZR(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:LR.of(a.to+t.length),range:G.range(a.anchor+t.length,a.head+t.length)};let o=YR(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:LR.of(a.head+t.length),range:G.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function QR(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&YR(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:G.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function $R(e,t,n,r){let i=r.stringPrefixes||IR.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:LR.of(r.to+t.length),range:G.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=YR(e.doc,o),c;if(s==t){if(ez(e,o))return{changes:{insert:t+t,from:o},effects:LR.of(o+t.length),range:G.cursor(o+t.length)};if(JR(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:G.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=nz(e,o-2*t.length,i))>-1&&ez(e,c))return{changes:{insert:t+t+t+t,from:o},effects:LR.of(o+t.length),range:G.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=CS.Word&&nz(e,o,i)>-1&&!tz(e,o,t,i))return{changes:{insert:t+t,from:o},effects:LR.of(o+t.length),range:G.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function ez(e,t){let n=Cj(e).resolveInner(t+1);return n.parent&&n.from==t}function tz(e,t,n,r){let i=Cj(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function nz(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=CS.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=CS.Word)return n}return-1}function rz(e={}){return[_R,aR,IL.of(e),hR,az,vR]}var iz=[{key:`Ctrl-Space`,run:uR},{mac:"Alt-`",run:uR},{mac:`Alt-i`,run:uR},{key:`Escape`,run:dR},{key:`ArrowDown`,run:cR(!0)},{key:`ArrowUp`,run:cR(!1)},{key:`PageDown`,run:cR(!0,`page`)},{key:`PageUp`,run:cR(!1,`page`)},{key:`Enter`,run:lR}],az=Yx.highest(mO.computeN([IL],e=>e.facet(IL).defaultKeymap?[iz]:[]));function $(e){return new Nj(aN.define(e))}function oz(e){return W(()=>import(`./dist-D2JPG7pC.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var sz=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return W(()=>import(`./dist-DjQKJaGi.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return W(()=>import(`./dist-DjQKJaGi.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return oz(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return W(()=>import(`./dist-Cybdu3nb.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return W(()=>import(`./dist-DqTi4q3N.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return W(()=>import(`./dist-Q6a4_tgv.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return W(()=>import(`./dist-Bb2GBx-1.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return W(()=>import(`./dist-DBDWFC2P.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return W(()=>import(`./dist-BVtcRB6j.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return W(()=>import(`./dist-DIe_LuNr.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return W(()=>import(`./dist-DBDWFC2P.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return W(()=>import(`./dist-DpijsPsZ.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return W(()=>import(`./dist-CTVErq35.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return oz(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return W(()=>import(`./dist-4wlqrTld.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return oz(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return oz(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return W(()=>import(`./dist-CJmGJ-_Y.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return oz(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return oz(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return W(()=>import(`./dist-Cy6uew5t.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return W(()=>import(`./dist-BicfrzOs.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return W(()=>import(`./dist-CejVKm1n.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return W(()=>import(`./dist-CejVKm1n.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return oz(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return oz(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return W(()=>import(`./dist-DBDWFC2P.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return W(()=>import(`./dist-DBDWFC2P.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return W(()=>import(`./dist-CQy3m9R-.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return W(()=>import(`./dist-f5z7EOt1.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return W(()=>import(`./dist-Bg1jewnS.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return W(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return W(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return W(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return W(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return W(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return W(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return W(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return W(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return W(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return W(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return W(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return W(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return W(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return W(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return W(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return W(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return W(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return W(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return W(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return W(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return W(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return W(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return W(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return W(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return W(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return W(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return W(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return W(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return W(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return W(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return W(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return W(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return W(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return W(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return W(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return W(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return W(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return W(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return W(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return W(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return W(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return W(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return W(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return W(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return W(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return W(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return W(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return W(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return W(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return W(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return W(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return W(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return W(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return W(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return W(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return W(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return W(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return W(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return W(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return W(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return W(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return W(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return W(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return W(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return W(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return W(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return W(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return W(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return W(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return W(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return W(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return W(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return W(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return W(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return W(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return W(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return W(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return W(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return W(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return W(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return W(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return W(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return W(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return W(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return W(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return W(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return W(()=>import(`./dist-DELPkMrm.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return W(()=>import(`./dist-CNP2pf7G.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function cz(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function lz(e){return Q.matchFilename(sz,`file${e}`)}function uz({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new Zx),u=(0,b.useRef)(new Zx),d=(0,b.useRef)(new Zx),f=(0,b.useRef)(!1),p=(0,b.useRef)(r),m=(0,b.useRef)(i),h=(0,b.useRef)(a);(0,b.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,b.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,b.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=mO.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new Y({state:OS.create({doc:e,extensions:[Uk(),qk(),RN(),OM(),MO(),VO(),OS.allowMultipleSelections.of(!0),eM(),PM(LM,{fallback:!0}),qM(),BR(),rz(),XO(),$O(),HO(),CI(),mO.of([...KR,...GF,...fL,...rP,...yM,...iz,KF]),i,Y.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(OS.readOnly.of(n)),l.current.of([]),u.current.of(r?lI:[]),Y.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=lz(cz(t));return f&&f.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}),()=>{a.destroy(),c.current=null,o&&(o.current=null)}},[]),(0,b.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,b.useEffect)(()=>{let e=c.current;if(!e)return;let n=lz(cz(t));n?n.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}):e.dispatch({effects:l.current.reconfigure([])})},[t]),(0,b.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(OS.readOnly.of(n))})},[n]),(0,b.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?lI:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,L.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function dz({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,L.jsx)($y,{content:e||``}):n===`image`&&t?(0,L.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,L.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,L.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,L.jsx)(uz,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,L.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:`该文件类型暂不支持在线预览,请直接下载查看。`})})}function fz(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function pz(e){let t=e.endsWith(`/`)?e:`${e}/`;if(typeof window>`u`)return`'self'`;try{return new URL(t,window.location.origin).toString()}catch{return`'self'`}}function mz(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function hz(e){let t=e?pz(e):void 0,n=mz(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=mz(`'self'`,`https:`,t);return[`default-src 'none'`,`script-src ${n}`,`style-src 'unsafe-inline' data: ${r}`,`img-src data: blob: ${r}`,`font-src data: ${r}`,`media-src data: blob: ${r}`,`worker-src blob:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'self'`].join(`; `)}function gz(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function _z(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=hz(r),a=`<script>
|
|
133
|
+
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new GI(this):new zI(this)}getCursor(e,t=0,n){let r=e.doc?e:OS.create({doc:e});return n??=r.doc.length,this.regexp?VI(this,r,t,n):LI(this,r,t,n)}},FI=class{constructor(e){this.spec=e}};function II(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function LI(e,t,n,r){let i;return e.wholeWord&&(i=RI(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=II(e.test,t,i)),new dI(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function RI(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(HI(i,n-a))!=CS.Word||t(UI(i,n-a))!=CS.Word)&&(t(UI(i,r-a))!=CS.Word||t(HI(i,r-a))!=CS.Word))}var zI=class extends FI{constructor(e){super(e)}nextMatch(e,t,n){let r=LI(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=LI(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=LI(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=LI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=LI(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function BI(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function VI(e,t,n,r){let i;return e.wholeWord&&(i=WI(t.charCategorizer(t.selection.main.head))),e.test&&(i=BI(e.test,t,i)),new mI(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function HI(e,t){return e.slice(xx(e,t,!1),t)}function UI(e,t){return e.slice(t,xx(e,t))}function WI(e){return(t,n,r)=>!r[0].length||(e(HI(r.input,r.index))!=CS.Word||e(UI(r.input,r.index))!=CS.Word)&&(e(UI(r.input,r.index+r[0].length))!=CS.Word||e(HI(r.input,r.index+r[0].length))!=CS.Word)}var GI=class extends FI{nextMatch(e,t,n){let r=VI(this.spec,e,n,e.doc.length).next();return r.done&&(r=VI(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=VI(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=VI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=VI(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},KI=pS.define(),qI=pS.define(),JI=Kx.define({create(e){return new YI(sL(e).create(),null)},update(e,t){for(let n of t.effects)n.is(KI)?e=new YI(n.value.create(),e.panel):n.is(qI)&&(e=new YI(e.query,n.value?oL:null));return e},provide:e=>gk.from(e,e=>e.panel)}),YI=class{constructor(e,t){this.query=e,this.panel=t}},XI=J.mark({class:`cm-searchMatch`}),ZI=J.mark({class:`cm-searchMatch cm-searchMatch-selected`}),QI=Qw.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(JI))}update(e){let t=e.state.field(JI);(t!=e.startState.field(JI)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return J.none;let{view:n}=this,r=new LS;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?ZI:XI)})}return r.finish()}},{decorations:e=>e.decorations});function $I(e){return t=>{let n=t.state.field(JI,!1);return n&&n.query.spec.valid?e(t,n):uL(t)}}var eL=$I((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=G.single(r.from,r.to),a=e.state.facet(NI);return e.dispatch({selection:i,effects:[_L(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),lL(e),!0}),tL=$I((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=G.single(i.from,i.to),o=e.state.facet(NI);return e.dispatch({selection:a,effects:[_L(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),lL(e),!0}),nL=$I((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:G.create(n.map(e=>G.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),rL=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new dI(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(G.range(t.value.from,t.value.to))}return t(e.update({selection:G.create(a,o),userEvent:`select.search.matches`})),!0},iL=$I((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(Y.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=G.single(o.from,o.to).map(d),u.push(_L(e,o)),u.push(n.facet(NI).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),aL=$I((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:Y.announce.of(r),userEvent:`input.replace.all`}),!0});function oL(e){return e.state.facet(NI).createPanel(e)}function sL(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(NI);return new PI({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function cL(e){let t=fk(e,oL);return t&&t.dom.querySelector(`[main-field]`)}function lL(e){let t=cL(e);t&&t==e.root.activeElement&&t.select()}var uL=e=>{let t=e.state.field(JI,!1);if(t&&t.panel){let n=cL(e);if(n&&n!=e.root.activeElement){let r=sL(e.state,t.query.spec);r.valid&&e.dispatch({effects:KI.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[qI.of(!0),t?KI.of(sL(e.state,t.query.spec)):pS.appendConfig.of(yL)]});return!0},dL=e=>{let t=e.state.field(JI,!1);if(!t||!t.panel)return!1;let n=fk(e,oL);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:qI.of(!1)}),!0},fL=[{key:`Mod-f`,run:uL,scope:`editor search-panel`},{key:`F3`,run:eL,shift:tL,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:eL,shift:tL,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:dL,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:rL},{key:`Mod-Alt-g`,run:bI},{key:`Mod-d`,run:MI,preventDefault:!0}],pL=class{constructor(e){this.view=e;let t=this.query=e.state.field(JI).query.spec;this.commit=this.commit.bind(this),this.searchField=uC(`input`,{value:t.search,placeholder:mL(e,`Find`),"aria-label":mL(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=uC(`input`,{value:t.replace,placeholder:mL(e,`Replace`),"aria-label":mL(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=uC(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=uC(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=uC(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return uC(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=uC(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>eL(e),[mL(e,`next`)]),n(`prev`,()=>tL(e),[mL(e,`previous`)]),n(`select`,()=>nL(e),[mL(e,`all`)]),uC(`label`,null,[this.caseField,mL(e,`match case`)]),uC(`label`,null,[this.reField,mL(e,`regexp`)]),uC(`label`,null,[this.wordField,mL(e,`by word`)]),...e.state.readOnly?[]:[uC(`br`),this.replaceField,n(`replace`,()=>iL(e),[mL(e,`replace`)]),n(`replaceAll`,()=>aL(e),[mL(e,`replace all`)])],uC(`button`,{name:`close`,onclick:()=>dL(e),"aria-label":mL(e,`close`),type:`button`},[`×`])])}commit(){let e=new PI({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:KI.of(e)}))}keydown(e){_O(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?tL:eL)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),iL(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(KI)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(NI).top}};function mL(e,t){return e.state.phrase(t)}var hL=30,gL=/[\s\.,:;?!]/;function _L(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-hL),o=Math.min(i,n+hL),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<hL;e++)if(!gL.test(s[e+1])&&gL.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-hL;e--)if(!gL.test(s[e-1])&&gL.test(s[e])){s=s.slice(0,e);break}}return Y.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var vL=Y.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),yL=[JI,Yx.low(QI),vL],bL=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Cj(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(DL(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function xL(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function SL(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=xL(t)+xL(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function CL(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:SL(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function wL(e,t){return n=>{for(let t=Cj(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var TL=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function EL(e){return e.selection.main.from}function DL(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var OL=uS.define();function kL(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:G.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var AL=new WeakMap;function jL(e){if(!Array.isArray(e))return e;let t=AL.get(e);return t||AL.set(e,t=CL(e)),t}var ML=pS.define(),NL=pS.define(),PL=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=wx(e,t),r=Ex(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(wx(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=wx(e,0),i=Ex(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=wx(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=Ex(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=wx(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=Tx(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=Ex(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?Ex(wx(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},FL=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},IL=K.define({combine(e){return kS(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:RL,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>LL(e(n),t(n)),optionClass:(e,t)=>n=>LL(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function LL(e,t){return e?t?e+` `+t:e:t}function RL(e,t,n,r,i,a){let o=e.textDirection==uw.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var zL=pS.define();function BL(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function VL(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var HL=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(IL);this.optionContent=BL(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=VL(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:zL.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(IL).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:NL.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=VL(r.length,i,e.state.facet(IL).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=VL(t.options.length,t.selected,this.view.state.facet(IL).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>Jw(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&WL(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(IL).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function UL(e,t){return n=>new HL(n,e,t)}function WL(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function GL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function KL(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(IL);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new TL(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new FL(n):new PL(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new TL(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):GL(e.completion)>GL(c)&&(s[s.length-1]=e),c=e.completion}return s}var qL=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,QL(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=KL(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(IL).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,QL(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:sR,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},JL=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e($L,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(IL),i=(r.override||n.languageDataAt(`autocomplete`,EL(n)).map(jL)).map(e=>(this.active.find(t=>t.source==e)||new tR(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(iR));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!YL(i,this.active)||o?a=qL.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new tR(e.source,0):e));for(let e of t.effects)e.is(zL)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?XL:ZL}};function YL(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var XL={"aria-autocomplete":`list`},ZL={};function QL(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var $L=[];function eR(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(OL);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var tR=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=eR(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(ML))i=new e(i.source,1,n.value);else if(n.is(NL))i=new e(i.source,0);else if(n.is(iR))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(EL(e.state))}},nR=class e extends tR{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=EL(t.state);if(o>a||!r||n&2&&(EL(t.startState)==this.from||o<this.limit))return new tR(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return rR(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new bL(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??EL(t.state)):new tR(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new tR(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function rR(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):DL(e,!0).test(i)}var iR=pS.define({map(e,t){return e.map(e=>e.map(t))}}),aR=Kx.define({create(){return JL.start()},update(e,t){return e.update(t)},provide:e=>[lk.from(e,e=>e.tooltip),Y.contentAttributes.from(e,e=>e.attrs)]});function oR(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(aR).active.find(e=>e.source==t.source);return r instanceof nR?(typeof n==`string`?e.dispatch({...kL(e.state,n,r.from,r.to),annotations:OL.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var sR=UL(aR,oR);function cR(e,t=`option`){return n=>{let r=n.state.field(aR,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(IL).interactionDelay)return!1;let i=1,a;t==`page`&&(a=uk(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:zL.of(s)}),!0}}var lR=e=>{let t=e.state.field(aR,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(IL).interactionDelay?!1:oR(e,t.open.options[t.open.selected])},uR=e=>e.state.field(aR,!1)?(e.dispatch({effects:ML.of(!0)}),!0):!1,dR=e=>{let t=e.state.field(aR,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:NL.of(null)}),!0)},fR=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},pR=50,mR=1e3,hR=Qw.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(aR).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(aR),n=e.state.facet(IL);if(!e.selectionSet&&!e.docChanged&&e.startState.field(aR)==t)return;let r=e.transactions.some(e=>{let t=eR(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>pR&&Date.now()-n.time>mR){for(let e of n.context.abortListeners)try{e()}catch(e){Jw(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(ML)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(aR);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(IL).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new bL(t,EL(t),e.explicit,this.view),r=new fR(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:NL.of(null)}),Jw(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(IL).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(IL),n=this.view.state.field(aR);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=EL(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new nR(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new tR(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:iR.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(aR,!1);if(t&&t.tooltip&&this.view.state.facet(IL).closeOnBlur){let n=t.open&&uk(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:NL.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ML.of(!1)}),20),this.composing=0}}}),gR=typeof navigator==`object`&&/Win/.test(navigator.platform),_R=Yx.highest(Y.domEventHandlers({keydown(e,t){let n=t.state.field(aR,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(gR&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&oR(t,r),!1}})),vR=Y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),yR=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},bR=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,Ox.TrackDel),r=t.mapPos(this.to,1,Ox.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},xR=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(Fj);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new bR(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new yR(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},SR=J.widget({widget:new class extends kC{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),CR=J.mark({class:`cm-snippetField`}),wR=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=J.set(e.map(e=>(e.from==e.to?SR:CR).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},TR=pS.define({map(e,t){return e&&e.map(t)}}),ER=pS.define(),DR=Kx.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(TR))return n.value;if(n.is(ER)&&e)return new wR(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>Y.decorations.from(e,e=>e?e.deco:J.none)});function OR(e,t){return G.create(e.filter(e=>e.field==t).map(e=>G.range(e.from,e.to)))}function kR(e){let t=xR.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:ux.of(a)},scrollIntoView:!0,annotations:n?[OL.of(n),mS.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=OR(o,0)),o.some(e=>e.field>0)){let t=new wR(o,0),n=c.effects=[TR.of(t)];e.state.field(DR,!1)===void 0&&n.push(pS.appendConfig.of([DR,NR,FR,vR]))}e.dispatch(e.state.update(c))}}function AR(e){return({state:t,dispatch:n})=>{let r=t.field(DR,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:OR(r.ranges,i),effects:TR.of(a?null:new wR(r.ranges,i)),scrollIntoView:!0})),!0}}var jR=[{key:`Tab`,run:AR(1),shift:AR(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(DR,!1)?(t(e.update({effects:TR.of(null)})),!0):!1}],MR=K.define({combine(e){return e.length?e[0]:jR}}),NR=Yx.highest(mO.compute([MR],e=>e.facet(MR)));function PR(e,t){return{...t,apply:kR(e)}}var FR=Y.domEventHandlers({mousedown(e,t){let n=t.state.field(DR,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:OR(n.ranges,i.field),effects:TR.of(n.ranges.some(e=>e.field>i.field)?new wR(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),IR={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},LR=pS.define({map(e,t){return t.mapPos(e,-1,Ox.TrackAfter)??void 0}}),RR=new class extends AS{};RR.startSide=1,RR.endSide=-1;var zR=Kx.define({create(){return FS.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(LR)&&(e=e.update({add:[RR.range(n.value,n.value+1)]}));return e}});function BR(){return[GR,zR]}var VR=`()[]{}<>«»»«[]{}`;function HR(e){for(let t=0;t<16;t+=2)if(VR.charCodeAt(t)==e)return VR.charAt(t+1);return Tx(e<128?e:e+1)}function UR(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||IR}var WR=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),GR=Y.inputHandler.of((e,t,n,r)=>{if((WR?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Ex(wx(r,0))==1||t!=i.from||n!=i.to)return!1;let a=qR(e.state,r);return a?(e.dispatch(a),!0):!1}),KR=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=UR(e,e.selection.main.head).brackets||IR.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=XR(e.doc,t.head);for(let i of n)if(i==r&&YR(e.doc,t.head)==HR(wx(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:G.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function qR(e,t){let n=UR(e,e.selection.main.head),r=n.brackets||IR.brackets;for(let i of r){let a=HR(wx(i,0));if(t==i)return a==i?$R(e,i,r.indexOf(i+i+i)>-1,n):ZR(e,i,a,n.before||IR.before);if(t==a&&JR(e,e.selection.main.from))return QR(e,i,a)}return null}function JR(e,t){let n=!1;return e.field(zR).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function YR(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Ex(wx(n,0)))}function XR(e,t){let n=e.sliceString(t-2,t);return Ex(wx(n,0))==n.length?n:n.slice(1)}function ZR(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:LR.of(a.to+t.length),range:G.range(a.anchor+t.length,a.head+t.length)};let o=YR(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:LR.of(a.head+t.length),range:G.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function QR(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&YR(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:G.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function $R(e,t,n,r){let i=r.stringPrefixes||IR.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:LR.of(r.to+t.length),range:G.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=YR(e.doc,o),c;if(s==t){if(ez(e,o))return{changes:{insert:t+t,from:o},effects:LR.of(o+t.length),range:G.cursor(o+t.length)};if(JR(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:G.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=nz(e,o-2*t.length,i))>-1&&ez(e,c))return{changes:{insert:t+t+t+t,from:o},effects:LR.of(o+t.length),range:G.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=CS.Word&&nz(e,o,i)>-1&&!tz(e,o,t,i))return{changes:{insert:t+t,from:o},effects:LR.of(o+t.length),range:G.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function ez(e,t){let n=Cj(e).resolveInner(t+1);return n.parent&&n.from==t}function tz(e,t,n,r){let i=Cj(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function nz(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=CS.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=CS.Word)return n}return-1}function rz(e={}){return[_R,aR,IL.of(e),hR,az,vR]}var iz=[{key:`Ctrl-Space`,run:uR},{mac:"Alt-`",run:uR},{mac:`Alt-i`,run:uR},{key:`Escape`,run:dR},{key:`ArrowDown`,run:cR(!0)},{key:`ArrowUp`,run:cR(!1)},{key:`PageDown`,run:cR(!0,`page`)},{key:`PageUp`,run:cR(!1,`page`)},{key:`Enter`,run:lR}],az=Yx.highest(mO.computeN([IL],e=>e.facet(IL).defaultKeymap?[iz]:[]));function $(e){return new Nj(aN.define(e))}function oz(e){return W(()=>import(`./dist-B8ZWpW4i.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([7,8]),import.meta.url)}var sz=[Q.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return W(()=>import(`./dist-CtpPIyFY.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return W(()=>import(`./dist-CtpPIyFY.js`).then(e=>e.cpp()),__vite__mapDeps([9,8]),import.meta.url)}}),Q.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return oz(`Cassandra`)}}),Q.of({name:`CSS`,extensions:[`css`],load(){return W(()=>import(`./dist-C1FbzTlR.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([10,8]),import.meta.url)}}),Q.of({name:`Go`,extensions:[`go`],load(){return W(()=>import(`./dist-xjcaveNh.js`).then(e=>e.go()),__vite__mapDeps([11,8]),import.meta.url)}}),Q.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return W(()=>import(`./dist-SOaE0trD.js`).then(e=>e.html()),__vite__mapDeps([12,10,8,13]),import.meta.url)}}),Q.of({name:`Java`,extensions:[`java`],load(){return W(()=>import(`./dist-CQj_mZtX.js`).then(e=>e.java()),__vite__mapDeps([14,8]),import.meta.url)}}),Q.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return W(()=>import(`./dist-CprtF_Yw.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return W(()=>import(`./dist-BZzeSVME.js`).then(e=>e.jinja()),__vite__mapDeps([15,12,10,8,13]),import.meta.url)}}),Q.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return W(()=>import(`./dist-DNQ5Xgkl.js`).then(e=>e.json()),__vite__mapDeps([16,8]),import.meta.url)}}),Q.of({name:`JSX`,extensions:[`jsx`],load(){return W(()=>import(`./dist-CprtF_Yw.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`LESS`,extensions:[`less`],load(){return W(()=>import(`./dist-BI5M27-4.js`).then(e=>e.less()),__vite__mapDeps([17,10,8]),import.meta.url)}}),Q.of({name:`Liquid`,extensions:[`liquid`],load(){return W(()=>import(`./dist-loAWb-yY.js`).then(e=>e.liquid()),__vite__mapDeps([18,12,10,8,13]),import.meta.url)}}),Q.of({name:`MariaDB SQL`,load(){return oz(`MariaSQL`)}}),Q.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return W(()=>import(`./dist-BE76hYy3.js`).then(e=>e.markdown()),__vite__mapDeps([19,12,10,8,13]),import.meta.url)}}),Q.of({name:`MS SQL`,load(){return oz(`MSSQL`)}}),Q.of({name:`MySQL`,load(){return oz(`MySQL`)}}),Q.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return W(()=>import(`./dist-qmkcKPdJ.js`).then(e=>e.php()),__vite__mapDeps([20,12,10,8,13]),import.meta.url)}}),Q.of({name:`PLSQL`,extensions:[`pls`],load(){return oz(`PLSQL`)}}),Q.of({name:`PostgreSQL`,load(){return oz(`PostgreSQL`)}}),Q.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return W(()=>import(`./dist-BbsQ32yZ.js`).then(e=>e.python()),__vite__mapDeps([21,8]),import.meta.url)}}),Q.of({name:`Rust`,extensions:[`rs`],load(){return W(()=>import(`./dist-DhwceB_X.js`).then(e=>e.rust()),__vite__mapDeps([22,8]),import.meta.url)}}),Q.of({name:`Sass`,extensions:[`sass`],load(){return W(()=>import(`./dist-CltMulHu.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SCSS`,extensions:[`scss`],load(){return W(()=>import(`./dist-CltMulHu.js`).then(e=>e.sass()),__vite__mapDeps([23,10,8]),import.meta.url)}}),Q.of({name:`SQL`,extensions:[`sql`],load(){return oz(`StandardSQL`)}}),Q.of({name:`SQLite`,load(){return oz(`SQLite`)}}),Q.of({name:`TSX`,extensions:[`tsx`],load(){return W(()=>import(`./dist-CprtF_Yw.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return W(()=>import(`./dist-CprtF_Yw.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([13,8]),import.meta.url)}}),Q.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return W(()=>import(`./dist-Br4tabXH.js`).then(e=>e.wast()),__vite__mapDeps([24,8]),import.meta.url)}}),Q.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return W(()=>import(`./dist-Cs_CrFvx.js`).then(e=>e.xml()),__vite__mapDeps([25,8]),import.meta.url)}}),Q.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return W(()=>import(`./dist-FWZSQYuG.js`).then(e=>e.yaml()),__vite__mapDeps([26,8]),import.meta.url)}}),Q.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return W(()=>import(`./apl-CnwPGSsG.js`).then(e=>$(e.apl)),[],import.meta.url)}}),Q.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return W(()=>import(`./asciiarmor-qTkVPQu6.js`).then(e=>$(e.asciiArmor)),[],import.meta.url)}}),Q.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return W(()=>import(`./asn1-Dr8qZg38.js`).then(e=>$(e.asn1({}))),[],import.meta.url)}}),Q.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return W(()=>import(`./asterisk-Bja0s6e1.js`).then(e=>$(e.asterisk)),[],import.meta.url)}}),Q.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return W(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[],import.meta.url)}}),Q.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return W(()=>import(`./cobol-B_OZ4V-R.js`).then(e=>$(e.cobol)),[],import.meta.url)}}),Q.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.csharp)),[],import.meta.url)}}),Q.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`ClojureScript`,extensions:[`cljs`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return W(()=>import(`./css-CYpP4FRV.js`).then(e=>$(e.gss)),[],import.meta.url)}}),Q.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return W(()=>import(`./cmake-CyVbuzPu.js`).then(e=>$(e.cmake)),[],import.meta.url)}}),Q.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return W(()=>import(`./coffeescript-B2pKbFk8.js`).then(e=>$(e.coffeeScript)),[],import.meta.url)}}),Q.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return W(()=>import(`./commonlisp-CcllspGY.js`).then(e=>$(e.commonLisp)),[],import.meta.url)}}),Q.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return W(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[],import.meta.url)}}),Q.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return W(()=>import(`./python-BqYw9LYJ.js`).then(e=>$(e.cython)),[],import.meta.url)}}),Q.of({name:`Crystal`,extensions:[`cr`],load(){return W(()=>import(`./crystal-M5-qzICs.js`).then(e=>$(e.crystal)),[],import.meta.url)}}),Q.of({name:`D`,extensions:[`d`],load(){return W(()=>import(`./d-BhMjBjQP.js`).then(e=>$(e.d)),[],import.meta.url)}}),Q.of({name:`Dart`,extensions:[`dart`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.dart)),[],import.meta.url)}}),Q.of({name:`diff`,extensions:[`diff`,`patch`],load(){return W(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[],import.meta.url)}}),Q.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return W(()=>import(`./dockerfile-BLkNEvjs.js`).then(e=>$(e.dockerFile)),__vite__mapDeps([27,28]),import.meta.url)}}),Q.of({name:`DTD`,extensions:[`dtd`],load(){return W(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[],import.meta.url)}}),Q.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return W(()=>import(`./dylan-C6jEEEk-.js`).then(e=>$(e.dylan)),[],import.meta.url)}}),Q.of({name:`EBNF`,load(){return W(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[],import.meta.url)}}),Q.of({name:`ECL`,extensions:[`ecl`],load(){return W(()=>import(`./ecl-BSZaIHnp.js`).then(e=>$(e.ecl)),[],import.meta.url)}}),Q.of({name:`edn`,extensions:[`edn`],load(){return W(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[],import.meta.url)}}),Q.of({name:`Eiffel`,extensions:[`e`],load(){return W(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[],import.meta.url)}}),Q.of({name:`Elm`,extensions:[`elm`],load(){return W(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[],import.meta.url)}}),Q.of({name:`Erlang`,extensions:[`erl`],load(){return W(()=>import(`./erlang-DaB2Rkuy.js`).then(e=>$(e.erlang)),[],import.meta.url)}}),Q.of({name:`Esper`,load(){return W(()=>import(`./sql-DcCJ9jop.js`).then(e=>$(e.esper)),[],import.meta.url)}}),Q.of({name:`Factor`,extensions:[`factor`],load(){return W(()=>import(`./factor-D7LVTn2l.js`).then(e=>$(e.factor)),__vite__mapDeps([29,28]),import.meta.url)}}),Q.of({name:`FCL`,load(){return W(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[],import.meta.url)}}),Q.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return W(()=>import(`./forth-Cezjo90N.js`).then(e=>$(e.forth)),[],import.meta.url)}}),Q.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return W(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[],import.meta.url)}}),Q.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[],import.meta.url)}}),Q.of({name:`Gas`,extensions:[`s`],load(){return W(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[],import.meta.url)}}),Q.of({name:`Gherkin`,extensions:[`feature`],load(){return W(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[],import.meta.url)}}),Q.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return W(()=>import(`./groovy-BC3IOsC8.js`).then(e=>$(e.groovy)),[],import.meta.url)}}),Q.of({name:`Haskell`,extensions:[`hs`],load(){return W(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[],import.meta.url)}}),Q.of({name:`Haxe`,extensions:[`hx`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.haxe)),[],import.meta.url)}}),Q.of({name:`HXML`,extensions:[`hxml`],load(){return W(()=>import(`./haxe-DIz0ZZqd.js`).then(e=>$(e.hxml)),[],import.meta.url)}}),Q.of({name:`HTTP`,load(){return W(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[],import.meta.url)}}),Q.of({name:`IDL`,extensions:[`pro`],load(){return W(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[],import.meta.url)}}),Q.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return W(()=>import(`./javascript-9Tg8ixDm.js`).then(e=>$(e.jsonld)),[],import.meta.url)}}),Q.of({name:`Julia`,extensions:[`jl`],load(){return W(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[],import.meta.url)}}),Q.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.kotlin)),[],import.meta.url)}}),Q.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return W(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[],import.meta.url)}}),Q.of({name:`Lua`,extensions:[`lua`],load(){return W(()=>import(`./lua-CiA1ziua.js`).then(e=>$(e.lua)),[],import.meta.url)}}),Q.of({name:`mIRC`,extensions:[`mrc`],load(){return W(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[],import.meta.url)}}),Q.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return W(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[],import.meta.url)}}),Q.of({name:`Modelica`,extensions:[`mo`],load(){return W(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[],import.meta.url)}}),Q.of({name:`MUMPS`,extensions:[`mps`],load(){return W(()=>import(`./mumps-CW_TBmxz.js`).then(e=>$(e.mumps)),[],import.meta.url)}}),Q.of({name:`Mbox`,extensions:[`mbox`],load(){return W(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[],import.meta.url)}}),Q.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return W(()=>import(`./nginx-BMaDbqW3.js`).then(e=>$(e.nginx)),[],import.meta.url)}}),Q.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return W(()=>import(`./nsis-AQ_alPln.js`).then(e=>$(e.nsis)),__vite__mapDeps([30,28]),import.meta.url)}}),Q.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return W(()=>import(`./ntriples-d28e9m0E.js`).then(e=>$(e.ntriples)),[],import.meta.url)}}),Q.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveC)),[],import.meta.url)}}),Q.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.objectiveCpp)),[],import.meta.url)}}),Q.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[],import.meta.url)}}),Q.of({name:`Octave`,extensions:[`m`],load(){return W(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[],import.meta.url)}}),Q.of({name:`Oz`,extensions:[`oz`],load(){return W(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[],import.meta.url)}}),Q.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return W(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[],import.meta.url)}}),Q.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return W(()=>import(`./perl-CdEHsPfU.js`).then(e=>$(e.perl)),[],import.meta.url)}}),Q.of({name:`Pig`,extensions:[`pig`],load(){return W(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[],import.meta.url)}}),Q.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return W(()=>import(`./powershell-CzG71I4L.js`).then(e=>$(e.powerShell)),[],import.meta.url)}}),Q.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return W(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[],import.meta.url)}}),Q.of({name:`ProtoBuf`,extensions:[`proto`],load(){return W(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[],import.meta.url)}}),Q.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return W(()=>import(`./pug-Bugr-47h.js`).then(e=>$(e.pug)),__vite__mapDeps([31,32]),import.meta.url)}}),Q.of({name:`Puppet`,extensions:[`pp`],load(){return W(()=>import(`./puppet-B4hC2X4m.js`).then(e=>$(e.puppet)),[],import.meta.url)}}),Q.of({name:`Q`,extensions:[`q`],load(){return W(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[],import.meta.url)}}),Q.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return W(()=>import(`./r-DADKenSm.js`).then(e=>$(e.r)),[],import.meta.url)}}),Q.of({name:`RPM Changes`,load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[],import.meta.url)}}),Q.of({name:`RPM Spec`,extensions:[`spec`],load(){return W(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[],import.meta.url)}}),Q.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return W(()=>import(`./ruby-DsYpTuWg.js`).then(e=>$(e.ruby)),[],import.meta.url)}}),Q.of({name:`SAS`,extensions:[`sas`],load(){return W(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[],import.meta.url)}}),Q.of({name:`Scala`,extensions:[`scala`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.scala)),[],import.meta.url)}}),Q.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return W(()=>import(`./scheme-CyDdOh7e.js`).then(e=>$(e.scheme)),[],import.meta.url)}}),Q.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return W(()=>import(`./shell-Du5Qg9im.js`).then(e=>$(e.shell)),[],import.meta.url)}}),Q.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return W(()=>import(`./sieve-BAxa3IjF.js`).then(e=>$(e.sieve)),[],import.meta.url)}}),Q.of({name:`Smalltalk`,extensions:[`st`],load(){return W(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[],import.meta.url)}}),Q.of({name:`Solr`,load(){return W(()=>import(`./solr-BBopId9w.js`).then(e=>$(e.solr)),[],import.meta.url)}}),Q.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return W(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[],import.meta.url)}}),Q.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return W(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[],import.meta.url)}}),Q.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return W(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[],import.meta.url)}}),Q.of({name:`Squirrel`,extensions:[`nut`],load(){return W(()=>import(`./clike-DHH8Ad3s.js`).then(e=>$(e.squirrel)),[],import.meta.url)}}),Q.of({name:`Stylus`,extensions:[`styl`],load(){return W(()=>import(`./stylus-DLLZ8dgm.js`).then(e=>$(e.stylus)),[],import.meta.url)}}),Q.of({name:`Swift`,extensions:[`swift`],load(){return W(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[],import.meta.url)}}),Q.of({name:`sTeX`,load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return W(()=>import(`./stex-sDrdk2BW.js`).then(e=>$(e.stex)),[],import.meta.url)}}),Q.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`Tcl`,extensions:[`tcl`],load(){return W(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[],import.meta.url)}}),Q.of({name:`Textile`,extensions:[`textile`],load(){return W(()=>import(`./textile-DWBqthVk.js`).then(e=>$(e.textile)),[],import.meta.url)}}),Q.of({name:`TiddlyWiki`,load(){return W(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[],import.meta.url)}}),Q.of({name:`Tiki wiki`,load(){return W(()=>import(`./tiki-CxVlf5KZ.js`).then(e=>$(e.tiki)),[],import.meta.url)}}),Q.of({name:`TOML`,extensions:[`toml`],load(){return W(()=>import(`./toml-LvoKBwCs.js`).then(e=>$(e.toml)),[],import.meta.url)}}),Q.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return W(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[],import.meta.url)}}),Q.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return W(()=>import(`./ttcn-BePYh-hG.js`).then(e=>$(e.ttcn)),[],import.meta.url)}}),Q.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return W(()=>import(`./ttcn-cfg-CY0aot7Q.js`).then(e=>$(e.ttcnCfg)),[],import.meta.url)}}),Q.of({name:`Turtle`,extensions:[`ttl`],load(){return W(()=>import(`./turtle-BDLWE2cD.js`).then(e=>$(e.turtle)),[],import.meta.url)}}),Q.of({name:`Web IDL`,extensions:[`webidl`],load(){return W(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[],import.meta.url)}}),Q.of({name:`VB.NET`,extensions:[`vb`],load(){return W(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[],import.meta.url)}}),Q.of({name:`VBScript`,extensions:[`vbs`],load(){return W(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[],import.meta.url)}}),Q.of({name:`Velocity`,extensions:[`vtl`],load(){return W(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[],import.meta.url)}}),Q.of({name:`Verilog`,extensions:[`v`],load(){return W(()=>import(`./verilog-D-x6ne0Z.js`).then(e=>$(e.verilog)),[],import.meta.url)}}),Q.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return W(()=>import(`./vhdl-CMrOq2q1.js`).then(e=>$(e.vhdl)),[],import.meta.url)}}),Q.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return W(()=>import(`./xquery-fj_R-kMw.js`).then(e=>$(e.xQuery)),[],import.meta.url)}}),Q.of({name:`Yacas`,extensions:[`ys`],load(){return W(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[],import.meta.url)}}),Q.of({name:`Z80`,extensions:[`z80`],load(){return W(()=>import(`./z80-CL1naaMV.js`).then(e=>$(e.z80)),[],import.meta.url)}}),Q.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[],import.meta.url)}}),Q.of({name:`Xù`,extensions:[`xu`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[],import.meta.url)}}),Q.of({name:`MsGenny`,extensions:[`msgenny`],load(){return W(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[],import.meta.url)}}),Q.of({name:`Vue`,extensions:[`vue`],load(){return W(()=>import(`./dist-FgO6dUv_.js`).then(e=>e.vue()),__vite__mapDeps([33,12,10,8,13]),import.meta.url)}}),Q.of({name:`Angular Template`,load(){return W(()=>import(`./dist-B4yXtSg3.js`).then(e=>e.angular()),__vite__mapDeps([34,12,10,8,13]),import.meta.url)}})];function cz(e){let t=String(e||``).split(`/`).pop()||``,n=t.lastIndexOf(`.`);return n>=0?t.slice(n):``}function lz(e){return Q.matchFilename(sz,`file${e}`)}function uz({content:e,path:t,readOnly:n=!1,onSave:r,onDirtyChange:i,onContentChange:a,getContentRef:o}){let s=(0,b.useRef)(null),c=(0,b.useRef)(null),l=(0,b.useRef)(new Zx),u=(0,b.useRef)(new Zx),d=(0,b.useRef)(new Zx),f=(0,b.useRef)(!1),p=(0,b.useRef)(r),m=(0,b.useRef)(i),h=(0,b.useRef)(a);(0,b.useEffect)(()=>{p.current=r,m.current=i,h.current=a},[r,i,a]);let g=(0,b.useCallback)(e=>{f.current!==e&&(f.current=e,m.current?.(e))},[]);return(0,b.useEffect)(()=>{if(!s.current)return;let r=document.documentElement.classList.contains(`dark`),i=mO.of([{key:`Mod-s`,run:e=>{let t=e.state.doc.toString();return p.current?.(t),g(!1),!0},preventDefault:!0}]),a=new Y({state:OS.create({doc:e,extensions:[Uk(),qk(),RN(),OM(),MO(),VO(),OS.allowMultipleSelections.of(!0),eM(),PM(LM,{fallback:!0}),qM(),BR(),rz(),XO(),$O(),HO(),CI(),mO.of([...KR,...GF,...fL,...rP,...yM,...iz,KF]),i,Y.updateListener.of(e=>{e.docChanged&&(g(!0),h.current?.(e.state.doc.toString()))}),d.current.of(OS.readOnly.of(n)),l.current.of([]),u.current.of(r?lI:[]),Y.theme({"&":{height:`100%`},".cm-scroller":{overflow:`auto`}})]}),parent:s.current});c.current=a,o&&(o.current=()=>a.state.doc.toString());let f=lz(cz(t));return f&&f.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}),()=>{a.destroy(),c.current=null,o&&(o.current=null)}},[]),(0,b.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),g(!1))},[e,g]),(0,b.useEffect)(()=>{let e=c.current;if(!e)return;let n=lz(cz(t));n?n.load().then(e=>{c.current&&c.current.dispatch({effects:l.current.reconfigure(e)})}).catch(()=>{}):e.dispatch({effects:l.current.reconfigure([])})},[t]),(0,b.useEffect)(()=>{let e=c.current;e&&e.dispatch({effects:d.current.reconfigure(OS.readOnly.of(n))})},[n]),(0,b.useEffect)(()=>{let e=new MutationObserver(()=>{let e=c.current;if(!e)return;let t=document.documentElement.classList.contains(`dark`);e.dispatch({effects:u.current.reconfigure(t?lI:[])})});return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]),(0,L.jsx)(`div`,{ref:s,className:`h-full w-full overflow-hidden [&_.cm-editor]:h-full [&_.cm-scroller]:auto`})}function dz({content:e,objectUrl:t,kind:n,filename:r,path:i}){return n===`markdown`?(0,L.jsx)($y,{content:e||``}):n===`image`&&t?(0,L.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,L.jsx)(`img`,{src:t,alt:r,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n===`pdf`&&t?(0,L.jsx)(`iframe`,{src:t,title:r,className:`h-full w-full border-0`}):(n===`text`||n===`code`)&&e!==null?(0,L.jsx)(uz,{content:e,path:i||r,readOnly:!0,onSave:()=>{},onDirtyChange:()=>{},getContentRef:{current:()=>e||``}}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center`,children:(0,L.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:`该文件类型暂不支持在线预览,请直接下载查看。`})})}function fz(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function pz(e){let t=e.endsWith(`/`)?e:`${e}/`;if(typeof window>`u`)return`'self'`;try{return new URL(t,window.location.origin).toString()}catch{return`'self'`}}function mz(...e){return Array.from(new Set(e.filter(e=>!!e))).join(` `)}function hz(e){let t=e?pz(e):void 0,n=mz(`'unsafe-inline'`,`'unsafe-eval'`,`'self'`,`https:`,t),r=mz(`'self'`,`https:`,t);return[`default-src 'none'`,`script-src ${n}`,`style-src 'unsafe-inline' data: ${r}`,`img-src data: blob: ${r}`,`font-src data: ${r}`,`media-src data: blob: ${r}`,`worker-src blob:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'self'`].join(`; `)}function gz(e){try{let t=new URL(e,window.location.href);return[`http:`,`https:`,`mailto:`].includes(t.protocol)}catch{return!1}}function _z(e,t={}){let{channelId:n,basePath:r}=typeof t==`string`?{channelId:t}:t,i=hz(r),a=`<script>
|
|
134
134
|
function ksadkScrollToHash(rawHref) {
|
|
135
135
|
if (!rawHref || rawHref === '#') return;
|
|
136
136
|
var rawId = rawHref.slice(1);
|
|
@@ -162,4 +162,4 @@ document.addEventListener('click', function(event) {
|
|
|
162
162
|
}, '*');
|
|
163
163
|
}
|
|
164
164
|
}, true);
|
|
165
|
-
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${fz(i)}">`}${r?`<base href="${fz(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function vz(e,t){let n=(0,b.useRef)(null);(0,b.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&gz(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function yz({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),[c,l]=(0,b.useState)(`preview`),u=Pe(t),d=Ne(t),f=(0,b.useCallback)(()=>_z(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,b.useState)(f());(0,b.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),vz(o,s);let h=(0,b.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,L.jsxs)(`button`,{onClick:()=>l(`editor`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,L.jsxs)(`button`,{onClick:()=>l(`preview`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,L.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`})]}):c===`editor`?(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,L.jsxs)(`button`,{onClick:()=>l(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`}),(0,L.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,L.jsxs)(`button`,{onClick:h,className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,title:`在新窗口中打开当前预览`,children:[(0,L.jsx)(Zr,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,L.jsxs)(`button`,{onClick:()=>l(`editor`),className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function bz(e){e.current&&clearTimeout(e.current)}function xz({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,b.useState)(`editor`),[c,l]=(0,b.useState)(e),u=(0,b.useRef)(null);return(0,b.useEffect)(()=>(bz(u),u.current=setTimeout(()=>l(e),300),()=>bz(u)),[e]),a?(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30`,children:[(0,L.jsxs)(`button`,{onClick:()=>s(`editor`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,L.jsxs)(`button`,{onClick:()=>s(`preview`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,L.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,L.jsx)($y,{content:c})})]}):o===`editor`?(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,L.jsxs)(`button`,{onClick:()=>s(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,L.jsx)($y,{content:c})}),(0,L.jsxs)(`button`,{onClick:()=>s(`editor`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Sz=`/agentengine/api/v1/GetWorkspaceFileContent`,Cz=4e3;function wz(e){let t=je(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function Tz(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Ez(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}var Dz=[{label:`Markdown`,detail:`.md .markdown .mdx`},{label:`代码/文本`,detail:`.py .js .ts .tsx .json .yaml .log .txt`},{label:`图片`,detail:`PNG JPG GIF WebP SVG`},{label:`PDF`,detail:`.pdf`},{label:`表格文本`,detail:`CSV TSV`}];function Oz(e){return Ne(e)}function kz({label:e,showSupportedTypes:t=!1}){return(0,L.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:[(0,L.jsx)(`div`,{children:e}),t?(0,L.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,L.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,L.jsx)(`div`,{className:`mt-2 grid gap-2`,children:Dz.map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,L.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,L.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Az({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(`.`),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(``),[T,ee]=(0,b.useState)(null),[E,D]=(0,b.useState)(null),[O,te]=(0,b.useState)(!1),[ne,re]=(0,b.useState)(!1),ie=(0,b.useRef)(null),ae=(0,b.useRef)(null),oe=(0,b.useRef)(`selection`),k=(0,b.useRef)(We()),A=(0,b.useMemo)(()=>m.find(e=>e.Path===T)??null,[m,T]),se=(0,b.useMemo)(()=>A?He({path:A.Path,mimeType:A.MimeType}):null,[A]),ce=(0,b.useCallback)(()=>O?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[O]),le=t.ContentPath||Sz,ue=t.RootLabel||`Workspace`,j=ue?`${ue.charAt(0).toUpperCase()}${ue.slice(1)}`:`Workspace`,de=Ie(f),fe=(0,b.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,b.useEffect)(()=>()=>fe(),[fe]);let pe=(0,b.useCallback)(async(t,n={})=>{let r=!!n.background;r?y(!0):_(!0),r||w(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=je(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),oe.current=r?`background-refresh`:`selection`,ee(e=>{if(e){let t=a.find(t=>t.Path===e);if(t&&t.Type===`file`)return e}return a.find(e=>e.Type===`file`)?.Path??null})}catch(e){console.error(`Failed to load workspace entries:`,e),r||w(e instanceof Error?e.message:String(e))}finally{r?y(!1):_(!1)}},[e,s]);(0,b.useEffect)(()=>{!n||u||(d(!0),pe(`.`))},[u,pe,n]),(0,b.useEffect)(()=>{if(!n||O||!u)return;let e=window.setInterval(()=>{pe(f,{background:!0})},Cz);return()=>window.clearInterval(e)},[f,O,u,pe,n]);let me=(0,b.useCallback)(async t=>{let n=k.current.next(t.Path),r=Be({path:t.Path,mimeType:t.MimeType});if(ae.current=t.Path,r===`unsupported`){fe(),D({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}fe(),D({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!k.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Be({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,D({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!k.current.isCurrent(n))return;let o=Be({path:t.Path,mimeType:e});D({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Be({path:t.Path,mimeType:e});D({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!k.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),D({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,fe]);(0,b.useEffect)(()=>{if(!A||A.Type!==`file`){fe(),D(null),te(!1),ae.current=null;return}if(oe.current===`background-refresh`&&ae.current===A.Path){oe.current=`selection`;return}oe.current=`selection`,me(A)},[fe,me,A]);let he=async n=>{if(!(!n||n.length===0)){S(!0),w(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=Fe(f)?r.name:`${f}/${r.name}`,i=new FormData;i.append(`file`,r),i.append(`AgentId`,e),i.append(`Path`,n),await s.addWorkspaceFile(i)}await pe(f)}catch(e){console.error(`Failed to upload workspace files:`,e),w(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),S(!1)}}},ge=async n=>{if(!t.SupportsDelete)return;let r=je(n.Path);if(window.confirm(`删除 ${r} ?`)){w(``);try{await s.deleteWorkspaceFile(e,r),T&&je(T)===r&&(ee(null),te(!1)),await pe(n.Type===`directory`&&(je(f)===r||je(f).startsWith(`${r}/`))?wz(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),w(e instanceof Error?e.message:String(e))}}},_e=()=>!A||A.Type!==`file`?(0,L.jsx)(kz,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!E||E.path!==A.Path||E.status===`loading`?(0,L.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,L.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400`,children:[(0,L.jsx)(ri,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):E.status===`error`?(0,L.jsx)(kz,{label:E.error||`文件预览加载失败。`}):E.kind===`markdown`?(0,L.jsx)(xz,{content:E.content||``,path:A.Path,onSave:ve,onDirtyChange:te,getContentRef:ie,isMobile:o}):E.kind===`image`&&E.objectUrl?(0,L.jsx)(dz,{content:null,objectUrl:E.objectUrl,kind:`image`,filename:A.Name,mimeType:E.mimeType||``}):E.kind===`pdf`&&E.objectUrl?(0,L.jsx)(dz,{content:null,objectUrl:E.objectUrl,kind:`pdf`,filename:A.Name,mimeType:E.mimeType||``}):E.kind===`html`?(0,L.jsx)(yz,{content:E.content||``,path:A.Path,onSave:ve,onDirtyChange:te,getContentRef:ie,isMobile:o,agentId:e,contentPath:le}):E.kind===`text`||E.kind===`code`?(0,L.jsx)(uz,{content:E.content||``,path:A.Path,onSave:ve,onDirtyChange:te,getContentRef:ie}):(0,L.jsx)(dz,{content:null,kind:`unsupported`,filename:A.Name,mimeType:E.mimeType||``}),ve=async t=>{if(A){re(!0),w(``);try{let n=new Blob([t],{type:A.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,A.Name),r.append(`AgentId`,e),r.append(`Path`,A.Path),await s.addWorkspaceFile(r),k.current.invalidate(),te(!1),D(e=>e&&e.path===A.Path?{...e,content:t}:e),ae.current=A.Path,await pe(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),w(e instanceof Error?e.message:String(e))}finally{re(!1)}}},ye=A?.Type===`file`&&E?.path===A.Path&&E.status===`ready`&&(E.kind===`text`||E.kind===`code`||E.kind===`html`||E.kind===`markdown`),M=A?.Type===`file`&&E?.path===A.Path&&E.status===`ready`&&E.kind===`pdf`;return(0,L.jsxs)(`div`,{className:`flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200`,children:[(0,L.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:j}),(0,L.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,L.jsx)(`div`,{className:`custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300`,title:`${de},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:de})]}),(0,L.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,L.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void he(e.target.files)}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),disabled:x,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900`,title:`上传文件,上限 ${Math.floor(t.MaxUploadBytes/(1024*1024))}MB`,children:[(0,L.jsx)(wi,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams({Path:f}).toString();window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900`,title:`导出当前目录为 ZIP`,children:[(0,L.jsx)(si,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":i?`退出全屏`:`全屏查看 Workspace`,title:i?`退出全屏`:`全屏查看`,children:i?(0,L.jsx)(oi,{className:`h-4 w-4`}):(0,L.jsx)(ii,{className:`h-4 w-4`})}):null,r?(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&r?.()},className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":`关闭 Workspace`,title:`关闭`,children:(0,L.jsx)(Ti,{className:`h-4 w-4`})}):null]})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,L.jsxs)(`div`,{className:`flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r`,children:[(0,L.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,L.jsxs)(`span`,{children:[m.length,` 项`]}),v?(0,L.jsx)(hi,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&pe(wz(f))},disabled:g||Fe(f),className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`返回上级目录`,children:(0,L.jsx)(Vr,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&pe(f)},disabled:g,className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`刷新目录`,children:(0,L.jsx)(hi,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),C?(0,L.jsx)(`div`,{className:`mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300`,children:C}):null]}),(0,L.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,L.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Be({path:e.Path,mimeType:e.MimeType}),r=T===e.Path,i=e.Type===`file`?Oz(e.Path):``;return(0,L.jsxs)(`div`,{title:e.Path,className:I(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){pe(e.Path);return}T!==e.Path&&!ce()||ee(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,L.jsx)(`div`,{className:I(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,L.jsx)(ti,{className:`h-3.5 w-3.5`}):n===`image`?(0,L.jsx)(ni,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,L.jsx)($r,{className:`h-3.5 w-3.5`}):(0,L.jsx)(ei,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,L.jsx)(`div`,{className:I(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:Ez(e.SizeBytes)})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,L.jsx)(`a`,{href:i,download:e.Name,className:I(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,L.jsx)(Yr,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,L.jsx)(`button`,{type:`button`,onClick:()=>void ge(e),className:I(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,L.jsx)(Ci,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:A?(0,L.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:A.Name}),(0,L.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:A.Path}),(0,L.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[Ez(A.SizeBytes),A.MimeType?` · ${A.MimeType}`:``,A.ModifiedAt?` · ${Tz(A.ModifiedAt)}`:``]})]}),se===`text`||se===`code`||se===`html`||se===`markdown`?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{let e=ie.current;e&&ve(e())},disabled:!O||ne,className:I(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,O&&!ne?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,L.jsx)(gi,{className:`h-3.5 w-3.5`}),ne?`保存中`:O?`保存`:`已保存`]}):null]}):(0,L.jsxs)(`div`,{className:`w-full`,children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,L.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,L.jsx)(`div`,{className:I(`custom-scrollbar min-h-0 flex-1`,M||ye?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:_e()})]})]})]})}function jz({agentId:e,capability:t,workspacePanelOpen:n,workspacePanelWidth:r,workspacePanelFullscreen:i,isMobile:a,workspaceEnabled:o,workspaceFiles:s,workspacePanelPresentation:c,closeWorkspacePanel:l,handleWorkspacePanelResizeStart:u,api:d}){let f=c.renderMode===`inline`,p=c.renderMode===`sheet`;return!o||!s?null:(0,L.jsxs)(L.Fragment,{children:[f?(0,L.jsxs)(L.Fragment,{children:[n&&!i?(0,L.jsx)(`div`,{role:`separator`,"aria-label":`调整 Workspace 宽度`,"aria-orientation":`vertical`,onPointerDown:u,className:`hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block`}):null,(0,L.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:I(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,L.jsx)(Az,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>E.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,L.jsx)(Nl,{open:n,onOpenChange:e=>{e||E.getState().setWorkspacePanelFullscreen(!1),E.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,L.jsxs)(Ll,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:I(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,L.jsx)(Bl,{className:`sr-only`,children:`Workspace 文件`}),(0,L.jsx)(Vl,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,L.jsx)(Az,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}async function Mz(e,t){let n=await ht(`ListSessions`,{AgentId:e,Page:t?.page,PageSize:t?.pageSize},t);return{Sessions:n.Sessions??[],Total:Number.isFinite(Number(n.Total))?Number(n.Total):n.Sessions?.length??0,Page:Number.isFinite(Number(n.Page))?Number(n.Page):t?.page??1,PageSize:Number.isFinite(Number(n.PageSize))?Number(n.PageSize):t?.pageSize??n.Sessions?.length??0}}async function Nz(e,t){return(await ht(`CreateSession`,{AgentId:e},t)).Session}async function Pz(e,t){await ht(`DeleteSession`,{SessionId:e},t)}async function Fz(e,t){let n=await ht(`ListSessionEvents`,{SessionId:e,Offset:t?.offset,Limit:t?.limit},t);return{Events:n.Events??[],Total:Number.isFinite(Number(n.Total))?Number(n.Total):n.Events?.length??0,Offset:Number.isFinite(Number(n.Offset))?Number(n.Offset):t?.offset??0,Limit:Number.isFinite(Number(n.Limit))?Number(n.Limit):t?.limit??n.Events?.length??0}}async function Iz(e,t){return vt(`RunAgent`,e,t)}async function Lz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),ht(`ListSessionCheckpoints`,n,t)}async function Rz(e,t){return ht(`PreviewCheckpointResume`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async function zz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),e.checkpointId&&(n.CheckpointId=e.checkpointId),ht(`ListToolReceipts`,n,t)}async function Bz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0};return e.resumeAttemptId&&(n.ResumeAttemptId=e.resumeAttemptId),e.invocationId&&(n.InvocationId=e.invocationId),vt(`ResumeRun`,n,t)}async function Vz(e,t,n){return ht(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n})}async function Hz(e){return gt(`AddWorkspaceFile`,e)}async function Uz(e,t){return ht(`DeleteWorkspaceFile`,{AgentId:e,Path:t})}async function Wz(e,t,n){return _t(`GetWorkspaceFileContent`,{AgentId:e,FilePath:t},{signal:n?.signal,asText:n?.asText??!0})}async function Gz(e,t){return gt(`UploadFile`,e,t)}var Kz=new class{async listSessions(e,t){return Mz(e,t)}async createSession(e,t){return{SessionId:(await Nz(e,t)).SessionId}}async deleteSession(e,t){await Pz(e,t)}async listSessionEvents(e,t){return Fz(e,t)}async listSessionCheckpoints(e,t){return Lz(e,t)}async previewCheckpointResume(e,t){return Rz(e,t)}async listToolReceipts(e,t){return zz(e,t)}async runAgent(e,t){return Iz(e,t)}async resumeRun(e,t){return Bz(e,t)}async subscribeRunEvents(e,t){return yt(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async cancelRun(e,t,n){return ht(`CancelRun`,{AgentId:e,InvocationId:t},n)}async getResponseFeedback(e,t){return ht(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return ht(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await ht(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n){return Vz(e,t,n)}async addWorkspaceFile(e){return Hz(e)}async deleteWorkspaceFile(e,t){await Uz(e,t)}async getWorkspaceFileContent(e,t,n){return Wz(e,t,n)}async listAgentModels(e){return xt(e)}async getAgentUiBootstrap(){return bt()}async uploadFile(e,t){return Gz(e,t)}},qz=b.lazy(()=>W(()=>import(`./ArtifactsPanel-DWKSsYb9.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Jz=b.lazy(()=>W(()=>import(`./NativeTerminalPanel-DEfOlZBW.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Yz({apiAdapter:e,initialSurface:t=`chat`,routeShell:n}={}){let r=e||Kz,i=se(e=>e.agentId),a=M(e=>e.currentSessionId),o=j(e=>e.isStreaming),s=E(e=>e.sidebarOpen),c=E(e=>e.mobileSidebarOpen),l=E(e=>e.mobileActionsOpen),u=se(e=>e.agentName),d=le(e=>e.selectedModel),f=le(e=>e.availableModels),p=le(e=>e.modelSource),m=le(e=>e.modelCatalogLoaded),h=le(e=>e.thinkingMode),g=se(e=>e.agentFramework),_=se(e=>e.workspaceFiles),v=se(e=>e.accessMode),y=E(e=>e.workspacePanelOpen),x=E(e=>e.workspacePanelWidth),S=E(e=>e.workspacePanelFullscreen),C=se(e=>e.apiFormats),w=se(e=>e.capabilities),T=be(e=>e.visible&&!!e.content),ee=(0,b.useRef)([]),D=(0,b.useRef)(null),{isMobile:O,viewportHeight:te}=lt(),ne=we({isMobile:O,viewportHeight:te}),{fetchSessions:re,loadMoreSessions:ie,loadSession:ae,loadOlderSessionEvents:oe,createNewSession:k,deleteSession:ce,currentSessionIdRef:ue,agentIdRef:de,runSubscriptionAbortRef:fe}=Ar({agentId:i,currentSessionId:a,isMobile:O,uiCapabilities:w,api:r,resetCompaction:()=>{},disconnectRun:()=>D.current?.()}),pe=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{re(de.current,e),ue.current===e&&!j.getState().isStreaming&&ae(e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[de,ue,re,ae]),{submitDraft:me,stopGeneration:he,disconnectRun:ge,resumeCheckpoint:_e}=ur({agentId:i,currentSessionId:a,agentFramework:g,apiFormats:C,selectedModel:d,thinkingMode:h,uiCapabilities:w,isMobile:O,api:r,currentSessionIdRef:ue,agentIdRef:de,queuedDraftRef:ee,onRunSettled:pe});(0,b.useEffect)(()=>{D.current=ge},[ge]);let ve=(0,b.useCallback)(()=>{let e=ue.current;fe.current?.abort(),j.getState().stopActivity(),j.getState().stopSessionActivity(e),he()},[ue,fe,he]),ye=(0,b.useCallback)(async()=>{let e=ue.current,t=j.getState(),n=t.currentRunId||t.getSessionActivity(e)?.runId||``;if(n)try{await r.cancelRun(i,n),j.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),j.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}pe(e)},[r,i,ue,pe]),{submitResponseFeedback:xe,deleteResponseFeedback:Se,respondToApproval:Ce}=xr({agentId:i,currentSessionId:a,isStreaming:o,api:r,submitDraft:me});wt({fetchSessions:re}),(0,b.useEffect)(()=>{de.current=i,ue.current=a,Ze(i,a)},[i,a,de,ue]),(0,b.useEffect)(()=>{O?E.getState().setWorkspacePanelFullscreen(!1):(E.getState().setMobileSidebarOpen(!1),E.getState().setMobileActionsOpen(!1))},[O]),(0,b.useEffect)(()=>{y||E.getState().setWorkspacePanelFullscreen(!1)},[y]),(0,b.useEffect)(()=>()=>{fe.current?.abort()},[fe]);let Te=A(w),Ee=!!w.Thinking,De=Ge({workspaceFiles:_,accessMode:v}),Oe=Ue({isMobile:O}),ke=rt({capability:w.NativeDashboard,agentFramework:g,accessMode:v,origin:window.location.origin}),Ae=!Te,je=g===`openclaw`?`OpenClaw`:g===`hermes`?`Hermes`:`原生运行时`,Me=(f.find(e=>e.id===d)||null)?.display_name||d||``,Ne=!O&&s&&Te,Pe=(0,b.useRef)(!1),[Fe,Ie]=(0,b.useState)(t===`tui`),Le=Fe&&!!w.NativeTerminal?.Enabled;(0,b.useEffect)(()=>{Pe.current||t!==`workspace`||!De||(Pe.current=!0,E.getState().setWorkspacePanelOpen(!0),E.getState().setWorkspacePanelFullscreen(!0))},[t,De]);let Re=(0,L.jsxs)(`div`,{className:`flex h-[var(--app-height)] min-h-[var(--app-height)] overflow-hidden bg-white font-sans text-slate-800 dark:bg-slate-900 dark:text-slate-200`,children:[(0,L.jsx)(Wl,{uiCapabilities:w,createNewSession:k,deleteSession:ce,loadSession:ae,loadMoreSessions:ie}),(0,L.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,L.jsx)(Yb,{agentName:u,currentSessionId:a,nativeLauncherMode:Ae,isMobile:O,sidebarOpen:s,mobileSidebarOpen:c,onToggleSidebar:()=>{O?E.getState().toggleMobileSidebar():E.getState().toggleSidebar()},availableModels:f,selectedModel:d,onSelectModel:e=>{le.getState().setSelectedModel(e),O&&E.getState().setMobileActionsOpen(!1)},selectedModelLabel:Me,modelCatalogLoaded:m,modelSource:p,thinkingEnabled:Ee,thinkingMode:h,onSelectThinkingMode:e=>le.getState().setThinkingMode(at(e)),mobileActionsOpen:l,onMobileActionsOpenChange:e=>E.getState().setMobileActionsOpen(e),workspaceEnabled:De,onOpenWorkspace:()=>E.getState().setWorkspacePanelOpen(!0),nativeManagementLink:ke,nativeTerminal:w.NativeTerminal}),Ae?(0,L.jsx)(Zb,{productLabel:je,nativeManagementLink:ke,nativeTerminal:w.NativeTerminal,workspaceEnabled:De,onOpenWorkspace:()=>E.getState().setWorkspacePanelOpen(!0)}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Vb,{agentName:u,isMobile:O,onDeleteFeedback:Se,onSubmitFeedback:xe,onRespondToApproval:Ce,onStopGeneration:ve,onCancelRemote:w.StopRun?ye:void 0,checkpointResumeEnabled:w.RunLifecycle.Enabled&&w.RunLifecycle.Checkpoints&&w.RunLifecycle.CheckpointResume,onResumeCheckpoint:_e,onLoadOlderSessionEvents:oe}),(0,L.jsx)(Kb,{composerMaxHeight:ne,submitDraft:me,stopGeneration:ve,cancelRemote:w.StopRun?ye:void 0,isMobile:O})]})]}),(0,L.jsx)(jz,{agentId:i,capability:_,workspacePanelOpen:y,workspacePanelWidth:x,workspacePanelFullscreen:S,isMobile:O,workspaceEnabled:De,workspaceFiles:_,workspacePanelPresentation:Oe,closeWorkspacePanel:()=>{E.getState().setWorkspacePanelFullscreen(!1),E.getState().setWorkspacePanelOpen(!1)},handleWorkspacePanelResizeStart:e=>{if(S||O)return;e.preventDefault();let t=e.clientX,n=x,r=Te&&Ne?280:0,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let i=n+t-e.clientX;E.getState().setWorkspacePanelWidth(Qt(i,window.innerWidth,r))},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},api:r}),T&&(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(qz,{})}),Le?(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(Jz,{capability:w.NativeTerminal,open:!0,onClose:()=>Ie(!1)})}):null]});return n?(0,L.jsx)(n,{children:Re}):Re}function Xz(){return(0,L.jsx)(Yz,{})}function Zz(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var Qz=`agentengine-ui:chunk-reload-attempted`,$z=class extends b.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Zz(e))try{window.sessionStorage.getItem(Qz)||(window.sessionStorage.setItem(Qz,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem(Qz)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,L.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,L.jsxs)(`div`,{className:`max-w-md rounded-2xl border border-red-200 bg-white p-8 text-center shadow-lg dark:border-red-900 dark:bg-slate-950`,children:[(0,L.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,L.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,L.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,L.jsx)(`button`,{onClick:this.handleReload,className:`rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-medium text-white transition hover:bg-blue-700`,children:`刷新页面`})]})}):this.props.children}};function eB(){let e=E(e=>e.toasts),t=E(e=>e.dismissToast);return(0,b.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,L.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-3 text-sm shadow-lg transition-all ${e.variant===`error`?`bg-red-600 text-white`:`bg-slate-800 text-white dark:bg-slate-200 dark:text-slate-900`}`,children:[(0,L.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,L.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,L.jsx)(Ti,{size:14})})]},e.id))}):null}T.createRoot(document.getElementById(`root`)).render((0,L.jsxs)($z,{children:[(0,L.jsx)(Xz,{}),(0,L.jsx)(eB,{})]}));export{H as $,Zk as A,OS as B,yj as C,s as Ct,Z as D,YA as E,aA as F,Uy as G,JS as H,kA as I,Eg as J,Ay as K,Y as L,eA as M,TA as N,Jk as O,DA as P,Xd as Q,mO as R,_j as S,o as St,WA as T,eb as U,Yx as V,W,Eh as X,Th as Y,gh as Z,rM as _,Jr as _t,wL as a,ru as at,Bj as b,be as bt,bj as c,so as ct,Ej as d,Ci as dt,Ad as et,JM as f,bi as ft,Zj as g,Yr as gt,Yj as h,Qr as ht,CL as i,ku as it,tA as j,iA as k,Q as l,I as lt,vj as m,pi as mt,vz as n,Mu as nt,PR as o,Kl as ot,Qj as p,hi as pt,k_ as q,bL as r,Nu as rt,Sj as s,Gl as st,_z as t,Pu as tt,Nj as u,Ti as ut,nM as v,Ur as vt,Cj as w,l as wt,Fj as x,p as xt,tM as y,Br as yt,G as z};
|
|
165
|
+
<\/script>`,o=`${`<meta http-equiv="Content-Security-Policy" content="${fz(i)}">`}${r?`<base href="${fz(r)}">`:``}${a}`;return/<head[^>]*>/i.test(e)?e.replace(/<head[^>]*>/i,`$&${o}`):`${o}${e}`}function vz(e,t){let n=(0,b.useRef)(null);(0,b.useEffect)(()=>(n.current=n=>{if(n.source!==e.current?.contentWindow||n.data?.type!==`ksadk:linkClick`||t&&n.data?.channelId!==t)return;let r=n.data?.href;typeof r==`string`&&r&&gz(r)&&window.open(r,`_blank`,`noopener,noreferrer`)},window.addEventListener(`message`,n.current),()=>{n.current&&window.removeEventListener(`message`,n.current)}),[e,t])}function yz({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let o=(0,b.useRef)(null),s=(0,b.useId)(),[c,l]=(0,b.useState)(`preview`),u=Pe(t),d=Ne(t),f=(0,b.useCallback)(()=>_z(e,{basePath:u,channelId:s}),[e,u,s]),[p,m]=(0,b.useState)(f());(0,b.useEffect)(()=>{let e=setTimeout(()=>{m(f())},300);return()=>clearTimeout(e)},[f]),vz(o,s);let h=(0,b.useCallback)(()=>{let e=new Blob([p],{type:`text/html;charset=utf-8`}),t=URL.createObjectURL(e),n=window.open(t,`_blank`,`noopener,noreferrer`);window.setTimeout(()=>URL.revokeObjectURL(t),3e4),n||window.open(d,`_blank`,`noopener,noreferrer`)},[d,p]);return a?(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200 px-2 py-1.5 dark:border-slate-700`,children:[(0,L.jsxs)(`button`,{onClick:()=>l(`editor`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,L.jsxs)(`button`,{onClick:()=>l(`preview`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,c===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}),c===`editor`?(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,L.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`})]}):c===`editor`?(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,L.jsxs)(`button`,{onClick:()=>l(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(`iframe`,{ref:o,srcDoc:p,sandbox:`allow-scripts allow-downloads allow-same-origin`,title:`HTML 预览`,className:`h-full w-full border-0 bg-white`}),(0,L.jsxs)(`div`,{className:`absolute right-3 top-3 z-10 flex gap-1.5`,children:[(0,L.jsxs)(`button`,{onClick:h,className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,title:`在新窗口中打开当前预览`,children:[(0,L.jsx)(Zr,{className:`h-3.5 w-3.5`}),`新窗口`]}),(0,L.jsxs)(`button`,{onClick:()=>l(`editor`),className:`inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]})]})]})}function bz(e){e.current&&clearTimeout(e.current)}function xz({content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i,isMobile:a}){let[o,s]=(0,b.useState)(`editor`),[c,l]=(0,b.useState)(e),u=(0,b.useRef)(null);return(0,b.useEffect)(()=>(bz(u),u.current=setTimeout(()=>l(e),300),()=>bz(u)),[e]),a?(0,L.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-slate-200/30 px-2 py-1.5 dark:border-slate-700/30`,children:[(0,L.jsxs)(`button`,{onClick:()=>s(`editor`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`editor`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]}),(0,L.jsxs)(`button`,{onClick:()=>s(`preview`),className:I(`flex items-center gap-1.5 rounded-md px-3 py-1 text-xs font-medium transition-colors`,o===`preview`?`bg-slate-100 text-slate-900 dark:bg-slate-700 dark:text-slate-100`:`text-slate-500 hover:bg-slate-50 dark:text-slate-400 dark:hover:bg-slate-800`),children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}),o===`editor`?(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}):(0,L.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,L.jsx)($y,{content:c})})]}):o===`editor`?(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(uz,{content:e,path:t,onSave:n,onDirtyChange:r,getContentRef:i}),(0,L.jsxs)(`button`,{onClick:()=>s(`preview`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(Qr,{className:`h-3.5 w-3.5`}),`预览`]})]}):(0,L.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,L.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:(0,L.jsx)($y,{content:c})}),(0,L.jsxs)(`button`,{onClick:()=>s(`editor`),className:`absolute right-3 top-3 z-10 inline-flex items-center gap-1.5 rounded-lg border border-slate-200/30 bg-white/90 px-2.5 py-1.5 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-sm transition hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-800/90 dark:text-slate-300 dark:hover:bg-slate-700`,children:[(0,L.jsx)(qr,{className:`h-3.5 w-3.5`}),`编辑`]})]})}var Sz=`/agentengine/api/v1/GetWorkspaceFileContent`,Cz=4e3;function wz(e){let t=je(e);if(!t||t===`.`)return`.`;let n=t.split(`/`).filter(Boolean);return n.length<=1?`.`:n.slice(0,-1).join(`/`)}function Tz(e){if(!e)return``;let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Ez(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(1)} GB`}var Dz=[{label:`Markdown`,detail:`.md .markdown .mdx`},{label:`代码/文本`,detail:`.py .js .ts .tsx .json .yaml .log .txt`},{label:`图片`,detail:`PNG JPG GIF WebP SVG`},{label:`PDF`,detail:`.pdf`},{label:`表格文本`,detail:`CSV TSV`}];function Oz(e){return Ne(e)}function kz({label:e,showSupportedTypes:t=!1}){return(0,L.jsx)(`div`,{className:`flex h-full min-h-[16rem] flex-col items-center justify-center px-6 text-center`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-dashed border-slate-300 bg-slate-50 px-5 py-5 text-slate-500 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-400`,children:[(0,L.jsx)(`div`,{children:e}),t?(0,L.jsxs)(`div`,{className:`mt-4 text-left`,children:[(0,L.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-[0.12em] text-slate-400`,children:`支持在线预览`}),(0,L.jsx)(`div`,{className:`mt-2 grid gap-2`,children:Dz.map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-slate-200 bg-white px-3 py-2 dark:border-slate-800 dark:bg-slate-950`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium text-slate-700 dark:text-slate-200`,children:e.label}),(0,L.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-slate-400`,children:e.detail})]},e.label))}),(0,L.jsx)(`div`,{className:`mt-3 text-xs leading-5 text-slate-400`,children:`Word、Excel、PPT 当前不支持在线预览,可下载后查看。`})]}):null]})})}function Az({agentId:e,capability:t,open:n,onClose:r,isFullscreen:i=!1,onToggleFullscreen:a,isMobile:o=!1,api:s}){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(`.`),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(``),[T,ee]=(0,b.useState)(null),[E,D]=(0,b.useState)(null),[O,te]=(0,b.useState)(!1),[ne,re]=(0,b.useState)(!1),ie=(0,b.useRef)(null),ae=(0,b.useRef)(null),oe=(0,b.useRef)(`selection`),k=(0,b.useRef)(We()),A=(0,b.useMemo)(()=>m.find(e=>e.Path===T)??null,[m,T]),se=(0,b.useMemo)(()=>A?He({path:A.Path,mimeType:A.MimeType}):null,[A]),ce=(0,b.useCallback)(()=>O?window.confirm(`当前文件有未保存的更改,确定要离开吗?`):!0,[O]),le=t.ContentPath||Sz,ue=t.RootLabel||`Workspace`,j=ue?`${ue.charAt(0).toUpperCase()}${ue.slice(1)}`:`Workspace`,de=Ie(f),fe=(0,b.useCallback)(()=>{l.current&&=(URL.revokeObjectURL(l.current),null)},[]);(0,b.useEffect)(()=>()=>fe(),[fe]);let pe=(0,b.useCallback)(async(t,n={})=>{let r=!!n.background;r?y(!0):_(!0),r||w(``);try{let n=await s.listWorkspaceFiles(e,t,!1),i=je(String(n?.Path||t||`.`)),a=Array.isArray(n?.Entries)?n.Entries:[];p(i),h(a),oe.current=r?`background-refresh`:`selection`,ee(e=>{if(e){let t=a.find(t=>t.Path===e);if(t&&t.Type===`file`)return e}return a.find(e=>e.Type===`file`)?.Path??null})}catch(e){console.error(`Failed to load workspace entries:`,e),r||w(e instanceof Error?e.message:String(e))}finally{r?y(!1):_(!1)}},[e,s]);(0,b.useEffect)(()=>{!n||u||(d(!0),pe(`.`))},[u,pe,n]),(0,b.useEffect)(()=>{if(!n||O||!u)return;let e=window.setInterval(()=>{pe(f,{background:!0})},Cz);return()=>window.clearInterval(e)},[f,O,u,pe,n]);let me=(0,b.useCallback)(async t=>{let n=k.current.next(t.Path),r=Be({path:t.Path,mimeType:t.MimeType});if(ae.current=t.Path,r===`unsupported`){fe(),D({path:t.Path,kind:r,status:`ready`,mimeType:t.MimeType??void 0});return}fe(),D({path:t.Path,kind:r,status:`loading`,mimeType:t.MimeType??void 0});try{let r=await s.getWorkspaceFileContent(e,t.Path,{asText:!1});if(!k.current.isCurrent(n))return;if(r instanceof Blob){let e=t.MimeType||``,i=Be({path:t.Path,mimeType:e});if(i===`image`||i===`pdf`){let n=URL.createObjectURL(r);l.current=n,D({path:t.Path,kind:i,status:`ready`,mimeType:e,objectUrl:n});return}let a=await r.text();if(!k.current.isCurrent(n))return;let o=Be({path:t.Path,mimeType:e});D({path:t.Path,kind:o,status:`ready`,mimeType:e,content:a})}else{let e=t.MimeType||``,n=Be({path:t.Path,mimeType:e});D({path:t.Path,kind:n,status:`ready`,mimeType:e,content:r})}}catch(e){if(!k.current.isCurrent(n))return;console.error(`Failed to preview workspace file:`,e),D({path:t.Path,kind:r,status:`error`,mimeType:t.MimeType??void 0,error:e instanceof Error?e.message:String(e)})}},[e,s,fe]);(0,b.useEffect)(()=>{if(!A||A.Type!==`file`){fe(),D(null),te(!1),ae.current=null;return}if(oe.current===`background-refresh`&&ae.current===A.Path){oe.current=`selection`;return}oe.current=`selection`,me(A)},[fe,me,A]);let he=async n=>{if(!(!n||n.length===0)){S(!0),w(``);try{for(let r of Array.from(n)){if(r.size>t.MaxUploadBytes)throw Error(`文件 ${r.name} 超过上传上限`);let n=Fe(f)?r.name:`${f}/${r.name}`,i=new FormData;i.append(`file`,r),i.append(`AgentId`,e),i.append(`Path`,n),await s.addWorkspaceFile(i)}await pe(f)}catch(e){console.error(`Failed to upload workspace files:`,e),w(e instanceof Error?e.message:String(e))}finally{c.current&&(c.current.value=``),S(!1)}}},ge=async n=>{if(!t.SupportsDelete)return;let r=je(n.Path);if(window.confirm(`删除 ${r} ?`)){w(``);try{await s.deleteWorkspaceFile(e,r),T&&je(T)===r&&(ee(null),te(!1)),await pe(n.Type===`directory`&&(je(f)===r||je(f).startsWith(`${r}/`))?wz(r):f)}catch(e){console.error(`Failed to delete workspace file:`,e),w(e instanceof Error?e.message:String(e))}}},_e=()=>!A||A.Type!==`file`?(0,L.jsx)(kz,{label:`从左侧选择文件后在这里查看内容预览。`,showSupportedTypes:!0}):!E||E.path!==A.Path||E.status===`loading`?(0,L.jsx)(`div`,{className:`flex h-full min-h-[16rem] items-center justify-center`,children:(0,L.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-slate-200 bg-white px-4 py-2 text-sm text-slate-500 shadow-sm dark:border-slate-800 dark:bg-slate-900 dark:text-slate-400`,children:[(0,L.jsx)(ri,{className:`h-4 w-4 animate-spin`}),`正在加载预览...`]})}):E.status===`error`?(0,L.jsx)(kz,{label:E.error||`文件预览加载失败。`}):E.kind===`markdown`?(0,L.jsx)(xz,{content:E.content||``,path:A.Path,onSave:ve,onDirtyChange:te,getContentRef:ie,isMobile:o}):E.kind===`image`&&E.objectUrl?(0,L.jsx)(dz,{content:null,objectUrl:E.objectUrl,kind:`image`,filename:A.Name,mimeType:E.mimeType||``}):E.kind===`pdf`&&E.objectUrl?(0,L.jsx)(dz,{content:null,objectUrl:E.objectUrl,kind:`pdf`,filename:A.Name,mimeType:E.mimeType||``}):E.kind===`html`?(0,L.jsx)(yz,{content:E.content||``,path:A.Path,onSave:ve,onDirtyChange:te,getContentRef:ie,isMobile:o,agentId:e,contentPath:le}):E.kind===`text`||E.kind===`code`?(0,L.jsx)(uz,{content:E.content||``,path:A.Path,onSave:ve,onDirtyChange:te,getContentRef:ie}):(0,L.jsx)(dz,{content:null,kind:`unsupported`,filename:A.Name,mimeType:E.mimeType||``}),ve=async t=>{if(A){re(!0),w(``);try{let n=new Blob([t],{type:A.MimeType||`text/plain`}),r=new FormData;r.append(`file`,n,A.Name),r.append(`AgentId`,e),r.append(`Path`,A.Path),await s.addWorkspaceFile(r),k.current.invalidate(),te(!1),D(e=>e&&e.path===A.Path?{...e,content:t}:e),ae.current=A.Path,await pe(f,{background:!0})}catch(e){console.error(`Failed to save workspace file:`,e),w(e instanceof Error?e.message:String(e))}finally{re(!1)}}},ye=A?.Type===`file`&&E?.path===A.Path&&E.status===`ready`&&(E.kind===`text`||E.kind===`code`||E.kind===`html`||E.kind===`markdown`),M=A?.Type===`file`&&E?.path===A.Path&&E.status===`ready`&&E.kind===`pdf`;return(0,L.jsxs)(`div`,{className:`flex h-full min-h-[22rem] w-full min-w-0 flex-col bg-white text-slate-800 dark:bg-slate-950 dark:text-slate-200`,children:[(0,L.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center gap-3 border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:j}),(0,L.jsx)(`div`,{className:`hidden h-4 w-px bg-slate-200/70 dark:bg-slate-800 sm:block`}),(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex-shrink-0 text-xs text-slate-400`,children:`当前目录`}),(0,L.jsx)(`div`,{className:`custom-scrollbar max-w-[min(42vw,34rem)] overflow-x-auto whitespace-nowrap rounded-md bg-slate-50 px-2 py-1 font-mono text-[11px] text-slate-600 dark:bg-slate-900 dark:text-slate-300`,title:`${de},来自 ListWorkspaceFiles 返回的 Data.Path 字段`,children:de})]}),(0,L.jsx)(`div`,{className:`hidden truncate text-[11px] text-slate-400 xl:block`,children:`工作区内相对路径,不是宿主机绝对路径。`})]}),(0,L.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:e=>void he(e.target.files)}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c.current?.click(),disabled:x,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-300 dark:hover:bg-slate-900`,title:`上传文件,上限 ${Math.floor(t.MaxUploadBytes/(1024*1024))}MB`,children:[(0,L.jsx)(wi,{className:`h-3.5 w-3.5`}),x?`上传中`:`上传`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{let e=new URLSearchParams({Path:f}).toString();window.open(`/agentengine/api/v1/ExportWorkspaceZip?${e}`,`_blank`,`noopener,noreferrer`)},className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-slate-600 transition hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-900`,title:`导出当前目录为 ZIP`,children:[(0,L.jsx)(si,{className:`h-3.5 w-3.5`}),`导出`]}),a?(0,L.jsx)(`button`,{type:`button`,onClick:a,className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":i?`退出全屏`:`全屏查看 Workspace`,title:i?`退出全屏`:`全屏查看`,children:i?(0,L.jsx)(oi,{className:`h-4 w-4`}):(0,L.jsx)(ii,{className:`h-4 w-4`})}):null,r?(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&r?.()},className:`rounded-lg p-1.5 text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-slate-900 dark:hover:text-slate-100`,"aria-label":`关闭 Workspace`,title:`关闭`,children:(0,L.jsx)(Ti,{className:`h-4 w-4`})}):null]})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col md:flex-row`,children:[(0,L.jsxs)(`div`,{className:`flex w-full flex-col border-b border-slate-200/30 dark:border-slate-800/40 md:w-[13.5rem] md:border-b-0 md:border-r`,children:[(0,L.jsxs)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-3 dark:border-slate-800/40`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-slate-900 dark:text-slate-100`,children:`文件`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-slate-400`,children:[(0,L.jsxs)(`span`,{children:[m.length,` 项`]}),v?(0,L.jsx)(hi,{className:`h-3 w-3 animate-spin`,"aria-label":`正在同步 Workspace 目录`}):null]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&pe(wz(f))},disabled:g||Fe(f),className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`返回上级目录`,children:(0,L.jsx)(Vr,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ce()&&pe(f)},disabled:g,className:`rounded-md p-1.5 text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-40 dark:text-slate-400 dark:hover:bg-slate-900`,title:`刷新目录`,children:(0,L.jsx)(hi,{className:`h-4 w-4 ${g?`animate-spin`:``}`})})]})]}),C?(0,L.jsx)(`div`,{className:`mt-3 rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-600 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300`,children:C}):null]}),(0,L.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto px-2 py-2`,children:!u&&!n?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`打开面板后加载 workspace 文件。`}):g?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`正在加载目录...`}):m.length===0?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-slate-400`,children:`当前目录为空。`}):(0,L.jsx)(`div`,{className:`space-y-0.5`,children:m.map(e=>{let n=Be({path:e.Path,mimeType:e.MimeType}),r=T===e.Path,i=e.Type===`file`?Oz(e.Path):``;return(0,L.jsxs)(`div`,{title:e.Path,className:I(`group flex items-center gap-1 rounded-lg px-1.5 py-1 transition`,r?`bg-slate-100 text-slate-950 dark:bg-slate-800 dark:text-slate-50`:`text-slate-700 hover:bg-slate-50 dark:text-slate-300 dark:hover:bg-slate-900`),children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{if(e.Type===`directory`){pe(e.Path);return}T!==e.Path&&!ce()||ee(e.Path)},className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,L.jsx)(`div`,{className:I(`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md`,r?`text-slate-900 dark:text-slate-50`:`text-slate-400 dark:text-slate-500`),children:e.Type===`directory`?(0,L.jsx)(ti,{className:`h-3.5 w-3.5`}):n===`image`?(0,L.jsx)(ni,{className:`h-3.5 w-3.5`}):n===`markdown`||n===`text`||n===`html`?(0,L.jsx)($r,{className:`h-3.5 w-3.5`}):(0,L.jsx)(ei,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-[13px] leading-5`,children:e.Name}),(0,L.jsx)(`div`,{className:I(`truncate text-[11px] leading-4`,r?`text-slate-500 dark:text-slate-400`:`text-slate-400`),children:e.Type===`directory`?`目录`:Ez(e.SizeBytes)})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5 opacity-0 transition group-hover:opacity-100`,children:[e.Type===`file`?(0,L.jsx)(`a`,{href:i,download:e.Name,className:I(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`下载`,children:(0,L.jsx)(Yr,{className:`h-3.5 w-3.5`})}):null,t.SupportsDelete?(0,L.jsx)(`button`,{type:`button`,onClick:()=>void ge(e),className:I(`rounded-md p-1.5 transition`,r?`hover:bg-white dark:hover:bg-slate-700`:`hover:bg-slate-100 dark:hover:bg-slate-800`),title:`删除`,children:(0,L.jsx)(Ci,{className:`h-3.5 w-3.5`})}):null]})]},e.Path)})})})]}),(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(`div`,{className:`flex h-14 flex-shrink-0 items-center border-b border-slate-200/30 px-4 dark:border-slate-800/40`,children:A?(0,L.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-900 dark:text-slate-100`,children:A.Name}),(0,L.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-[11px] text-slate-400`,children:A.Path}),(0,L.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-400`,children:[Ez(A.SizeBytes),A.MimeType?` · ${A.MimeType}`:``,A.ModifiedAt?` · ${Tz(A.ModifiedAt)}`:``]})]}),se===`text`||se===`code`||se===`html`||se===`markdown`?(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{let e=ie.current;e&&ve(e())},disabled:!O||ne,className:I(`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition`,O&&!ne?`bg-blue-600 text-white hover:bg-blue-700`:`text-slate-400 dark:text-slate-500 cursor-not-allowed`),children:[(0,L.jsx)(gi,{className:`h-3.5 w-3.5`}),ne?`保存中`:O?`保存`:`已保存`]}):null]}):(0,L.jsxs)(`div`,{className:`w-full`,children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold text-slate-900 dark:text-slate-100`,children:`文件预览`}),(0,L.jsx)(`div`,{className:`mt-0.5 text-xs text-slate-500 dark:text-slate-400`,children:`选择左侧文件后可在此查看内容。`})]})}),(0,L.jsx)(`div`,{className:I(`custom-scrollbar min-h-0 flex-1`,M||ye?`overflow-hidden p-0`:`overflow-y-auto px-4 py-4`),children:_e()})]})]})]})}function jz({agentId:e,capability:t,workspacePanelOpen:n,workspacePanelWidth:r,workspacePanelFullscreen:i,isMobile:a,workspaceEnabled:o,workspaceFiles:s,workspacePanelPresentation:c,closeWorkspacePanel:l,handleWorkspacePanelResizeStart:u,api:d}){let f=c.renderMode===`inline`,p=c.renderMode===`sheet`;return!o||!s?null:(0,L.jsxs)(L.Fragment,{children:[f?(0,L.jsxs)(L.Fragment,{children:[n&&!i?(0,L.jsx)(`div`,{role:`separator`,"aria-label":`调整 Workspace 宽度`,"aria-orientation":`vertical`,onPointerDown:u,className:`hidden h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-blue-200/60 dark:hover:bg-blue-900/50 md:block`}):null,(0,L.jsx)(`aside`,{style:n&&!i?{width:`${r}px`}:void 0,className:I(i?`fixed inset-0 z-40 flex h-[var(--app-height)] w-screen overflow-hidden bg-white dark:bg-slate-950`:`hidden h-full flex-shrink-0 overflow-hidden bg-white transition-[width] duration-200 ease-out dark:bg-slate-950 md:flex`,n?`border-l border-slate-200/30 dark:border-slate-800/40`:`w-0 border-l border-transparent`),children:n?(0,L.jsx)(Az,{agentId:e,capability:t,open:n,onClose:l,isFullscreen:i,onToggleFullscreen:()=>E.getState().setWorkspacePanelFullscreen(!i),isMobile:a,api:d}):null})]}):null,p?(0,L.jsx)(Nl,{open:n,onOpenChange:e=>{e||E.getState().setWorkspacePanelFullscreen(!1),E.getState().setWorkspacePanelOpen(e)},modal:c.modal,children:(0,L.jsxs)(Ll,{side:c.side,showOverlay:c.showOverlay,onInteractOutside:e=>{c.preventOutsideClose&&e.preventDefault()},showCloseButton:!1,className:I(`border-slate-200 bg-white p-0 dark:border-slate-800 dark:bg-slate-950`,a?`h-[70vh] rounded-t-[1.75rem]`:`h-[calc(100vh-1.5rem)] w-[min(72rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] rounded-l-[1.5rem] border-l shadow-2xl`),children:[(0,L.jsx)(Bl,{className:`sr-only`,children:`Workspace 文件`}),(0,L.jsx)(Vl,{className:`sr-only`,children:`浏览、上传和预览 Workspace 文件。`}),(0,L.jsx)(Az,{agentId:e,capability:t,open:n,onClose:l,isMobile:a,api:d})]})}):null]})}async function Mz(e,t){let n=await ht(`ListSessions`,{AgentId:e,Page:t?.page,PageSize:t?.pageSize},t);return{Sessions:n.Sessions??[],Total:Number.isFinite(Number(n.Total))?Number(n.Total):n.Sessions?.length??0,Page:Number.isFinite(Number(n.Page))?Number(n.Page):t?.page??1,PageSize:Number.isFinite(Number(n.PageSize))?Number(n.PageSize):t?.pageSize??n.Sessions?.length??0}}async function Nz(e,t){return(await ht(`CreateSession`,{AgentId:e},t)).Session}async function Pz(e,t){await ht(`DeleteSession`,{SessionId:e},t)}async function Fz(e,t){let n=await ht(`ListSessionEvents`,{SessionId:e,Offset:t?.offset,Limit:t?.limit},t);return{Events:n.Events??[],Total:Number.isFinite(Number(n.Total))?Number(n.Total):n.Events?.length??0,Offset:Number.isFinite(Number(n.Offset))?Number(n.Offset):t?.offset??0,Limit:Number.isFinite(Number(n.Limit))?Number(n.Limit):t?.limit??n.Events?.length??0}}async function Iz(e,t){return vt(`RunAgent`,e,t)}async function Lz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),ht(`ListSessionCheckpoints`,n,t)}async function Rz(e,t){return ht(`PreviewCheckpointResume`,{AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId},t)}async function zz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId};return e.runId&&(n.RunId=e.runId),e.checkpointId&&(n.CheckpointId=e.checkpointId),ht(`ListToolReceipts`,n,t)}async function Bz(e,t){let n={AgentId:e.agentId,SessionId:e.sessionId,RunId:e.runId,CheckpointId:e.checkpointId,Stream:!0};return e.resumeAttemptId&&(n.ResumeAttemptId=e.resumeAttemptId),e.invocationId&&(n.InvocationId=e.invocationId),vt(`ResumeRun`,n,t)}async function Vz(e,t,n){return ht(`ListWorkspaceFiles`,{AgentId:e,Path:t,Recursive:n})}async function Hz(e){return gt(`AddWorkspaceFile`,e)}async function Uz(e,t){return ht(`DeleteWorkspaceFile`,{AgentId:e,Path:t})}async function Wz(e,t,n){return _t(`GetWorkspaceFileContent`,{AgentId:e,FilePath:t},{signal:n?.signal,asText:n?.asText??!0})}async function Gz(e,t){return gt(`UploadFile`,e,t)}var Kz=new class{async listSessions(e,t){return Mz(e,t)}async createSession(e,t){return{SessionId:(await Nz(e,t)).SessionId}}async deleteSession(e,t){await Pz(e,t)}async listSessionEvents(e,t){return Fz(e,t)}async listSessionCheckpoints(e,t){return Lz(e,t)}async previewCheckpointResume(e,t){return Rz(e,t)}async listToolReceipts(e,t){return zz(e,t)}async runAgent(e,t){return Iz(e,t)}async resumeRun(e,t){return Bz(e,t)}async subscribeRunEvents(e,t){return yt(`SubscribeRunEvents`,{SessionId:e.sessionId,InvocationId:e.invocationId,AfterSeqId:String(e.afterSeqId)},t)}async cancelRun(e,t,n){return ht(`CancelRun`,{AgentId:e,InvocationId:t},n)}async getResponseFeedback(e,t){return ht(`GetResponseFeedback`,e,t)}async upsertResponseFeedback(e,t){return ht(`UpsertResponseFeedback`,e,t)}async deleteResponseFeedback(e,t){await ht(`DeleteResponseFeedback`,e,t)}async listWorkspaceFiles(e,t,n){return Vz(e,t,n)}async addWorkspaceFile(e){return Hz(e)}async deleteWorkspaceFile(e,t){await Uz(e,t)}async getWorkspaceFileContent(e,t,n){return Wz(e,t,n)}async listAgentModels(e){return xt(e)}async getAgentUiBootstrap(){return bt()}async uploadFile(e,t){return Gz(e,t)}},qz=b.lazy(()=>W(()=>import(`./ArtifactsPanel-BF4v3fIu.js`).then(e=>({default:e.ArtifactsPanel})),[],import.meta.url)),Jz=b.lazy(()=>W(()=>import(`./NativeTerminalPanel-DKuFni1-.js`).then(e=>({default:e.NativeTerminalPanel})),__vite__mapDeps([5,6]),import.meta.url));function Yz({apiAdapter:e,initialSurface:t=`chat`,routeShell:n}={}){let r=e||Kz,i=se(e=>e.agentId),a=M(e=>e.currentSessionId),o=j(e=>e.isStreaming),s=E(e=>e.sidebarOpen),c=E(e=>e.mobileSidebarOpen),l=E(e=>e.mobileActionsOpen),u=se(e=>e.agentName),d=le(e=>e.selectedModel),f=le(e=>e.availableModels),p=le(e=>e.modelSource),m=le(e=>e.modelCatalogLoaded),h=le(e=>e.thinkingMode),g=se(e=>e.agentFramework),_=se(e=>e.workspaceFiles),v=se(e=>e.accessMode),y=E(e=>e.workspacePanelOpen),x=E(e=>e.workspacePanelWidth),S=E(e=>e.workspacePanelFullscreen),C=se(e=>e.apiFormats),w=se(e=>e.capabilities),T=be(e=>e.visible&&!!e.content),ee=(0,b.useRef)([]),D=(0,b.useRef)(null),{isMobile:O,viewportHeight:te}=lt(),ne=we({isMobile:O,viewportHeight:te}),{fetchSessions:re,loadMoreSessions:ie,loadSession:ae,loadOlderSessionEvents:oe,createNewSession:k,deleteSession:ce,currentSessionIdRef:ue,agentIdRef:de,runSubscriptionAbortRef:fe}=Ar({agentId:i,currentSessionId:a,isMobile:O,uiCapabilities:w,api:r,resetCompaction:()=>{},disconnectRun:()=>D.current?.()}),pe=(0,b.useCallback)(e=>{if(!e)return;let t=()=>{re(de.current,e),ue.current===e&&!j.getState().isStreaming&&ae(e)};queueMicrotask(t),window.setTimeout(t,1800),window.setTimeout(t,5e3)},[de,ue,re,ae]),{submitDraft:me,stopGeneration:he,disconnectRun:ge,resumeCheckpoint:_e}=ur({agentId:i,currentSessionId:a,agentFramework:g,apiFormats:C,selectedModel:d,thinkingMode:h,uiCapabilities:w,isMobile:O,api:r,currentSessionIdRef:ue,agentIdRef:de,queuedDraftRef:ee,onRunSettled:pe});(0,b.useEffect)(()=>{D.current=ge},[ge]);let ve=(0,b.useCallback)(()=>{let e=ue.current;fe.current?.abort(),j.getState().stopActivity(),j.getState().stopSessionActivity(e),he()},[ue,fe,he]),ye=(0,b.useCallback)(async()=>{let e=ue.current,t=j.getState(),n=t.currentRunId||t.getSessionActivity(e)?.runId||``;if(n)try{await r.cancelRun(i,n),j.getState().stopSessionActivity(e,`取消请求已发送,后台运行会停在最近 checkpoint。`)}catch(t){console.warn(`[App] cancelRun failed:`,t),j.getState().updateActivity({sessionId:e,status:`failed`,phase:`取消请求失败`,detail:t instanceof Error?t.message:String(t),countEvent:!1})}pe(e)},[r,i,ue,pe]),{submitResponseFeedback:xe,deleteResponseFeedback:Se,respondToApproval:Ce}=xr({agentId:i,currentSessionId:a,isStreaming:o,api:r,submitDraft:me});wt({fetchSessions:re}),(0,b.useEffect)(()=>{de.current=i,ue.current=a,Ze(i,a)},[i,a,de,ue]),(0,b.useEffect)(()=>{O?E.getState().setWorkspacePanelFullscreen(!1):(E.getState().setMobileSidebarOpen(!1),E.getState().setMobileActionsOpen(!1))},[O]),(0,b.useEffect)(()=>{y||E.getState().setWorkspacePanelFullscreen(!1)},[y]),(0,b.useEffect)(()=>()=>{fe.current?.abort()},[fe]);let Te=A(w),Ee=!!w.Thinking,De=Ge({workspaceFiles:_,accessMode:v}),Oe=Ue({isMobile:O}),ke=rt({capability:w.NativeDashboard,agentFramework:g,accessMode:v,origin:window.location.origin}),Ae=!Te,je=g===`openclaw`?`OpenClaw`:g===`hermes`?`Hermes`:`原生运行时`,Me=(f.find(e=>e.id===d)||null)?.display_name||d||``,Ne=!O&&s&&Te,Pe=(0,b.useRef)(!1),[Fe,Ie]=(0,b.useState)(t===`tui`),Le=Fe&&!!w.NativeTerminal?.Enabled;(0,b.useEffect)(()=>{Pe.current||t!==`workspace`||!De||(Pe.current=!0,E.getState().setWorkspacePanelOpen(!0),E.getState().setWorkspacePanelFullscreen(!0))},[t,De]);let Re=(0,L.jsxs)(`div`,{className:`flex h-[var(--app-height)] min-h-[var(--app-height)] overflow-hidden bg-white font-sans text-slate-800 dark:bg-slate-900 dark:text-slate-200`,children:[(0,L.jsx)(Wl,{uiCapabilities:w,createNewSession:k,deleteSession:ce,loadSession:ae,loadMoreSessions:ie}),(0,L.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col bg-white dark:bg-slate-900`,children:[(0,L.jsx)(Yb,{agentName:u,currentSessionId:a,nativeLauncherMode:Ae,isMobile:O,sidebarOpen:s,mobileSidebarOpen:c,onToggleSidebar:()=>{O?E.getState().toggleMobileSidebar():E.getState().toggleSidebar()},availableModels:f,selectedModel:d,onSelectModel:e=>{le.getState().setSelectedModel(e),O&&E.getState().setMobileActionsOpen(!1)},selectedModelLabel:Me,modelCatalogLoaded:m,modelSource:p,thinkingEnabled:Ee,thinkingMode:h,onSelectThinkingMode:e=>le.getState().setThinkingMode(at(e)),mobileActionsOpen:l,onMobileActionsOpenChange:e=>E.getState().setMobileActionsOpen(e),workspaceEnabled:De,onOpenWorkspace:()=>E.getState().setWorkspacePanelOpen(!0),nativeManagementLink:ke,nativeTerminal:w.NativeTerminal}),Ae?(0,L.jsx)(Zb,{productLabel:je,nativeManagementLink:ke,nativeTerminal:w.NativeTerminal,workspaceEnabled:De,onOpenWorkspace:()=>E.getState().setWorkspacePanelOpen(!0)}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Vb,{agentName:u,isMobile:O,onDeleteFeedback:Se,onSubmitFeedback:xe,onRespondToApproval:Ce,onStopGeneration:ve,onCancelRemote:w.StopRun?ye:void 0,checkpointResumeEnabled:w.RunLifecycle.Enabled&&w.RunLifecycle.Checkpoints&&w.RunLifecycle.CheckpointResume,onResumeCheckpoint:_e,onLoadOlderSessionEvents:oe}),(0,L.jsx)(Kb,{composerMaxHeight:ne,submitDraft:me,stopGeneration:ve,cancelRemote:w.StopRun?ye:void 0,isMobile:O})]})]}),(0,L.jsx)(jz,{agentId:i,capability:_,workspacePanelOpen:y,workspacePanelWidth:x,workspacePanelFullscreen:S,isMobile:O,workspaceEnabled:De,workspaceFiles:_,workspacePanelPresentation:Oe,closeWorkspacePanel:()=>{E.getState().setWorkspacePanelFullscreen(!1),E.getState().setWorkspacePanelOpen(!1)},handleWorkspacePanelResizeStart:e=>{if(S||O)return;e.preventDefault();let t=e.clientX,n=x,r=Te&&Ne?280:0,i=document.body.style.cursor,a=document.body.style.userSelect;document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let o=e=>{let i=n+t-e.clientX;E.getState().setWorkspacePanelWidth(Qt(i,window.innerWidth,r))},s=()=>{document.body.style.cursor=i,document.body.style.userSelect=a,window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},api:r}),T&&(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(qz,{})}),Le?(0,L.jsx)(b.Suspense,{fallback:null,children:(0,L.jsx)(Jz,{capability:w.NativeTerminal,open:!0,sessionId:a,onClose:()=>Ie(!1)})}):null]});return n?(0,L.jsx)(n,{children:Re}):Re}function Xz(){return(0,L.jsx)(Yz,{})}function Zz(e){let t=e instanceof Error?e.message:String(e||``);return/loading chunk|chunkloaderror|failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed/i.test(t)}var Qz=`agentengine-ui:chunk-reload-attempted`,$z=class extends b.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){if(console.error(`UI 渲染错误:`,e,t),Zz(e))try{window.sessionStorage.getItem(Qz)||(window.sessionStorage.setItem(Qz,String(Date.now())),window.location.reload())}catch{window.location.reload()}}handleReload=()=>{try{window.sessionStorage.removeItem(Qz)}catch{}this.setState({hasError:!1,error:null}),window.location.reload()};render(){return this.state.hasError?(0,L.jsx)(`div`,{className:`flex h-screen w-screen items-center justify-center bg-slate-50 dark:bg-slate-900`,children:(0,L.jsxs)(`div`,{className:`max-w-md rounded-2xl border border-red-200 bg-white p-8 text-center shadow-lg dark:border-red-900 dark:bg-slate-950`,children:[(0,L.jsx)(`div`,{className:`mb-4 text-4xl`,children:`⚠`}),(0,L.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-red-600 dark:text-red-400`,children:`页面渲染出错`}),(0,L.jsx)(`p`,{className:`mb-6 text-sm text-slate-600 dark:text-slate-400`,children:this.state.error?.message||`发生了未知错误,请刷新页面重试。`}),(0,L.jsx)(`button`,{onClick:this.handleReload,className:`rounded-lg bg-blue-600 px-6 py-2.5 text-sm font-medium text-white transition hover:bg-blue-700`,children:`刷新页面`})]})}):this.props.children}};function eB(){let e=E(e=>e.toasts),t=E(e=>e.dismissToast);return(0,b.useEffect)(()=>{if(!e.length)return;let n=e[0],r=3e3-(Date.now()-n.createdAt);if(r<=0){t(n.id);return}let i=setTimeout(()=>t(n.id),r);return()=>clearTimeout(i)},[e,t]),e.length?(0,L.jsx)(`div`,{className:`fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-4 py-3 text-sm shadow-lg transition-all ${e.variant===`error`?`bg-red-600 text-white`:`bg-slate-800 text-white dark:bg-slate-200 dark:text-slate-900`}`,children:[(0,L.jsx)(`span`,{className:`flex-1`,children:e.message}),(0,L.jsx)(`button`,{onClick:()=>t(e.id),className:`shrink-0 rounded p-0.5 opacity-70 hover:opacity-100`,children:(0,L.jsx)(Ti,{size:14})})]},e.id))}):null}T.createRoot(document.getElementById(`root`)).render((0,L.jsxs)($z,{children:[(0,L.jsx)(Xz,{}),(0,L.jsx)(eB,{})]}));export{H as $,Zk as A,OS as B,yj as C,s as Ct,Z as D,YA as E,aA as F,Uy as G,JS as H,kA as I,Eg as J,Ay as K,Y as L,eA as M,TA as N,Jk as O,DA as P,Xd as Q,mO as R,_j as S,o as St,WA as T,eb as U,Yx as V,W,Eh as X,Th as Y,gh as Z,rM as _,Jr as _t,wL as a,ru as at,Bj as b,be as bt,bj as c,so as ct,Ej as d,Ci as dt,Ad as et,JM as f,bi as ft,Zj as g,Yr as gt,Yj as h,Qr as ht,CL as i,ku as it,tA as j,iA as k,Q as l,I as lt,vj as m,pi as mt,vz as n,Mu as nt,PR as o,Kl as ot,Qj as p,hi as pt,k_ as q,bL as r,Nu as rt,Sj as s,Gl as st,_z as t,Pu as tt,Nj as u,Ti as ut,nM as v,Ur as vt,Cj as w,l as wt,Fj as x,p as xt,tM as y,Br as yt,G as z};
|