@juki-team/base-ui 1.4.107 → 1.4.108
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/esm/ArrowForwardIcon-CAW87Y9x.js +1 -0
- package/dist/esm/BarChart-DIQRNd6X.js +1 -0
- package/dist/esm/{CartesianChart-CElijOBx.js → CartesianChart-Baw7HRSt.js} +1 -1
- package/dist/esm/ChangePasswordModal-Ct1SQk_8.js +1 -0
- package/dist/esm/CodeEditor-B2a58qPl.js +1 -0
- package/dist/esm/CodeViewer-DQU8BMXl.js +1 -0
- package/dist/esm/Collapse-BptfTJkN.js +1 -0
- package/dist/esm/{DataGrid-KSAQkuSJ.js → DataGrid-DfeSy9_J.js} +1 -1
- package/dist/esm/DataViewer-DtHc31H0.js +1 -0
- package/dist/esm/DrawerView-Dj3KsxZ5.js +1 -0
- package/dist/esm/ExcalidrawButton-BxKNP8Ju.js +1 -0
- package/dist/esm/GraphvizViewer-CoUNA6V3.js +1 -0
- package/dist/esm/ImageLoaderCropper-BfEUj6Lt.js +1 -0
- package/dist/esm/InputCellPhoneNumber-C3wckkgH.js +1 -0
- package/dist/esm/{InputColor-CzaiXHCJ.js → InputColor-BP4osp1m.js} +3 -3
- package/dist/esm/LineChart-BEBY05Jk.js +1 -0
- package/dist/esm/LineLoader-DJ-mqlCg.js +1 -0
- package/dist/esm/MdMath-BPRFr0z2.js +1 -0
- package/dist/esm/{MdMathEditor-CTEtr0aR.js → MdMathEditor-CpZtmRPS.js} +2 -2
- package/dist/esm/{Popover-BlT2A-w_.js → Popover-D_58lHiS.js} +2 -2
- package/dist/esm/ReplyIcon-CFQENJJ2.js +1 -0
- package/dist/esm/SettingsIcon-B-R6M6zm.js +1 -0
- package/dist/esm/SlideDeck-VjBsZWE5.js +1 -0
- package/dist/esm/TableEyeIcon-ArU4vD_b.js +1 -0
- package/dist/esm/TableOfContents-CJTjJpW1.js +1 -0
- package/dist/esm/{Tooltip--Hk5NXW1.js → Tooltip-yTYBsAPO.js} +1 -1
- package/dist/esm/UserCodeEditor-DDOoLvCn.js +30 -0
- package/dist/esm/VirtualizedRowsFixed-CSfuBo-L.js +1 -0
- package/dist/esm/WorksheetAsSlides-BsxgD7Ou.js +1 -0
- package/dist/esm/WorksheetBodies-CoUCsRQL.js +1 -0
- package/dist/esm/WorksheetContents-CXwCj_9n.js +1 -0
- package/dist/esm/WorksheetEditor-B6sFcv5f.js +1 -0
- package/dist/esm/WorksheetNode-D9TYabCW.js +1 -0
- package/dist/esm/WorksheetViewer-DzWM2z--.js +1 -0
- package/dist/esm/{arc-C3w0f5o0.js → arc-BqJSq9Se.js} +1 -1
- package/dist/esm/architecture-YZFGNWBL-B4l12l1n.js +1 -0
- package/dist/esm/architectureDiagram-Q4EWVU46-35IDohve.js +1 -0
- package/dist/esm/blockDiagram-DXYQGD6D-DMV0Turg.js +1 -0
- package/dist/esm/c4Diagram-AHTNJAMY-B1Q5D-a4.js +1 -0
- package/dist/esm/channel-BmfGiUet.js +1 -0
- package/dist/esm/{chunk-4BX2VUAB-4ZUwd1O6.js → chunk-4BX2VUAB-CnWIexnZ.js} +1 -1
- package/dist/esm/{chunk-4TB4RGXK-D2mW1pqz.js → chunk-4TB4RGXK-DZFf4xWt.js} +1 -1
- package/dist/esm/{chunk-55IACEB6--ZczWsRz.js → chunk-55IACEB6--eYNbhf5.js} +1 -1
- package/dist/esm/{chunk-EDXVE4YY-BPNWF9oE.js → chunk-EDXVE4YY-Bz1Eb3eQ.js} +1 -1
- package/dist/esm/{chunk-FMBD7UC4-Bmdi5hmV.js → chunk-FMBD7UC4-_aFPbUyk.js} +1 -1
- package/dist/esm/{chunk-OYMX7WX6-WI9XjvUl.js → chunk-OYMX7WX6-6xwPlg6L.js} +1 -1
- package/dist/esm/{chunk-QZHKN3VN-C8GYxSTj.js → chunk-QZHKN3VN-Cbrr74yt.js} +1 -1
- package/dist/esm/{chunk-YZCP3GAM-o_a1UyKt.js → chunk-YZCP3GAM-bcgQ75kF.js} +1 -1
- package/dist/esm/classDiagram-6PBFFD2Q-DfQo6n2Y.js +1 -0
- package/dist/esm/classDiagram-v2-HSJHXN6E-DfQo6n2Y.js +1 -0
- package/dist/esm/clone-ytho4G-U.js +1 -0
- package/dist/esm/constants.js +1 -1
- package/dist/esm/cose-bilkent-S5V4N54A-BSGvXKpJ.js +1 -0
- package/dist/esm/dagre-KV5264BT-vfGof8_w.js +1 -0
- package/dist/esm/diagram-5BDNPKRD-BNLEkZrt.js +1 -0
- package/dist/esm/diagram-G4DWMVQ6-BNy00oOM.js +1 -0
- package/dist/esm/diagram-MMDJMWI5-m5lju_Ql.js +1 -0
- package/dist/esm/diagram-TYMM5635-DcdkioVb.js +1 -0
- package/dist/esm/erDiagram-SMLLAGMA-CceV2aLj.js +1 -0
- package/dist/esm/flowDiagram-DWJPFMVM-7JDV2iFZ.js +1 -0
- package/dist/esm/ganttDiagram-T4ZO3ILL-BJitnff4.js +1 -0
- package/dist/esm/gitGraph-7Q5UKJZL-Lm8K3gu8.js +1 -0
- package/dist/esm/gitGraphDiagram-UUTBAWPF-BFIe5oyZ.js +1 -0
- package/dist/esm/{graph-D5gMyoP2.js → graph-i0Iev2-Z.js} +1 -1
- package/dist/esm/helpers.js +1 -1
- package/dist/esm/{index-D_n03nrN.js → index-1CDORI5w.js} +1 -1
- package/dist/esm/{index-sqmv4QZn.js → index-9OsMb8z-.js} +1 -1
- package/dist/esm/{index-7cljmW1I.js → index-B5nEC544.js} +1 -1
- package/dist/esm/{index-CelmPxD_.js → index-BD2F8534.js} +1 -1
- package/dist/esm/{index-DUfEmFQX.js → index-BEVf94U5.js} +1 -1
- package/dist/esm/{index-bngthCD9.js → index-BLW3It0q.js} +1 -1
- package/dist/esm/{index-Dv_4je56.js → index-BR_DZYGh.js} +1 -1
- package/dist/esm/{index-CzXiRooS.js → index-BUSYadhg.js} +1 -1
- package/dist/esm/{index-BHg86Mzp.js → index-BjZU1VKq.js} +1 -1
- package/dist/esm/{index-B7cp16F7.js → index-BmpEdvsk.js} +1 -1
- package/dist/esm/{index-fnbFLugT.js → index-C1WDoixa.js} +1 -1
- package/dist/esm/{index-DO8Rvfkr.js → index-C8adNPQr.js} +1 -1
- package/dist/esm/{index-CMr1eo1C.js → index-CM96a8L6.js} +1 -1
- package/dist/esm/{index-Cf8MV2sc.js → index-CNCj4you.js} +1 -1
- package/dist/esm/{index-FQiPOUDD.js → index-CQlgVNck.js} +1 -1
- package/dist/esm/{index-t34paUSo.js → index-CWn0Vi5N.js} +1 -1
- package/dist/esm/{index-BJfNhuMS.js → index-CgfL5OzV.js} +1 -1
- package/dist/esm/index-CpZesTpI.js +1 -0
- package/dist/esm/{index-CjeytJGX.js → index-Cpax-OZ_.js} +1 -1
- package/dist/esm/{index-Dkhj8d0H.js → index-CxP7N0Hx.js} +1 -1
- package/dist/esm/index-DEsPeQN2.js +1 -0
- package/dist/esm/{index-DLY1bED3.js → index-DJK6aeDm.js} +1 -1
- package/dist/esm/index-DS396i5X.js +2 -0
- package/dist/esm/{index-CLjVKJLy.js → index-DptBXgBN.js} +1 -1
- package/dist/esm/{index-CVXCpqrb.js → index-DzHNpFcT.js} +1 -1
- package/dist/esm/{index-14GfR8IH.js → index-M6y9Wbel.js} +1 -1
- package/dist/esm/{index-uGQmOcUj.js → index-lcxmGwoj.js} +1 -1
- package/dist/esm/{index-BXBstKiI.js → index-nQf0NFR-.js} +1 -1
- package/dist/esm/{index-6ReRCi2b.js → index-rdA_qZgh.js} +1 -1
- package/dist/esm/index-sCShfFDb.js +1 -0
- package/dist/esm/info-OMHHGYJF-DgFByN2Q.js +1 -0
- package/dist/esm/infoDiagram-42DDH7IO-_pYHRGdQ.js +1 -0
- package/dist/esm/ishikawaDiagram-UXIWVN3A-DDWTFBtt.js +1 -0
- package/dist/esm/journeyDiagram-VCZTEJTY-DyNlikrx.js +1 -0
- package/dist/esm/kanban-definition-6JOO6SKY-Cvqzz0T0.js +1 -0
- package/dist/esm/{layout-CqpEv5Ef.js → layout-Dl8swpJM.js} +1 -1
- package/dist/esm/{linear-GzuvzgOY.js → linear-Bjc68iA-.js} +1 -1
- package/dist/esm/main.js +1 -1
- package/dist/esm/{mermaid-parser.core-B_3uoTN_.js → mermaid-parser.core-CKOUdqet.js} +2 -1
- package/dist/esm/{mermaid.core-glgrFJAR.js → mermaid.core-DcN2Nakz.js} +1 -1
- package/dist/esm/mindmap-definition-QFDTVHPH-D6o47E4D.js +1 -0
- package/dist/esm/packet-4T2RLAQJ-nSjqpN2G.js +1 -0
- package/dist/esm/pie-ZZUOXDRM-DE0yKaq5.js +1 -0
- package/dist/esm/pieDiagram-DEJITSTG-DNKo_uDP.js +1 -0
- package/dist/esm/quadrantDiagram-34T5L4WZ-CfNwmuso.js +1 -0
- package/dist/esm/radar-PYXPWWZC-B221trO2.js +1 -0
- package/dist/esm/requirementDiagram-MS252O5E-DMqflNcm.js +1 -0
- package/dist/esm/sankeyDiagram-XADWPNL6-Bxl0NJ7t.js +1 -0
- package/dist/esm/sequenceDiagram-FGHM5R23-BcciAiMg.js +1 -0
- package/dist/esm/server.js +1 -1
- package/dist/esm/stateDiagram-FHFEXIEX-Cn-RB4wx.js +1 -0
- package/dist/esm/stateDiagram-v2-QKLJ7IA2-C6pgM7SG.js +1 -0
- package/dist/esm/{time-jZCPqKop.js → time-D_shzpG-.js} +1 -1
- package/dist/esm/timeline-definition-GMOUNBTQ-BLR2EM9w.js +1 -0
- package/dist/esm/treeView-SZITEDCU-ChLgNmS5.js +1 -0
- package/dist/esm/treemap-W4RFUUIX-DRWvqad0.js +1 -0
- package/dist/esm/{types-7NLLIJmg.js → types-5lPOp5sX.js} +1 -1
- package/dist/esm/vennDiagram-DHZGUBPP-jpRGjpOo.js +1 -0
- package/dist/esm/wardley-RL74JXVD-zNwlgftV.js +1 -0
- package/dist/esm/wardleyDiagram-NUSXRM2D-B8WsPQJA.js +1 -0
- package/dist/esm/websocket-Dly3sf0m.js +1 -0
- package/dist/esm/worksheet-C49PpYy4.js +1 -0
- package/dist/esm/worksheet-CglFWSed.js +1 -0
- package/dist/esm/worksheet-b5Ja38dB.js +1 -0
- package/dist/esm/xychartDiagram-5P7HB3ND-5kY0N0P9.js +1 -0
- package/dist/module-types/src/components/molecules/ProgressMultiBar/types.d.ts +0 -4
- package/dist/module-types/src/components/molecules/index.d.ts +0 -1
- package/dist/module-types/src/components/molecules/{CircularProgress → server/CircularProgress}/CircularProgress.d.ts +1 -1
- package/dist/module-types/src/components/molecules/server/CircularProgress/types.d.ts +4 -0
- package/dist/module-types/src/components/molecules/server/index.d.ts +1 -0
- package/dist/module-types/src/components/molecules/server/types.d.ts +1 -0
- package/dist/module-types/src/components/server/index.d.ts +1 -0
- package/dist/module-types/src/components/server/types.d.ts +1 -0
- package/package.json +10 -1
- package/dist/esm/ArrowForwardIcon-BFdZXYqA.js +0 -1
- package/dist/esm/BarChart-rHEQRDsQ.js +0 -1
- package/dist/esm/ChangePasswordModal-e8L2Cngl.js +0 -1
- package/dist/esm/CodeEditor-CRjfcpkl.js +0 -1
- package/dist/esm/CodeViewer-25pEO9Pe.js +0 -1
- package/dist/esm/Collapse-jhVhJLV1.js +0 -1
- package/dist/esm/DataViewer-C2RLFvmR.js +0 -1
- package/dist/esm/DrawerView-BkBgQ_KO.js +0 -1
- package/dist/esm/ExcalidrawButton-CNzKX3P2.js +0 -1
- package/dist/esm/GraphvizViewer-7he-mVaS.js +0 -1
- package/dist/esm/ImageLoaderCropper-B6ElDlKP.js +0 -1
- package/dist/esm/InputCellPhoneNumber-C4wFsu2S.js +0 -1
- package/dist/esm/LineChart-CVC3t17b.js +0 -1
- package/dist/esm/LineLoader-MXNXwWbx.js +0 -1
- package/dist/esm/MdMath-BhzwzxY8.js +0 -1
- package/dist/esm/ReplyIcon-iCSuwrnA.js +0 -1
- package/dist/esm/SettingsIcon-FPyAuh1r.js +0 -1
- package/dist/esm/SlideDeck-C4zAIVZY.js +0 -1
- package/dist/esm/TableEyeIcon-DoRP1Qqm.js +0 -1
- package/dist/esm/TableOfContents-Bp0mcHgt.js +0 -1
- package/dist/esm/UserCodeEditor-B7i_hqV2.js +0 -28
- package/dist/esm/VirtualizedRowsFixed-B8CJN2bo.js +0 -1
- package/dist/esm/WorksheetAsSlides-BYzPExMn.js +0 -1
- package/dist/esm/WorksheetBodies-B5Q2KxLo.js +0 -1
- package/dist/esm/WorksheetContents-BcZlaaJ4.js +0 -1
- package/dist/esm/WorksheetEditor-CoacQJzm.js +0 -1
- package/dist/esm/WorksheetNode-B-u6_9dU.js +0 -1
- package/dist/esm/WorksheetViewer-Cx6wBRQ4.js +0 -1
- package/dist/esm/architecture-YZFGNWBL-ogQVJdmw.js +0 -1
- package/dist/esm/architectureDiagram-Q4EWVU46-CylRjjC_.js +0 -1
- package/dist/esm/blockDiagram-DXYQGD6D-BY03UsWB.js +0 -1
- package/dist/esm/c4Diagram-AHTNJAMY-BR1JuWrc.js +0 -1
- package/dist/esm/channel-PzxfWuhy.js +0 -1
- package/dist/esm/classDiagram-6PBFFD2Q-DPIKRzmm.js +0 -1
- package/dist/esm/classDiagram-v2-HSJHXN6E-DPIKRzmm.js +0 -1
- package/dist/esm/clone-HdSdeBcS.js +0 -1
- package/dist/esm/cose-bilkent-S5V4N54A-DQJ8eGOM.js +0 -1
- package/dist/esm/dagre-KV5264BT-C6jHX11q.js +0 -1
- package/dist/esm/diagram-5BDNPKRD-DRYoW5SO.js +0 -1
- package/dist/esm/diagram-G4DWMVQ6-Dt04_fCb.js +0 -1
- package/dist/esm/diagram-MMDJMWI5-NgnMSwWt.js +0 -1
- package/dist/esm/diagram-TYMM5635-BANKIbao.js +0 -1
- package/dist/esm/erDiagram-SMLLAGMA-Dc__Qe1C.js +0 -1
- package/dist/esm/flowDiagram-DWJPFMVM-DLfn59Xi.js +0 -1
- package/dist/esm/ganttDiagram-T4ZO3ILL-DTrDD2fs.js +0 -1
- package/dist/esm/gitGraph-7Q5UKJZL-CLx_42i-.js +0 -1
- package/dist/esm/gitGraphDiagram-UUTBAWPF-B5UroeaI.js +0 -1
- package/dist/esm/index-CcaaEwWS.js +0 -1
- package/dist/esm/index-DrP1myKY.js +0 -1
- package/dist/esm/index-DyiX6a_0.js +0 -1
- package/dist/esm/index-Ymqmzwwn.js +0 -1
- package/dist/esm/info-OMHHGYJF-CLOQWVpo.js +0 -1
- package/dist/esm/infoDiagram-42DDH7IO-Ctz230_R.js +0 -1
- package/dist/esm/ishikawaDiagram-UXIWVN3A-C4VaALMs.js +0 -1
- package/dist/esm/journeyDiagram-VCZTEJTY-C3UgSTP-.js +0 -1
- package/dist/esm/kanban-definition-6JOO6SKY-DAjq3zPX.js +0 -1
- package/dist/esm/mindmap-definition-QFDTVHPH-BFz0YWyg.js +0 -1
- package/dist/esm/packet-4T2RLAQJ-BbFgGou9.js +0 -1
- package/dist/esm/pie-ZZUOXDRM-BR28ozyC.js +0 -1
- package/dist/esm/pieDiagram-DEJITSTG-DhomC37o.js +0 -1
- package/dist/esm/quadrantDiagram-34T5L4WZ-CA6Ta31y.js +0 -1
- package/dist/esm/radar-PYXPWWZC-9yJ8ROGn.js +0 -1
- package/dist/esm/requirementDiagram-MS252O5E-wfI49PrB.js +0 -1
- package/dist/esm/sankeyDiagram-XADWPNL6-CL9SZMZz.js +0 -1
- package/dist/esm/sequenceDiagram-FGHM5R23-LvEp8oJU.js +0 -1
- package/dist/esm/stateDiagram-FHFEXIEX-C_tVesub.js +0 -1
- package/dist/esm/stateDiagram-v2-QKLJ7IA2-CwWWOv9F.js +0 -1
- package/dist/esm/timeline-definition-GMOUNBTQ-DpK2qW4X.js +0 -1
- package/dist/esm/treeView-SZITEDCU-CvJPHoiT.js +0 -1
- package/dist/esm/treemap-W4RFUUIX-C2JwXBVL.js +0 -1
- package/dist/esm/vennDiagram-DHZGUBPP-DQhtuX0l.js +0 -1
- package/dist/esm/wardley-RL74JXVD-BFYJz9AQ.js +0 -1
- package/dist/esm/wardleyDiagram-NUSXRM2D-BFuXTIFq.js +0 -1
- package/dist/esm/websocket-D1DK1xtc.js +0 -1
- package/dist/esm/worksheet--STrt7aY.js +0 -1
- package/dist/esm/worksheet-Btqtgeym.js +0 -1
- package/dist/esm/xychartDiagram-5P7HB3ND-iZBXhewx.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e,a as t,b as n,h as r,N as s,s as i,T as o,p as a,t as l,L as h,y as f,z as c,j as u,n as d,o as p,A as m,B as g,C as k,w as x,F as L,G as b,f as S,i as C,H as w,E as y,g as A,J as I}from"./basic-setup-Cz3rV4Fo.js";import{html as T,htmlCompletionSource as B}from"./index-CVXCpqrb.js";import"./index-BHg86Mzp.js";import"./index-FQiPOUDD.js";import"./index-B7cp16F7.js";class E{static create(e,t,n,r,s){return new E(e,t,n,r+(r<<8)+e+(t<<4)|0,s,[],[])}constructor(e,t,r,s,i,o,a){this.type=e,this.value=t,this.from=r,this.hash=s,this.end=i,this.children=o,this.positions=a,this.hashProp=[[n.contextHash,s]]}addChild(e,t){e.prop(n.contextHash)!=this.hash&&(e=new o(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new o(e.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(e,n,r)=>new o(t.none,e,n,r,this.hashProp)})}}var v;!function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"}(v||(v={}));class H{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class M{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return R(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=9==this.text.charCodeAt(r)?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=9==this.text.charCodeAt(t)?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e="";for(let t=0;t<this.basePos;t++)e+=" ";return e+this.text.slice(this.basePos)}}function P(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==v.OrderedList?q:F)(n,t,!1);return r>0&&(e.type!=v.BulletList||D(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const N={[v.Blockquote]:(e,t,n)=>62==n.next&&(n.markers.push(ke(v.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(O(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0),[v.ListItem]:(e,t,n)=>!(n.indent<n.baseIndent+e.value&&n.next>-1)&&(n.moveBaseColumn(n.baseIndent+e.value),!0),[v.OrderedList]:P,[v.BulletList]:P,[v.Document]:()=>!0};function O(e){return 32==e||9==e||10==e||13==e}function R(e,t=0){for(;t<e.length&&O(e.charCodeAt(t));)t++;return t}function X(e,t,n){for(;t>n&&O(e.charCodeAt(t-1));)t--;return t}function z(e){if(96!=e.next&&126!=e.next)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(96==e.next)for(let n=t;n<e.text.length;n++)if(96==e.text.charCodeAt(n))return-1;return t}function $(e){return 62!=e.next?-1:32==e.text.charCodeAt(e.pos+1)?2:1}function D(e,t,n){if(42!=e.next&&45!=e.next&&95!=e.next)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!O(n))return-1}return n&&45==e.next&&_(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(re.SetextHeading)>-1||r<3?-1:1}function j(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function F(e,t,n){return 45!=e.next&&43!=e.next&&42!=e.next||e.pos!=e.text.length-1&&!O(e.text.charCodeAt(e.pos+1))||!(!n||j(t,v.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?-1:1}function q(e,t,n){let r=e.pos,s=e.next;for(;s>=48&&s<=57;){if(r++,r==e.text.length)return-1;s=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||46!=s&&41!=s||r<e.text.length-1&&!O(e.text.charCodeAt(r+1))||n&&!j(t,v.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||49!=e.next)?-1:r+1-e.pos}function U(e){if(35!=e.next)return-1;let t=e.pos+1;for(;t<e.text.length&&35==e.text.charCodeAt(t);)t++;if(t<e.text.length&&32!=e.text.charCodeAt(t))return-1;let n=t-e.pos;return n>6?-1:n}function _(e){if(45!=e.next&&61!=e.next||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&O(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const Z=/^[ \t]*$/,Q=/-->/,V=/\?>/,G=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Q],[/^\s*<\?/,V],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Z],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Z]];function J(e,t,n){if(60!=e.next)return-1;let r=e.text.slice(e.pos);for(let e=0,t=G.length-(n?1:0);e<t;e++)if(G[e][0].test(r))return e;return-1}function K(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function Y(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==v.CodeText?e[r].to=n:e.push(ke(v.CodeText,t,n))}const W={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),s=e.lineStart+r,i=e.lineStart+t.text.length,o=[],a=[];for(Y(o,s,i);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){Y(a,e.lineStart-1,e.lineStart);for(let e of t.markers)a.push(e)}else{if(t.indent<n)break;{if(a.length){for(let e of a)e.type==v.CodeText?Y(o,e.from,e.to):o.push(e);a=[]}Y(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);i=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<i&&Y(o,n,i)}}return a.length&&(a=a.filter(e=>e.type!=v.CodeText),a.length&&(t.markers=a.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-s).finish(v.CodeBlock,i-s),s),!0},FencedCode(e,t){let n=z(t);if(n<0)return!1;let r=e.lineStart+t.pos,s=t.next,i=n-t.pos,o=t.skipSpace(n),a=X(t.text,t.text.length,o),l=[ke(v.CodeMark,r,r+i)];o<a&&l.push(ke(v.CodeInfo,e.lineStart+o,e.lineStart+a));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let a=t.pos;if(t.indent-t.baseIndent<4)for(;a<t.text.length&&t.text.charCodeAt(a)==s;)a++;if(a-t.pos>=i&&t.skipSpace(a)==t.text.length){for(let e of t.markers)l.push(e);r&&o&&Y(l,e.lineStart-1,e.lineStart),l.push(ke(v.CodeMark,e.lineStart+t.pos,e.lineStart+a)),e.nextLine();break}{o=!0,n||(Y(l,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)l.push(e);let s=e.lineStart+t.basePos,i=e.lineStart+t.text.length;s<i&&(Y(l,s,i),r=!1)}}return e.addNode(e.buffer.writeElements(l,-r).finish(v.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=$(t);return!(n<0)&&(e.startContext(v.Blockquote,t.pos),e.addNode(v.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(D(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(v.HorizontalRule,n),!0},BulletList(e,t){let n=F(t,e,!1);if(n<0)return!1;e.block.type!=v.BulletList&&e.startContext(v.BulletList,t.basePos,t.next);let r=K(t,t.pos+1);return e.startContext(v.ListItem,t.basePos,r-t.baseIndent),e.addNode(v.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=q(t,e,!1);if(n<0)return!1;e.block.type!=v.OrderedList&&e.startContext(v.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=K(t,t.pos+n);return e.startContext(v.ListItem,t.basePos,r-t.baseIndent),e.addNode(v.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=U(t);if(n<0)return!1;let r=t.pos,s=e.lineStart+r,i=X(t.text,t.text.length,r),o=i;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;o!=i&&o!=r&&O(t.text.charCodeAt(o-1))||(o=t.text.length);let a=e.buffer.write(v.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),s+n+1),-s);o<t.text.length&&a.write(v.HeaderMark,o-r,i-r);let l=a.finish(v.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,s),!0},HTMLBlock(e,t){let n=J(t,0,!1);if(n<0)return!1;let r=e.lineStart+t.pos,s=G[n][1],i=[],o=s!=Z;for(;!s.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)i.push(e)}o&&e.nextLine();let a=s==Q?v.CommentBlock:s==V?v.ProcessingInstructionBlock:v.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(i,-r).finish(a,l-r),r),!0},SetextHeading:void 0};class ee{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(-1==this.stage)return!1;let r=n.content+"\n"+t.scrub(),s=this.advance(r);return s>-1&&s<r.length&&this.complete(e,n,s)}finish(e,t){return(2==this.stage||3==this.stage)&&R(t.content,this.pos)==t.content.length&&this.complete(e,t,t.content.length)}complete(e,t,n){return e.addLeafElement(t,ke(v.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(!1===e&&(this.stage=-1),!1)}advance(e){for(;;){if(-1==this.stage)return-1;if(0==this.stage){if(!this.nextStage(Ee(e,this.pos,this.start,!0)))return-1;if(58!=e.charCodeAt(this.pos))return this.stage=-1;this.elts.push(ke(v.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else{if(1!=this.stage){if(2==this.stage){let t=R(e,this.pos),n=0;if(t>this.pos){let r=Be(e,t,this.start);if(r){let t=te(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||(n=te(e,this.pos)),n>0&&n<e.length?n:-1}return te(e,this.pos)}if(!this.nextStage(Te(e,R(e,this.pos),this.start)))return-1}}}}function te(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(10==n)break;if(!O(n))return-1}return t}class ne{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:_(t),s=t.next;if(r<0)return!1;let i=ke(v.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,ke(61==s?v.SetextHeading1:v.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),i])),!0}finish(){return!1}}const re={LinkReference:(e,t)=>91==t.content.charCodeAt(0)?new ee(t):null,SetextHeading:()=>new ne},se=[(e,t)=>U(t)>=0,(e,t)=>z(t)>=0,(e,t)=>$(t)>=0,(e,t)=>F(t,e,!0)>=0,(e,t)=>q(t,e,!0)>=0,(e,t)=>D(t,e,!0)>=0,(e,t)=>J(t,0,!0)>=0],ie={text:"",end:0};class oe{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new M,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=E.create(v.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new Pe(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(null!=this.stoppedAt&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(0!=n){if(1==n)return null;e.forward();continue e}}break}let t=new H(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4)for(let n of this.parser.endLeafBlock)if(n(this,e,t))break e;for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+="\n"+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return!!t&&(this.absoluteLineStart+=t,this.lineStart=Ne(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0)}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=ie;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,s=this.lineChunkAt(r);t.end=r+s.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+s,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw new Error("Unhandled block context "+v[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t,n=this.input.chunk(e);if(this.input.lineChunks)t="\n"==n?"":n;else{let e=n.indexOf("\n");t=e<0?n:n.slice(0,e)}return e+t.length>this.to?t.slice(0,this.to-e):t}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,n=0){this.block=E.create(e,n,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,n=0){this.startContext(this.parser.getNodeType(e),t,n)}addNode(e,t,n){"number"==typeof e&&(e=new o(this.parser.nodeSet.types[e],de,de,(null!=n?n:this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(He(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?ae(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let t of e.parsers)if(t.finish(this,e))return;let t=He(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(v.Paragraph,e.content.length),e.start)}elt(e,t,n,r){return"string"==typeof e?ke(this.parser.getNodeType(e),t,n,r):new ge(e,t)}get buffer(){return new pe(this.parser.nodeSet)}}function ae(e,t,n,r,s){let i=e[t].to,a=[],l=[],h=n.from+r;function f(n,s){for(;s?n>=i:n>i;){let s=e[t+1].from-i;r+=s,n+=s,t++,i=e[t].to}}for(let o=n.firstChild;o;o=o.nextSibling){f(o.from+r,!0);let n,c=o.from+r,u=s.get(o.tree);u?n=u:o.to+r>i?(n=ae(e,t,o,r,s),f(o.to+r,!1)):n=o.toTree(),a.push(n),l.push(c-h)}return f(n.to+r,!1),new o(n.type,a,l,n.to+r-h,n.tree?n.tree.propValues:void 0)}class le extends e{constructor(e,t,n,r,s,i,o,a,l){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=n,this.blockNames=r,this.endLeafBlock=s,this.skipContextMarkup=i,this.inlineParsers=o,this.inlineNames=a,this.wrappers=l,this.nodeTypes=Object.create(null);for(let t of e.types)this.nodeTypes[t.name]=t.id}createParse(e,t,n){let r=new oe(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}configure(e){let o=fe(e);if(!o)return this;let{nodeSet:a,skipContextMarkup:l}=this,h=this.blockParsers.slice(),f=this.leafBlockParsers.slice(),c=this.blockNames.slice(),u=this.inlineParsers.slice(),d=this.inlineNames.slice(),p=this.endLeafBlock.slice(),m=this.wrappers;if(he(o.defineNodes)){l=Object.assign({},l);let e,h=a.types.slice();for(let s of o.defineNodes){let{name:i,block:o,composite:a,style:f}="string"==typeof s?{name:s}:s;if(h.some(e=>e.name==i))continue;a&&(l[h.length]=(e,t,n)=>a(t,n,e.value));let c=h.length,u=a?["Block","BlockContext"]:o?c>=v.ATXHeading1&&c<=v.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;h.push(t.define({id:c,name:i,props:u&&[[n.group,u]]})),f&&(e||(e={}),Array.isArray(f)||f instanceof r?e[i]=f:Object.assign(e,f))}a=new s(h),e&&(a=a.extend(i(e)))}if(he(o.props)&&(a=a.extend(...o.props)),he(o.remove))for(let e of o.remove){let t=this.blockNames.indexOf(e),n=this.inlineNames.indexOf(e);t>-1&&(h[t]=f[t]=void 0),n>-1&&(u[n]=void 0)}if(he(o.parseBlock))for(let e of o.parseBlock){let t=c.indexOf(e.name);if(t>-1)h[t]=e.parse,f[t]=e.leaf;else{let t=e.before?ce(c,e.before):e.after?ce(c,e.after)+1:c.length-1;h.splice(t,0,e.parse),f.splice(t,0,e.leaf),c.splice(t,0,e.name)}e.endLeaf&&p.push(e.endLeaf)}if(he(o.parseInline))for(let e of o.parseInline){let t=d.indexOf(e.name);if(t>-1)u[t]=e.parse;else{let t=e.before?ce(d,e.before):e.after?ce(d,e.after)+1:d.length-1;u.splice(t,0,e.parse),d.splice(t,0,e.name)}}return o.wrap&&(m=m.concat(o.wrap)),new le(a,h,f,c,p,l,u,d,m)}getNodeType(e){let t=this.nodeTypes[e];if(null==t)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let n=new ve(this,e,t);e:for(let e=t;e<n.end;){let t=n.char(e);for(let r of this.inlineParsers)if(r){let s=r(n,t,e);if(s>=0){e=s;continue e}}e++}return n.resolveMarkers(0)}}function he(e){return null!=e&&e.length>0}function fe(e){if(!Array.isArray(e))return e;if(0==e.length)return null;let t=fe(e[0]);if(1==e.length)return t;let n=fe(e.slice(1));if(!n||!t)return t||n;let r=(e,t)=>(e||de).concat(t||de),s=t.wrap,i=n.wrap;return{props:r(t.props,n.props),defineNodes:r(t.defineNodes,n.defineNodes),parseBlock:r(t.parseBlock,n.parseBlock),parseInline:r(t.parseInline,n.parseInline),remove:r(t.remove,n.remove),wrap:s?i?(e,t,n,r)=>s(i(e,t,n,r),t,n,r):s:i}}function ce(e,t){let n=e.indexOf(t);if(n<0)throw new RangeError(`Position specified relative to unknown parser ${t}`);return n}let ue=[t.none];for(let e,r=1;e=v[r];r++)ue[r]=t.define({id:r,name:e,props:r>=v.Escape?[]:[[n.group,r in N?["Block","BlockContext"]:["Block","LeafBlock"]]],top:"Document"==e});const de=[];class pe{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,n,r=0){return this.content.push(e,t,n,4+4*r),this}writeElements(e,t=0){for(let n of e)n.writeTo(this,t);return this}finish(e,t){return o.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}class me{constructor(e,t,n,r=de){this.type=e,this.from=t,this.to=n,this.children=r}writeTo(e,t){let n=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-n)}toTree(e){return new pe(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}}class ge{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return de}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}}function ke(e,t,n,r){return new me(e,t,n,r)}const xe={resolve:"Emphasis",mark:"EmphasisMark"},Le={resolve:"Emphasis",mark:"EmphasisMark"},be={},Se={};class Ce{constructor(e,t,n,r){this.type=e,this.from=t,this.to=n,this.side=r}}const we="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let ye=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{ye=new RegExp("[\\p{S}|\\p{P}]","u")}catch(e){}const Ae={Escape(e,t,n){if(92!=t||n==e.end-1)return-1;let r=e.char(n+1);for(let t=0;t<32;t++)if(we.charCodeAt(t)==r)return e.append(ke(v.Escape,n,n+2));return-1},Entity(e,t,n){if(38!=t)return-1;let r=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(e.slice(n+1,n+31));return r?e.append(ke(v.Entity,n,n+1+r[0].length)):-1},InlineCode(e,t,n){if(96!=t||n&&96==e.char(n-1))return-1;let r=n+1;for(;r<e.end&&96==e.char(r);)r++;let s=r-n,i=0;for(;r<e.end;r++)if(96==e.char(r)){if(i++,i==s&&96!=e.char(r+1))return e.append(ke(v.InlineCode,n,r+1,[ke(v.CodeMark,n,n+s),ke(v.CodeMark,r+1-s,r+1)]))}else i=0;return-1},HTMLTag(e,t,n){if(60!=t||n==e.end-1)return-1;let r=e.slice(n+1,e.end),s=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(r);if(s)return e.append(ke(v.Autolink,n,n+1+s[0].length,[ke(v.LinkMark,n,n+1),ke(v.URL,n+1,n+s[0].length),ke(v.LinkMark,n+s[0].length,n+1+s[0].length)]));let i=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(r);if(i)return e.append(ke(v.Comment,n,n+1+i[0].length));let o=/^\?[^]*?\?>/.exec(r);if(o)return e.append(ke(v.ProcessingInstruction,n,n+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);return a?e.append(ke(v.HTMLTag,n,n+1+a[0].length)):-1},Emphasis(e,t,n){if(95!=t&&42!=t)return-1;let r=n+1;for(;e.char(r)==t;)r++;let s=e.slice(n-1,n),i=e.slice(r,r+1),o=ye.test(s),a=ye.test(i),l=/\s|^$/.test(s),h=/\s|^$/.test(i),f=!h&&(!a||l||o),c=!l&&(!o||h||a),u=f&&(42==t||!c||o),d=c&&(42==t||!f||a);return e.append(new Ce(95==t?xe:Le,n,r,(u?1:0)|(d?2:0)))},HardBreak(e,t,n){if(92==t&&10==e.char(n+1))return e.append(ke(v.HardBreak,n,n+2));if(32==t){let t=n+1;for(;32==e.char(t);)t++;if(10==e.char(t)&&t>=n+2)return e.append(ke(v.HardBreak,n,t+1))}return-1},Link:(e,t,n)=>91==t?e.append(new Ce(be,n,n+1,1)):-1,Image:(e,t,n)=>33==t&&91==e.char(n+1)?e.append(new Ce(Se,n,n+2,1)):-1,LinkEnd(e,t,n){if(93!=t)return-1;for(let t=e.parts.length-1;t>=0;t--){let r=e.parts[t];if(r instanceof Ce&&(r.type==be||r.type==Se)){if(!r.side||e.skipSpace(r.to)==n&&!/[(\[]/.test(e.slice(n+1,n+2)))return e.parts[t]=null,-1;let s=e.takeContent(t),i=e.parts[t]=Ie(e,s,r.type==be?v.Link:v.Image,r.from,n+1);if(r.type==be)for(let n=0;n<t;n++){let t=e.parts[n];t instanceof Ce&&t.type==be&&(t.side=0)}return i.to}}return-1}};function Ie(e,t,n,r,s){let{text:i}=e,o=e.char(s),a=s;if(t.unshift(ke(v.LinkMark,r,r+(n==v.Image?2:1))),t.push(ke(v.LinkMark,s-1,s)),40==o){let n,r=e.skipSpace(s+1),o=Te(i,r-e.offset,e.offset);o&&(r=e.skipSpace(o.to),r!=o.to&&(n=Be(i,r-e.offset,e.offset),n&&(r=e.skipSpace(n.to)))),41==e.char(r)&&(t.push(ke(v.LinkMark,s,s+1)),a=r+1,o&&t.push(o),n&&t.push(n),t.push(ke(v.LinkMark,r,a)))}else if(91==o){let n=Ee(i,s-e.offset,e.offset,!1);n&&(t.push(n),a=n.to)}return ke(n,r,a,t)}function Te(e,t,n){if(60==e.charCodeAt(t)){for(let r=t+1;r<e.length;r++){let s=e.charCodeAt(r);if(62==s)return ke(v.URL,t+n,r+1+n);if(60==s||10==s)return!1}return null}{let r=0,s=t;for(let t=!1;s<e.length;s++){let n=e.charCodeAt(s);if(O(n))break;if(t)t=!1;else if(40==n)r++;else if(41==n){if(!r)break;r--}else 92==n&&(t=!0)}return s>t?ke(v.URL,t+n,s+n):s==e.length&&null}}function Be(e,t,n){let r=e.charCodeAt(t);if(39!=r&&34!=r&&40!=r)return!1;let s=40==r?41:r;for(let r=t+1,i=!1;r<e.length;r++){let o=e.charCodeAt(r);if(i)i=!1;else{if(o==s)return ke(v.LinkTitle,t+n,r+1+n);92==o&&(i=!0)}}return null}function Ee(e,t,n,r){for(let s=!1,i=t+1,o=Math.min(e.length,i+999);i<o;i++){let o=e.charCodeAt(i);if(s)s=!1;else{if(93==o)return!r&&ke(v.LinkLabel,t+n,i+1+n);if(r&&!O(o)&&(r=!1),91==o)return!1;92==o&&(s=!0)}}return null}class ve{constructor(e,t,n){this.parser=e,this.text=t,this.offset=n,this.parts=[]}char(e){return e>=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,n,r,s){return this.append(new Ce(e,t,n,(r?1:0)|(s?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof Ce&&(t.type==be||t.type==Se))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let t=e;t<this.parts.length;t++){let n=this.parts[t];if(!(n instanceof Ce&&n.type.resolve&&2&n.side))continue;let r,s=n.type==xe||n.type==Le,i=n.to-n.from,o=t-1;for(;o>=e;o--){let e=this.parts[o];if(e instanceof Ce&&1&e.side&&e.type==n.type&&!(s&&(1&n.side||2&e.side)&&(e.to-e.from+i)%3==0&&((e.to-e.from)%3||i%3))){r=e;break}}if(!r)continue;let a=n.type.resolve,l=[],h=r.from,f=n.to;if(s){let e=Math.min(2,r.to-r.from,i);h=r.to-e,f=n.from+e,a=1==e?"Emphasis":"StrongEmphasis"}r.type.mark&&l.push(this.elt(r.type.mark,h,r.to));for(let e=o+1;e<t;e++)this.parts[e]instanceof me&&l.push(this.parts[e]),this.parts[e]=null;n.type.mark&&l.push(this.elt(n.type.mark,n.from,f));let c=this.elt(a,h,f,l);this.parts[o]=s&&r.from!=h?new Ce(r.type,r.from,h,r.side):null,(this.parts[t]=s&&n.to!=f?new Ce(n.type,f,n.to,n.side):null)?this.parts.splice(t,0,c):this.parts[t]=c}let t=[];for(let n=e;n<this.parts.length;n++){let e=this.parts[n];e instanceof me&&t.push(e)}return t}findOpeningDelimiter(e){for(let t=this.parts.length-1;t>=0;t--){let n=this.parts[t];if(n instanceof Ce&&n.type==e&&1&n.side)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}getDelimiterAt(e){let t=this.parts[e];return t instanceof Ce?t:null}skipSpace(e){return R(this.text,e-this.offset)+this.offset}elt(e,t,n,r){return"string"==typeof e?ke(this.parser.getNodeType(e),t,n,r):new ge(e,t)}}function He(e,t){if(!t.length)return e;if(!e.length)return t;let n=e.slice(),r=0;for(let e of t){for(;r<n.length&&n[r].to<e.to;)r++;if(r<n.length&&n[r].from<e.from){let t=n[r];t instanceof me&&(n[r]=new me(t.type,t.from,t.to,He(t.children,[e])))}else n.splice(r++,0,e)}return n}ve.linkStart=be,ve.imageStart=Se;const Me=[v.CodeBlock,v.ListItem,v.OrderedList,v.BulletList];class Pe{constructor(e,t){this.fragments=e,this.input=t,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(e,t){for(;this.fragment&&this.fragment.to<=e;)this.nextFragment();if(!this.fragment||this.fragment.from>(e?e-1:0))return!1;if(this.fragmentEnd<0){let e=this.fragment.to;for(;e>0&&"\n"!=this.input.read(e-1,e);)e--;this.fragmentEnd=e?e-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let r=e+this.fragment.offset;for(;n.to<=r;)if(!n.parent())return!1;for(;;){if(n.from>=r)return this.fragment.from<=t;if(!n.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(n.contextHash)==e}takeNodes(e){let t=this.cursor,n=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,i=s,a=e.block.children.length,l=i,h=a;for(;;){if(t.to-n>r){if(t.type.isAnonymous&&t.firstChild())continue;break}let s=Ne(t.from-n,e.ranges);if(t.to-n<=e.ranges[e.rangeI].to)e.addNode(t.tree,s);else{let n=new o(e.parser.nodeSet.types[v.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(n,t.tree),e.addNode(n,s)}if(t.type.is("Block")&&(Me.indexOf(t.type.id)<0?(i=t.to-n,a=e.block.children.length):(i=l,a=h),l=t.to-n,h=e.block.children.length),!t.nextSibling())break}for(;e.block.children.length>a;)e.block.children.pop(),e.block.positions.pop();return i-s}}function Ne(e,t){let n=e;for(let r=1;r<t.length;r++){let s=t[r-1].to,i=t[r].from;s<e&&(n-=i-s)}return n}const Oe=i({"Blockquote/...":l.quote,HorizontalRule:l.contentSeparator,"ATXHeading1/... SetextHeading1/...":l.heading1,"ATXHeading2/... SetextHeading2/...":l.heading2,"ATXHeading3/...":l.heading3,"ATXHeading4/...":l.heading4,"ATXHeading5/...":l.heading5,"ATXHeading6/...":l.heading6,"Comment CommentBlock":l.comment,Escape:l.escape,Entity:l.character,"Emphasis/...":l.emphasis,"StrongEmphasis/...":l.strong,"Link/... Image/...":l.link,"OrderedList/... BulletList/...":l.list,"BlockQuote/...":l.quote,"InlineCode CodeText":l.monospace,"URL Autolink":l.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":l.processingInstruction,"CodeInfo LinkLabel":l.labelName,LinkTitle:l.string,Paragraph:l.content}),Re=new le(new s(ue).extend(Oe),Object.keys(W).map(e=>W[e]),Object.keys(W).map(e=>re[e]),Object.keys(W),se,N,Object.keys(Ae).map(e=>Ae[e]),Object.keys(Ae),[]);function Xe(e,t,n){let r=[];for(let s=e.firstChild,i=t;;s=s.nextSibling){let e=s?s.from:n;if(e>i&&r.push({from:i,to:e}),!s)break;i=s.to}return r}const ze={resolve:"Strikethrough",mark:"StrikethroughMark"},$e={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":l.strikethrough}},{name:"StrikethroughMark",style:l.processingInstruction}],parseInline:[{name:"Strikethrough",parse(e,t,n){if(126!=t||126!=e.char(n+1)||126==e.char(n+2))return-1;let r=e.slice(n-1,n),s=e.slice(n+2,n+3),i=/\s|^$/.test(r),o=/\s|^$/.test(s),a=ye.test(r),l=ye.test(s);return e.addDelimiter(ze,n,n+2,!o&&(!l||i||a),!i&&(!a||o||l))},after:"Emphasis"}]};function De(e,t,n=0,r,s=0){let i=0,o=!0,a=-1,l=-1,h=!1,f=()=>{r.push(e.elt("TableCell",s+a,s+l,e.parser.parseInline(t.slice(a,l),s+a)))};for(let c=n;c<t.length;c++){let n=t.charCodeAt(c);124!=n||h?(h||32!=n&&9!=n)&&(a<0&&(a=c),l=c+1):((!o||a>-1)&&i++,o=!1,r&&(a>-1&&f(),r.push(e.elt("TableDelimiter",c+s,c+s+1))),a=l=-1),h=!h&&92==n}return a>-1&&(i++,r&&f()),i}function je(e,t){for(let n=t;n<e.length;n++){let t=e.charCodeAt(n);if(124==t)return!0;92==t&&n++}return!1}const Fe=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class qe{constructor(){this.rows=null}nextLine(e,t,n){if(null==this.rows){let r;if(this.rows=!1,(45==t.next||58==t.next||124==t.next)&&Fe.test(r=t.text.slice(t.pos))){let s=[];De(e,n.content,0,s,n.start)==De(e,r,t.pos)&&(this.rows=[e.elt("TableHeader",n.start,n.start+n.content.length,s),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let n=[];De(e,t.text,t.pos,n,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+t.pos,e.lineStart+t.text.length,n))}return!1}finish(e,t){return!!this.rows&&(e.addLeafElement(t,e.elt("Table",t.start,t.start+t.content.length,this.rows)),!0)}}const Ue={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":l.heading}},"TableRow",{name:"TableCell",style:l.content},{name:"TableDelimiter",style:l.processingInstruction}],parseBlock:[{name:"Table",leaf:(e,t)=>je(t.content,0)?new qe:null,endLeaf(e,t,n){if(n.parsers.some(e=>e instanceof qe)||!je(t.text,t.basePos))return!1;let r=e.peekLine();return Fe.test(r)&&De(e,t.text,t.basePos)==De(e,r,t.basePos)},before:"SetextHeading"}]};class _e{nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt("Task",t.start,t.start+t.content.length,[e.elt("TaskMarker",t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}}const Ze={defineNodes:[{name:"Task",block:!0,style:l.list},{name:"TaskMarker",style:l.atom}],parseBlock:[{name:"TaskList",leaf:(e,t)=>/^\[[ xX]\][ \t]/.test(t.content)&&"ListItem"==e.parentType().name?new _e:null,after:"SetextHeading"}]},Qe=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,Ve=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,Ge=/[\w-]+\.[\w-]+($|\/)/,Je=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Ke=/\/[a-zA-Z\d@.]+/gy;function Ye(e,t,n,r){let s=0;for(let i=t;i<n;i++)e[i]==r&&s++;return s}function We(e,t){Je.lastIndex=t;let n=Je.exec(e);if(!n)return-1;let r=n[0][n[0].length-1];return"_"==r||"-"==r?-1:t+n[0].length-("."==r?1:0)}const et=[Ue,Ze,$e,{parseInline:[{name:"Autolink",parse(e,t,n){let r=n-e.offset;if(r&&/\w/.test(e.text[r-1]))return-1;Qe.lastIndex=r;let s=Qe.exec(e.text),i=-1;if(!s)return-1;if(s[1]||s[2]){if(i=function(e,t){Ve.lastIndex=t;let n=Ve.exec(e);if(!n||Ge.exec(n[0])[0].indexOf("_")>-1)return-1;let r=t+n[0].length;for(;;){let n,s=e[r-1];if(/[?!.,:*_~]/.test(s)||")"==s&&Ye(e,t,r,")")>Ye(e,t,r,"("))r--;else{if(";"!=s||!(n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(t,r))))break;r=t+n.index}}return r}(e.text,r+s[0].length),i>-1&&e.hasOpenLink){i=r+/([^\[\]]|\[[^\]]*\])*/.exec(e.text.slice(r,i))[0].length}}else s[3]?i=We(e.text,r):(i=We(e.text,r+s[0].length),i>-1&&"xmpp:"==s[0]&&(Ke.lastIndex=i,s=Ke.exec(e.text),s&&(i=s.index+s[0].length)));return i<0?-1:(e.addElement(e.elt("URL",n,i+e.offset)),i+e.offset)}}]}];function tt(e,t,n){return(r,s,i)=>{if(s!=e||r.char(i+1)==e)return-1;let o=[r.elt(n,i,i+1)];for(let s=i+1;s<r.end;s++){let a=r.char(s);if(a==e)return r.addElement(r.elt(t,i,s+1,o.concat(r.elt(n,s,s+1))));if(92==a&&o.push(r.elt("Escape",s,2+s++)),O(a))break}return-1}}const nt={defineNodes:[{name:"Superscript",style:l.special(l.content)},{name:"SuperscriptMark",style:l.processingInstruction}],parseInline:[{name:"Superscript",parse:tt(94,"Superscript","SuperscriptMark")}]},rt={defineNodes:[{name:"Subscript",style:l.special(l.content)},{name:"SubscriptMark",style:l.processingInstruction}],parseInline:[{name:"Subscript",parse:tt(126,"Subscript","SubscriptMark")}]},st={defineNodes:[{name:"Emoji",style:l.character}],parseInline:[{name:"Emoji",parse(e,t,n){let r;return 58==t&&(r=/^[a-zA-Z_0-9]+:/.exec(e.slice(n+1,e.end)))?e.addElement(e.elt("Emoji",n,n+1+r[0].length)):-1}}]},it=x({commentTokens:{block:{open:"\x3c!--",close:"--\x3e"}}}),ot=new n,at=Re.configure({props:[S.add(e=>!e.is("Block")||e.is("Document")||null!=lt(e)||function(e){return"OrderedList"==e.name||"BulletList"==e.name}(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),ot.add(lt),C.add({Document:()=>null}),w.add({Document:it})]});function lt(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function ht(e,t){let n=e;for(;;){let e,r=n.nextSibling;if(!r||null!=(e=lt(r.type))&&e<=t)break;n=r}return n.to}const ft=u.of((e,t,n)=>{for(let r=d(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(ot);if(null==e)continue;let t=ht(r,e);if(t>n)return{from:n,to:t}}return null});function ct(e){return new g(it,e,[],"markdown")}const ut=ct(at),dt=ct(at.configure([et,rt,nt,st,{props:[S.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));class pt{constructor(e,t,n,r,s,i,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=s,this.type=i,this.item=o}blank(e,t=!0){let n=this.spaceBefore+("Blockquote"==this.node.name?">":"");if(null!=e){for(;n.length<e;)n+=" ";return n}for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=" ";return n+(t?this.spaceAfter:"")}marker(e,t){let n="OrderedList"==this.node.name?String(+gt(this.item,e)[2]+t):"";return this.spaceBefore+n+this.type+this.spaceAfter}}function mt(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if("FencedCode"==t.name)return r;"ListItem"!=t.name&&"Blockquote"!=t.name||n.push(t)}for(let e=n.length-1;e>=0;e--){let s,i=n[e],o=t.lineAt(i.from),a=i.from-o.from;if("Blockquote"==i.name&&(s=/^ *>( ?)/.exec(o.text.slice(a))))r.push(new pt(i,a,a+s[0].length,"",s[1],">",null));else if("ListItem"==i.name&&"OrderedList"==i.parent.name&&(s=/^( *)\d+([.)])( *)/.exec(o.text.slice(a)))){let e=s[3],t=s[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new pt(i.parent,a,a+t,s[1],e,s[2],i))}else if("ListItem"==i.name&&"BulletList"==i.parent.name&&(s=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(a)))){let e=s[4],t=s[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=s[2];s[3]&&(n+=s[3].replace(/[xX]/," ")),r.push(new pt(i.parent,a,a+t,s[1],e,n,i))}}return r}function gt(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function kt(e,t,n,r=0){for(let s=-1,i=e;;){if("ListItem"==i.name){let e=gt(i,t),o=+e[2];if(s>=0){if(o!=s+1)return;n.push({from:i.from+e[1].length,to:i.from+e[0].length,insert:String(s+2+r)})}s=o}let e=i.nextSibling;if(!e)break;i=e}}function xt(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||"\t"!=t.facet(k))return e;let r="";for(let t=m(e,4,n);t>0;)t>=4?(r+="\t",t-=4):(r+=" ",t--);return r+e.slice(n)}const Lt=(e={})=>({state:t,dispatch:n})=>{let r=d(t),{doc:s}=t,i=null,o=t.changeByRange(n=>{if(!n.empty||!dt.isActiveAt(t,n.from,-1)&&!dt.isActiveAt(t,n.from,1))return i={range:n};let o=n.from,a=s.lineAt(o),l=mt(r.resolveInner(o,-1),s);for(;l.length&&l[l.length-1].from>o-a.from;)l.pop();if(!l.length)return i={range:n};let h=l[l.length-1];if(h.to-h.spaceAfter.length>o-a.from)return i={range:n};let f=o>=h.to-h.spaceAfter.length&&!/\S/.test(a.text.slice(h.to));if(h.item&&f){let n=h.node.firstChild,r=h.node.getChild("ListItem","ListItem");if(n.to>=o||r&&r.to<o||a.from>0&&!/[^\s>]/.test(s.lineAt(a.from-1).text)||!1===e.nonTightLists){let e,t=l.length>1?l[l.length-2]:null,n="";t&&t.item?(e=a.from+t.from,n=t.marker(s,1)):e=a.from+(t?t.to:0);let r=[{from:e,to:o,insert:n}];return"OrderedList"==h.node.name&&kt(h.item,s,r,-2),t&&"OrderedList"==t.node.name&&kt(t.item,s,r),{range:p.cursor(e+n.length),changes:r}}{let e=Ct(l,t,a);return{range:p.cursor(o+e.length+1),changes:{from:a.from,insert:e+t.lineBreak}}}}if("Blockquote"==h.node.name&&f&&a.from){let e=s.lineAt(a.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==h.from){let s=t.changes([{from:e.from+r.index,to:e.to},{from:a.from+h.from,to:a.to}]);return{range:n.map(s),changes:s}}}let c=[];"OrderedList"==h.node.name&&kt(h.item,s,c);let u=h.item&&h.item.from<a.from,d="";if(!u||/^[\s\d.)\-+*>]*/.exec(a.text)[0].length>=h.to)for(let e=0,t=l.length-1;e<=t;e++)d+=e!=t||u?l[e].blank(e<t?m(a.text,4,l[e+1].from)-d.length:null):l[e].marker(s,1);let g=o;for(;g>a.from&&/\s/.test(a.text.charAt(g-a.from-1));)g--;return d=xt(d,t),function(e,t){if("OrderedList"!=e.name&&"BulletList"!=e.name)return!1;let n=e.firstChild,r=e.getChild("ListItem","ListItem");if(!r)return!1;let s=t.lineAt(n.to),i=t.lineAt(r.from),o=/^[\s>]*$/.test(s.text);return s.number+(o?0:1)<i.number}(h.node,t.doc)&&(d=Ct(l,t,a)+t.lineBreak+d),c.push({from:g,to:o,insert:t.lineBreak+d}),{range:p.cursor(g+d.length+1),changes:c}});return!i&&(n(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},bt=Lt();function St(e){return"QuoteMark"==e.name||"ListMark"==e.name}function Ct(e,t,n){let r="";for(let t=0,s=e.length-2;t<=s;t++)r+=e[t].blank(t<s?m(n.text,4,e[t+1].from)-r.length:null,t<s);return xt(r,t)}const wt=({state:e,dispatch:t})=>{let n=d(e),r=null,s=e.changeByRange(t=>{let s=t.from,{doc:i}=e;if(t.empty&&dt.isActiveAt(e,t.from)){let t=i.lineAt(s),r=mt(function(e,t){let n=e.resolveInner(t,-1),r=t;St(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(St(e))r=e.from;else{if("OrderedList"!=e.name&&"BulletList"!=e.name)break;n=e.lastChild,r=n.to}return n}(n,s),i);if(r.length){let n=r[r.length-1],i=n.to-n.spaceAfter.length+(n.spaceAfter?1:0);if(s-t.from>i&&!/\S/.test(t.text.slice(i,s-t.from)))return{range:p.cursor(t.from+i),changes:{from:t.from+i,to:s}};if(s-t.from==i&&(!n.item||t.from<=n.item.from||!/\S/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from<n.item.from&&/\S/.test(t.text.slice(n.from,n.to))){let s=n.blank(m(t.text,4,n.to)-m(t.text,4,n.from));return r==t.from&&(s=xt(s,e)),{range:p.cursor(r+s.length),changes:{from:r,to:t.from+n.to,insert:s}}}if(r<s)return{range:p.cursor(r),changes:{from:r,to:s}}}}}return r={range:t}});return!r&&(t(e.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},yt=[{key:"Enter",run:bt},{key:"Backspace",run:wt}],At=T({matchClosingTags:!1});function It(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:s}=ut,completeHTMLTags:i=!0,pasteURLAsLink:o=!0,htmlTagLanguage:l=At}=e;if(!(s instanceof le))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let u,d=e.extensions?[e.extensions]:[],p=[l.support,ft];o&&p.push(Ht),n instanceof h?(p.push(n.support),u=n.language):n&&(u=n);let m=t||u?(g=t,k=u,e=>{if(e&&g){let t=null;if(e=/\S*/.exec(e)[0],t="function"==typeof g?g(e):A.matchLanguageName(g,e,!0),t instanceof A)return t.support?t.support.language.parser:I.getSkippingParser(t.load());if(t)return t.parser}return k?k.parser:null}):void 0;var g,k;d.push(function(e){let{codeParser:t,htmlParser:n}=e,r=a((e,r)=>{let s=e.type.id;if(!t||s!=v.CodeBlock&&s!=v.FencedCode){if(n&&(s==v.HTMLBlock||s==v.HTMLTag||s==v.CommentBlock))return{parser:n,overlay:Xe(e.node,e.from,e.to)}}else{let n="";if(s==v.FencedCode){let t=e.node.getChild(v.CodeInfo);t&&(n=r.read(t.from,t.to))}let i=t(n);if(i)return{parser:i,overlay:e=>e.type.id==v.CodeText,bracketed:s==v.FencedCode}}return null});return{wrap:r}}({codeParser:m,htmlParser:l.language.parser})),r&&p.push(f.high(c.of(yt)));let x=ct(s.configure(d));return i&&p.push(x.data.of({autocomplete:Tt})),new h(x,p)}function Tt(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let s=d(t).resolveInner(n,-1);for(;s&&!s.type.isTop;){if("CodeBlock"==s.name||"FencedCode"==s.name||"ProcessingInstructionBlock"==s.name||"CommentBlock"==s.name||"Link"==s.name||"Image"==s.name)return null;s=s.parent}return{from:n-r[0].length,to:n,options:Et(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let Bt=null;function Et(){if(Bt)return Bt;let e=B(new L(b.create({extensions:At}),0,!0));return Bt=e?e.options:[]}const vt=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Ht=y.domEventHandlers({paste:(e,t)=>{var n;let{main:r}=t.state.selection;if(r.empty)return!1;let s=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s))return!1;if(/^www\./.test(s)&&(s="https://"+s),!dt.isActiveAt(t.state,r.from,1))return!1;let i=d(t.state),o=!1;return i.iterate({from:r.from,to:r.to,enter:e=>{(e.from>r.from||vt.test(e.name))&&(o=!0)},leave:e=>{e.to<r.to&&(o=!0)}}),!o&&(t.dispatch({changes:[{from:r.from,insert:"["},{from:r.to,insert:`](${s})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});export{ut as commonmarkLanguage,wt as deleteMarkupBackward,bt as insertNewlineContinueMarkup,Lt as insertNewlineContinueMarkupCommand,It as markdown,yt as markdownKeymap,dt as markdownLanguage,Ht as pasteURLAsLink};
|
|
1
|
+
import{P as e,a as t,b as n,h as r,N as s,s as i,T as o,p as a,t as l,L as h,y as f,z as c,j as u,n as d,o as p,A as m,B as g,C as k,w as x,F as L,G as b,f as S,i as C,H as w,E as y,g as A,J as I}from"./basic-setup-Cz3rV4Fo.js";import{html as T,htmlCompletionSource as B}from"./index-DzHNpFcT.js";import"./index-BjZU1VKq.js";import"./index-CQlgVNck.js";import"./index-BmpEdvsk.js";class E{static create(e,t,n,r,s){return new E(e,t,n,r+(r<<8)+e+(t<<4)|0,s,[],[])}constructor(e,t,r,s,i,o,a){this.type=e,this.value=t,this.from=r,this.hash=s,this.end=i,this.children=o,this.positions=a,this.hashProp=[[n.contextHash,s]]}addChild(e,t){e.prop(n.contextHash)!=this.hash&&(e=new o(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new o(e.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(e,n,r)=>new o(t.none,e,n,r,this.hashProp)})}}var v;!function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"}(v||(v={}));class H{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}}class M{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return R(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=9==this.text.charCodeAt(r)?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=9==this.text.charCodeAt(t)?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e="";for(let t=0;t<this.basePos;t++)e+=" ";return e+this.text.slice(this.basePos)}}function P(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==v.OrderedList?q:F)(n,t,!1);return r>0&&(e.type!=v.BulletList||D(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const N={[v.Blockquote]:(e,t,n)=>62==n.next&&(n.markers.push(ke(v.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(O(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0),[v.ListItem]:(e,t,n)=>!(n.indent<n.baseIndent+e.value&&n.next>-1)&&(n.moveBaseColumn(n.baseIndent+e.value),!0),[v.OrderedList]:P,[v.BulletList]:P,[v.Document]:()=>!0};function O(e){return 32==e||9==e||10==e||13==e}function R(e,t=0){for(;t<e.length&&O(e.charCodeAt(t));)t++;return t}function X(e,t,n){for(;t>n&&O(e.charCodeAt(t-1));)t--;return t}function z(e){if(96!=e.next&&126!=e.next)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(96==e.next)for(let n=t;n<e.text.length;n++)if(96==e.text.charCodeAt(n))return-1;return t}function $(e){return 62!=e.next?-1:32==e.text.charCodeAt(e.pos+1)?2:1}function D(e,t,n){if(42!=e.next&&45!=e.next&&95!=e.next)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!O(n))return-1}return n&&45==e.next&&_(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(re.SetextHeading)>-1||r<3?-1:1}function j(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function F(e,t,n){return 45!=e.next&&43!=e.next&&42!=e.next||e.pos!=e.text.length-1&&!O(e.text.charCodeAt(e.pos+1))||!(!n||j(t,v.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?-1:1}function q(e,t,n){let r=e.pos,s=e.next;for(;s>=48&&s<=57;){if(r++,r==e.text.length)return-1;s=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||46!=s&&41!=s||r<e.text.length-1&&!O(e.text.charCodeAt(r+1))||n&&!j(t,v.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||49!=e.next)?-1:r+1-e.pos}function U(e){if(35!=e.next)return-1;let t=e.pos+1;for(;t<e.text.length&&35==e.text.charCodeAt(t);)t++;if(t<e.text.length&&32!=e.text.charCodeAt(t))return-1;let n=t-e.pos;return n>6?-1:n}function _(e){if(45!=e.next&&61!=e.next||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&O(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const Z=/^[ \t]*$/,Q=/-->/,V=/\?>/,G=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Q],[/^\s*<\?/,V],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Z],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Z]];function J(e,t,n){if(60!=e.next)return-1;let r=e.text.slice(e.pos);for(let e=0,t=G.length-(n?1:0);e<t;e++)if(G[e][0].test(r))return e;return-1}function K(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function Y(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==v.CodeText?e[r].to=n:e.push(ke(v.CodeText,t,n))}const W={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),s=e.lineStart+r,i=e.lineStart+t.text.length,o=[],a=[];for(Y(o,s,i);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){Y(a,e.lineStart-1,e.lineStart);for(let e of t.markers)a.push(e)}else{if(t.indent<n)break;{if(a.length){for(let e of a)e.type==v.CodeText?Y(o,e.from,e.to):o.push(e);a=[]}Y(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);i=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<i&&Y(o,n,i)}}return a.length&&(a=a.filter(e=>e.type!=v.CodeText),a.length&&(t.markers=a.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-s).finish(v.CodeBlock,i-s),s),!0},FencedCode(e,t){let n=z(t);if(n<0)return!1;let r=e.lineStart+t.pos,s=t.next,i=n-t.pos,o=t.skipSpace(n),a=X(t.text,t.text.length,o),l=[ke(v.CodeMark,r,r+i)];o<a&&l.push(ke(v.CodeInfo,e.lineStart+o,e.lineStart+a));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let a=t.pos;if(t.indent-t.baseIndent<4)for(;a<t.text.length&&t.text.charCodeAt(a)==s;)a++;if(a-t.pos>=i&&t.skipSpace(a)==t.text.length){for(let e of t.markers)l.push(e);r&&o&&Y(l,e.lineStart-1,e.lineStart),l.push(ke(v.CodeMark,e.lineStart+t.pos,e.lineStart+a)),e.nextLine();break}{o=!0,n||(Y(l,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)l.push(e);let s=e.lineStart+t.basePos,i=e.lineStart+t.text.length;s<i&&(Y(l,s,i),r=!1)}}return e.addNode(e.buffer.writeElements(l,-r).finish(v.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=$(t);return!(n<0)&&(e.startContext(v.Blockquote,t.pos),e.addNode(v.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(D(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(v.HorizontalRule,n),!0},BulletList(e,t){let n=F(t,e,!1);if(n<0)return!1;e.block.type!=v.BulletList&&e.startContext(v.BulletList,t.basePos,t.next);let r=K(t,t.pos+1);return e.startContext(v.ListItem,t.basePos,r-t.baseIndent),e.addNode(v.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=q(t,e,!1);if(n<0)return!1;e.block.type!=v.OrderedList&&e.startContext(v.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=K(t,t.pos+n);return e.startContext(v.ListItem,t.basePos,r-t.baseIndent),e.addNode(v.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=U(t);if(n<0)return!1;let r=t.pos,s=e.lineStart+r,i=X(t.text,t.text.length,r),o=i;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;o!=i&&o!=r&&O(t.text.charCodeAt(o-1))||(o=t.text.length);let a=e.buffer.write(v.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),s+n+1),-s);o<t.text.length&&a.write(v.HeaderMark,o-r,i-r);let l=a.finish(v.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,s),!0},HTMLBlock(e,t){let n=J(t,0,!1);if(n<0)return!1;let r=e.lineStart+t.pos,s=G[n][1],i=[],o=s!=Z;for(;!s.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)i.push(e)}o&&e.nextLine();let a=s==Q?v.CommentBlock:s==V?v.ProcessingInstructionBlock:v.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(i,-r).finish(a,l-r),r),!0},SetextHeading:void 0};class ee{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(-1==this.stage)return!1;let r=n.content+"\n"+t.scrub(),s=this.advance(r);return s>-1&&s<r.length&&this.complete(e,n,s)}finish(e,t){return(2==this.stage||3==this.stage)&&R(t.content,this.pos)==t.content.length&&this.complete(e,t,t.content.length)}complete(e,t,n){return e.addLeafElement(t,ke(v.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(!1===e&&(this.stage=-1),!1)}advance(e){for(;;){if(-1==this.stage)return-1;if(0==this.stage){if(!this.nextStage(Ee(e,this.pos,this.start,!0)))return-1;if(58!=e.charCodeAt(this.pos))return this.stage=-1;this.elts.push(ke(v.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else{if(1!=this.stage){if(2==this.stage){let t=R(e,this.pos),n=0;if(t>this.pos){let r=Be(e,t,this.start);if(r){let t=te(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||(n=te(e,this.pos)),n>0&&n<e.length?n:-1}return te(e,this.pos)}if(!this.nextStage(Te(e,R(e,this.pos),this.start)))return-1}}}}function te(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(10==n)break;if(!O(n))return-1}return t}class ne{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:_(t),s=t.next;if(r<0)return!1;let i=ke(v.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,ke(61==s?v.SetextHeading1:v.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),i])),!0}finish(){return!1}}const re={LinkReference:(e,t)=>91==t.content.charCodeAt(0)?new ee(t):null,SetextHeading:()=>new ne},se=[(e,t)=>U(t)>=0,(e,t)=>z(t)>=0,(e,t)=>$(t)>=0,(e,t)=>F(t,e,!0)>=0,(e,t)=>q(t,e,!0)>=0,(e,t)=>D(t,e,!0)>=0,(e,t)=>J(t,0,!0)>=0],ie={text:"",end:0};class oe{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new M,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=E.create(v.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new Pe(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(null!=this.stoppedAt&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(0!=n){if(1==n)return null;e.forward();continue e}}break}let t=new H(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4)for(let n of this.parser.endLeafBlock)if(n(this,e,t))break e;for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+="\n"+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return!!t&&(this.absoluteLineStart+=t,this.lineStart=Ne(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0)}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=ie;if(t.end=e,e>=this.to)t.text="";else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,s=this.lineChunkAt(r);t.end=r+s.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+s,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw new Error("Unhandled block context "+v[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t,n=this.input.chunk(e);if(this.input.lineChunks)t="\n"==n?"":n;else{let e=n.indexOf("\n");t=e<0?n:n.slice(0,e)}return e+t.length>this.to?t.slice(0,this.to-e):t}prevLineEnd(){return this.atEnd?this.lineStart:this.lineStart-1}startContext(e,t,n=0){this.block=E.create(e,n,this.lineStart+t,this.block.hash,this.lineStart+this.line.text.length),this.stack.push(this.block)}startComposite(e,t,n=0){this.startContext(this.parser.getNodeType(e),t,n)}addNode(e,t,n){"number"==typeof e&&(e=new o(this.parser.nodeSet.types[e],de,de,(null!=n?n:this.prevLineEnd())-t)),this.block.addChild(e,t-this.block.from)}addElement(e){this.block.addChild(e.toTree(this.parser.nodeSet),e.from-this.block.from)}addLeafElement(e,t){this.addNode(this.buffer.writeElements(He(t.children,e.marks),-t.from).finish(t.type,t.to-t.from),t.from)}finishContext(){let e=this.stack.pop(),t=this.stack[this.stack.length-1];t.addChild(e.toTree(this.parser.nodeSet),e.from-t.from),this.block=t}finish(){for(;this.stack.length>1;)this.finishContext();return this.addGaps(this.block.toTree(this.parser.nodeSet,this.lineStart))}addGaps(e){return this.ranges.length>1?ae(this.ranges,0,e.topNode,this.ranges[0].from,this.reusePlaceholders):e}finishLeaf(e){for(let t of e.parsers)if(t.finish(this,e))return;let t=He(this.parser.parseInline(e.content,e.start),e.marks);this.addNode(this.buffer.writeElements(t,-e.start).finish(v.Paragraph,e.content.length),e.start)}elt(e,t,n,r){return"string"==typeof e?ke(this.parser.getNodeType(e),t,n,r):new ge(e,t)}get buffer(){return new pe(this.parser.nodeSet)}}function ae(e,t,n,r,s){let i=e[t].to,a=[],l=[],h=n.from+r;function f(n,s){for(;s?n>=i:n>i;){let s=e[t+1].from-i;r+=s,n+=s,t++,i=e[t].to}}for(let o=n.firstChild;o;o=o.nextSibling){f(o.from+r,!0);let n,c=o.from+r,u=s.get(o.tree);u?n=u:o.to+r>i?(n=ae(e,t,o,r,s),f(o.to+r,!1)):n=o.toTree(),a.push(n),l.push(c-h)}return f(n.to+r,!1),new o(n.type,a,l,n.to+r-h,n.tree?n.tree.propValues:void 0)}class le extends e{constructor(e,t,n,r,s,i,o,a,l){super(),this.nodeSet=e,this.blockParsers=t,this.leafBlockParsers=n,this.blockNames=r,this.endLeafBlock=s,this.skipContextMarkup=i,this.inlineParsers=o,this.inlineNames=a,this.wrappers=l,this.nodeTypes=Object.create(null);for(let t of e.types)this.nodeTypes[t.name]=t.id}createParse(e,t,n){let r=new oe(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}configure(e){let o=fe(e);if(!o)return this;let{nodeSet:a,skipContextMarkup:l}=this,h=this.blockParsers.slice(),f=this.leafBlockParsers.slice(),c=this.blockNames.slice(),u=this.inlineParsers.slice(),d=this.inlineNames.slice(),p=this.endLeafBlock.slice(),m=this.wrappers;if(he(o.defineNodes)){l=Object.assign({},l);let e,h=a.types.slice();for(let s of o.defineNodes){let{name:i,block:o,composite:a,style:f}="string"==typeof s?{name:s}:s;if(h.some(e=>e.name==i))continue;a&&(l[h.length]=(e,t,n)=>a(t,n,e.value));let c=h.length,u=a?["Block","BlockContext"]:o?c>=v.ATXHeading1&&c<=v.SetextHeading2?["Block","LeafBlock","Heading"]:["Block","LeafBlock"]:void 0;h.push(t.define({id:c,name:i,props:u&&[[n.group,u]]})),f&&(e||(e={}),Array.isArray(f)||f instanceof r?e[i]=f:Object.assign(e,f))}a=new s(h),e&&(a=a.extend(i(e)))}if(he(o.props)&&(a=a.extend(...o.props)),he(o.remove))for(let e of o.remove){let t=this.blockNames.indexOf(e),n=this.inlineNames.indexOf(e);t>-1&&(h[t]=f[t]=void 0),n>-1&&(u[n]=void 0)}if(he(o.parseBlock))for(let e of o.parseBlock){let t=c.indexOf(e.name);if(t>-1)h[t]=e.parse,f[t]=e.leaf;else{let t=e.before?ce(c,e.before):e.after?ce(c,e.after)+1:c.length-1;h.splice(t,0,e.parse),f.splice(t,0,e.leaf),c.splice(t,0,e.name)}e.endLeaf&&p.push(e.endLeaf)}if(he(o.parseInline))for(let e of o.parseInline){let t=d.indexOf(e.name);if(t>-1)u[t]=e.parse;else{let t=e.before?ce(d,e.before):e.after?ce(d,e.after)+1:d.length-1;u.splice(t,0,e.parse),d.splice(t,0,e.name)}}return o.wrap&&(m=m.concat(o.wrap)),new le(a,h,f,c,p,l,u,d,m)}getNodeType(e){let t=this.nodeTypes[e];if(null==t)throw new RangeError(`Unknown node type '${e}'`);return t}parseInline(e,t){let n=new ve(this,e,t);e:for(let e=t;e<n.end;){let t=n.char(e);for(let r of this.inlineParsers)if(r){let s=r(n,t,e);if(s>=0){e=s;continue e}}e++}return n.resolveMarkers(0)}}function he(e){return null!=e&&e.length>0}function fe(e){if(!Array.isArray(e))return e;if(0==e.length)return null;let t=fe(e[0]);if(1==e.length)return t;let n=fe(e.slice(1));if(!n||!t)return t||n;let r=(e,t)=>(e||de).concat(t||de),s=t.wrap,i=n.wrap;return{props:r(t.props,n.props),defineNodes:r(t.defineNodes,n.defineNodes),parseBlock:r(t.parseBlock,n.parseBlock),parseInline:r(t.parseInline,n.parseInline),remove:r(t.remove,n.remove),wrap:s?i?(e,t,n,r)=>s(i(e,t,n,r),t,n,r):s:i}}function ce(e,t){let n=e.indexOf(t);if(n<0)throw new RangeError(`Position specified relative to unknown parser ${t}`);return n}let ue=[t.none];for(let e,r=1;e=v[r];r++)ue[r]=t.define({id:r,name:e,props:r>=v.Escape?[]:[[n.group,r in N?["Block","BlockContext"]:["Block","LeafBlock"]]],top:"Document"==e});const de=[];class pe{constructor(e){this.nodeSet=e,this.content=[],this.nodes=[]}write(e,t,n,r=0){return this.content.push(e,t,n,4+4*r),this}writeElements(e,t=0){for(let n of e)n.writeTo(this,t);return this}finish(e,t){return o.build({buffer:this.content,nodeSet:this.nodeSet,reused:this.nodes,topID:e,length:t})}}class me{constructor(e,t,n,r=de){this.type=e,this.from=t,this.to=n,this.children=r}writeTo(e,t){let n=e.content.length;e.writeElements(this.children,t),e.content.push(this.type,this.from+t,this.to+t,e.content.length+4-n)}toTree(e){return new pe(e).writeElements(this.children,-this.from).finish(this.type,this.to-this.from)}}class ge{constructor(e,t){this.tree=e,this.from=t}get to(){return this.from+this.tree.length}get type(){return this.tree.type.id}get children(){return de}writeTo(e,t){e.nodes.push(this.tree),e.content.push(e.nodes.length-1,this.from+t,this.to+t,-1)}toTree(){return this.tree}}function ke(e,t,n,r){return new me(e,t,n,r)}const xe={resolve:"Emphasis",mark:"EmphasisMark"},Le={resolve:"Emphasis",mark:"EmphasisMark"},be={},Se={};class Ce{constructor(e,t,n,r){this.type=e,this.from=t,this.to=n,this.side=r}}const we="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";let ye=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\u2010-\u2027]/;try{ye=new RegExp("[\\p{S}|\\p{P}]","u")}catch(e){}const Ae={Escape(e,t,n){if(92!=t||n==e.end-1)return-1;let r=e.char(n+1);for(let t=0;t<32;t++)if(we.charCodeAt(t)==r)return e.append(ke(v.Escape,n,n+2));return-1},Entity(e,t,n){if(38!=t)return-1;let r=/^(?:#\d+|#x[a-f\d]+|\w+);/i.exec(e.slice(n+1,n+31));return r?e.append(ke(v.Entity,n,n+1+r[0].length)):-1},InlineCode(e,t,n){if(96!=t||n&&96==e.char(n-1))return-1;let r=n+1;for(;r<e.end&&96==e.char(r);)r++;let s=r-n,i=0;for(;r<e.end;r++)if(96==e.char(r)){if(i++,i==s&&96!=e.char(r+1))return e.append(ke(v.InlineCode,n,r+1,[ke(v.CodeMark,n,n+s),ke(v.CodeMark,r+1-s,r+1)]))}else i=0;return-1},HTMLTag(e,t,n){if(60!=t||n==e.end-1)return-1;let r=e.slice(n+1,e.end),s=/^(?:[a-z][-\w+.]+:[^\s>]+|[a-z\d.!#$%&'*+/=?^_`{|}~-]+@[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*)>/i.exec(r);if(s)return e.append(ke(v.Autolink,n,n+1+s[0].length,[ke(v.LinkMark,n,n+1),ke(v.URL,n+1,n+s[0].length),ke(v.LinkMark,n+s[0].length,n+1+s[0].length)]));let i=/^!--[^>](?:-[^-]|[^-])*?-->/i.exec(r);if(i)return e.append(ke(v.Comment,n,n+1+i[0].length));let o=/^\?[^]*?\?>/.exec(r);if(o)return e.append(ke(v.ProcessingInstruction,n,n+1+o[0].length));let a=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(r);return a?e.append(ke(v.HTMLTag,n,n+1+a[0].length)):-1},Emphasis(e,t,n){if(95!=t&&42!=t)return-1;let r=n+1;for(;e.char(r)==t;)r++;let s=e.slice(n-1,n),i=e.slice(r,r+1),o=ye.test(s),a=ye.test(i),l=/\s|^$/.test(s),h=/\s|^$/.test(i),f=!h&&(!a||l||o),c=!l&&(!o||h||a),u=f&&(42==t||!c||o),d=c&&(42==t||!f||a);return e.append(new Ce(95==t?xe:Le,n,r,(u?1:0)|(d?2:0)))},HardBreak(e,t,n){if(92==t&&10==e.char(n+1))return e.append(ke(v.HardBreak,n,n+2));if(32==t){let t=n+1;for(;32==e.char(t);)t++;if(10==e.char(t)&&t>=n+2)return e.append(ke(v.HardBreak,n,t+1))}return-1},Link:(e,t,n)=>91==t?e.append(new Ce(be,n,n+1,1)):-1,Image:(e,t,n)=>33==t&&91==e.char(n+1)?e.append(new Ce(Se,n,n+2,1)):-1,LinkEnd(e,t,n){if(93!=t)return-1;for(let t=e.parts.length-1;t>=0;t--){let r=e.parts[t];if(r instanceof Ce&&(r.type==be||r.type==Se)){if(!r.side||e.skipSpace(r.to)==n&&!/[(\[]/.test(e.slice(n+1,n+2)))return e.parts[t]=null,-1;let s=e.takeContent(t),i=e.parts[t]=Ie(e,s,r.type==be?v.Link:v.Image,r.from,n+1);if(r.type==be)for(let n=0;n<t;n++){let t=e.parts[n];t instanceof Ce&&t.type==be&&(t.side=0)}return i.to}}return-1}};function Ie(e,t,n,r,s){let{text:i}=e,o=e.char(s),a=s;if(t.unshift(ke(v.LinkMark,r,r+(n==v.Image?2:1))),t.push(ke(v.LinkMark,s-1,s)),40==o){let n,r=e.skipSpace(s+1),o=Te(i,r-e.offset,e.offset);o&&(r=e.skipSpace(o.to),r!=o.to&&(n=Be(i,r-e.offset,e.offset),n&&(r=e.skipSpace(n.to)))),41==e.char(r)&&(t.push(ke(v.LinkMark,s,s+1)),a=r+1,o&&t.push(o),n&&t.push(n),t.push(ke(v.LinkMark,r,a)))}else if(91==o){let n=Ee(i,s-e.offset,e.offset,!1);n&&(t.push(n),a=n.to)}return ke(n,r,a,t)}function Te(e,t,n){if(60==e.charCodeAt(t)){for(let r=t+1;r<e.length;r++){let s=e.charCodeAt(r);if(62==s)return ke(v.URL,t+n,r+1+n);if(60==s||10==s)return!1}return null}{let r=0,s=t;for(let t=!1;s<e.length;s++){let n=e.charCodeAt(s);if(O(n))break;if(t)t=!1;else if(40==n)r++;else if(41==n){if(!r)break;r--}else 92==n&&(t=!0)}return s>t?ke(v.URL,t+n,s+n):s==e.length&&null}}function Be(e,t,n){let r=e.charCodeAt(t);if(39!=r&&34!=r&&40!=r)return!1;let s=40==r?41:r;for(let r=t+1,i=!1;r<e.length;r++){let o=e.charCodeAt(r);if(i)i=!1;else{if(o==s)return ke(v.LinkTitle,t+n,r+1+n);92==o&&(i=!0)}}return null}function Ee(e,t,n,r){for(let s=!1,i=t+1,o=Math.min(e.length,i+999);i<o;i++){let o=e.charCodeAt(i);if(s)s=!1;else{if(93==o)return!r&&ke(v.LinkLabel,t+n,i+1+n);if(r&&!O(o)&&(r=!1),91==o)return!1;92==o&&(s=!0)}}return null}class ve{constructor(e,t,n){this.parser=e,this.text=t,this.offset=n,this.parts=[]}char(e){return e>=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,t){return this.text.slice(e-this.offset,t-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,t,n,r,s){return this.append(new Ce(e,t,n,(r?1:0)|(s?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let t=this.parts[e];if(t instanceof Ce&&(t.type==be||t.type==Se))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let t=e;t<this.parts.length;t++){let n=this.parts[t];if(!(n instanceof Ce&&n.type.resolve&&2&n.side))continue;let r,s=n.type==xe||n.type==Le,i=n.to-n.from,o=t-1;for(;o>=e;o--){let e=this.parts[o];if(e instanceof Ce&&1&e.side&&e.type==n.type&&!(s&&(1&n.side||2&e.side)&&(e.to-e.from+i)%3==0&&((e.to-e.from)%3||i%3))){r=e;break}}if(!r)continue;let a=n.type.resolve,l=[],h=r.from,f=n.to;if(s){let e=Math.min(2,r.to-r.from,i);h=r.to-e,f=n.from+e,a=1==e?"Emphasis":"StrongEmphasis"}r.type.mark&&l.push(this.elt(r.type.mark,h,r.to));for(let e=o+1;e<t;e++)this.parts[e]instanceof me&&l.push(this.parts[e]),this.parts[e]=null;n.type.mark&&l.push(this.elt(n.type.mark,n.from,f));let c=this.elt(a,h,f,l);this.parts[o]=s&&r.from!=h?new Ce(r.type,r.from,h,r.side):null,(this.parts[t]=s&&n.to!=f?new Ce(n.type,f,n.to,n.side):null)?this.parts.splice(t,0,c):this.parts[t]=c}let t=[];for(let n=e;n<this.parts.length;n++){let e=this.parts[n];e instanceof me&&t.push(e)}return t}findOpeningDelimiter(e){for(let t=this.parts.length-1;t>=0;t--){let n=this.parts[t];if(n instanceof Ce&&n.type==e&&1&n.side)return t}return null}takeContent(e){let t=this.resolveMarkers(e);return this.parts.length=e,t}getDelimiterAt(e){let t=this.parts[e];return t instanceof Ce?t:null}skipSpace(e){return R(this.text,e-this.offset)+this.offset}elt(e,t,n,r){return"string"==typeof e?ke(this.parser.getNodeType(e),t,n,r):new ge(e,t)}}function He(e,t){if(!t.length)return e;if(!e.length)return t;let n=e.slice(),r=0;for(let e of t){for(;r<n.length&&n[r].to<e.to;)r++;if(r<n.length&&n[r].from<e.from){let t=n[r];t instanceof me&&(n[r]=new me(t.type,t.from,t.to,He(t.children,[e])))}else n.splice(r++,0,e)}return n}ve.linkStart=be,ve.imageStart=Se;const Me=[v.CodeBlock,v.ListItem,v.OrderedList,v.BulletList];class Pe{constructor(e,t){this.fragments=e,this.input=t,this.i=0,this.fragment=null,this.fragmentEnd=-1,this.cursor=null,e.length&&(this.fragment=e[this.i++])}nextFragment(){this.fragment=this.i<this.fragments.length?this.fragments[this.i++]:null,this.cursor=null,this.fragmentEnd=-1}moveTo(e,t){for(;this.fragment&&this.fragment.to<=e;)this.nextFragment();if(!this.fragment||this.fragment.from>(e?e-1:0))return!1;if(this.fragmentEnd<0){let e=this.fragment.to;for(;e>0&&"\n"!=this.input.read(e-1,e);)e--;this.fragmentEnd=e?e-1:0}let n=this.cursor;n||(n=this.cursor=this.fragment.tree.cursor(),n.firstChild());let r=e+this.fragment.offset;for(;n.to<=r;)if(!n.parent())return!1;for(;;){if(n.from>=r)return this.fragment.from<=t;if(!n.childAfter(r))return!1}}matches(e){let t=this.cursor.tree;return t&&t.prop(n.contextHash)==e}takeNodes(e){let t=this.cursor,n=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,i=s,a=e.block.children.length,l=i,h=a;for(;;){if(t.to-n>r){if(t.type.isAnonymous&&t.firstChild())continue;break}let s=Ne(t.from-n,e.ranges);if(t.to-n<=e.ranges[e.rangeI].to)e.addNode(t.tree,s);else{let n=new o(e.parser.nodeSet.types[v.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(n,t.tree),e.addNode(n,s)}if(t.type.is("Block")&&(Me.indexOf(t.type.id)<0?(i=t.to-n,a=e.block.children.length):(i=l,a=h),l=t.to-n,h=e.block.children.length),!t.nextSibling())break}for(;e.block.children.length>a;)e.block.children.pop(),e.block.positions.pop();return i-s}}function Ne(e,t){let n=e;for(let r=1;r<t.length;r++){let s=t[r-1].to,i=t[r].from;s<e&&(n-=i-s)}return n}const Oe=i({"Blockquote/...":l.quote,HorizontalRule:l.contentSeparator,"ATXHeading1/... SetextHeading1/...":l.heading1,"ATXHeading2/... SetextHeading2/...":l.heading2,"ATXHeading3/...":l.heading3,"ATXHeading4/...":l.heading4,"ATXHeading5/...":l.heading5,"ATXHeading6/...":l.heading6,"Comment CommentBlock":l.comment,Escape:l.escape,Entity:l.character,"Emphasis/...":l.emphasis,"StrongEmphasis/...":l.strong,"Link/... Image/...":l.link,"OrderedList/... BulletList/...":l.list,"BlockQuote/...":l.quote,"InlineCode CodeText":l.monospace,"URL Autolink":l.url,"HeaderMark HardBreak QuoteMark ListMark LinkMark EmphasisMark CodeMark":l.processingInstruction,"CodeInfo LinkLabel":l.labelName,LinkTitle:l.string,Paragraph:l.content}),Re=new le(new s(ue).extend(Oe),Object.keys(W).map(e=>W[e]),Object.keys(W).map(e=>re[e]),Object.keys(W),se,N,Object.keys(Ae).map(e=>Ae[e]),Object.keys(Ae),[]);function Xe(e,t,n){let r=[];for(let s=e.firstChild,i=t;;s=s.nextSibling){let e=s?s.from:n;if(e>i&&r.push({from:i,to:e}),!s)break;i=s.to}return r}const ze={resolve:"Strikethrough",mark:"StrikethroughMark"},$e={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":l.strikethrough}},{name:"StrikethroughMark",style:l.processingInstruction}],parseInline:[{name:"Strikethrough",parse(e,t,n){if(126!=t||126!=e.char(n+1)||126==e.char(n+2))return-1;let r=e.slice(n-1,n),s=e.slice(n+2,n+3),i=/\s|^$/.test(r),o=/\s|^$/.test(s),a=ye.test(r),l=ye.test(s);return e.addDelimiter(ze,n,n+2,!o&&(!l||i||a),!i&&(!a||o||l))},after:"Emphasis"}]};function De(e,t,n=0,r,s=0){let i=0,o=!0,a=-1,l=-1,h=!1,f=()=>{r.push(e.elt("TableCell",s+a,s+l,e.parser.parseInline(t.slice(a,l),s+a)))};for(let c=n;c<t.length;c++){let n=t.charCodeAt(c);124!=n||h?(h||32!=n&&9!=n)&&(a<0&&(a=c),l=c+1):((!o||a>-1)&&i++,o=!1,r&&(a>-1&&f(),r.push(e.elt("TableDelimiter",c+s,c+s+1))),a=l=-1),h=!h&&92==n}return a>-1&&(i++,r&&f()),i}function je(e,t){for(let n=t;n<e.length;n++){let t=e.charCodeAt(n);if(124==t)return!0;92==t&&n++}return!1}const Fe=/^\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class qe{constructor(){this.rows=null}nextLine(e,t,n){if(null==this.rows){let r;if(this.rows=!1,(45==t.next||58==t.next||124==t.next)&&Fe.test(r=t.text.slice(t.pos))){let s=[];De(e,n.content,0,s,n.start)==De(e,r,t.pos)&&(this.rows=[e.elt("TableHeader",n.start,n.start+n.content.length,s),e.elt("TableDelimiter",e.lineStart+t.pos,e.lineStart+t.text.length)])}}else if(this.rows){let n=[];De(e,t.text,t.pos,n,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+t.pos,e.lineStart+t.text.length,n))}return!1}finish(e,t){return!!this.rows&&(e.addLeafElement(t,e.elt("Table",t.start,t.start+t.content.length,this.rows)),!0)}}const Ue={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":l.heading}},"TableRow",{name:"TableCell",style:l.content},{name:"TableDelimiter",style:l.processingInstruction}],parseBlock:[{name:"Table",leaf:(e,t)=>je(t.content,0)?new qe:null,endLeaf(e,t,n){if(n.parsers.some(e=>e instanceof qe)||!je(t.text,t.basePos))return!1;let r=e.peekLine();return Fe.test(r)&&De(e,t.text,t.basePos)==De(e,r,t.basePos)},before:"SetextHeading"}]};class _e{nextLine(){return!1}finish(e,t){return e.addLeafElement(t,e.elt("Task",t.start,t.start+t.content.length,[e.elt("TaskMarker",t.start,t.start+3),...e.parser.parseInline(t.content.slice(3),t.start+3)])),!0}}const Ze={defineNodes:[{name:"Task",block:!0,style:l.list},{name:"TaskMarker",style:l.atom}],parseBlock:[{name:"TaskList",leaf:(e,t)=>/^\[[ xX]\][ \t]/.test(t.content)&&"ListItem"==e.parentType().name?new _e:null,after:"SetextHeading"}]},Qe=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,Ve=/[\w-]+(\.[\w-]+)+(\/[^\s<]*)?/gy,Ge=/[\w-]+\.[\w-]+($|\/)/,Je=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,Ke=/\/[a-zA-Z\d@.]+/gy;function Ye(e,t,n,r){let s=0;for(let i=t;i<n;i++)e[i]==r&&s++;return s}function We(e,t){Je.lastIndex=t;let n=Je.exec(e);if(!n)return-1;let r=n[0][n[0].length-1];return"_"==r||"-"==r?-1:t+n[0].length-("."==r?1:0)}const et=[Ue,Ze,$e,{parseInline:[{name:"Autolink",parse(e,t,n){let r=n-e.offset;if(r&&/\w/.test(e.text[r-1]))return-1;Qe.lastIndex=r;let s=Qe.exec(e.text),i=-1;if(!s)return-1;if(s[1]||s[2]){if(i=function(e,t){Ve.lastIndex=t;let n=Ve.exec(e);if(!n||Ge.exec(n[0])[0].indexOf("_")>-1)return-1;let r=t+n[0].length;for(;;){let n,s=e[r-1];if(/[?!.,:*_~]/.test(s)||")"==s&&Ye(e,t,r,")")>Ye(e,t,r,"("))r--;else{if(";"!=s||!(n=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(e.slice(t,r))))break;r=t+n.index}}return r}(e.text,r+s[0].length),i>-1&&e.hasOpenLink){i=r+/([^\[\]]|\[[^\]]*\])*/.exec(e.text.slice(r,i))[0].length}}else s[3]?i=We(e.text,r):(i=We(e.text,r+s[0].length),i>-1&&"xmpp:"==s[0]&&(Ke.lastIndex=i,s=Ke.exec(e.text),s&&(i=s.index+s[0].length)));return i<0?-1:(e.addElement(e.elt("URL",n,i+e.offset)),i+e.offset)}}]}];function tt(e,t,n){return(r,s,i)=>{if(s!=e||r.char(i+1)==e)return-1;let o=[r.elt(n,i,i+1)];for(let s=i+1;s<r.end;s++){let a=r.char(s);if(a==e)return r.addElement(r.elt(t,i,s+1,o.concat(r.elt(n,s,s+1))));if(92==a&&o.push(r.elt("Escape",s,2+s++)),O(a))break}return-1}}const nt={defineNodes:[{name:"Superscript",style:l.special(l.content)},{name:"SuperscriptMark",style:l.processingInstruction}],parseInline:[{name:"Superscript",parse:tt(94,"Superscript","SuperscriptMark")}]},rt={defineNodes:[{name:"Subscript",style:l.special(l.content)},{name:"SubscriptMark",style:l.processingInstruction}],parseInline:[{name:"Subscript",parse:tt(126,"Subscript","SubscriptMark")}]},st={defineNodes:[{name:"Emoji",style:l.character}],parseInline:[{name:"Emoji",parse(e,t,n){let r;return 58==t&&(r=/^[a-zA-Z_0-9]+:/.exec(e.slice(n+1,e.end)))?e.addElement(e.elt("Emoji",n,n+1+r[0].length)):-1}}]},it=x({commentTokens:{block:{open:"\x3c!--",close:"--\x3e"}}}),ot=new n,at=Re.configure({props:[S.add(e=>!e.is("Block")||e.is("Document")||null!=lt(e)||function(e){return"OrderedList"==e.name||"BulletList"==e.name}(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),ot.add(lt),C.add({Document:()=>null}),w.add({Document:it})]});function lt(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function ht(e,t){let n=e;for(;;){let e,r=n.nextSibling;if(!r||null!=(e=lt(r.type))&&e<=t)break;n=r}return n.to}const ft=u.of((e,t,n)=>{for(let r=d(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(ot);if(null==e)continue;let t=ht(r,e);if(t>n)return{from:n,to:t}}return null});function ct(e){return new g(it,e,[],"markdown")}const ut=ct(at),dt=ct(at.configure([et,rt,nt,st,{props:[S.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));class pt{constructor(e,t,n,r,s,i,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=s,this.type=i,this.item=o}blank(e,t=!0){let n=this.spaceBefore+("Blockquote"==this.node.name?">":"");if(null!=e){for(;n.length<e;)n+=" ";return n}for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=" ";return n+(t?this.spaceAfter:"")}marker(e,t){let n="OrderedList"==this.node.name?String(+gt(this.item,e)[2]+t):"";return this.spaceBefore+n+this.type+this.spaceAfter}}function mt(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if("FencedCode"==t.name)return r;"ListItem"!=t.name&&"Blockquote"!=t.name||n.push(t)}for(let e=n.length-1;e>=0;e--){let s,i=n[e],o=t.lineAt(i.from),a=i.from-o.from;if("Blockquote"==i.name&&(s=/^ *>( ?)/.exec(o.text.slice(a))))r.push(new pt(i,a,a+s[0].length,"",s[1],">",null));else if("ListItem"==i.name&&"OrderedList"==i.parent.name&&(s=/^( *)\d+([.)])( *)/.exec(o.text.slice(a)))){let e=s[3],t=s[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new pt(i.parent,a,a+t,s[1],e,s[2],i))}else if("ListItem"==i.name&&"BulletList"==i.parent.name&&(s=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(a)))){let e=s[4],t=s[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=s[2];s[3]&&(n+=s[3].replace(/[xX]/," ")),r.push(new pt(i.parent,a,a+t,s[1],e,n,i))}}return r}function gt(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function kt(e,t,n,r=0){for(let s=-1,i=e;;){if("ListItem"==i.name){let e=gt(i,t),o=+e[2];if(s>=0){if(o!=s+1)return;n.push({from:i.from+e[1].length,to:i.from+e[0].length,insert:String(s+2+r)})}s=o}let e=i.nextSibling;if(!e)break;i=e}}function xt(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||"\t"!=t.facet(k))return e;let r="";for(let t=m(e,4,n);t>0;)t>=4?(r+="\t",t-=4):(r+=" ",t--);return r+e.slice(n)}const Lt=(e={})=>({state:t,dispatch:n})=>{let r=d(t),{doc:s}=t,i=null,o=t.changeByRange(n=>{if(!n.empty||!dt.isActiveAt(t,n.from,-1)&&!dt.isActiveAt(t,n.from,1))return i={range:n};let o=n.from,a=s.lineAt(o),l=mt(r.resolveInner(o,-1),s);for(;l.length&&l[l.length-1].from>o-a.from;)l.pop();if(!l.length)return i={range:n};let h=l[l.length-1];if(h.to-h.spaceAfter.length>o-a.from)return i={range:n};let f=o>=h.to-h.spaceAfter.length&&!/\S/.test(a.text.slice(h.to));if(h.item&&f){let n=h.node.firstChild,r=h.node.getChild("ListItem","ListItem");if(n.to>=o||r&&r.to<o||a.from>0&&!/[^\s>]/.test(s.lineAt(a.from-1).text)||!1===e.nonTightLists){let e,t=l.length>1?l[l.length-2]:null,n="";t&&t.item?(e=a.from+t.from,n=t.marker(s,1)):e=a.from+(t?t.to:0);let r=[{from:e,to:o,insert:n}];return"OrderedList"==h.node.name&&kt(h.item,s,r,-2),t&&"OrderedList"==t.node.name&&kt(t.item,s,r),{range:p.cursor(e+n.length),changes:r}}{let e=Ct(l,t,a);return{range:p.cursor(o+e.length+1),changes:{from:a.from,insert:e+t.lineBreak}}}}if("Blockquote"==h.node.name&&f&&a.from){let e=s.lineAt(a.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==h.from){let s=t.changes([{from:e.from+r.index,to:e.to},{from:a.from+h.from,to:a.to}]);return{range:n.map(s),changes:s}}}let c=[];"OrderedList"==h.node.name&&kt(h.item,s,c);let u=h.item&&h.item.from<a.from,d="";if(!u||/^[\s\d.)\-+*>]*/.exec(a.text)[0].length>=h.to)for(let e=0,t=l.length-1;e<=t;e++)d+=e!=t||u?l[e].blank(e<t?m(a.text,4,l[e+1].from)-d.length:null):l[e].marker(s,1);let g=o;for(;g>a.from&&/\s/.test(a.text.charAt(g-a.from-1));)g--;return d=xt(d,t),function(e,t){if("OrderedList"!=e.name&&"BulletList"!=e.name)return!1;let n=e.firstChild,r=e.getChild("ListItem","ListItem");if(!r)return!1;let s=t.lineAt(n.to),i=t.lineAt(r.from),o=/^[\s>]*$/.test(s.text);return s.number+(o?0:1)<i.number}(h.node,t.doc)&&(d=Ct(l,t,a)+t.lineBreak+d),c.push({from:g,to:o,insert:t.lineBreak+d}),{range:p.cursor(g+d.length+1),changes:c}});return!i&&(n(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},bt=Lt();function St(e){return"QuoteMark"==e.name||"ListMark"==e.name}function Ct(e,t,n){let r="";for(let t=0,s=e.length-2;t<=s;t++)r+=e[t].blank(t<s?m(n.text,4,e[t+1].from)-r.length:null,t<s);return xt(r,t)}const wt=({state:e,dispatch:t})=>{let n=d(e),r=null,s=e.changeByRange(t=>{let s=t.from,{doc:i}=e;if(t.empty&&dt.isActiveAt(e,t.from)){let t=i.lineAt(s),r=mt(function(e,t){let n=e.resolveInner(t,-1),r=t;St(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(St(e))r=e.from;else{if("OrderedList"!=e.name&&"BulletList"!=e.name)break;n=e.lastChild,r=n.to}return n}(n,s),i);if(r.length){let n=r[r.length-1],i=n.to-n.spaceAfter.length+(n.spaceAfter?1:0);if(s-t.from>i&&!/\S/.test(t.text.slice(i,s-t.from)))return{range:p.cursor(t.from+i),changes:{from:t.from+i,to:s}};if(s-t.from==i&&(!n.item||t.from<=n.item.from||!/\S/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from<n.item.from&&/\S/.test(t.text.slice(n.from,n.to))){let s=n.blank(m(t.text,4,n.to)-m(t.text,4,n.from));return r==t.from&&(s=xt(s,e)),{range:p.cursor(r+s.length),changes:{from:r,to:t.from+n.to,insert:s}}}if(r<s)return{range:p.cursor(r),changes:{from:r,to:s}}}}}return r={range:t}});return!r&&(t(e.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},yt=[{key:"Enter",run:bt},{key:"Backspace",run:wt}],At=T({matchClosingTags:!1});function It(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:s}=ut,completeHTMLTags:i=!0,pasteURLAsLink:o=!0,htmlTagLanguage:l=At}=e;if(!(s instanceof le))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let u,d=e.extensions?[e.extensions]:[],p=[l.support,ft];o&&p.push(Ht),n instanceof h?(p.push(n.support),u=n.language):n&&(u=n);let m=t||u?(g=t,k=u,e=>{if(e&&g){let t=null;if(e=/\S*/.exec(e)[0],t="function"==typeof g?g(e):A.matchLanguageName(g,e,!0),t instanceof A)return t.support?t.support.language.parser:I.getSkippingParser(t.load());if(t)return t.parser}return k?k.parser:null}):void 0;var g,k;d.push(function(e){let{codeParser:t,htmlParser:n}=e,r=a((e,r)=>{let s=e.type.id;if(!t||s!=v.CodeBlock&&s!=v.FencedCode){if(n&&(s==v.HTMLBlock||s==v.HTMLTag||s==v.CommentBlock))return{parser:n,overlay:Xe(e.node,e.from,e.to)}}else{let n="";if(s==v.FencedCode){let t=e.node.getChild(v.CodeInfo);t&&(n=r.read(t.from,t.to))}let i=t(n);if(i)return{parser:i,overlay:e=>e.type.id==v.CodeText,bracketed:s==v.FencedCode}}return null});return{wrap:r}}({codeParser:m,htmlParser:l.language.parser})),r&&p.push(f.high(c.of(yt)));let x=ct(s.configure(d));return i&&p.push(x.data.of({autocomplete:Tt})),new h(x,p)}function Tt(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let s=d(t).resolveInner(n,-1);for(;s&&!s.type.isTop;){if("CodeBlock"==s.name||"FencedCode"==s.name||"ProcessingInstructionBlock"==s.name||"CommentBlock"==s.name||"Link"==s.name||"Image"==s.name)return null;s=s.parent}return{from:n-r[0].length,to:n,options:Et(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let Bt=null;function Et(){if(Bt)return Bt;let e=B(new L(b.create({extensions:At}),0,!0));return Bt=e?e.options:[]}const vt=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Ht=y.domEventHandlers({paste:(e,t)=>{var n;let{main:r}=t.state.selection;if(r.empty)return!1;let s=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s))return!1;if(/^www\./.test(s)&&(s="https://"+s),!dt.isActiveAt(t.state,r.from,1))return!1;let i=d(t.state),o=!1;return i.iterate({from:r.from,to:r.to,enter:e=>{(e.from>r.from||vt.test(e.name))&&(o=!0)},leave:e=>{e.to<r.to&&(o=!0)}}),!o&&(t.dispatch({changes:[{from:r.from,insert:"["},{from:r.to,insert:`](${s})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});export{ut as commonmarkLanguage,wt as deleteMarkupBackward,bt as insertNewlineContinueMarkup,Lt as insertNewlineContinueMarkupCommand,It as markdown,yt as markdownKeymap,dt as markdownLanguage,Ht as pasteURLAsLink};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as O,a}from"./index-
|
|
1
|
+
import{L as O,a}from"./index-BjZU1VKq.js";import{L as e,c as t,p as Q,s as P,t as X,i as r,d as S,f as o,e as i}from"./basic-setup-Cz3rV4Fo.js";import{p as n}from"./index-1CDORI5w.js";const s={strict:1,graph:2,digraph:3,subgraph:4,node:5,edge:6};function p(O){let a=s[O.toLowerCase()];return null==a?-1:a}const l=O.deserialize({version:14,states:"+WO]QPOOOOQO'#Cg'#CgOhQPO'#CfO`QPO'#CfOyQPOOO!OQPO'#D`O#]OQO'#ClOOQO'#D`'#D`OOQO,59Q,59QO#hQPO,59QO$hQPO'#CoQOQPOOO$oQPO'#DUO$tQPO,59VO#]OQO'#DVOOOO'#DV'#DVO&ROQO'#DbOOOO'#Cn'#CnO&^OQO,59WOOQO1G.l1G.lO'gQPO'#CrO'nQPO'#DgO(oQPO'#CvOOQO'#Cu'#CuOyQPO'#CuOOQO'#Dg'#DgO)QQPO'#CyO)VQPO'#CqOOQO'#DR'#DROOQO'#Dm'#DmOOQO'#Df'#DfO*TQPO'#DWO*xQPO,59ZOOQO,59Z,59ZO+PQPO'#DSOOQO,59p,59pOOQO-E7S-E7SO+UOQO,59qOOOO-E7T-E7TOOQO1G.r1G.rO+ZQPO'#CsOOQO,59^,59^O+ZQPO'#DXO+iQPO,59`OOQO,59b,59bOOQO,59a,59aO+ZQPO,59eO,jQPO'#CwOOQO'#DY'#DYO,{QPO,59]OOQO'#DO'#DOO-sQPO'#D[O.XQPO,59iOOQO,59r,59rOOQO-E7U-E7UOOQO1G.u1G.uO/VQPO,59nOOOO1G/]1G/]O/}QPO,59_O&cQPO'#CrOOQO,59s,59sOOQO-E7V-E7VOOQO'#C{'#C{OOQO1G/P1G/POOQO'#Cz'#CzO1RQPO'#DjOOQO'#DZ'#DZO1jQPO,59cOOQO,59c,59cOOQO-E7W-E7WOOQO,59v,59vO1{QPO1G/TOOQO-E7Y-E7YO+ZQPO1G.yOOQO,5:U,5:UOOQO-E7X-E7XOOQO1G.}1G.}OOQO7+$e7+$e",stateData:"2s~O!ROSVOSWOS~OPROQPORPO~O[VO]VO^TOaUOdYX~OdYO~O!T[Od!SXQ!SXS!SXT!SXU!SX[!SX]!SX^!SXa!SXl!SXs!SXt!SXw!SX![!SX!]!SX!_!SX!`!SXp!SX~O!V^O!X_O!W!UP~O[VO]VO^TOaUOdYa~OQmOSfOTmOUmO[VO]VO^TOaUOdYO~OwqO~P#yO^sO~O!T[Od_aQ_aS_aT_aU_a[_a]_a^_aa_al_as_at_aw_a![_a!]_a!__a!`_ap_a~O!V^O!X_O!W!UX~O!WwO~O![xOQfXSfXTfXUfX[fX]fX^fXafXdfXlfXsfXtfXwfX!]fX!`fX~O!_nX~P&cO!]zOQ!ZXS!ZXT!ZXU!ZX[!ZX]!ZX^!ZXa!ZXd!ZXl!ZXs!ZXt!ZXw!ZX!`!ZX~O[VO]VO^TOaUOdjX~O!_!OO~Ol!POs!SOt!SOQeXSeXTeXUeX[eX]eX^eXaeXdeXweX!`eX~O!`!VOQzXSzXTzXUzX[zX]zX^zXazXdzXwzX~Ow!XO~P#yOl!PO~O!W!ZO~O[VO]VO^TOaUO~O!]zOQhaShaThaUha[ha]ha^haahadhalhashathawha!`ha~O[VO]VO^TOaUOp!fO~Ol!POQeaSeaTeaUea[ea]ea^eaaeadeawea!`ea~OSfO[VO]VO^TOaUOdYO~Ol!POs!SOt!SOQqaSqaTqaUqa[qa]qa^qaaqadqawqa!`qa~Ol!POQvaSvaTvaUva[va]va^vaavadvawva!`va~O![!kOQgaSgaTgaUga[ga]ga^gaagadgalgasgatgawga!]ga!`ga~O!]!lO!`!lO[!^X]!^X^!^Xa!^Xp!^X~O[VO]VO^TOaUOp!nO~Ol!POQqiSqiTqiUqi[qi]qi^qiaqidqiwqi!`qi~O",goto:"&q!bPPPPPPPPPP!c!fPPP!l!lP!z!}P#Y#^#f#j#j#o#tP#|$U$[P#Y$_PP#Y#YP$c$i$p$v$|%[%bPPP%hP&WPPP&^&bPP&iPP&mRSOQQORXRiVQXYfpxz!O!P!T!e!kRbUQZSUgYp!TR}hTnYpUeYp!TR!^zTyd!]ViYp!TVhYp!T]!Qkr!R!U!Y!iSlYpT!c!P!eXjYp!P!eR!a!OT!Tk!UQ]TRt]S`U^Rv`QpYR!WpQ{eR!_{Q!RkQ!YrU!g!R!Y!iR!i!UQ!e!PR!m!eQ!UkR!j!UQWQQcXSdYpQ|fQ![xS!]z!TQ!`!OS!b!P!eR!o!kQaURu^ToYpSkYpR!h!TT!d!P!eTrYp",nodeNames:"⚠ strict graph digraph subgraph node edge LineComment BlockComment Graph Header Graphtype Name Number String ConcatString HTMLString < HTMLStringContent Body { SimpleStatement Node Port NodeList Subgraph SubgraphHeader Attributes [ Attribute AttributeName AttributeValue ] EdgeStatement Edgeop -- -> GraphAttributeStatement AttributeStatement }",maxTerm:63,skippedNodes:[0,7,8],repeatNodeCount:7,tokenData:")k~RkXY!vYZ!v]^!vpq!vrs#Xst$utu%^{|&R|}&W}!O&]!O!P&q!P!Q'a!QQ!c!}%^!}#O)V#P#Q)[#R#S%^#T#o%^#o#p)a#q#r)f#t;'S%^;'S;=`%{<%lO%^~!{S!R~XY!vYZ!v]^!vpq!v~#[VOr#Xrs#qs#O#X#O#P#v#P;'S#X;'S;=`$o<%lO#X~#vO^~~#yRO;'S#X;'S;=`$S;=`O#X~$VWOr#Xrs#qs#O#X#O#P#v#P;'S#X;'S;=`$o;=`<%l#X<%lO#X~$rP;=`<%l#X~$zSV~OY$uZ;'S$u;'S;=`%W<%lO$u~%ZP;=`<%l$u~%cW[~tu%^!Q![%^!c!}%^#R#S%^#T#o%^#t;'S%^;'S;=`%{<%lO%^~&OP;=`<%l%^~&WO!T~~&]O!]~~&`S}!O&l!O!P&q!Q!['P!`!a'[~&qOs~~&tP!Q![&w~&|P]~!Q![&w~'UQ]~!O!P&w!Q!['P~'aOt~~'dQz{'j!P!Q$u~'mTOz'jz{'|{;'S'j;'S;=`(k<%lO'j~(PVOz'jz{'|{!P'j!P!Q(f!Q;'S'j;'S;=`(k<%lO'j~(kOW~~(nP;=`<%l'j~(vO![~~({O!`~~)QOa~~)VO!_~~)[Ol~~)aOp~~)fOd~~)kOw~",tokenizers:[1,new a("d~RQ!^!_X!`!a^~^O!V~~cO!W~~",19,55)],topRules:{Graph:[0,9]},specialized:[{term:12,get:(O,a)=>p(O)<<1,external:p}],tokenPrec:0}),d=t.define({parser:l.configure({props:[P({"strict digraph graph subgraph node edge":X.keyword,Name:X.literal,"String HTMLString < >":X.string,Number:X.number,"Node/Name":X.definition(X.variableName),"Port/Name":X.variableName,"AttrName/Name":X.definition(X.propertyName),"[ ]":X.squareBracket,"{ }":X.brace,", ;":X.separator,":":X.punctuation,"-> -- = +":X.operator,LineComment:X.lineComment,BlockComment:X.blockComment}),r.add({Body:S({closing:"}"}),Attributes:S({closing:"]"})}),o.add({"Body Attributes":i,BlockComment:O=>({from:O.from+2,to:O.to-2})})],wrap:Q(O=>"HTMLStringContent"==O.name?{parser:n}:null)}),languageData:{closeBrackets:{brackets:["[","{",'"',"<"]},commentTokens:{line:"#",block:{open:"/*",close:"*/"}}}});function m(){return new e(d)}export{m as dot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e}from"./index-
|
|
1
|
+
import{p as e}from"./index-1CDORI5w.js";import{E as t,n,o as l,L as o,c as a,i as r,f as i,q as s}from"./basic-setup-Cz3rV4Fo.js";import"./index-BjZU1VKq.js";function m(e,t){let n=t&&t.getChild("TagName");return n?e.sliceString(n.from,n.to):""}function c(e,t){let n=t&&t.firstChild;return n&&"OpenTag"==n.name?m(e,n):""}function p(e){for(let t=e&&e.parent;t;t=t.parent)if("Element"==t.name)return t;return null}class u{constructor(e,t,n){this.attrs=t,this.attrValues=n,this.children=[],this.name=e.name,this.completion=Object.assign(Object.assign({type:"type"},e.completion||{}),{label:this.name}),this.openCompletion=Object.assign(Object.assign({},this.completion),{label:"<"+this.name}),this.closeCompletion=Object.assign(Object.assign({},this.completion),{label:"</"+this.name+">",boost:2}),this.closeNameCompletion=Object.assign(Object.assign({},this.completion),{label:this.name+">"}),this.text=e.textContent?e.textContent.map(e=>({label:e,type:"text"})):[]}}const f=/^[:\-\.\w\u00b7-\uffff]*$/;function g(e){return Object.assign(Object.assign({type:"property"},e.completion||{}),{label:e.name})}function d(e){return"string"==typeof e?{label:`"${e}"`,type:"constant"}:/^"/.test(e.label)?e:Object.assign(Object.assign({},e),{label:`"${e.label}"`})}function h(e,t){let l=[],o=[],a=Object.create(null);for(let e of t){let t=g(e);l.push(t),e.global&&o.push(t),e.values&&(a[e.name]=e.values.map(d))}let r=[],i=[],s=Object.create(null);for(let t of e){let e=o,n=a;t.attributes&&(e=e.concat(t.attributes.map(e=>"string"==typeof e?l.find(t=>t.label==e)||{label:e,type:"property"}:(e.values&&(n==a&&(n=Object.create(n)),n[e.name]=e.values.map(d)),g(e)))));let m=new u(t,e,n);s[m.name]=m,r.push(m),t.top&&i.push(m)}i.length||(i=r);for(let t=0;t<r.length;t++){let n=e[t],l=r[t];if(n.children)for(let e of n.children)s[e]&&l.children.push(s[e]);else l.children=r}return e=>{var t;let{doc:l}=e.state,u=function(e,t){var l;let o=n(e).resolveInner(t,-1),a=null;for(let e=o;!a&&e.parent;e=e.parent)"OpenTag"!=e.name&&"CloseTag"!=e.name&&"SelfClosingTag"!=e.name&&"MismatchedCloseTag"!=e.name||(a=e);if(a&&(a.to>t||a.lastChild.type.isError)){let e=a.parent;if("TagName"==o.name)return"CloseTag"==a.name||"MismatchedCloseTag"==a.name?{type:"closeTag",from:o.from,context:e}:{type:"openTag",from:o.from,context:p(e)};if("AttributeName"==o.name)return{type:"attrName",from:o.from,context:a};if("AttributeValue"==o.name)return{type:"attrValue",from:o.from,context:a};let n=o==a||"Attribute"==o.name?o.childBefore(t):o;return"StartTag"==(null==n?void 0:n.name)?{type:"openTag",from:t,context:p(e)}:"StartCloseTag"==(null==n?void 0:n.name)&&n.to<=t?{type:"closeTag",from:t,context:e}:"Is"==(null==n?void 0:n.name)?{type:"attrValue",from:t,context:a}:n?{type:"attrName",from:t,context:a}:null}if("StartCloseTag"==o.name)return{type:"closeTag",from:t,context:o.parent};for(;o.parent&&o.to==t&&!(null===(l=o.lastChild)||void 0===l?void 0:l.type.isError);)o=o.parent;return"Element"==o.name||"Text"==o.name||"Document"==o.name?{type:"tag",from:t,context:"Element"==o.name?o:p(o)}:null}(e.state,e.pos);if(!u||"tag"==u.type&&!e.explicit)return null;let{type:g,from:d,context:h}=u;if("openTag"==g){let e=i,t=c(l,h);if(t){let n=s[t];e=(null==n?void 0:n.children)||r}return{from:d,options:e.map(e=>e.completion),validFor:f}}if("closeTag"==g){let n=c(l,h);return n?{from:d,to:e.pos+(">"==l.sliceString(e.pos,e.pos+1)?1:0),options:[(null===(t=s[n])||void 0===t?void 0:t.closeNameCompletion)||{label:n+">",type:"type"}],validFor:f}:null}if("attrName"==g){let e=s[m(l,h)];return{from:d,options:(null==e?void 0:e.attrs)||o,validFor:f}}if("attrValue"==g){let t=function(e,t,n){let l=t&&t.getChildren("Attribute").find(e=>e.from<=n&&e.to>=n),o=l&&l.getChild("AttributeName");return o?e.sliceString(o.from,o.to):""}(l,h,d);if(!t)return null;let n=s[m(l,h)],o=((null==n?void 0:n.attrValues)||a)[t];return o&&o.length?{from:d,to:e.pos+('"'==l.sliceString(e.pos,e.pos+1)?1:0),options:o,validFor:/^"[^"]*"?$/}:null}if("tag"==g){let t=c(l,h),n=s[t],o=[],a=h&&h.lastChild;!t||a&&"CloseTag"==a.name&&m(l,a)==t||o.push(n?n.closeCompletion:{label:"</"+t+">",type:"type",boost:2});let p=o.concat(((null==n?void 0:n.children)||(h?r:i)).map(e=>e.openCompletion));if(h&&(null==n?void 0:n.text.length)){let t=h.firstChild;t.to>e.pos-20&&!/\S/.test(e.state.sliceDoc(t.to,e.pos))&&(p=p.concat(n.text))}return{from:d,options:p,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}return null}}const b=a.define({name:"xml",parser:e.configure({props:[r.add({Element(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"OpenTag CloseTag SelfClosingTag":e=>e.column(e.node.from)+e.unit}),i.add({Element(e){let t=e.firstChild,n=e.lastChild;return t&&"OpenTag"==t.name?{from:t.to,to:"CloseTag"==n.name?n.from:e.to}:null}}),s.add({"OpenTag CloseTag":e=>e.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"\x3c!--",close:"--\x3e"}},indentOnInput:/^\s*<\/$/}});function C(e={}){let t=[b.data.of({autocomplete:h(e.elements||[],e.attributes||[])})];return!1!==e.autoCloseTags&&t.push(v),new o(b,t)}function T(e,t,n=e.length){if(!t)return"";let l=t.firstChild,o=l&&l.getChild("TagName");return o?e.sliceString(o.from,Math.min(o.to,n)):""}const v=t.inputHandler.of((e,t,o,a,r)=>{if(e.composing||e.state.readOnly||t!=o||">"!=a&&"/"!=a||!b.isActiveAt(e.state,t,-1))return!1;let i=r(),{state:s}=i,m=s.changeByRange(e=>{var t,o,r;let i,{head:m}=e,c=s.doc.sliceString(m-1,m)==a,p=n(s).resolveInner(m,-1);if(c&&">"==a&&"EndTag"==p.name){let n=p.parent;if("CloseTag"!=(null===(o=null===(t=n.parent)||void 0===t?void 0:t.lastChild)||void 0===o?void 0:o.name)&&(i=T(s.doc,n.parent,m))){return{range:e,changes:{from:m,to:m+(">"===s.doc.sliceString(m,m+1)?1:0),insert:`</${i}>`}}}}else if(c&&"/"==a&&"StartCloseTag"==p.name){let e=p.parent;if(p.from==m-2&&"CloseTag"!=(null===(r=e.lastChild)||void 0===r?void 0:r.name)&&(i=T(s.doc,e,m))){let e=m+(">"===s.doc.sliceString(m,m+1)?1:0),t=`${i}>`;return{range:l.cursor(m+t.length,-1),changes:{from:m,to:e,insert:t}}}}return{range:e}});return!m.changes.empty&&(e.dispatch([i,s.update(m,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});export{v as autoCloseTags,h as completeFromSchema,C as xml,b as xmlLanguage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as t,N as e,a as s,D as i,b as r,T as h,I as n}from"./basic-setup-Cz3rV4Fo.js";class o{constructor(t,e,s,i,r,h,n,o,a,l=0,c){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=r,this.score=h,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=l,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new o(t,[],e,s,s,0,[],0,i?new a(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=65535&t,{parser:r}=this.p,h=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=r.dynamicPrecedence(i);if(n&&(this.score+=n),0==s)return i<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,i,!0),this.reducePos),i<r.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,h?8:4,!0),void this.reduceContext(i,this.reducePos);let o=this.stack.length-3*(s-1)-(262144&t?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from;i<r.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let l=this.reducePos-a;l>=2e3&&!(null===(e=this.p.parser.nodeSet.types[i])||void 0===e?void 0:e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=l):this.p.lastBigReductionSize<l&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=l));let c=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-c;if(i<r.minRepeatTerm||131072&t){let t=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,t,u+4,!0)}if(262144&t)this.state=this.stack[o];else{let t=this.stack[o-3];this.state=r.getGoto(t,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,r=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this.buffer.length;if(t>0&&0==this.buffer[t-4]&&this.buffer[t-1]>-1){if(e==s)return;if(this.buffer[t-2]>=e)return void(this.buffer[t-2]=s)}}if(r&&this.pos!=s){let r=this.buffer.length;if(r>0&&(0!=this.buffer[r-4]||this.buffer[r-1]<0)){let t=!1;for(let e=r;e>0&&this.buffer[e-2]>s;e-=4)if(this.buffer[e-1]>=0){t=!0;break}if(t)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}else this.buffer.push(t,e,s,i)}shift(t,e,s,i){if(131072&t)this.pushState(65535&t,this.pos);else if(262144&t)this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4);else{let r=t,{parser:h}=this.p;this.pos=i;let n=h.stateFlag(r,1);!n&&(i>s||e<=h.maxNode)&&(this.reducePos=i),this.pushState(r,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=h.maxNode&&this.buffer.push(e,s,i,4)}}apply(t,e,s,i){65536&t?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&0==t.buffer[e-4]&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new o(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new l(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(0==s)return!1;if(!(65536&s))return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let s=[];for(let i,r=0;r<e.length;r+=2)(i=e[r+1])!=this.state&&this.p.parser.hasAction(i,t)&&s.push(e[r],i);if(this.stack.length<120)for(let t=0;s.length<8&&t<e.length;t+=2){let i=e[t+1];s.some((t,e)=>1&e&&t==i)||s.push(e[t],i)}e=s}let s=[];for(let t=0;t<e.length&&s.length<4;t+=2){let i=e[t+1];if(i==this.state)continue;let r=this.split();r.pushState(i,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[t],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if(!(65536&e))return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=65535&e,r=this.stack.length-3*s;if(r<0||t.getGoto(this.stack[r],i,!1)<0){let t=this.findForcedReduction();if(null==t)return!1;e=t}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,r)=>{if(!e.includes(i))return e.push(i),t.allActions(i,e=>{if(393216&e);else if(65536&e){let s=(e>>19)-r;if(s>1){let i=65535&e,r=this.stack.length-3*s;if(r>=0&&t.getGoto(this.stack[r],i,!1)>=0)return s<<19|65536|i}}else{let t=s(e,r+1);if(null!=t)return t}})};return s(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(3!=this.stack.length)return!1;let{parser:t}=this.p;return 65535==t.data[t.stateSlot(this.state,1)]&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||-3!=this.buffer[t])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||-4!=this.buffer[t])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new a(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return!(t<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class a{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class l{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=65535&t,s=t>>19;0==s?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(s-1);let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class c{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,0==this.index&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new c(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;null!=t&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new c(this.stack,this.pos,this.index)}}function u(t,e=Uint16Array){if("string"!=typeof t)return t;let s=null;for(let i=0,r=0;i<t.length;){let h=0;for(;;){let e=t.charCodeAt(i++),s=!1;if(126==e){h=65535;break}e>=92&&e--,e>=34&&e--;let r=e-32;if(r>=46&&(r-=46,s=!0),h+=r,s)break;h*=46}s?s[r++]=h:s=new e(h)}return s}class f{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const p=new f;class d{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=p,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,r=this.pos+t;for(;r<s.from;){if(!i)return null;let t=this.ranges[--i];r-=s.from-t.to,s=t}for(;e<0?r>s.to:r>=s.to;){if(i==this.ranges.length-1)return null;let t=this.ranges[++i];r+=t.from-s.to,s=t}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e,s,i=this.chunkOff+t;if(i>=0&&i<this.chunk.length)e=this.pos+t,s=this.chunk.charCodeAt(i);else{let i=this.resolveOffset(t,1);if(null==i)return-1;if(e=i,e>=this.chunk2Pos&&e<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(e-this.chunk2Pos);else{let t=this.rangeIndex,i=this.range;for(;i.to<=e;)i=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=e),e+this.chunk2.length>i.to&&(this.chunk2=this.chunk2.slice(0,i.to-e)),s=this.chunk2.charCodeAt(0)}}return e>=this.token.lookAhead&&(this.token.lookAhead=e+1),s}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(null==s||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=p,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class k{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;x(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}k.prototype.contextual=k.prototype.fallback=k.prototype.extend=!1;class g{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data="string"==typeof t?u(t):t}token(t,e){let s=t.pos,i=0;for(;;){let s=t.next<0,r=t.resolveOffset(1,1);if(x(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(null==this.elseToken)return;if(s||i++,null==r)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}g.prototype.contextual=k.prototype.fallback=k.prototype.extend=!1;class m{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function x(t,e,s,i,r,h){let n=0,o=1<<i,{dialect:a}=s.p.parser;t:for(;0!=(o&t[n]);){let s=t[n+1];for(let i=n+3;i<s;i+=2)if((t[i+1]&o)>0){let s=t[i];if(a.allows(s)&&(-1==e.token.value||e.token.value==s||S(s,e.token.value,r,h))){e.acceptToken(s);break}}let i=e.next,l=0,c=t[n+2];if(!(e.next<0&&c>l&&65535==t[s+3*c-3])){for(;l<c;){let r=l+c>>1,h=s+r+(r<<1),o=t[h],a=t[h+1]||65536;if(i<o)c=r;else{if(!(i>=a)){n=t[h+2],e.advance();continue t}l=r+1}}break}n=t[s+3*c-1]}}function b(t,e,s){for(let i,r=e;65535!=(i=t[r]);r++)if(i==s)return r-e;return-1}function S(t,e,s,i){let r=b(s,i,e);return r<0||b(s,i,t)<r}const v="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let P=null;function A(t,e,s){let i=t.cursor(n.IncludeAnonymous);for(i.moveTo(e);;)if(!(s<0?i.childBefore(e):i.childAfter(e)))for(;;){if((s<0?i.to<e:i.from>e)&&!i.type.isError)return s<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(s<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return s<0?0:t.length}}class C{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?A(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?A(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=s.children[i],o=this.start[e]+s.positions[i];if(o>t)return this.nextStart=o,null;if(n instanceof h){if(o==t){if(o<this.safeFrom)return null;let t=o+n.length;if(t<=this.safeTo){let e=n.prop(r.lookAhead);if(!e||t+e<this.fragment.to)return n}}this.index[e]++,o+n.length>=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+n.length}}}class T{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(t=>new f)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:r}=i,h=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let i=0;i<r.length;i++){if(!(1<<i&h))continue;let a=r[i],l=this.tokens[i];if((!s||a.fallback)&&((a.contextual||l.start!=t.pos||l.mask!=h||l.context!=n)&&(this.updateCachedToken(l,a,t),l.mask=h,l.context=n),l.lookAhead>l.end+25&&(o=Math.max(l.lookAhead,o)),0!=l.value)){let i=e;if(l.extended>-1&&(e=this.addActions(t,l.extended,l.end,e)),e=this.addActions(t,l.value,l.end,e),!a.extend&&(s=l,e>i))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),s||t.pos!=this.stream.end||(s=new f,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new f,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:e}=s.p;for(let i=0;i<e.specialized.length;i++)if(e.specialized[i]==t.value){let r=e.specializers[i](this.stream.read(t.start,t.end),s);if(r>=0&&s.p.parser.dialect.allows(r>>1)){1&r?t.extended=r>>1:t.value=r>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let e=0;e<i;e+=3)if(this.actions[e]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:r}=t,{parser:h}=t.p,{data:n}=h;for(let t=0;t<2;t++)for(let o=h.stateSlot(r,t?2:1);;o+=3){if(65535==n[o]){if(1!=n[o+1]){0==i&&2==n[o+1]&&(i=this.putAction(D(n,o+2),e,s,i));break}o=D(n,o+2)}n[o]==e&&(i=this.putAction(D(n,o+1),e,s,i))}return i}}class y{constructor(t,e,s,i){this.parser=t,this.input=e,this.ranges=i,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 d(e,i),this.tokens=new T(t,this.stream),this.topTerm=t.top[1];let{from:r}=i[0];this.stacks=[o.start(this,t.top[0],r)],this.fragments=s.length&&this.stream.end-r>4*t.bufferLength?new C(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t,e,s=this.stacks,i=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==s.length){let[t]=s;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let h=0;h<s.length;h++){let n=s[h];for(;;){if(this.tokens.mainToken=null,n.pos>i)r.push(n);else{if(this.advanceStack(n,r,s))continue;{t||(t=[],e=[]),t.push(n);let s=this.tokens.getMainToken(n);e.push(s.value,s.end)}}break}}if(!r.length){let e=t&&function(t){let e=null;for(let s of t){let t=s.p.stoppedAt;(s.pos==s.p.stream.end||null!=t&&s.pos>t)&&s.p.parser.stateFlag(s.state,2)&&(!e||e.score<s.score)&&(e=s)}return e}(t);if(e)return v&&console.log("Finish with "+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw v&&t&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&t){let s=null!=this.stoppedAt&&t[0].pos>this.stoppedAt?t[0]:this.runRecovery(t,e,r);if(s)return v&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let t=1==this.recovering?1:3*this.recovering;if(r.length>t)for(r.sort((t,e)=>e.score-t.score);r.length>t;)r.pop();r.some(t=>t.reducePos>i)&&this.recovering--}else if(r.length>1){t:for(let t=0;t<r.length-1;t++){let e=r[t];for(let s=t+1;s<r.length;s++){let i=r[s];if(e.sameState(i)||e.buffer.length>500&&i.buffer.length>500){if(!((e.score-i.score||e.buffer.length-i.buffer.length)>0)){r.splice(t--,1);continue t}r.splice(s--,1)}}}r.length>12&&(r.sort((t,e)=>e.score-t.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let t=1;t<r.length;t++)r[t].pos<this.minStackPos&&(this.minStackPos=r[t].pos);return null}stopAt(t){if(null!=this.stoppedAt&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:n}=this,o=v?this.stackID(t)+" -> ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let e=t.curContext&&t.curContext.tracker.strict,s=e?t.curContext.hash:0;for(let a=this.fragments.nodeAt(i);a;){let i=this.parser.nodeSet.types[a.type.id]==a.type?n.getGoto(t.state,a.type.id):-1;if(i>-1&&a.length&&(!e||(a.prop(r.contextHash)||0)==s))return t.useNode(a,i),v&&console.log(o+this.stackID(t)+` (via reuse of ${n.getName(a.type.id)})`),!0;if(!(a instanceof h)||0==a.children.length||a.positions[0]>0)break;let l=a.children[0];if(!(l instanceof h&&0==a.positions[0]))break;a=l}}let a=n.stateSlot(t.state,4);if(a>0)return t.reduce(a),v&&console.log(o+this.stackID(t)+` (via always-reduce ${n.getName(65535&a)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let r=0;r<l.length;){let h=l[r++],a=l[r++],c=l[r++],u=r==l.length||!s,f=u?t:t.split(),p=this.tokens.mainToken;if(f.apply(h,a,p?p.start:f.pos,c),v&&console.log(o+this.stackID(f)+` (via ${65536&h?`reduce of ${n.getName(65535&h)}`:"shift"} for ${n.getName(a)} @ ${i}${f==t?"":", split"})`),u)return!0;f.pos>i?e.push(f):s.push(f)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return w(t,e),!0}}runRecovery(t,e,s){let i=null,r=!1;for(let h=0;h<t.length;h++){let n=t[h],o=e[h<<1],a=e[1+(h<<1)],l=v?this.stackID(n)+" -> ":"";if(n.deadEnd){if(r)continue;if(r=!0,n.restart(),v&&console.log(l+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))continue}let c=n.split(),u=l;for(let t=0;t<10&&c.forceReduce();t++){if(v&&console.log(u+this.stackID(c)+" (via force-reduce)"),this.advanceFully(c,s))break;v&&(u=this.stackID(c)+" -> ")}for(let t of n.recoverByInsert(o))v&&console.log(l+this.stackID(t)+" (via recover-insert)"),this.advanceFully(t,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),v&&console.log(l+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),w(n,s)):(!i||i.score<c.score)&&(i=c)}return i}stackToTree(t){return t.close(),h.build({buffer:c.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(P||(P=new WeakMap)).get(t);return e||P.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function w(t,e){for(let s=0;s<e.length;s++){let i=e[s];if(i.pos==t.pos&&i.sameState(t))return void(e[s].score<t.score&&(e[s]=t))}e.push(t)}class N{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||0==this.disabled[t]}}const R=t=>t;class z{constructor(t){this.start=t.start,this.shift=t.shift||R,this.reduce=t.reduce||R,this.reuse=t.reuse||R,this.hash=t.hash||(()=>0),this.strict=!1!==t.strict}}class I extends t{constructor(t){if(super(),this.wrappers=[],14!=t.version)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let h=t.nodeNames.split(" ");this.minRepeatTerm=h.length;for(let e=0;e<t.repeatNodeCount;e++)h.push("");let n=Object.keys(t.topRules).map(e=>t.topRules[e][1]),o=[];for(let t=0;t<h.length;t++)o.push([]);function a(t,e,s){o[t].push([e,e.deserialize(String(s))])}if(t.nodeProps)for(let e of t.nodeProps){let t=e[0];"string"==typeof t&&(t=r[t]);for(let s=1;s<e.length;){let i=e[s++];if(i>=0)a(i,t,e[s++]);else{let r=e[s+-i];for(let h=-i;h>0;h--)a(e[s++],t,r);s++}}}this.nodeSet=new e(h.map((e,i)=>s.define({name:i>=this.minRepeatTerm?void 0:e,id:i,props:o[i],top:n.indexOf(i)>-1,error:0==i,skipped:t.skippedNodes&&t.skippedNodes.indexOf(i)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=i;let l=u(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t<this.specializerSpecs.length;t++)this.specialized[t]=this.specializerSpecs[t].term;this.specializers=this.specializerSpecs.map(B),this.states=u(t.states,Uint32Array),this.data=u(t.stateData),this.goto=u(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(t=>"number"==typeof t?new k(l,t):t),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new y(this,t,e,s);for(let r of this.wrappers)i=r(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let r=i[e+1];;){let e=i[r++],h=1&e,n=i[r++];if(h&&s)return n;for(let s=r+(e>>1);r<s;r++)if(i[r]==t)return n;if(h)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let r,h=this.stateSlot(t,i?2:1);;h+=3){if(65535==(r=s[h])){if(1!=s[h+1]){if(2==s[h+1])return D(s,h+2);break}r=s[h=D(s,h+2)]}if(r==e||0==r)return D(s,h+1)}return 0}stateSlot(t,e){return this.states[6*t+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,t=>t==e||null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let s=this.stateSlot(t,1);null==i;s+=3){if(65535==this.data[s]){if(1!=this.data[s+1])break;s=D(this.data,s+2)}i=e(D(this.data,s+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(65535==this.data[s]){if(1!=this.data[s+1])break;s=D(this.data,s+2)}if(!(1&this.data[s+2])){let t=this.data[s+1];e.some((e,s)=>1&s&&e==t)||e.push(this.data[s],t)}}return e}configure(t){let e=Object.assign(Object.create(I.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(e=>{let s=t.tokenizers.find(t=>t.from==e);return s?s.to:e})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let r=t.specializers.find(t=>t.from==s.external);if(!r)return s;let h=Object.assign(Object.assign({},s),{external:r.to});return e.specializers[i]=B(h),h})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),null!=t.bufferLength&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return null==e?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let i of t.split(" ")){let t=e.indexOf(i);t>=0&&(s[t]=!0)}let i=null;for(let t=0;t<e.length;t++)if(!s[t])for(let s,r=this.dialects[e[t]];65535!=(s=this.data[r++]);)(i||(i=new Uint8Array(this.maxTerm+1)))[s]=1;return new N(t,s,i)}static deserialize(t){return new I(t)}}function D(t,e){return t[e]|t[e+1]<<16}function B(t){if(t.external){let e=t.extend?1:0;return(s,i)=>t.external(s,i)<<1|e}return t.get}export{z as C,m as E,I as L,g as a};
|
|
1
|
+
import{P as t,N as e,a as s,D as i,b as r,T as h,I as n}from"./basic-setup-Cz3rV4Fo.js";class o{constructor(t,e,s,i,r,h,n,o,a,l=0,c){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=r,this.score=h,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=l,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new o(t,[],e,s,s,0,[],0,i?new a(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=65535&t,{parser:r}=this.p,h=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=r.dynamicPrecedence(i);if(n&&(this.score+=n),0==s)return i<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,i,!0),this.reducePos),i<r.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,h?8:4,!0),void this.reduceContext(i,this.reducePos);let o=this.stack.length-3*(s-1)-(262144&t?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from;i<r.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let l=this.reducePos-a;l>=2e3&&!(null===(e=this.p.parser.nodeSet.types[i])||void 0===e?void 0:e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=l):this.p.lastBigReductionSize<l&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=l));let c=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-c;if(i<r.minRepeatTerm||131072&t){let t=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,t,u+4,!0)}if(262144&t)this.state=this.stack[o];else{let t=this.stack[o-3];this.state=r.getGoto(t,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,r=!1){if(0==t&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let t=this.buffer.length;if(t>0&&0==this.buffer[t-4]&&this.buffer[t-1]>-1){if(e==s)return;if(this.buffer[t-2]>=e)return void(this.buffer[t-2]=s)}}if(r&&this.pos!=s){let r=this.buffer.length;if(r>0&&(0!=this.buffer[r-4]||this.buffer[r-1]<0)){let t=!1;for(let e=r;e>0&&this.buffer[e-2]>s;e-=4)if(this.buffer[e-1]>=0){t=!0;break}if(t)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}else this.buffer.push(t,e,s,i)}shift(t,e,s,i){if(131072&t)this.pushState(65535&t,this.pos);else if(262144&t)this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4);else{let r=t,{parser:h}=this.p;this.pos=i;let n=h.stateFlag(r,1);!n&&(i>s||e<=h.maxNode)&&(this.reducePos=i),this.pushState(r,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=h.maxNode&&this.buffer.push(e,s,i,4)}}apply(t,e,s,i){65536&t?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&0==t.buffer[e-4]&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new o(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new l(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(0==s)return!1;if(!(65536&s))return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let s=[];for(let i,r=0;r<e.length;r+=2)(i=e[r+1])!=this.state&&this.p.parser.hasAction(i,t)&&s.push(e[r],i);if(this.stack.length<120)for(let t=0;s.length<8&&t<e.length;t+=2){let i=e[t+1];s.some((t,e)=>1&e&&t==i)||s.push(e[t],i)}e=s}let s=[];for(let t=0;t<e.length&&s.length<4;t+=2){let i=e[t+1];if(i==this.state)continue;let r=this.split();r.pushState(i,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[t],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if(!(65536&e))return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=65535&e,r=this.stack.length-3*s;if(r<0||t.getGoto(this.stack[r],i,!1)<0){let t=this.findForcedReduction();if(null==t)return!1;e=t}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,r)=>{if(!e.includes(i))return e.push(i),t.allActions(i,e=>{if(393216&e);else if(65536&e){let s=(e>>19)-r;if(s>1){let i=65535&e,r=this.stack.length-3*s;if(r>=0&&t.getGoto(this.stack[r],i,!1)>=0)return s<<19|65536|i}}else{let t=s(e,r+1);if(null!=t)return t}})};return s(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(3!=this.stack.length)return!1;let{parser:t}=this.p;return 65535==t.data[t.stateSlot(this.state,1)]&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||-3!=this.buffer[t])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||-4!=this.buffer[t])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new a(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return!(t<=this.lookAhead)&&(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class a{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class l{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=65535&t,s=t>>19;0==s?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(s-1);let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class c{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,0==this.index&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new c(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;null!=t&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new c(this.stack,this.pos,this.index)}}function u(t,e=Uint16Array){if("string"!=typeof t)return t;let s=null;for(let i=0,r=0;i<t.length;){let h=0;for(;;){let e=t.charCodeAt(i++),s=!1;if(126==e){h=65535;break}e>=92&&e--,e>=34&&e--;let r=e-32;if(r>=46&&(r-=46,s=!0),h+=r,s)break;h*=46}s?s[r++]=h:s=new e(h)}return s}class f{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const p=new f;class d{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=p,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,r=this.pos+t;for(;r<s.from;){if(!i)return null;let t=this.ranges[--i];r-=s.from-t.to,s=t}for(;e<0?r>s.to:r>=s.to;){if(i==this.ranges.length-1)return null;let t=this.ranges[++i];r+=t.from-s.to,s=t}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e,s,i=this.chunkOff+t;if(i>=0&&i<this.chunk.length)e=this.pos+t,s=this.chunk.charCodeAt(i);else{let i=this.resolveOffset(t,1);if(null==i)return-1;if(e=i,e>=this.chunk2Pos&&e<this.chunk2Pos+this.chunk2.length)s=this.chunk2.charCodeAt(e-this.chunk2Pos);else{let t=this.rangeIndex,i=this.range;for(;i.to<=e;)i=this.ranges[++t];this.chunk2=this.input.chunk(this.chunk2Pos=e),e+this.chunk2.length>i.to&&(this.chunk2=this.chunk2.slice(0,i.to-e)),s=this.chunk2.charCodeAt(0)}}return e>=this.token.lookAhead&&(this.token.lookAhead=e+1),s}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(null==s||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=p,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class k{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;x(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}k.prototype.contextual=k.prototype.fallback=k.prototype.extend=!1;class g{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data="string"==typeof t?u(t):t}token(t,e){let s=t.pos,i=0;for(;;){let s=t.next<0,r=t.resolveOffset(1,1);if(x(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(null==this.elseToken)return;if(s||i++,null==r)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}g.prototype.contextual=k.prototype.fallback=k.prototype.extend=!1;class m{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function x(t,e,s,i,r,h){let n=0,o=1<<i,{dialect:a}=s.p.parser;t:for(;0!=(o&t[n]);){let s=t[n+1];for(let i=n+3;i<s;i+=2)if((t[i+1]&o)>0){let s=t[i];if(a.allows(s)&&(-1==e.token.value||e.token.value==s||S(s,e.token.value,r,h))){e.acceptToken(s);break}}let i=e.next,l=0,c=t[n+2];if(!(e.next<0&&c>l&&65535==t[s+3*c-3])){for(;l<c;){let r=l+c>>1,h=s+r+(r<<1),o=t[h],a=t[h+1]||65536;if(i<o)c=r;else{if(!(i>=a)){n=t[h+2],e.advance();continue t}l=r+1}}break}n=t[s+3*c-1]}}function b(t,e,s){for(let i,r=e;65535!=(i=t[r]);r++)if(i==s)return r-e;return-1}function S(t,e,s,i){let r=b(s,i,e);return r<0||b(s,i,t)<r}const v="undefined"!=typeof process&&process.env&&/\bparse\b/.test(process.env.LOG);let P=null;function A(t,e,s){let i=t.cursor(n.IncludeAnonymous);for(i.moveTo(e);;)if(!(s<0?i.childBefore(e):i.childAfter(e)))for(;;){if((s<0?i.to<e:i.from>e)&&!i.type.isError)return s<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(s<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return s<0?0:t.length}}class C{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?A(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?A(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let n=s.children[i],o=this.start[e]+s.positions[i];if(o>t)return this.nextStart=o,null;if(n instanceof h){if(o==t){if(o<this.safeFrom)return null;let t=o+n.length;if(t<=this.safeTo){let e=n.prop(r.lookAhead);if(!e||t+e<this.fragment.to)return n}}this.index[e]++,o+n.length>=Math.max(this.safeFrom,t)&&(this.trees.push(n),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+n.length}}}class T{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(t=>new f)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:r}=i,h=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let i=0;i<r.length;i++){if(!(1<<i&h))continue;let a=r[i],l=this.tokens[i];if((!s||a.fallback)&&((a.contextual||l.start!=t.pos||l.mask!=h||l.context!=n)&&(this.updateCachedToken(l,a,t),l.mask=h,l.context=n),l.lookAhead>l.end+25&&(o=Math.max(l.lookAhead,o)),0!=l.value)){let i=e;if(l.extended>-1&&(e=this.addActions(t,l.extended,l.end,e)),e=this.addActions(t,l.value,l.end,e),!a.extend&&(s=l,e>i))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),s||t.pos!=this.stream.end||(s=new f,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new f,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:e}=s.p;for(let i=0;i<e.specialized.length;i++)if(e.specialized[i]==t.value){let r=e.specializers[i](this.stream.read(t.start,t.end),s);if(r>=0&&s.p.parser.dialect.allows(r>>1)){1&r?t.extended=r>>1:t.value=r>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let e=0;e<i;e+=3)if(this.actions[e]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:r}=t,{parser:h}=t.p,{data:n}=h;for(let t=0;t<2;t++)for(let o=h.stateSlot(r,t?2:1);;o+=3){if(65535==n[o]){if(1!=n[o+1]){0==i&&2==n[o+1]&&(i=this.putAction(D(n,o+2),e,s,i));break}o=D(n,o+2)}n[o]==e&&(i=this.putAction(D(n,o+1),e,s,i))}return i}}class y{constructor(t,e,s,i){this.parser=t,this.input=e,this.ranges=i,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 d(e,i),this.tokens=new T(t,this.stream),this.topTerm=t.top[1];let{from:r}=i[0];this.stacks=[o.start(this,t.top[0],r)],this.fragments=s.length&&this.stream.end-r>4*t.bufferLength?new C(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t,e,s=this.stacks,i=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==s.length){let[t]=s;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let h=0;h<s.length;h++){let n=s[h];for(;;){if(this.tokens.mainToken=null,n.pos>i)r.push(n);else{if(this.advanceStack(n,r,s))continue;{t||(t=[],e=[]),t.push(n);let s=this.tokens.getMainToken(n);e.push(s.value,s.end)}}break}}if(!r.length){let e=t&&function(t){let e=null;for(let s of t){let t=s.p.stoppedAt;(s.pos==s.p.stream.end||null!=t&&s.pos>t)&&s.p.parser.stateFlag(s.state,2)&&(!e||e.score<s.score)&&(e=s)}return e}(t);if(e)return v&&console.log("Finish with "+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw v&&t&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&t){let s=null!=this.stoppedAt&&t[0].pos>this.stoppedAt?t[0]:this.runRecovery(t,e,r);if(s)return v&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let t=1==this.recovering?1:3*this.recovering;if(r.length>t)for(r.sort((t,e)=>e.score-t.score);r.length>t;)r.pop();r.some(t=>t.reducePos>i)&&this.recovering--}else if(r.length>1){t:for(let t=0;t<r.length-1;t++){let e=r[t];for(let s=t+1;s<r.length;s++){let i=r[s];if(e.sameState(i)||e.buffer.length>500&&i.buffer.length>500){if(!((e.score-i.score||e.buffer.length-i.buffer.length)>0)){r.splice(t--,1);continue t}r.splice(s--,1)}}}r.length>12&&(r.sort((t,e)=>e.score-t.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let t=1;t<r.length;t++)r[t].pos<this.minStackPos&&(this.minStackPos=r[t].pos);return null}stopAt(t){if(null!=this.stoppedAt&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:n}=this,o=v?this.stackID(t)+" -> ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let e=t.curContext&&t.curContext.tracker.strict,s=e?t.curContext.hash:0;for(let a=this.fragments.nodeAt(i);a;){let i=this.parser.nodeSet.types[a.type.id]==a.type?n.getGoto(t.state,a.type.id):-1;if(i>-1&&a.length&&(!e||(a.prop(r.contextHash)||0)==s))return t.useNode(a,i),v&&console.log(o+this.stackID(t)+` (via reuse of ${n.getName(a.type.id)})`),!0;if(!(a instanceof h)||0==a.children.length||a.positions[0]>0)break;let l=a.children[0];if(!(l instanceof h&&0==a.positions[0]))break;a=l}}let a=n.stateSlot(t.state,4);if(a>0)return t.reduce(a),v&&console.log(o+this.stackID(t)+` (via always-reduce ${n.getName(65535&a)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let l=this.tokens.getActions(t);for(let r=0;r<l.length;){let h=l[r++],a=l[r++],c=l[r++],u=r==l.length||!s,f=u?t:t.split(),p=this.tokens.mainToken;if(f.apply(h,a,p?p.start:f.pos,c),v&&console.log(o+this.stackID(f)+` (via ${65536&h?`reduce of ${n.getName(65535&h)}`:"shift"} for ${n.getName(a)} @ ${i}${f==t?"":", split"})`),u)return!0;f.pos>i?e.push(f):s.push(f)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return w(t,e),!0}}runRecovery(t,e,s){let i=null,r=!1;for(let h=0;h<t.length;h++){let n=t[h],o=e[h<<1],a=e[1+(h<<1)],l=v?this.stackID(n)+" -> ":"";if(n.deadEnd){if(r)continue;if(r=!0,n.restart(),v&&console.log(l+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))continue}let c=n.split(),u=l;for(let t=0;t<10&&c.forceReduce();t++){if(v&&console.log(u+this.stackID(c)+" (via force-reduce)"),this.advanceFully(c,s))break;v&&(u=this.stackID(c)+" -> ")}for(let t of n.recoverByInsert(o))v&&console.log(l+this.stackID(t)+" (via recover-insert)"),this.advanceFully(t,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),v&&console.log(l+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),w(n,s)):(!i||i.score<c.score)&&(i=c)}return i}stackToTree(t){return t.close(),h.build({buffer:c.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(P||(P=new WeakMap)).get(t);return e||P.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function w(t,e){for(let s=0;s<e.length;s++){let i=e[s];if(i.pos==t.pos&&i.sameState(t))return void(e[s].score<t.score&&(e[s]=t))}e.push(t)}class N{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||0==this.disabled[t]}}const R=t=>t;class z{constructor(t){this.start=t.start,this.shift=t.shift||R,this.reduce=t.reduce||R,this.reuse=t.reuse||R,this.hash=t.hash||(()=>0),this.strict=!1!==t.strict}}class I extends t{constructor(t){if(super(),this.wrappers=[],14!=t.version)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let h=t.nodeNames.split(" ");this.minRepeatTerm=h.length;for(let e=0;e<t.repeatNodeCount;e++)h.push("");let n=Object.keys(t.topRules).map(e=>t.topRules[e][1]),o=[];for(let t=0;t<h.length;t++)o.push([]);function a(t,e,s){o[t].push([e,e.deserialize(String(s))])}if(t.nodeProps)for(let e of t.nodeProps){let t=e[0];"string"==typeof t&&(t=r[t]);for(let s=1;s<e.length;){let i=e[s++];if(i>=0)a(i,t,e[s++]);else{let r=e[s+-i];for(let h=-i;h>0;h--)a(e[s++],t,r);s++}}}this.nodeSet=new e(h.map((e,i)=>s.define({name:i>=this.minRepeatTerm?void 0:e,id:i,props:o[i],top:n.indexOf(i)>-1,error:0==i,skipped:t.skippedNodes&&t.skippedNodes.indexOf(i)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=i;let l=u(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let t=0;t<this.specializerSpecs.length;t++)this.specialized[t]=this.specializerSpecs[t].term;this.specializers=this.specializerSpecs.map(O),this.states=u(t.states,Uint32Array),this.data=u(t.stateData),this.goto=u(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(t=>"number"==typeof t?new k(l,t):t),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new y(this,t,e,s);for(let r of this.wrappers)i=r(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let r=i[e+1];;){let e=i[r++],h=1&e,n=i[r++];if(h&&s)return n;for(let s=r+(e>>1);r<s;r++)if(i[r]==t)return n;if(h)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let r,h=this.stateSlot(t,i?2:1);;h+=3){if(65535==(r=s[h])){if(1!=s[h+1]){if(2==s[h+1])return D(s,h+2);break}r=s[h=D(s,h+2)]}if(r==e||0==r)return D(s,h+1)}return 0}stateSlot(t,e){return this.states[6*t+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,t=>t==e||null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let s=this.stateSlot(t,1);null==i;s+=3){if(65535==this.data[s]){if(1!=this.data[s+1])break;s=D(this.data,s+2)}i=e(D(this.data,s+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(65535==this.data[s]){if(1!=this.data[s+1])break;s=D(this.data,s+2)}if(!(1&this.data[s+2])){let t=this.data[s+1];e.some((e,s)=>1&s&&e==t)||e.push(this.data[s],t)}}return e}configure(t){let e=Object.assign(Object.create(I.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(e=>{let s=t.tokenizers.find(t=>t.from==e);return s?s.to:e})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let r=t.specializers.find(t=>t.from==s.external);if(!r)return s;let h=Object.assign(Object.assign({},s),{external:r.to});return e.specializers[i]=O(h),h})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),null!=t.strict&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),null!=t.bufferLength&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return null==e?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let i of t.split(" ")){let t=e.indexOf(i);t>=0&&(s[t]=!0)}let i=null;for(let t=0;t<e.length;t++)if(!s[t])for(let s,r=this.dialects[e[t]];65535!=(s=this.data[r++]);)(i||(i=new Uint8Array(this.maxTerm+1)))[s]=1;return new N(t,s,i)}static deserialize(t){return new I(t)}}function D(t,e){return t[e]|t[e+1]<<16}function O(t){if(t.external){let e=t.extend?1:0;return(s,i)=>t.external(s,i)<<1|e}return t.get}export{z as C,m as E,I as L,g as a};
|