@rho-workspace/rho 0.5.5 → 0.5.7
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/dist/agent-connect.d.ts +42 -0
- package/dist/agent-connect.js +68 -0
- package/dist/answer-board.js +3 -3
- package/dist/bridge.js +6 -1
- package/dist/browser-access.d.ts +1 -0
- package/dist/browser-access.js +5 -3
- package/dist/capabilities.d.ts +21 -5
- package/dist/capabilities.js +6 -4
- package/dist/cli.js +113 -18
- package/dist/composition.d.ts +1 -1
- package/dist/composition.js +13 -3
- package/dist/connect-cli.d.ts +50 -0
- package/dist/connect-cli.js +128 -0
- package/dist/contract.generated.d.ts +1437 -381
- package/dist/contract.generated.js +1 -1
- package/dist/contracts/owners.generated.js +1160 -267
- package/dist/conversation-presentation.d.ts +9 -2
- package/dist/conversation-presentation.js +3 -1
- package/dist/conversations.d.ts +306 -7
- package/dist/conversations.js +208 -22
- package/dist/discovery.js +3 -3
- package/dist/extension-contract.d.ts +19 -0
- package/dist/extension-contract.js +15 -6
- package/dist/extension-markets.d.ts +74 -0
- package/dist/extension-markets.js +166 -0
- package/dist/extensions.d.ts +29 -1
- package/dist/extensions.js +13 -4
- package/dist/external-work.d.ts +22 -0
- package/dist/external-work.js +91 -0
- package/dist/plugin-cli.js +75 -3
- package/dist/plugin-inventory.d.ts +56 -0
- package/dist/plugin-inventory.js +41 -0
- package/dist/plugin-inventory.json +1581 -102
- package/dist/plugin-presentation.d.ts +105 -2
- package/dist/plugin-presentation.js +59 -5
- package/dist/plugins.d.ts +14 -3
- package/dist/plugins.js +12 -6
- package/dist/project-notes.js +1 -1
- package/dist/protocol.d.ts +7 -0
- package/dist/protocol.js +40 -15
- package/dist/replay.js +4 -0
- package/dist/response-contracts.js +26 -11
- package/dist/running.d.ts +10 -0
- package/dist/running.js +45 -0
- package/dist/server.d.ts +4 -10
- package/dist/server.js +140 -14
- package/dist/state.d.ts +8 -0
- package/dist/state.js +8 -0
- package/dist/studio-layout.js +3 -3
- package/dist/task-frame.d.ts +1 -1
- package/dist/timeline-events.d.ts +1 -0
- package/dist/timeline-events.js +8 -1
- package/dist/ui-context.d.ts +73 -0
- package/dist/ui-context.js +98 -0
- package/dist/ui-contract.d.ts +23 -0
- package/dist/web/.vite/manifest.json +135 -76
- package/dist/web/assets/answer-board-CeYS8k8y.js +1 -0
- package/dist/web/assets/choices-D8vGwsl2.js +1 -0
- package/dist/web/assets/{console-BSjLGe0T.js → console-Dyuo1q4N.js} +4 -4
- package/dist/web/assets/{dist-Tzoe_zm-.js → dist-CSiCyBml.js} +1 -1
- package/dist/web/assets/{dist-Cw8hRIlT.js → dist-D9FLb9Hm.js} +1 -1
- package/dist/web/assets/{dist-foH9IKc6.js → dist-FXbTBwML.js} +1 -1
- package/dist/web/assets/{dist-Buk0lwzI.js → dist-l3DUhbw5.js} +1 -1
- package/dist/web/assets/{explore-in-BVUy3ZW_.js → explore-in-BfSFGRh2.js} +1 -1
- package/dist/web/assets/graph-BU2_o5uA.js +2 -0
- package/dist/web/assets/index-C16mXVvk.css +1 -0
- package/dist/web/assets/index-CWg9XYXx.js +952 -0
- package/dist/web/assets/markdown.reader-Ct2-e2Zt.png +0 -0
- package/dist/web/assets/{notes-meaning-pVbbQUGP.js → notes-meaning-T2m5zQfv.js} +1 -1
- package/dist/web/assets/overview-PzfLJCo-.js +6 -0
- package/dist/web/assets/preview-BguEdsza.js +1 -0
- package/dist/web/assets/previews-pWNik-2g.js +3 -0
- package/dist/web/assets/{review-CMxQlQ-C.js → review-Dy_85lcH.js} +1 -1
- package/dist/web/assets/rho.editor-CCJeyHma.png +0 -0
- package/dist/web/assets/rho.flow-WkMj6fRS.png +0 -0
- package/dist/web/assets/rho.media-Cc6amodO.png +0 -0
- package/dist/web/assets/rho.notebook-6vsZKGDq.png +0 -0
- package/dist/web/assets/rho.object-BGoeXjte.png +0 -0
- package/dist/web/assets/rho.plots-yIiISCkb.png +0 -0
- package/dist/web/assets/rho.scatter-DwHxesCs.png +0 -0
- package/dist/web/assets/rho.servers-DKf_mnNq.png +0 -0
- package/dist/web/assets/rho.table-DWOGaWDa.png +0 -0
- package/dist/web/assets/rho.variables-CKcWczhQ.png +0 -0
- package/dist/web/assets/{skills-BFNSyrnD.js → skills-Dyz7mBlc.js} +1 -1
- package/dist/web/assets/{skills-work-BGPSnF_I.js → skills-work-BEGqlCkx.js} +1 -1
- package/dist/web/assets/studio-process-D-ykbC4D.js +2 -0
- package/dist/web/assets/timeline-events-DKTho9fU.js +1 -0
- package/dist/web/assets/work-turns-DSabCogR.js +1 -0
- package/dist/web/assets/{workspace-CWlkjLNx.js → workspace-DfjBL--r.js} +2 -2
- package/dist/web/composition.json +135 -80
- package/dist/web/index.html +3 -3
- package/dist/web/renderer.json +1 -1
- package/dist/web-assets.js +2 -2
- package/dist/work-graph.d.ts +11 -1
- package/dist/work-graph.js +16 -5
- package/dist/workspace.d.ts +2 -2
- package/dist/workspace.js +8 -7
- package/docs/FRONTEND.md +71 -21
- package/docs/HEADLESS.md +127 -24
- package/docs/THIRD-PARTY-PLUGINS.md +75 -3
- package/node_modules/@rho-workspace/plugin-agent/README.md +34 -0
- package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.d.ts +32 -0
- package/node_modules/@rho-workspace/plugin-agent/dist/acp-command.js +54 -11
- package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.d.ts +1 -0
- package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.js +29 -3
- package/node_modules/@rho-workspace/plugin-agent/dist/external-session-contract.js +11 -5
- package/node_modules/@rho-workspace/plugin-agent/dist/external-session.d.ts +12 -1
- package/node_modules/@rho-workspace/plugin-agent/dist/index.d.ts +8 -0
- package/node_modules/@rho-workspace/plugin-agent/dist/index.js +3 -2
- package/node_modules/@rho-workspace/plugin-agent/dist/mcp-entry.d.ts +13 -0
- package/node_modules/@rho-workspace/plugin-agent/dist/mcp-entry.js +13 -0
- package/node_modules/@rho-workspace/plugin-agent/dist/mcp.js +16 -8
- package/node_modules/@rho-workspace/plugin-agent/dist/native-sessions.d.ts +70 -0
- package/node_modules/@rho-workspace/plugin-agent/dist/native-sessions.js +538 -0
- package/node_modules/@rho-workspace/plugin-agent/package.json +2 -1
- package/node_modules/@rho-workspace/plugin-figures/LICENSE +661 -0
- package/node_modules/@rho-workspace/plugin-figures/README.md +191 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/index.d.ts +236 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/index.js +165 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/operations.d.ts +44 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/operations.js +39 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/presentation.d.ts +19 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/presentation.js +26 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/record.d.ts +188 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/record.js +143 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/ui-styles.d.ts +1 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/ui-styles.js +68 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/ui.d.ts +56 -0
- package/node_modules/@rho-workspace/plugin-figures/dist/ui.js +363 -0
- package/node_modules/@rho-workspace/plugin-figures/package.json +41 -0
- package/node_modules/@rho-workspace/plugin-figures/py/figures.py +856 -0
- package/node_modules/@rho-workspace/plugin-figures/r/figures.R +775 -0
- package/node_modules/@rho-workspace/plugin-kernel/README.md +27 -3
- package/node_modules/@rho-workspace/plugin-kernel/dist/contract.d.ts +12 -0
- package/node_modules/@rho-workspace/plugin-kernel/dist/contract.js +8 -1
- package/node_modules/@rho-workspace/plugin-kernel/dist/index.d.ts +61 -0
- package/node_modules/@rho-workspace/plugin-kernel/dist/index.js +125 -9
- package/node_modules/@rho-workspace/plugin-kernel/dist/session-scope.d.ts +14 -0
- package/node_modules/@rho-workspace/plugin-kernel/dist/session-scope.js +9 -0
- package/node_modules/@rho-workspace/plugin-kernel/dist/ui-base.d.ts +23 -5
- package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook-work.js +1 -1
- package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook.d.ts +6 -4
- package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook.js +44 -17
- package/node_modules/@rho-workspace/plugin-kernel/dist/ui-styles.js +6 -0
- package/node_modules/@rho-workspace/plugin-kernel/package.json +1 -1
- package/node_modules/@rho-workspace/plugin-kernel/runners/runner.R +144 -4
- package/node_modules/@rho-workspace/plugin-kernel/runners/runner.py +106 -1
- package/node_modules/@rho-workspace/plugin-tables/README.md +5 -0
- package/node_modules/@rho-workspace/plugin-tables/dist/index.d.ts +1 -0
- package/node_modules/@rho-workspace/plugin-tables/dist/index.js +19 -3
- package/node_modules/@rho-workspace/plugin-tables/dist/ui.js +1 -1
- package/node_modules/@rho-workspace/plugin-tables/package.json +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
- package/node_modules/hono/dist/cjs/client/fetch-result-please.js +1 -1
- package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +2 -1
- package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +5 -3
- package/node_modules/hono/dist/cjs/jsx/base.js +49 -30
- package/node_modules/hono/dist/cjs/jsx/components.js +2 -2
- package/node_modules/hono/dist/cjs/jsx/constants.js +2 -0
- package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +13 -17
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +1 -0
- package/node_modules/hono/dist/cjs/middleware/timing/timing.js +4 -3
- package/node_modules/hono/dist/cjs/utils/cookie.js +2 -2
- package/node_modules/hono/dist/cjs/utils/mime.js +1 -1
- package/node_modules/hono/dist/cjs/utils/url.js +1 -1
- package/node_modules/hono/dist/client/fetch-result-please.js +1 -1
- package/node_modules/hono/dist/helper/accepts/accepts.js +2 -1
- package/node_modules/hono/dist/helper/ssg/ssg.js +5 -3
- package/node_modules/hono/dist/jsx/base.js +49 -32
- package/node_modules/hono/dist/jsx/components.js +2 -2
- package/node_modules/hono/dist/jsx/constants.js +2 -1
- package/node_modules/hono/dist/jsx/jsx-runtime.js +15 -19
- package/node_modules/hono/dist/middleware/etag/index.js +3 -1
- package/node_modules/hono/dist/middleware/language/language.js +1 -1
- package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -0
- package/node_modules/hono/dist/middleware/timing/timing.js +4 -3
- package/node_modules/hono/dist/utils/cookie.js +2 -2
- package/node_modules/hono/dist/utils/mime.js +1 -1
- package/node_modules/hono/dist/utils/url.js +1 -1
- package/node_modules/hono/package.json +1 -1
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
- package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
- package/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
- package/node_modules/jose/package.json +1 -1
- package/package.json +6 -4
- package/protocol/index.json +106 -64
- package/protocol/operations/agent.sessions.list.json +57 -3
- package/protocol/operations/agent.sessions.read.json +61 -4
- package/protocol/operations/capability.list.json +382 -6
- package/protocol/operations/composition.apply.json +10 -2
- package/protocol/operations/composition.delete.json +845 -0
- package/protocol/operations/composition.read.json +10 -2
- package/protocol/operations/composition.undo.json +10 -2
- package/protocol/operations/conversation.agents.add.json +346 -0
- package/protocol/operations/conversation.agents.remove.json +340 -0
- package/protocol/operations/conversation.configure.json +29 -0
- package/protocol/operations/conversation.decide.json +225 -0
- package/protocol/operations/conversation.list.json +29 -0
- package/protocol/operations/conversation.permission.json +225 -0
- package/protocol/operations/conversation.read.json +225 -0
- package/protocol/operations/conversation.restore.json +29 -0
- package/protocol/operations/conversation.send.json +294 -0
- package/protocol/operations/conversation.settings.check.json +226 -416
- package/protocol/operations/conversation.settings.read.json +224 -411
- package/protocol/operations/conversation.settings.update.json +248 -475
- package/protocol/operations/conversation.start.json +313 -6
- package/protocol/operations/conversation.stop.json +225 -0
- package/protocol/operations/conversation.trash.json +29 -0
- package/protocol/operations/extension.describe.json +39 -0
- package/protocol/operations/extension.install.json +62 -0
- package/protocol/operations/extension.list.json +164 -1
- package/protocol/operations/extension.market.change.json +210 -0
- package/protocol/operations/figure.read.json +265 -0
- package/protocol/operations/figure.select.json +157 -0
- package/protocol/operations/kernel.interrupt.json +119 -0
- package/protocol/operations/kernel.read.json +119 -0
- package/protocol/operations/kernel.run.json +119 -0
- package/protocol/operations/observation.snapshot.json +445 -8
- package/protocol/operations/project.openFile.json +10 -2
- package/protocol/operations/session.grant.json +4 -0
- package/protocol/operations/session.instructions.json +43 -0
- package/protocol/operations/shared.json +1 -0
- package/protocol/operations/view.close.json +10 -2
- package/protocol/operations/view.protection.set.json +10 -2
- package/vendor/composition.json +174 -109
- package/vendor/rho-workspace-plugin-agent-0.4.33.tgz +0 -0
- package/vendor/rho-workspace-plugin-figures-0.5.1.tgz +0 -0
- package/vendor/rho-workspace-plugin-kernel-0.5.13.tgz +0 -0
- package/vendor/rho-workspace-plugin-tables-0.5.2.tgz +0 -0
- package/web/theme.css +17 -0
- package/dist/web/assets/answer-board-CBkGbSLD.js +0 -1
- package/dist/web/assets/canvas-D8rDdfDz.js +0 -1
- package/dist/web/assets/choices-b0XhrGQV.js +0 -1
- package/dist/web/assets/graph-1OdIJ9l7.js +0 -2
- package/dist/web/assets/index-CsC3sTRq.css +0 -1
- package/dist/web/assets/index-CxmItXqa.js +0 -891
- package/dist/web/assets/overview-B9UtVJ32.js +0 -6
- package/dist/web/assets/preview-CksD_5KS.js +0 -1
- package/dist/web/assets/studio-process-CsRoTHOh.js +0 -2
- package/dist/web/assets/timeline-events-BbuuFWHV.js +0 -1
- package/dist/web/assets/work-turns-BvJlIMmA.js +0 -1
- package/vendor/rho-workspace-plugin-agent-0.4.29.tgz +0 -0
- package/vendor/rho-workspace-plugin-kernel-0.5.5.tgz +0 -0
- package/vendor/rho-workspace-plugin-tables-0.5.0.tgz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{n,t as r}from"./react-Dss-ouuy.js";import{a as i}from"./home-CCbP6kS-.js";import{r as a}from"./markdown-0ngRuTpW.js";import{
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{n,t as r}from"./react-Dss-ouuy.js";import{a as i}from"./home-CCbP6kS-.js";import{r as a}from"./markdown-0ngRuTpW.js";import{W as o,g as s}from"./previews-pWNik-2g.js";import{Dt as c,It as l,Lt as u,Rt as d,St as f,xt as p,zt as m}from"./index-CWg9XYXx.js";import{c as h,l as g,t as _}from"./facts-BMO6V3-3.js";import{t as v}from"./work-turns-DSabCogR.js";var y=n(),b=t(r(),1),x={shownBytes:262144,pollMs:700,listed:50},S=e=>e instanceof Error?e.message:`The Console could not be reached.`,C=e=>[`unavailable`,`unauthorized`].includes(e?.error?.kind??``),w=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function T(e){if(e<1e4)return(Math.max(e,100)/1e3).toFixed(1)+` s`;if(e<6e4)return Math.round(e/1e3)+` s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return t+` min`+(n?` `+n+` s`:``)}function E(e,t,n){N();let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)({off:!1,problem:``}),s=(0,b.useCallback)(()=>e.call(`console.list`,{projectId:t,limit:x.listed}).then(e=>{i(e.commands),o({off:!1,problem:``})},e=>o({off:C(e),problem:S(e)})),[e,t]);return(0,b.useEffect)(()=>{s()},[s,n]),{commands:r,...a,read:s}}function D(e,t,{onRan:n,center:r=!1}={}){let[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(``),f=(0,b.useRef)(null),p=(0,b.useRef)(null);async function m(r){if(r.trim()&&!c){f.current?.command!==r&&(f.current={command:r,changeId:`console-`+crypto.randomUUID()}),l(!0),d(``);try{await e.call(`console.run`,{projectId:t,command:r,changeId:f.current.changeId}),f.current=null,a(``),s(``),n?.()}catch(e){d(S(e))}finally{l(!1)}}}async function h(r){try{await e.call(`console.stop`,{projectId:t,commandId:r.commandId,changeId:`stop-`+r.commandId}),n?.()}catch(e){d(S(e))}}function g(e,t){a(e),s(`From `+t+`. Check it, then press Run.`),d(``),r&&p.current?.scrollIntoView({block:`center`}),p.current?.focus()}return{draft:i,setDraft:e=>{a(e),e||s(``)},note:o,busy:c,problem:u,input:p,start:m,stop:h,prepare:g}}function O({folder:e,line:t,problem:n}){N();let{draft:r,setDraft:i,note:a,busy:o,input:s}=t,c=Math.min(8,r.split(`
|
|
2
2
|
`).length),l=(0,b.useId)(),u=t.problem||n;return(0,y.jsxs)(`form`,{className:`console-prompt`,onSubmit:e=>{e.preventDefault(),t.start(r)},children:[(0,y.jsxs)(`label`,{htmlFor:l,className:`console-prompt-label`,children:[`Run a command in `,(0,y.jsx)(`strong`,{children:e})]}),(0,y.jsxs)(`div`,{className:`console-line`,children:[(0,y.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,y.jsx)(`textarea`,{id:l,ref:s,rows:c,value:r,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,placeholder:`python3 analysis.py`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),t.start(r))}}),(0,y.jsx)(`button`,{type:`submit`,className:`primary`,disabled:o||!r.trim(),children:o?`Starting…`:`Run`})]}),a&&(0,y.jsx)(`p`,{className:`console-note`,children:a}),u&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:u})]})}function k(e,t,n,r){let[i,a]=(0,b.useState)({text:``,more:!1,problem:``}),o=(0,b.useRef)(0);return(0,b.useEffect)(()=>{if(!r)return;let i=!0,s,c=async()=>{try{for(;;){if(o.current>=x.shownBytes){a(e=>({...e,more:!0}));return}let r=await e.call(`console.output`,{projectId:t,commandId:n.commandId,offset:o.current,maxBytes:65536});if(!i)return;if(o.current=r.nextOffset,a(e=>({text:e.text+r.text,more:!1,problem:``})),!r.more)break}}catch(e){i&&a(t=>({...t,problem:S(e)}))}i&&n.state===`running`&&(s=setTimeout(c,x.pollMs))};return c(),()=>{i=!1,clearTimeout(s)}},[e,t,n.commandId,n.state,r]),i}var A=e=>e.state===`running`?`Running`:e.state===`stopped`?`Stopped`:e.state===`continuing`?`Still running outside Rho`:e.state===`unknown`?`Outcome unknown`:e.state===`not-started`?`Did not start`:e.exit?.signal?`Ended by `+e.exit.signal:`Exit `+(e.exit?.code??`?`);function j({record:e,client:t,projectId:n,made:r,after:i,onRunAgain:a,onStop:o}){N();let[s,c]=(0,b.useState)(e.state===`running`),[l,u]=(0,b.useState)(Date.now()),d=k(t,n,e,s),f=e.state===`running`;(0,b.useEffect)(()=>{if(!f)return;let e=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(e)},[f]);let p=(e.endedAt?Date.parse(e.endedAt):l)-Date.parse(e.startedAt),m=e.state===`exited`&&e.exit?.code===0,h=[m?``:A(e),p>=1e3?T(p):``].filter(Boolean).join(` · `);return(0,y.jsxs)(`li`,{className:`console-command mine`+(r||f?` made`:``)+(!m&&!f?` problem`:``),children:[(0,y.jsxs)(`details`,{open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,y.jsxs)(`summary`,{children:[(0,y.jsx)(`span`,{className:`console-time`,children:w(Date.parse(e.startedAt))}),(0,y.jsx)(`span`,{className:`console-what`,title:e.command,children:(0,y.jsx)(`code`,{className:`alone`,children:e.command})}),(0,y.jsx)(`span`,{className:`console-end`+(f?` running`:m?``:` problem`),children:h})]}),(0,y.jsxs)(`div`,{className:`console-detail`,children:[e.cwd&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`In `,e.cwd,`/`]}),d.text?(0,y.jsx)(`pre`,{className:`console-output`,ref:e=>{e&&f&&(e.scrollTop=e.scrollHeight)},children:d.text}):(0,y.jsx)(`p`,{className:`console-note`,children:f?`Waiting for output…`:d.problem?``:`It printed nothing.`}),d.more&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`Showing the first `,(x.shownBytes/1024).toFixed(0),` KiB of `,e.kept.toLocaleString(`en-US`),` kept bytes.`]}),e.cut&&!f&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`It printed `,e.bytes.toLocaleString(`en-US`),` bytes; the middle was not kept.`]}),e.problem&&(0,y.jsx)(`p`,{className:`console-note`,children:e.problem}),d.problem&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:d.problem}),!f&&e.state!==`continuing`&&(0,y.jsx)(`div`,{className:`console-actions`,children:(0,y.jsx)(`button`,{className:`text-button console-again`,onClick:()=>a(e),children:`Run again`})})]})]}),i,f&&(0,y.jsx)(`div`,{className:`console-actions`,children:(0,y.jsx)(`button`,{className:`text-button console-again`,disabled:!!e.stop,onClick:()=>o(e),children:e.stop?`Stopping…`:`Stop`})})]})}var M=`.console-command { border-top: 1px solid var(--color-divider); }
|
|
3
3
|
.console-command summary { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 8px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; list-style: none; }
|
|
4
4
|
.console-command summary:hover { background: var(--color-hover); }
|
|
@@ -30,6 +30,6 @@ import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{n,t as r}from".
|
|
|
30
30
|
.console-time { display: none; }
|
|
31
31
|
.console-detail, .console-command > .console-actions { margin-left: 0; }
|
|
32
32
|
}
|
|
33
|
-
`;function N(){if(typeof document>`u`||document.querySelector(`style[data-owner="rho-plugins.console"]`))return;let e=document.createElement(`style`);e.dataset.owner=`rho-plugins.console`,e.textContent=M,document.head.append(e)}var P=(0,b.createContext)(null),F=e=>`studio-`+s(e).slice(5,17),I=()=>(0,b.useContext)(P),L=e({CommandPane:()=>X,ConsolePage:()=>J}),R=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),z=e=>e.outcome===`returned`&&(!e.end||/^exit 0\b/i.test(e.end)),B=e=>e.outcome===`failed`||e.outcome===`rejected`||e.outcome===`unknown`||/^exit [1-9]/i.test(e.end??``),V=e=>!/<<-?\s*['"]?\w+['"]?\s*$/.test(e.trim());function H({runs:e,root:t,onPath:n,onRunAgain:r}){let i=e.flatMap(e=>e.purpose?[e.purpose]:
|
|
34
|
-
`)||s.length>90||o!==e.command)&&(0,y.jsx)(`pre`,{className:`console-ran`,children:
|
|
35
|
-
…`:``]}):(0,y.jsx)(`p`,{className:`console-note`,children:c?`Running…`:`No output was reported.`}),g&&(0,y.jsx)(`div`,{className:`console-actions`,children:g})]})]}),(0,y.jsx)(G,{files:t.map(e=>({path:e.path,name:e.title})),onPath:r})]})}function q({graph:e,turn:t,root:n,onPath:r,onConversation:i,focused:a,onRunAgain:o}){let s=e.nodes.find(e=>e.id===`q:`+t.id),c=e.nodes.filter(e=>e.kind===`run`&&e.turn===t.id),l=U(e,c),u=new Set(l.flatMap(e=>(e.changed??[]).map(e=>e.path))),d=c.filter(B).length,f=(0,b.useRef)(null);return(0,b.useEffect)(()=>{a&&f.current?.scrollIntoView({block:`start`})},[a]),c.length?(0,y.jsxs)(`section`,{ref:f,className:`console-message`+(a?` focused`:``),"aria-label":s?.title??`A message`,children:[(0,y.jsxs)(`header`,{children:[(0,y.jsx)(`button`,{className:`text-button console-ask`,title:s?.text,onClick:()=>i(t.conversationId),children:s?.title??`A message`}),(0,y.jsxs)(`small`,{children:[t.agent,` · `,
|
|
33
|
+
`;function N(){if(typeof document>`u`||document.querySelector(`style[data-owner="rho-plugins.console"]`))return;let e=document.createElement(`style`);e.dataset.owner=`rho-plugins.console`,e.textContent=M,document.head.append(e)}var P=(0,b.createContext)(null),F=e=>`studio-`+s(e).slice(5,17),I=()=>(0,b.useContext)(P),L=e({CommandPane:()=>X,ConsolePage:()=>J}),R=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),z=e=>e.outcome===`returned`&&(!e.end||/^exit 0\b/i.test(e.end)),B=e=>e.outcome===`failed`||e.outcome===`rejected`||e.outcome===`unknown`||/^exit [1-9]/i.test(e.end??``),V=e=>!/<<-?\s*['"]?\w+['"]?\s*$/.test(e.trim());function H({runs:e,root:t,onPath:n,onRunAgain:r}){let i=e.flatMap(e=>e.purpose?[e.purpose]:l(d(e.command,t)).split(` → `)).filter((e,t,n)=>n.indexOf(e)===t),a=e.reduce((e,t)=>e+(t.durationMs??0),0);return(0,y.jsx)(`li`,{className:`console-command console-quiet-row`,children:(0,y.jsxs)(`details`,{children:[(0,y.jsxs)(`summary`,{children:[(0,y.jsx)(`span`,{className:`console-time`,children:R(e[0].at)}),(0,y.jsx)(`span`,{className:`console-what`,children:(0,y.jsx)(`span`,{className:`console-purpose`,children:i.join(` · `)})}),(0,y.jsxs)(`span`,{className:`console-end`,children:[e.length,` commands`,a?` · `+u(a):``]})]}),(0,y.jsx)(`ol`,{className:`console-list`,children:e.map(e=>(0,y.jsx)(K,{node:e,changed:[],root:t,onPath:n,onRunAgain:r},e.id))})]})})}function U(e,t){let n=new Map(e.nodes.map(e=>[e.id,e])),r=[];for(let i of[...t].sort((e,t)=>e.at-t.at)){let t=e.edges.filter(e=>e.from===i.id&&e.label===`changed while it ran`).map(e=>n.get(e.to)).filter(e=>!!e&&!!e.category);if(!t.length&&i.outcome!==`requested`&&z(i)){let e=r.at(-1);if(e?.quiet){e.quiet.push(i);continue}r.push({at:i.at,key:`quiet-`+i.id,quiet:[i]})}else r.push({at:i.at,key:i.id,agent:i,changed:t})}return r}function W({item:e,root:t,onPath:n,onRunAgain:r}){if(e.quiet&&e.quiet.length>1)return(0,y.jsx)(H,{runs:e.quiet,root:t,onPath:n,onRunAgain:r});let i=e.quiet?.[0]??e.agent;return(0,y.jsx)(K,{node:i,changed:e.changed??[],root:t,onPath:n,open:i.outcome===`requested`,onRunAgain:r})}var G=({files:e,onPath:t})=>e.length>0?(0,y.jsxs)(`div`,{className:`console-changed`,children:[(0,y.jsx)(`span`,{children:`Changed while it ran`}),e.map(e=>(0,y.jsxs)(`button`,{className:`work-file`,title:e.path,onClick:()=>t(e.path),children:[(0,y.jsx)(a,{name:f(e.path),size:13,stroke:1.7}),(0,y.jsx)(`span`,{children:e.name})]},e.path))]}):null;function K({node:e,changed:t,root:n,onPath:r,open:i,onRunAgain:a}){let o=e.ran??e.command,s=d(e.command,n),c=e.outcome===`requested`,f=B(e),p=c?`Running`:e.outcome===`rejected`?`Refused`:e.outcome===`unknown`?`Outcome unknown`:f?e.end??`Failed`:null,h=e.durationMs?u(e.durationMs):``,g=a&&!c&&(V(o)?(0,y.jsx)(`button`,{className:`text-button console-again`,onClick:()=>a(o,`the Agent's command at `+R(e.at)),children:`Run again`}):(0,y.jsx)(`span`,{className:`console-note`,children:`Only its first line was recorded, so it cannot run again from here.`}));return(0,y.jsxs)(`li`,{className:`console-command`+(t.length?` made`:``)+(f?` problem`:``),children:[(0,y.jsxs)(`details`,{open:i,children:[(0,y.jsxs)(`summary`,{children:[(0,y.jsx)(`span`,{className:`console-time`,children:R(e.at)}),(0,y.jsx)(`span`,{className:`console-what`,title:o,children:e.purpose?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`span`,{className:`console-purpose`,children:e.purpose}),(0,y.jsx)(`code`,{children:s})]}):m(s)?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`code`,{className:`alone`,children:l(s)}),(0,y.jsx)(`code`,{children:s})]}):(0,y.jsx)(`code`,{className:`alone`,children:s})}),(0,y.jsx)(`span`,{className:`console-end`+(c?` running`:f?` problem`:``),children:[p,h].filter(Boolean).join(` · `)})]}),(0,y.jsxs)(`div`,{className:`console-detail`,children:[(s.includes(`
|
|
34
|
+
`)||s.length>90||o!==e.command)&&(0,y.jsx)(`pre`,{className:`console-ran`,children:d(o,n)}),e.output?.text?(0,y.jsxs)(`pre`,{className:`console-output`,ref:e=>{e&&c&&(e.scrollTop=e.scrollHeight)},children:[e.output.text,e.output.cut?`
|
|
35
|
+
…`:``]}):(0,y.jsx)(`p`,{className:`console-note`,children:c?`Running…`:`No output was reported.`}),g&&(0,y.jsx)(`div`,{className:`console-actions`,children:g})]})]}),(0,y.jsx)(G,{files:t.map(e=>({path:e.path,name:e.title})),onPath:r})]})}function q({graph:e,turn:t,root:n,onPath:r,onConversation:i,focused:a,onRunAgain:o}){let s=e.nodes.find(e=>e.id===`q:`+t.id),c=e.nodes.filter(e=>e.kind===`run`&&e.turn===t.id),l=U(e,c),u=new Set(l.flatMap(e=>(e.changed??[]).map(e=>e.path))),d=c.filter(B).length,f=(0,b.useRef)(null);return(0,b.useEffect)(()=>{a&&f.current?.scrollIntoView({block:`start`})},[a]),c.length?(0,y.jsxs)(`section`,{ref:f,className:`console-message`+(a?` focused`:``),"aria-label":s?.title??`A message`,children:[(0,y.jsxs)(`header`,{children:[(0,y.jsx)(`button`,{className:`text-button console-ask`,title:s?.text,onClick:()=>i(t.conversationId),children:s?.title??`A message`}),(0,y.jsxs)(`small`,{children:[t.agent,` · `,p(new Date(t.start).toISOString()),` · `,c.length,` `,c.length===1?`command`:`commands`,u.size?` · ${u.size} ${u.size===1?`file`:`files`} changed`:``,d?` · ${d} did not end cleanly`:``,t.running?` · working`:``]})]}),(0,y.jsx)(`ol`,{className:`console-list`,children:l.map(e=>(0,y.jsx)(W,{item:e,root:n,onPath:r,onRunAgain:o},e.key))})]}):null}function J({client:e,snapshot:t,files:n,focusTurn:r,onPath:s,onConversation:l,children:u}){let d=t.project.id,{turns:f,loading:m,problem:x,omitted:S}=v(e,t),C=(0,b.useMemo)(()=>c({turns:f,files:n.files.map(e=>({path:e.path,bytes:e.bytes,modifiedAt:e.modifiedAt,category:e.category})),project:t.project,kindOf:o,now:Date.now()}),[f,n.files,t.project]),{runs:w,problem:T,readAgain:k}=h(e,d,t.cursor),{commands:A,off:j,problem:M,read:N}=E(e,d,t.cursor),P=D(e,d,{onRan:()=>void N(),center:!0}),[F,I]=(0,b.useState)(null),L=(0,b.useRef)(null);(0,b.useEffect)(()=>{F&&!L.current?.open&&L.current?.showModal()},[F]);let R=(A??[]).filter(e=>e.state!==`running`).length;(0,b.useEffect)(()=>{A&&n.refresh()},[R]);let z=e=>{let t=Date.parse(e.startedAt),r=e.endedAt?Date.parse(e.endedAt)+1e3:Date.now();return n.files.filter(e=>e.category&&e.modifiedAt&&Date.parse(e.modifiedAt)>=t-1e3&&Date.parse(e.modifiedAt)<=r).slice(0,8)},B=[...C.turns].sort((e,t)=>t.start-e.start).filter(e=>C.nodes.some(t=>t.kind===`run`&&t.turn===e.id)),V=[];for(let e of[...B.map(e=>({at:e.start,turn:e})),...(A??[]).map(e=>({at:Date.parse(e.startedAt),record:e}))].sort((e,t)=>t.at-e.at))if(`turn`in e)V.push({kind:`message`,at:e.at,turn:e.turn});else{let t=V.at(-1);t?.kind===`mine`?t.records.push(e.record):V.push({kind:`mine`,at:e.at,records:[e.record]})}let H=[...w??[]].sort((e,t)=>t.acceptedAt.localeCompare(e.acceptedAt)),U=!m&&!x&&!T&&!M&&!V.length&&!H.length;return(0,y.jsxs)(`div`,{className:`console-page`,children:[u,!j&&(0,y.jsx)(O,{folder:i(t.project),line:P}),j&&(0,y.jsx)(`p`,{className:`console-note`,children:`Running commands here needs the Console plugin, which is off for this project.`}),M&&!j&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:M}),x&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:x}),m&&(0,y.jsx)(`p`,{className:`muted`,role:`status`,children:`Reading the conversations…`}),U&&(0,y.jsx)(`div`,{className:`empty-state compact`,children:(0,y.jsx)(`p`,{children:`No shell commands recorded. R and Python cells run through the shared sessions are kept in Notebook.`})}),V.map(n=>n.kind===`message`?(0,y.jsx)(q,{graph:C,turn:n.turn,root:t.project.root,onPath:s,onConversation:l,focused:r===n.turn.id,onRunAgain:j?void 0:P.prepare},n.turn.id):(0,y.jsxs)(`section`,{className:`console-message mine`,"aria-label":`Your commands`,children:[(0,y.jsxs)(`header`,{children:[(0,y.jsx)(`strong`,{children:`You ran`}),(0,y.jsxs)(`small`,{children:[p(n.records.at(-1).startedAt),` · `,n.records.length,` `,n.records.length===1?`command`:`commands`,n.records.some(e=>e.state===`running`)?` · running`:``]})]}),(0,y.jsx)(`ol`,{className:`console-list`,children:n.records.map(t=>(0,y.jsx)(Y,{record:t,client:e,projectId:d,changed:z(t),onPath:s,line:P},t.commandId))})]},n.records[0].commandId)),S>0&&(0,y.jsxs)(`p`,{className:`console-note`,children:[S,` earlier `,S===1?`message is`:`messages are`,` not read here.`]}),(H.length>0||T)&&(0,y.jsxs)(`section`,{className:`console-message`,"aria-label":`Managed runs`,children:[(0,y.jsxs)(`header`,{children:[(0,y.jsx)(`strong`,{children:`Managed runs`}),(0,y.jsx)(`small`,{children:`Runs Rho submitted to Core, with their retained request and output`})]}),T&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:T}),(0,y.jsx)(`ol`,{className:`console-list`,children:H.map(e=>(0,y.jsx)(`li`,{className:`console-command made`,children:(0,y.jsxs)(`button`,{className:`console-managed`,onClick:()=>I(e.operationId),children:[(0,y.jsx)(`span`,{className:`console-time`,children:new Date(e.acceptedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}),(0,y.jsx)(`code`,{children:e.script??e.action}),(0,y.jsxs)(`span`,{className:`console-end `+e.execution,children:[g(e.execution),` · `,e.operationId]})]})},e.operationId))})]}),F&&(0,y.jsxs)(`dialog`,{ref:L,className:`run-dialog`,"aria-label":F,onClose:()=>I(null),onClick:e=>{e.target===e.currentTarget&&e.currentTarget.close()},children:[(0,y.jsx)(`button`,{className:`icon-button run-dialog-close`,"aria-label":`Close`,onClick:()=>L.current?.close(),children:(0,y.jsx)(a,{name:`close`,size:18})}),(0,y.jsx)(_,{snapshot:t,client:e,operationId:F,runs:w,readRuns:k,onOpenRun:I,opener:()=>null},F)]})]})}function Y({record:e,client:t,projectId:n,changed:r,onPath:i,line:a}){return(0,y.jsx)(j,{record:e,client:t,projectId:n,made:r.length>0,after:(0,y.jsx)(G,{files:r,onPath:i}),onRunAgain:e=>void a.start(e.command),onStop:e=>void a.stop(e)})}function X({client:e,snapshot:t}){let n=I(),r=t.project.id,{commands:a,off:o,problem:s,read:c}=E(e,r,t.cursor),l=(0,b.useRef)(null),u=(0,b.useRef)(!0),d=D(e,r,{onRan:()=>{u.current=!0,c()}}),f=n?.graph,p=n?.at??null,m=(0,b.useMemo)(()=>{if(!f||!n)return[];let e=f.turns.filter(e=>e.conversationId===n.conversationId),t=Math.min(...e.map(e=>e.start)),r=U(f,f.nodes.filter(t=>t.kind===`run`&&e.some(e=>e.id===t.turn)));for(let e of a??[]){let n=Date.parse(e.startedAt);n>=t&&(p===null||n<=p)&&r.push({at:n,key:e.commandId,mine:e})}return r.sort((e,t)=>e.at-t.at)},[f,a,p,n?.conversationId]);(0,b.useEffect)(()=>{let e=l.current;e&&u.current&&(e.scrollTop=e.scrollHeight)},[m]);let h=(a??[]).filter(e=>e.state!==`running`).length;(0,b.useEffect)(()=>{a&&c()},[h]);let g=e=>n?.showPath(e),_=e=>{let t=Date.parse(e.startedAt),r=e.endedAt?Date.parse(e.endedAt)+1e3:Date.now();return(n?.files??[]).filter(e=>e.versions.some(e=>e.at>=t-1e3&&e.at<=r)).map(e=>({path:e.path,name:e.title}))};return n?(0,y.jsxs)(`div`,{className:`command-pane`,children:[(0,y.jsxs)(`ol`,{ref:l,className:`console-list command-pane-list`,onScroll:e=>{let t=e.currentTarget;u.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},children:[!m.length&&(0,y.jsx)(`li`,{className:`console-note`,children:`No commands yet. The commands the Agent runs in this conversation appear here, and you can run your own below.`}),m.map(n=>n.mine?(0,y.jsx)(Y,{record:n.mine,client:e,projectId:r,changed:_(n.mine),onPath:g,line:d},n.key):(0,y.jsx)(W,{item:n,root:t.project.root,onPath:g,onRunAgain:p===null&&!o?d.prepare:void 0},n.key))]}),p===null?o?(0,y.jsx)(`p`,{className:`console-note`,children:`Running commands here needs the Console plugin, which is off for this project.`}):(0,y.jsx)(O,{folder:i(t.project),line:d,problem:s}):(0,y.jsx)(`p`,{className:`console-note command-pane-replay`,children:`Replaying · commands run from here use the project as it is now.`})]}):(0,y.jsx)(`p`,{className:`console-note`,children:`Commands show in a conversation's Studio.`})}export{I as a,F as i,L as n,P as r,X as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,D as r,E as i,G as a,I as o,L as s,N as c,P as l,R as u,S as d,T as f,V as ee,W as te,k as ne,w as re,x as p}from"./index-CxmItXqa.js";import{a as ie,c as ae,d as m,h,i as oe,l as g,m as _,o as v,p as se,r as ce,u as le}from"./dist-DCtcCJPs.js";function ue(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 y=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=ue(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??ue(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}{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)}},b=new g;function x(e){return l.define({combine:e?t=>t.concat(e):void 0})}var de=new g,S=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,c.prototype.hasOwnProperty(`tree`)||Object.defineProperty(c.prototype,"tree",{get(){return C(this)}}),this.parser=t,this.extension=[O.of(this),c.languageData.of((e,t,n)=>{let r=fe(e,t,n),i=r.type.prop(b);if(!i)return[];let a=e.facet(i),o=r.type.prop(de);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 fe(e,t,n).type.prop(b)==this.data}findRegions(e){let t=e.facet(O);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(b)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(g.mounted);if(i){if(i.tree.prop(b)==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}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 _&&r(i,e.positions[n]+t)}};return r(C(e),0),n}get allowsNesting(){return!0}};S.setState=t.define();function fe(e,t,n){let r=e.facet(O),i=C(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,ae.ExcludeBuffers|ae.EnterBracketed))e.type.isTop&&(i=e);return i}var pe=class e extends S{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=x(t.languageData);return new e(n,t.parser.configure({props:[b.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 C(e){let t=e.field(S.state,!1);return t?t.tree:_.empty}function me(e,t,n=50){let r=e.field(S.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}function he(e,t=e.doc.length){return e.field(S.state,!1)?.context.isDone(t)||!1}function ge(e,t=e.viewport.to,n=100){let r=me(e.state,t,n);return r!=C(e.state)&&e.dispatch({}),!!r}function _e(e){return e.plugin(xe)?.isWorking()||!1}var ve=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)}},w=null,T=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,[],_.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ve(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=_.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(h.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(h.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=w;w=this;try{return e()}finally{w=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ye(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=h.applyChanges(r,e),i=_.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=ye(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 se{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=w;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 _(m.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 w}};function ye(e,t,n){return h.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var E=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=T.create(t.facet(O).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};S.state=ee.define({create:E.init,update(e,t){for(let e of t.effects)if(e.is(S.setState))return e.value;return t.startState.facet(O)==t.state.facet(O)?e.apply(t):E.init(t.state)}});var be=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(be=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var D=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,xe=f.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(S.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(S.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=be(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(S.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!D?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>D&&D()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:S.setState.of(new E(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=>ne(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),O=l.define({combine(e){return e.length?e[0]:null},enables:e=>[S.state,xe,n.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Se=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Ce=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}},we=l.define(),k=l.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 A(e){let t=e.facet(k);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function j(e,t){let n=``,r=e.tabSize,i=e.facet(k)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function M(e,t){e instanceof c&&(e=new N(e));for(let n of e.state.facet(we)){let r=n(e,t);if(r!==void 0)return r}let n=C(e.state);return n.length>=t?Ee(e,n,t):null}function Te(e,t,n){let r=Object.create(null),i=new N(e,{overrideIndentation:e=>r[e]??-1}),a=[];for(let o=t;o<=n;){let t=e.doc.lineAt(o);o=t.to+1;let n=M(i,t.from);if(n==null)continue;/\S/.test(t.text)||(n=0);let s=/^\s*/.exec(t.text)[0],c=j(e,n);s!=c&&(r[t.from]=n,a.push({from:t.from,to:t.from+s.length,insert:c}))}return e.changes(a)}var N=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=A(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 a(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}},P=new g;function Ee(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 De(r,e,n)}function De(e,t,n){for(let r=e;r;r=r.next){let e=ke(r.node);if(e)return e(je.create(t,n,r))}return 0}function Oe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function ke(e){let t=e.type.prop(P);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(g.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Fe(e,!0,1,void 0,n&&!Oe(e)?t.from:void 0)}return e.parent==null?Ae:null}function Ae(){return 0}var je=class e extends N{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(Me(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return De(this.context.next,this.base,this.pos)}};function Me(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Ne(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 Pe({closing:e,align:t=!0,units:n=1}){return r=>Fe(r,t,n,e)}function Fe(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?Ne(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Ie=e=>e.baseIndent;function Le({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Re=200;function ze(){return c.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+Re)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=M(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=j(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 Be=l.define(),Ve=new g;function He(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 Ue(e,t,n){let r=C(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(Ve);if(s&&(i.to<r.length-50||r.length==e.doc.length||!We(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function We(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function F(e,t,n){for(let r of e.facet(Be)){let i=r(e,t,n);if(i)return i}return Ue(e,t,n)}function Ge(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 I=t.define({map:Ge}),L=t.define({map:Ge});function R(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 z=ee.define({create(){return p.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=Ke(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(I)&&!Je(e,r.value.from,r.value.to)?n.push(r.value):r.is(L)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(U),i=n.map(e=>(r?p.replace({widget:new at(r(t.state,e))}):it).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=Ke(e,t.selection.main.head)),e},provide:e=>n.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(it.range(r,i))}return p.set(t,!0)}});function Ke(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 qe(e){return e.field(z,!1)||s.empty}function B(e,t,n){var r;let i=null;return(r=e.field(z,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Je(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function V(e,n){return e.field(z,!1)?n:n.concat(t.appendConfig.of(W()))}var Ye=e=>{for(let t of R(e)){let n=F(e.state,t.from,t.to);if(n)return e.dispatch({effects:V(e.state,[I.of(n),H(e,n)])}),!0}return!1},Xe=e=>{if(!e.state.field(z,!1))return!1;let t=[];for(let n of R(e)){let r=B(e.state,n.from,n.to);r&&t.push(L.of(r),H(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function H(e,t,r=!0){let i=e.state.doc.lineAt(t.from).number,a=e.state.doc.lineAt(t.to).number;return n.announce.of(`${e.state.phrase(r?`Folded lines`:`Unfolded lines`)} ${i} ${e.state.phrase(`to`)} ${a}.`)}var Ze=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=F(t,i.from,i.to);a&&n.push(I.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:V(e.state,n)}),!!n.length},Qe=e=>{let t=e.state.field(z,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(L.of({from:e,to:t}))}),e.dispatch({effects:n}),!0};function $e(e,t){for(let n=t;;){let r=F(e.state,n.from,n.to);if(r&&r.to>t.from)return r;if(!n.from)return null;n=e.lineBlockAt(n.from-1)}}var et=e=>{let t=[];for(let n of R(e)){let r=B(e.state,n.from,n.to);if(r)t.push(L.of(r),H(e,r,!1));else{let r=$e(e,n);r&&t.push(I.of(r),H(e,r))}}return t.length>0&&e.dispatch({effects:V(e.state,t)}),!!t.length},tt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Ye},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Xe},{key:`Ctrl-Alt-[`,run:Ze},{key:`Ctrl-Alt-]`,run:Qe}],nt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},U=l.define({combine(e){return te(e,nt)}});function W(e){let t=[z,ct];return e&&t.push(U.of(e)),t}function rt(e,t){let{state:n}=e,r=n.facet(U),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=B(e.state,n.from,n.to);r&&e.dispatch({effects:L.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 it=p.replace({widget:new class extends i{toDOM(e){return rt(e,null)}}}),at=class extends i{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return rt(e,this.value)}},ot={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},G=class extends re{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 st(e={}){let t={...ot,...e},n=new G(t,!0),i=new G(t,!1),a=f.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(O)!=e.state.facet(O)||e.startState.field(z,!1)!=e.state.field(z,!1)||C(e.startState)!=C(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new u;for(let r of e.viewportLineBlocks){let a=B(e.state,r.from,r.to)?i:F(e.state,r.from,r.to)?n:null;a&&t.add(r.from,r.from,a)}return t.finish()}}),{domEventHandlers:o}=t;return[a,r({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||s.empty},initialSpacer(){return new G(t,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=B(e.state,t.from,t.to);if(r)return e.dispatch({effects:L.of(r)}),!0;let i=F(e.state,t.from,t.to);return i?(e.dispatch({effects:I.of(i)}),!0):!1}}}),W()]}var ct=n.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`}}),K=class t{constructor(t,n){this.specs=t;let r;function i(t){let n=e.newName();return(r||=Object.create(null))[`.`+n]=t,n}let a=typeof n.all==`string`?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof S?e=>e.prop(b)==o.data:o?e=>e==o:void 0,this.style=ie(t.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:a}).style,this.module=r?new e(r):null,this.themeType=n.themeType}static define(e,n){return new t(e,n||{})}},q=l.define(),lt=l.define({combine(e){return e.length?[e[0]]:null}});function J(e){let t=e.facet(q);return t.length?t:e.facet(lt)}function ut(e,t){let r=[pt],i;return e instanceof K&&(e.module&&r.push(n.styleModule.of(e.module)),i=e.themeType),t?.fallback?r.push(lt.of(e)):i?r.push(q.computeN([n.darkTheme],t=>t.facet(n.darkTheme)==(i==`dark`)?[e]:[])):r.push(q.of(e)),r}function dt(e,t,n){let r=J(e),i=null;if(r){for(let e of r)if(!e.scope||n&&e.scope(n)){let n=e.style(t);n&&(i=i?i+` `+n:n)}}return i}var ft=class{constructor(e){this.markCache=Object.create(null),this.tree=C(e.state),this.decorations=this.buildDeco(e,J(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=C(e.state),n=J(e.state),r=n!=J(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 p.none;let n=new u;for(let{from:r,to:i}of e.visibleRanges)ce(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=p.mark({class:r})))},r,i);return n.finish()}},pt=o.high(f.fromClass(ft,{decorations:e=>e.decorations})),mt=K.define([{tag:v.meta,color:`#404740`},{tag:v.link,textDecoration:`underline`},{tag:v.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:v.emphasis,fontStyle:`italic`},{tag:v.strong,fontWeight:`bold`},{tag:v.strikethrough,textDecoration:`line-through`},{tag:v.keyword,color:`#708`},{tag:[v.atom,v.bool,v.url,v.contentSeparator,v.labelName],color:`#219`},{tag:[v.literal,v.inserted],color:`#164`},{tag:[v.string,v.deleted],color:`#a11`},{tag:[v.regexp,v.escape,v.special(v.string)],color:`#e40`},{tag:v.definition(v.variableName),color:`#00f`},{tag:v.local(v.variableName),color:`#30a`},{tag:[v.typeName,v.namespace],color:`#085`},{tag:v.className,color:`#167`},{tag:[v.special(v.variableName),v.macroName],color:`#256`},{tag:v.definition(v.propertyName),color:`#00c`},{tag:v.comment,color:`#940`},{tag:v.invalid,color:`#f00`}]),ht=n.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),gt=1e4,_t=`()[]{}`,vt=l.define({combine(e){return te(e,{afterCursor:!0,brackets:_t,maxScanDistance:gt,renderMatch:xt})}}),yt=p.mark({class:`cm-matchingBracket`}),bt=p.mark({class:`cm-nonmatchingBracket`});function xt(e){let t=[],n=e.matched?yt:bt;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 St(e){let t=[],n=e.facet(vt);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Z(e,r.head,-1,n)||r.head>0&&Z(e,r.head-1,1,n)||n.afterCursor&&(Z(e,r.head,1,n)||r.head<e.doc.length&&Z(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return p.set(t,!0)}var Ct=[f.fromClass(class{constructor(e){this.paused=!1,this.decorations=St(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=St(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),ht];function wt(e={}){return[vt.of(e),Ct]}var Tt=new g;function Y(e,t,n){let r=e.prop(t<0?g.openedBy:g.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 X(e){let t=e.type.prop(Tt);return t?t(e.node):e}function Z(e,t,n,r={}){let i=r.maxScanDistance||gt,a=r.brackets||_t,o=C(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=Y(r.type,n,a);if(i&&r.from<r.to){let o=X(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Et(e,t,n,r,o,i,a)}}return Dt(e,t,n,o,s.type,i,a)}function Et(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=X(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(Y(u.type,n,o))l++;else if(Y(u.type,-n,o)){if(l==0){let e=X(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 Dt(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 Ot(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||kt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Lt,mergeTokens:e.mergeTokens!==!1}}function kt(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 At=new WeakMap,jt=class e extends S{constructor(e){let t=x(e.languageData),n=Ot(e),r,i=new class extends se{createParse(e,t,n){return new Ft(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Kt(t,this),r=this,this.streamParser=n,this.stateAfter=new g({perNode:!0}),this.tokenTable=e.tokenTable?new Ht(n.tokenTable):Ut}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=At.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Mt(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 y(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)It(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&&At.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Mt(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 _&&s<i&&Mt(e,o,s,r,i);if(c)return c}return null}function Nt(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 _){if(!(c=Nt(e,s,n-o,r-o,i)))break;return i?new _(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Pt(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&&Mt(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=Nt(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?A(i):4),tree:_.empty}}var Ft=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=T.get(),a=r[0].from,{state:o,tree:s}=Pt(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(A(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=T.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==`
|
|
1
|
+
import{A as e,B as t,C as n,D as r,E as i,G as a,I as o,L as s,N as c,P as l,R as u,S as d,T as f,V as ee,W as te,k as ne,w as re,x as p}from"./index-CWg9XYXx.js";import{a as ie,c as ae,d as m,h,i as oe,l as g,m as _,o as v,p as se,r as ce,u as le}from"./dist-DCtcCJPs.js";function ue(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 y=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=ue(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??ue(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}{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)}},b=new g;function x(e){return l.define({combine:e?t=>t.concat(e):void 0})}var de=new g,S=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,c.prototype.hasOwnProperty(`tree`)||Object.defineProperty(c.prototype,"tree",{get(){return C(this)}}),this.parser=t,this.extension=[O.of(this),c.languageData.of((e,t,n)=>{let r=fe(e,t,n),i=r.type.prop(b);if(!i)return[];let a=e.facet(i),o=r.type.prop(de);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 fe(e,t,n).type.prop(b)==this.data}findRegions(e){let t=e.facet(O);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(b)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(g.mounted);if(i){if(i.tree.prop(b)==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}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 _&&r(i,e.positions[n]+t)}};return r(C(e),0),n}get allowsNesting(){return!0}};S.setState=t.define();function fe(e,t,n){let r=e.facet(O),i=C(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,ae.ExcludeBuffers|ae.EnterBracketed))e.type.isTop&&(i=e);return i}var pe=class e extends S{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=x(t.languageData);return new e(n,t.parser.configure({props:[b.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 C(e){let t=e.field(S.state,!1);return t?t.tree:_.empty}function me(e,t,n=50){let r=e.field(S.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}function he(e,t=e.doc.length){return e.field(S.state,!1)?.context.isDone(t)||!1}function ge(e,t=e.viewport.to,n=100){let r=me(e.state,t,n);return r!=C(e.state)&&e.dispatch({}),!!r}function _e(e){return e.plugin(xe)?.isWorking()||!1}var ve=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)}},w=null,T=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,[],_.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ve(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=_.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(h.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(h.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=w;w=this;try{return e()}finally{w=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ye(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=h.applyChanges(r,e),i=_.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=ye(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 se{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=w;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 _(m.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 w}};function ye(e,t,n){return h.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var E=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=T.create(t.facet(O).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};S.state=ee.define({create:E.init,update(e,t){for(let e of t.effects)if(e.is(S.setState))return e.value;return t.startState.facet(O)==t.state.facet(O)?e.apply(t):E.init(t.state)}});var be=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(be=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var D=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,xe=f.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(S.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(S.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=be(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(S.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!D?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>D&&D()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:S.setState.of(new E(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=>ne(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),O=l.define({combine(e){return e.length?e[0]:null},enables:e=>[S.state,xe,n.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Se=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Ce=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}},we=l.define(),k=l.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 A(e){let t=e.facet(k);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function j(e,t){let n=``,r=e.tabSize,i=e.facet(k)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function M(e,t){e instanceof c&&(e=new N(e));for(let n of e.state.facet(we)){let r=n(e,t);if(r!==void 0)return r}let n=C(e.state);return n.length>=t?Ee(e,n,t):null}function Te(e,t,n){let r=Object.create(null),i=new N(e,{overrideIndentation:e=>r[e]??-1}),a=[];for(let o=t;o<=n;){let t=e.doc.lineAt(o);o=t.to+1;let n=M(i,t.from);if(n==null)continue;/\S/.test(t.text)||(n=0);let s=/^\s*/.exec(t.text)[0],c=j(e,n);s!=c&&(r[t.from]=n,a.push({from:t.from,to:t.from+s.length,insert:c}))}return e.changes(a)}var N=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=A(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 a(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}},P=new g;function Ee(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 De(r,e,n)}function De(e,t,n){for(let r=e;r;r=r.next){let e=ke(r.node);if(e)return e(je.create(t,n,r))}return 0}function Oe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function ke(e){let t=e.type.prop(P);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(g.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Fe(e,!0,1,void 0,n&&!Oe(e)?t.from:void 0)}return e.parent==null?Ae:null}function Ae(){return 0}var je=class e extends N{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(Me(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return De(this.context.next,this.base,this.pos)}};function Me(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Ne(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 Pe({closing:e,align:t=!0,units:n=1}){return r=>Fe(r,t,n,e)}function Fe(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?Ne(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Ie=e=>e.baseIndent;function Le({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Re=200;function ze(){return c.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+Re)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=M(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=j(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 Be=l.define(),Ve=new g;function He(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 Ue(e,t,n){let r=C(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(Ve);if(s&&(i.to<r.length-50||r.length==e.doc.length||!We(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function We(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function F(e,t,n){for(let r of e.facet(Be)){let i=r(e,t,n);if(i)return i}return Ue(e,t,n)}function Ge(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 I=t.define({map:Ge}),L=t.define({map:Ge});function R(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 z=ee.define({create(){return p.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=Ke(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(I)&&!Je(e,r.value.from,r.value.to)?n.push(r.value):r.is(L)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(U),i=n.map(e=>(r?p.replace({widget:new at(r(t.state,e))}):it).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=Ke(e,t.selection.main.head)),e},provide:e=>n.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(it.range(r,i))}return p.set(t,!0)}});function Ke(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 qe(e){return e.field(z,!1)||s.empty}function B(e,t,n){var r;let i=null;return(r=e.field(z,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Je(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function V(e,n){return e.field(z,!1)?n:n.concat(t.appendConfig.of(W()))}var Ye=e=>{for(let t of R(e)){let n=F(e.state,t.from,t.to);if(n)return e.dispatch({effects:V(e.state,[I.of(n),H(e,n)])}),!0}return!1},Xe=e=>{if(!e.state.field(z,!1))return!1;let t=[];for(let n of R(e)){let r=B(e.state,n.from,n.to);r&&t.push(L.of(r),H(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function H(e,t,r=!0){let i=e.state.doc.lineAt(t.from).number,a=e.state.doc.lineAt(t.to).number;return n.announce.of(`${e.state.phrase(r?`Folded lines`:`Unfolded lines`)} ${i} ${e.state.phrase(`to`)} ${a}.`)}var Ze=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=F(t,i.from,i.to);a&&n.push(I.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:V(e.state,n)}),!!n.length},Qe=e=>{let t=e.state.field(z,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(L.of({from:e,to:t}))}),e.dispatch({effects:n}),!0};function $e(e,t){for(let n=t;;){let r=F(e.state,n.from,n.to);if(r&&r.to>t.from)return r;if(!n.from)return null;n=e.lineBlockAt(n.from-1)}}var et=e=>{let t=[];for(let n of R(e)){let r=B(e.state,n.from,n.to);if(r)t.push(L.of(r),H(e,r,!1));else{let r=$e(e,n);r&&t.push(I.of(r),H(e,r))}}return t.length>0&&e.dispatch({effects:V(e.state,t)}),!!t.length},tt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Ye},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Xe},{key:`Ctrl-Alt-[`,run:Ze},{key:`Ctrl-Alt-]`,run:Qe}],nt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},U=l.define({combine(e){return te(e,nt)}});function W(e){let t=[z,ct];return e&&t.push(U.of(e)),t}function rt(e,t){let{state:n}=e,r=n.facet(U),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=B(e.state,n.from,n.to);r&&e.dispatch({effects:L.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 it=p.replace({widget:new class extends i{toDOM(e){return rt(e,null)}}}),at=class extends i{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return rt(e,this.value)}},ot={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},G=class extends re{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 st(e={}){let t={...ot,...e},n=new G(t,!0),i=new G(t,!1),a=f.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(O)!=e.state.facet(O)||e.startState.field(z,!1)!=e.state.field(z,!1)||C(e.startState)!=C(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new u;for(let r of e.viewportLineBlocks){let a=B(e.state,r.from,r.to)?i:F(e.state,r.from,r.to)?n:null;a&&t.add(r.from,r.from,a)}return t.finish()}}),{domEventHandlers:o}=t;return[a,r({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||s.empty},initialSpacer(){return new G(t,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=B(e.state,t.from,t.to);if(r)return e.dispatch({effects:L.of(r)}),!0;let i=F(e.state,t.from,t.to);return i?(e.dispatch({effects:I.of(i)}),!0):!1}}}),W()]}var ct=n.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`}}),K=class t{constructor(t,n){this.specs=t;let r;function i(t){let n=e.newName();return(r||=Object.create(null))[`.`+n]=t,n}let a=typeof n.all==`string`?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof S?e=>e.prop(b)==o.data:o?e=>e==o:void 0,this.style=ie(t.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:a}).style,this.module=r?new e(r):null,this.themeType=n.themeType}static define(e,n){return new t(e,n||{})}},q=l.define(),lt=l.define({combine(e){return e.length?[e[0]]:null}});function J(e){let t=e.facet(q);return t.length?t:e.facet(lt)}function ut(e,t){let r=[pt],i;return e instanceof K&&(e.module&&r.push(n.styleModule.of(e.module)),i=e.themeType),t?.fallback?r.push(lt.of(e)):i?r.push(q.computeN([n.darkTheme],t=>t.facet(n.darkTheme)==(i==`dark`)?[e]:[])):r.push(q.of(e)),r}function dt(e,t,n){let r=J(e),i=null;if(r){for(let e of r)if(!e.scope||n&&e.scope(n)){let n=e.style(t);n&&(i=i?i+` `+n:n)}}return i}var ft=class{constructor(e){this.markCache=Object.create(null),this.tree=C(e.state),this.decorations=this.buildDeco(e,J(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=C(e.state),n=J(e.state),r=n!=J(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 p.none;let n=new u;for(let{from:r,to:i}of e.visibleRanges)ce(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=p.mark({class:r})))},r,i);return n.finish()}},pt=o.high(f.fromClass(ft,{decorations:e=>e.decorations})),mt=K.define([{tag:v.meta,color:`#404740`},{tag:v.link,textDecoration:`underline`},{tag:v.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:v.emphasis,fontStyle:`italic`},{tag:v.strong,fontWeight:`bold`},{tag:v.strikethrough,textDecoration:`line-through`},{tag:v.keyword,color:`#708`},{tag:[v.atom,v.bool,v.url,v.contentSeparator,v.labelName],color:`#219`},{tag:[v.literal,v.inserted],color:`#164`},{tag:[v.string,v.deleted],color:`#a11`},{tag:[v.regexp,v.escape,v.special(v.string)],color:`#e40`},{tag:v.definition(v.variableName),color:`#00f`},{tag:v.local(v.variableName),color:`#30a`},{tag:[v.typeName,v.namespace],color:`#085`},{tag:v.className,color:`#167`},{tag:[v.special(v.variableName),v.macroName],color:`#256`},{tag:v.definition(v.propertyName),color:`#00c`},{tag:v.comment,color:`#940`},{tag:v.invalid,color:`#f00`}]),ht=n.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),gt=1e4,_t=`()[]{}`,vt=l.define({combine(e){return te(e,{afterCursor:!0,brackets:_t,maxScanDistance:gt,renderMatch:xt})}}),yt=p.mark({class:`cm-matchingBracket`}),bt=p.mark({class:`cm-nonmatchingBracket`});function xt(e){let t=[],n=e.matched?yt:bt;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 St(e){let t=[],n=e.facet(vt);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Z(e,r.head,-1,n)||r.head>0&&Z(e,r.head-1,1,n)||n.afterCursor&&(Z(e,r.head,1,n)||r.head<e.doc.length&&Z(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return p.set(t,!0)}var Ct=[f.fromClass(class{constructor(e){this.paused=!1,this.decorations=St(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=St(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),ht];function wt(e={}){return[vt.of(e),Ct]}var Tt=new g;function Y(e,t,n){let r=e.prop(t<0?g.openedBy:g.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 X(e){let t=e.type.prop(Tt);return t?t(e.node):e}function Z(e,t,n,r={}){let i=r.maxScanDistance||gt,a=r.brackets||_t,o=C(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=Y(r.type,n,a);if(i&&r.from<r.to){let o=X(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Et(e,t,n,r,o,i,a)}}return Dt(e,t,n,o,s.type,i,a)}function Et(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=X(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(Y(u.type,n,o))l++;else if(Y(u.type,-n,o)){if(l==0){let e=X(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 Dt(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 Ot(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||kt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Lt,mergeTokens:e.mergeTokens!==!1}}function kt(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 At=new WeakMap,jt=class e extends S{constructor(e){let t=x(e.languageData),n=Ot(e),r,i=new class extends se{createParse(e,t,n){return new Ft(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Kt(t,this),r=this,this.streamParser=n,this.stateAfter=new g({perNode:!0}),this.tokenTable=e.tokenTable?new Ht(n.tokenTable):Ut}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=At.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Mt(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 y(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)It(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&&At.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Mt(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 _&&s<i&&Mt(e,o,s,r,i);if(c)return c}return null}function Nt(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 _){if(!(c=Nt(e,s,n-o,r-o,i)))break;return i?new _(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Pt(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&&Mt(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=Nt(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?A(i):4),tree:_.empty}}var Ft=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=T.get(),a=r[0].from,{state:o,tree:s}=Pt(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(A(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=T.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==`
|
|
2
2
|
`&&(t=``);else{let e=t.indexOf(`
|
|
3
3
|
`);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 y(t,e?e.state.tabSize:4,e?A(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=It(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=_.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Rt,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new _(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 _(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function It(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 Lt=Object.create(null),Q=[m.none],Rt=new le(Q),zt=[],Bt=Object.create(null),Vt=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`]])Vt[e]=Gt(Lt,t);var Ht=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Vt)}resolve(e){return e?this.table[e]||(this.table[e]=Gt(this.extra,e)):0}},Ut=new Ht(Lt);function Wt(e,t){zt.indexOf(e)>-1||(zt.push(e),console.warn(t))}function Gt(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||v[n];r?typeof r==`function`?t.length?t=t.map(r):Wt(n,`Modifier ${n} used at start of tag`):t.length?Wt(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Wt(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=Bt[i];if(a)return a.id;let o=Bt[i]=m.define({id:Q.length,name:r,props:[oe({[r]:n})]});return Q.push(o),o.id}function Kt(e,t){let n=m.define({id:Q.length,name:`Document`,props:[b.add(()=>e),P.add(()=>e=>t.getIndent(e))],top:!0});return Q.push(n),n}function qt(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function Jt(e){for(let t=e.iter();!t.next().done;)if(qt(t.value))return!0;return!1}function Yt(e){let t=!1;return e.iterChanges((e,n,r,i,a)=>{!t&&Jt(a)&&(t=!0)}),t}var $=l.define({combine:e=>e.some(e=>e)});function Xt(e={}){let t=[Zt];return e.alwaysIsolate&&t.push($.of(!0)),t}var Zt=f.fromClass(class{constructor(e){this.always=e.state.facet($)||e.textDirection!=d.LTR||e.state.facet(n.perLineTextDirection),this.hasRTL=!this.always&&Jt(e.state.doc),this.tree=C(e.state),this.decorations=this.always||this.hasRTL?Qt(e,this.tree,this.always):p.none}update(e){let t=e.state.facet($)||e.view.textDirection!=d.LTR||e.state.facet(n.perLineTextDirection);if(!t&&!this.hasRTL&&Yt(e.changes)&&(this.hasRTL=!0),!t&&!this.hasRTL)return;let r=C(e.state);(t!=this.always||r!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=r,this.always=t,this.decorations=Qt(e.view,r,t))}},{provide:e=>{function t(t){return t.plugin(e)?.decorations??p.none}return[n.outerDecorations.of(t),o.lowest(n.bidiIsolatedRanges.of(t))]}});function Qt(e,t,n){let r=new u,i=e.visibleRanges;n||(i=$t(i,e.state.doc));for(let{from:e,to:n}of i)t.iterate({enter:e=>{let t=e.type.prop(g.isolate);t&&r.add(e.from,e.to,en[t])},from:e,to:n});return r.finish()}function $t(e,t){let n=t.iter(),r=0,i=[],a=null;for(let{from:t,to:o}of e)if(!(a&&a.to>t&&(t=a.to,t>=o)))for(r+n.value.length<t&&(n.next(t-(r+n.value.length)),r=t);;){let e=r,t=r+n.value.length;if(!n.lineBreak&&qt(n.value)&&(a&&a.to>e-10?a.to=Math.min(o,t):i.push(a={from:e,to:Math.min(o,t)})),t>=o)break;r=t,n.next()}return i}var en={rtl:p.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`rtl`},bidiIsolate:d.RTL}),ltr:p.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`ltr`},bidiIsolate:d.LTR}),auto:p.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`auto`},bidiIsolate:null})};export{ve as DocInput,K as HighlightStyle,N as IndentContext,pe as LRLanguage,S as Language,Ce as LanguageDescription,Se as LanguageSupport,T as ParseContext,jt as StreamLanguage,y as StringStream,je as TreeIndentContext,Xt as bidiIsolates,wt as bracketMatching,Tt as bracketMatchingHandle,W as codeFolding,Le as continuedIndent,mt as defaultHighlightStyle,x as defineLanguageFacet,Pe as delimitedIndent,me as ensureSyntaxTree,Ie as flatIndent,Ze as foldAll,Ye as foldCode,I as foldEffect,st as foldGutter,He as foldInside,tt as foldKeymap,Ve as foldNodeProp,Be as foldService,z as foldState,F as foldable,qe as foldedRanges,ge as forceParsing,A as getIndentUnit,M as getIndentation,dt as highlightingFor,P as indentNodeProp,ze as indentOnInput,Te as indentRange,we as indentService,j as indentString,k as indentUnit,O as language,b as languageDataProp,Z as matchBrackets,de as sublanguageProp,ut as syntaxHighlighting,_e as syntaxParserRunning,C as syntaxTree,he as syntaxTreeAvailable,et as toggleFold,Qe as unfoldAll,Xe as unfoldCode,L as unfoldEffect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,C as t,E as n,F as r,H as i,I as a,M as o,O as s,P as c,U as l,V as u,j as d,x as f,z as p}from"./index-CxmItXqa.js";import{c as ee,d as te,l as m,m as h,p as g,s as ne,u as re}from"./dist-DCtcCJPs.js";import{indentUnit as ie,syntaxTree as _}from"./dist-Tzoe_zm-.js";var v=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=_(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(se(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 y(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 ae(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=y(t)+y(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function b(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:ae(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function oe(e,t){return n=>{for(let t=_(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)}}function se(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 ce=d.define();typeof navigator==`object`&&navigator.platform;var x=t.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`}}}),S=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},C=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,r.TrackDel),i=t.mapPos(this.to,1,r.TrackDel);return n==null||i==null?null:new e(this.field,n,i)}},w=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(ie);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 C(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;t===0&&(t=1e9);let 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 S(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)}},le=f.widget({widget:new class extends n{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),ue=f.mark({class:`cm-snippetField`}),T=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=f.set(e.map(e=>(e.from==e.to?le:ue).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))}},E=e.define({map(e,t){return e&&e.map(t)}}),de=e.define(),D=u.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(E))return n.value;if(n.is(de)&&e)return new T(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=>t.decorations.from(e,e=>e?e.deco:f.none)});function O(e,t){return o.create(e.filter(e=>e.field==t).map(e=>o.range(e.from,e.to)))}function fe(t){let n=w.parse(t);return(t,r,a,o)=>{let{text:s,ranges:c}=n.instantiate(t.state,a),{main:u}=t.state.selection,d={changes:{from:a,to:o==u.from?u.to:o,insert:i.of(s)},scrollIntoView:!0,annotations:r?[ce.of(r),l.userEvent.of(`input.complete`)]:void 0};if(c.length&&(d.selection=O(c,0)),c.some(e=>e.field>0)){let n=new T(c,0),r=d.effects=[E.of(n)];t.state.field(D,!1)===void 0&&r.push(e.appendConfig.of([D,M,P,x]))}t.dispatch(t.state.update(d))}}function k(e){return({state:t,dispatch:n})=>{let r=t.field(D,!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:O(r.ranges,i),effects:E.of(a?null:new T(r.ranges,i)),scrollIntoView:!0})),!0}}var A=[{key:`Tab`,run:k(1),shift:k(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(D,!1)?(t(e.update({effects:E.of(null)})),!0):!1}],j=c.define({combine(e){return e.length?e[0]:A}}),M=a.highest(s.compute([j],e=>e.facet(j)));function N(e,t){return{...t,apply:fe(e)}}var P=t.domEventHandlers({mousedown(e,t){let n=t.state.field(D,!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:O(n.ranges,i.field),effects:E.of(n.ranges.some(e=>e.field>i.field)?new T(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),F=new class extends p{};F.startSide=1,F.endSide=-1,typeof navigator==`object`&&navigator.userAgent;var I=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new L(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.reducePos=this.pos=n+e.length;this.pushState(t,n),this.buffer.push(r,n,i,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new R(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.storeNode(this.curContext.hash,this.reducePos,this.reducePos,-3,!0)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new L(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},L=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},R=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},z=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function B(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var V=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},H=new V,pe=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=H,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=H,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},U=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;G(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};U.prototype.contextual=U.prototype.fallback=U.prototype.extend=!1;var W=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?B(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(G(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};W.prototype.contextual=U.prototype.fallback=U.prototype.extend=!1;var me=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function G(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||he(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function K(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function he(e,t,n,r){let i=K(n,r,t);return i<0||K(n,r,e)<i}var q=typeof process<`u`&&/\bparse\b/.test({}.LOG),J=null;function Y(e,t,n){let r=e.cursor(ee.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var ge=class{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Y(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Y(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof h){let n=a>this.lastRepeatPos&&i.type.id>=this.minRepeat;if(a==e||n){let t=a+i.length,r;if(a>=this.safeFrom&&t<=this.safeTo&&(!(r=i.prop(m.lookAhead))||t+r<this.fragment.to)){if(n&&(this.lastRepeat=i,this.lastRepeatPos=a),a==e)return i}else if(a==e)return null}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},_e=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new V)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if((!n||c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new V,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new V,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535){if(o[s+1]==1)s=Q(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(Q(o,s+2),t,n,r));break}}o[s]==t&&(r=this.putAction(Q(o,s+1),t,n,r))}return r}},ve=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new pe(t,r),this.tokens=new _e(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[I.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new ge(n,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&Se(r);if(e)return q&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw q&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return q&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}tryReuse(e,t,n,r){if(!n)return null;let i=e.curContext&&e.curContext.tracker.strict,a=i?e.curContext.hash:0;for(;n;){let o=this.parser.nodeSet.types[n.type.id]==n.type?this.parser.getGoto(e.state,n.type.id):-1;if(o>-1&&n.length&&(!i||(n.prop(m.contextHash)||0)==a))return e.useNode(n,o,t),n;if(n.children.length==0||n.positions[0]>0)break;let s=n.children[0];if(s instanceof h&&(!r||s.type.id>=this.parser.minRepeatTerm))n=s;else break}return null}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=q?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.reducePos<r&&e.buffer.length&&e.buffer[e.buffer.length-2]<=e.reducePos&&this.fragments.lastRepeatPos==e.reducePos&&this.tryReuse(e,e.reducePos,this.fragments.lastRepeat,!0)||this.tryReuse(e,r,this.fragments.nodeAt(r),!1);if(t)return q&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(t.type.id)})`),!0}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),q&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),q&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return X(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=q?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),q&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(q&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)q&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))q&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),q&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),X(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),h.build({buffer:z.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(J||=new WeakMap).get(e);return t||J.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function X(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var ye=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},Z=e=>e,be=class{constructor(e){this.start=e.start,this.shift=e.shift||Z,this.reduce=e.reduce||Z,this.reuse=e.reuse||Z,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},xe=class e extends g{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=m[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new re(t.map((t,i)=>te.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=ne;let a=B(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map($),this.states=B(e.states,Uint32Array),this.data=B(e.stateData),this.goto=B(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new U(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new ve(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535){if(n[i+1]==1)a=n[i=Q(n,i+2)];else if(n[i+1]==2)return Q(n,i+2);else break}if(a==t||a==0)return Q(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=Q(this.data,n+2);else break}r=t(Q(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=Q(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=$(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new ye(e,n,r)}static deserialize(t){return new e(t)}};function Q(e,t){return e[t]|e[t+1]<<16}function Se(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function $(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}export{v as a,N as c,W as i,me as n,b as o,xe as r,oe as s,be as t};
|
|
1
|
+
import{B as e,C as t,E as n,F as r,H as i,I as a,M as o,O as s,P as c,U as l,V as u,j as d,x as f,z as p}from"./index-CWg9XYXx.js";import{c as ee,d as te,l as m,m as h,p as g,s as ne,u as re}from"./dist-DCtcCJPs.js";import{indentUnit as ie,syntaxTree as _}from"./dist-CSiCyBml.js";var v=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=_(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(se(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 y(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 ae(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=y(t)+y(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function b(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:ae(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function oe(e,t){return n=>{for(let t=_(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)}}function se(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 ce=d.define();typeof navigator==`object`&&navigator.platform;var x=t.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`}}}),S=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},C=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,r.TrackDel),i=t.mapPos(this.to,1,r.TrackDel);return n==null||i==null?null:new e(this.field,n,i)}},w=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(ie);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 C(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;t===0&&(t=1e9);let 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 S(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)}},le=f.widget({widget:new class extends n{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),ue=f.mark({class:`cm-snippetField`}),T=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=f.set(e.map(e=>(e.from==e.to?le:ue).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))}},E=e.define({map(e,t){return e&&e.map(t)}}),de=e.define(),D=u.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(E))return n.value;if(n.is(de)&&e)return new T(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=>t.decorations.from(e,e=>e?e.deco:f.none)});function O(e,t){return o.create(e.filter(e=>e.field==t).map(e=>o.range(e.from,e.to)))}function fe(t){let n=w.parse(t);return(t,r,a,o)=>{let{text:s,ranges:c}=n.instantiate(t.state,a),{main:u}=t.state.selection,d={changes:{from:a,to:o==u.from?u.to:o,insert:i.of(s)},scrollIntoView:!0,annotations:r?[ce.of(r),l.userEvent.of(`input.complete`)]:void 0};if(c.length&&(d.selection=O(c,0)),c.some(e=>e.field>0)){let n=new T(c,0),r=d.effects=[E.of(n)];t.state.field(D,!1)===void 0&&r.push(e.appendConfig.of([D,M,P,x]))}t.dispatch(t.state.update(d))}}function k(e){return({state:t,dispatch:n})=>{let r=t.field(D,!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:O(r.ranges,i),effects:E.of(a?null:new T(r.ranges,i)),scrollIntoView:!0})),!0}}var A=[{key:`Tab`,run:k(1),shift:k(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(D,!1)?(t(e.update({effects:E.of(null)})),!0):!1}],j=c.define({combine(e){return e.length?e[0]:A}}),M=a.highest(s.compute([j],e=>e.facet(j)));function N(e,t){return{...t,apply:fe(e)}}var P=t.domEventHandlers({mousedown(e,t){let n=t.state.field(D,!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:O(n.ranges,i.field),effects:E.of(n.ranges.some(e=>e.field>i.field)?new T(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),F=new class extends p{};F.startSide=1,F.endSide=-1,typeof navigator==`object`&&navigator.userAgent;var I=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new L(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.reducePos=this.pos=n+e.length;this.pushState(t,n),this.buffer.push(r,n,i,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new R(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.storeNode(this.curContext.hash,this.reducePos,this.reducePos,-3,!0)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new L(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},L=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},R=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},z=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function B(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var V=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},H=new V,pe=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=H,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=H,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},U=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;G(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};U.prototype.contextual=U.prototype.fallback=U.prototype.extend=!1;var W=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?B(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(G(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};W.prototype.contextual=U.prototype.fallback=U.prototype.extend=!1;var me=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function G(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||he(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function K(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function he(e,t,n,r){let i=K(n,r,t);return i<0||K(n,r,e)<i}var q=typeof process<`u`&&/\bparse\b/.test({}.LOG),J=null;function Y(e,t,n){let r=e.cursor(ee.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var ge=class{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Y(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Y(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof h){let n=a>this.lastRepeatPos&&i.type.id>=this.minRepeat;if(a==e||n){let t=a+i.length,r;if(a>=this.safeFrom&&t<=this.safeTo&&(!(r=i.prop(m.lookAhead))||t+r<this.fragment.to)){if(n&&(this.lastRepeat=i,this.lastRepeatPos=a),a==e)return i}else if(a==e)return null}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},_e=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new V)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if((!n||c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new V,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new V,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535){if(o[s+1]==1)s=Q(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(Q(o,s+2),t,n,r));break}}o[s]==t&&(r=this.putAction(Q(o,s+1),t,n,r))}return r}},ve=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new pe(t,r),this.tokens=new _e(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[I.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new ge(n,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&Se(r);if(e)return q&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw q&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return q&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}tryReuse(e,t,n,r){if(!n)return null;let i=e.curContext&&e.curContext.tracker.strict,a=i?e.curContext.hash:0;for(;n;){let o=this.parser.nodeSet.types[n.type.id]==n.type?this.parser.getGoto(e.state,n.type.id):-1;if(o>-1&&n.length&&(!i||(n.prop(m.contextHash)||0)==a))return e.useNode(n,o,t),n;if(n.children.length==0||n.positions[0]>0)break;let s=n.children[0];if(s instanceof h&&(!r||s.type.id>=this.parser.minRepeatTerm))n=s;else break}return null}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=q?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.reducePos<r&&e.buffer.length&&e.buffer[e.buffer.length-2]<=e.reducePos&&this.fragments.lastRepeatPos==e.reducePos&&this.tryReuse(e,e.reducePos,this.fragments.lastRepeat,!0)||this.tryReuse(e,r,this.fragments.nodeAt(r),!1);if(t)return q&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(t.type.id)})`),!0}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),q&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),q&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return X(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=q?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),q&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(q&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)q&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))q&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),q&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),X(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),h.build({buffer:z.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(J||=new WeakMap).get(e);return t||J.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function X(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var ye=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},Z=e=>e,be=class{constructor(e){this.start=e.start,this.shift=e.shift||Z,this.reduce=e.reduce||Z,this.reuse=e.reuse||Z,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},xe=class e extends g{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=m[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new re(t.map((t,i)=>te.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=ne;let a=B(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map($),this.states=B(e.states,Uint32Array),this.data=B(e.stateData),this.goto=B(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new U(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new ve(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535){if(n[i+1]==1)a=n[i=Q(n,i+2)];else if(n[i+1]==2)return Q(n,i+2);else break}if(a==t||a==0)return Q(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=Q(this.data,n+2);else break}r=t(Q(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=Q(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=$(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new ye(e,n,r)}static deserialize(t){return new e(t)}};function Q(e,t){return e[t]|e[t+1]<<16}function Se(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function $(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}export{v as a,N as c,W as i,me as n,b as o,xe as r,oe as s,be as t};
|