@juki-team/base-ui 1.5.1 → 1.5.3

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.
Files changed (126) hide show
  1. package/README.md +17 -7
  2. package/dist/esm/ArrowForwardIcon-D6Jfdilm.js +1 -0
  3. package/dist/esm/{BarChart-D74BtmuY.js → BarChart-D6H2EH3B.js} +1 -1
  4. package/dist/esm/{CartesianChart-CW5O6vne.js → CartesianChart-_EyixekW.js} +1 -1
  5. package/dist/esm/{ChangePasswordModal-BjmZ4w-n.js → ChangePasswordModal-DP68K_jG.js} +1 -1
  6. package/dist/esm/{CodeEditor-DHSwOQl_.js → CodeEditor-CPsmXl7i.js} +1 -1
  7. package/dist/esm/{CodeViewer-BgcqqnsU.js → CodeViewer-DIncRhD1.js} +1 -1
  8. package/dist/esm/{Collapse-CJGjLO29.js → Collapse-Bn9-0z3I.js} +1 -1
  9. package/dist/esm/{DataGrid-B2ZsmTQN.js → DataGrid-CzZsh4gG.js} +1 -1
  10. package/dist/esm/{DataViewer-C7cqe5jJ.js → DataViewer-CSIcp1dE.js} +1 -1
  11. package/dist/esm/{DrawerView-CBLVa95i.js → DrawerView-D-MEVHS0.js} +1 -1
  12. package/dist/esm/{ExcalidrawButton-Gtzt3GBc.js → ExcalidrawButton-CL_vPewV.js} +1 -1
  13. package/dist/esm/{GraphvizViewer-Dyqijdc9.js → GraphvizViewer-BfJg604I.js} +1 -1
  14. package/dist/esm/{ImageLoaderCropper-DhWDuHK1.js → ImageLoaderCropper-BjHykYfo.js} +1 -1
  15. package/dist/esm/{InputCellPhoneNumber-BgKCDHLv.js → InputCellPhoneNumber-CAi0AXMP.js} +1 -1
  16. package/dist/esm/{InputColor-DeeYpvdA.js → InputColor-Ch5Do1U-.js} +1 -1
  17. package/dist/esm/{LineChart-D2VT5Aos.js → LineChart-BL9HlHkG.js} +1 -1
  18. package/dist/esm/{LoaderLayer-D9O7WqFD.js → LoaderLayer-CXFK-kAz.js} +1 -1
  19. package/dist/esm/{MdMath-PFhigRVS.js → MdMath-DwyNLKE_.js} +1 -1
  20. package/dist/esm/{MdMathEditor-CNn23WdZ.js → MdMathEditor-D0f1McYj.js} +1 -1
  21. package/dist/esm/{Popover-kYKitQai.js → Popover-DPn39FUa.js} +1 -1
  22. package/dist/esm/ReplyIcon-Dd5U6wGZ.js +1 -0
  23. package/dist/esm/{SettingsIcon-Dk27Vz1G.js → SettingsIcon-BCDZw0HR.js} +1 -1
  24. package/dist/esm/{SlideDeck-DMd0LgxX.js → SlideDeck-et5M4lE-.js} +1 -1
  25. package/dist/esm/{TableEyeIcon-D74isCSR.js → TableEyeIcon-CDLbQapU.js} +1 -1
  26. package/dist/esm/{TableOfContents-zzI7FQbW.js → TableOfContents-CLrH5fjb.js} +1 -1
  27. package/dist/esm/{Tooltip-B8AobPsl.js → Tooltip-CEgmNtFX.js} +1 -1
  28. package/dist/esm/{UserCodeEditor-CbgpE94F.js → UserCodeEditor-DlHeWLUu.js} +2 -2
  29. package/dist/esm/{VirtualizedRowsFixed-Cau69yw0.js → VirtualizedRowsFixed-8Wk8DRYc.js} +1 -1
  30. package/dist/esm/{WorksheetAsSlides-cYn12ViE.js → WorksheetAsSlides-X5Ljvk2t.js} +1 -1
  31. package/dist/esm/{WorksheetBodies-oAHNxEoL.js → WorksheetBodies-pHyqSVPy.js} +1 -1
  32. package/dist/esm/{WorksheetContents-m3z1cSCO.js → WorksheetContents-ByjM-HNk.js} +1 -1
  33. package/dist/esm/{WorksheetEditor-DL9l5iCM.js → WorksheetEditor-Dq3apeLg.js} +1 -1
  34. package/dist/esm/{WorksheetNode-D6tMtEqC.js → WorksheetNode-Chf37TwI.js} +1 -1
  35. package/dist/esm/{WorksheetViewer-tctJbZIu.js → WorksheetViewer-B-slMCYv.js} +1 -1
  36. package/dist/esm/{architecture-YZFGNWBL-rccIGhXm.js → architecture-YZFGNWBL-B4qRp-MK.js} +1 -1
  37. package/dist/esm/{architectureDiagram-Q4EWVU46-D4BxMEG7.js → architectureDiagram-Q4EWVU46-MfdUMKWh.js} +1 -1
  38. package/dist/esm/{blockDiagram-DXYQGD6D-z0-_xhoI.js → blockDiagram-DXYQGD6D-B53ncWj8.js} +1 -1
  39. package/dist/esm/{c4Diagram-AHTNJAMY-BoabvxgU.js → c4Diagram-AHTNJAMY-FdREycKs.js} +1 -1
  40. package/dist/esm/channel-D_ARZf1V.js +1 -0
  41. package/dist/esm/{chunk-4BX2VUAB-BD59bCvh.js → chunk-4BX2VUAB-Dc1mlsfk.js} +1 -1
  42. package/dist/esm/{chunk-4TB4RGXK-bRIvkE2u.js → chunk-4TB4RGXK-DpY00B8-.js} +1 -1
  43. package/dist/esm/{chunk-55IACEB6-B9SJqSMu.js → chunk-55IACEB6-Csh8qgjO.js} +1 -1
  44. package/dist/esm/{chunk-EDXVE4YY-DO0UVobI.js → chunk-EDXVE4YY-DCPe-NtF.js} +1 -1
  45. package/dist/esm/{chunk-FMBD7UC4-B0l_pK7G.js → chunk-FMBD7UC4-DAo4g5fP.js} +1 -1
  46. package/dist/esm/{chunk-OYMX7WX6-ChpTvaWt.js → chunk-OYMX7WX6-C7RHHgRc.js} +1 -1
  47. package/dist/esm/{chunk-QZHKN3VN-9SrlxM-A.js → chunk-QZHKN3VN-CUifo-Cb.js} +1 -1
  48. package/dist/esm/{chunk-YZCP3GAM-B9nB-mZv.js → chunk-YZCP3GAM-DELqvesl.js} +1 -1
  49. package/dist/esm/classDiagram-6PBFFD2Q-B7_Zpqtq.js +1 -0
  50. package/dist/esm/classDiagram-v2-HSJHXN6E-B7_Zpqtq.js +1 -0
  51. package/dist/esm/clone-DZNciEx8.js +1 -0
  52. package/dist/esm/{commons-B_OozOv-.js → commons-D9Mh1s5L.js} +1 -1
  53. package/dist/esm/constants.js +1 -1
  54. package/dist/esm/{cose-bilkent-S5V4N54A-DOOhcKZn.js → cose-bilkent-S5V4N54A-BOV94ldj.js} +1 -1
  55. package/dist/esm/{dagre-KV5264BT-DNQuzBru.js → dagre-KV5264BT-BfFz9a4k.js} +1 -1
  56. package/dist/esm/{diagram-5BDNPKRD-BuDsbwIH.js → diagram-5BDNPKRD-I9IS2ANw.js} +1 -1
  57. package/dist/esm/{diagram-G4DWMVQ6-Dqe6ehne.js → diagram-G4DWMVQ6-BXU7Dvs-.js} +1 -1
  58. package/dist/esm/{diagram-MMDJMWI5-DutUl44V.js → diagram-MMDJMWI5-Csk96FFg.js} +1 -1
  59. package/dist/esm/{diagram-TYMM5635-Dg8R_BVT.js → diagram-TYMM5635-DPvqrKRl.js} +1 -1
  60. package/dist/esm/{erDiagram-SMLLAGMA-Z9rnwC7z.js → erDiagram-SMLLAGMA-Dc1SOwcN.js} +1 -1
  61. package/dist/esm/{flowDiagram-DWJPFMVM-DlD4QYIw.js → flowDiagram-DWJPFMVM-Ck8eEuPh.js} +1 -1
  62. package/dist/esm/{ganttDiagram-T4ZO3ILL-DCyjcGXR.js → ganttDiagram-T4ZO3ILL-D5DV1RYK.js} +1 -1
  63. package/dist/esm/gitGraph-7Q5UKJZL-AWq1Wmi2.js +1 -0
  64. package/dist/esm/{gitGraphDiagram-UUTBAWPF-CdYpB5kl.js → gitGraphDiagram-UUTBAWPF-BWpwlfSt.js} +1 -1
  65. package/dist/esm/{graph-BuAvWT_r.js → graph-DcE5swO6.js} +1 -1
  66. package/dist/esm/helpers.js +1 -1
  67. package/dist/esm/{index-BoA3EjMr.js → index-33u6FCUW.js} +1 -1
  68. package/dist/esm/{index-DVFv6Eth.js → index-BVw40LAx.js} +1 -1
  69. package/dist/esm/index-TeLD_8PN.js +1 -0
  70. package/dist/esm/{index-CODLgwqm.js → index-o2jBRnrQ.js} +1 -1
  71. package/dist/esm/{index-Cj5SSv5l.js → index-tAJiDyYy.js} +1 -1
  72. package/dist/esm/info-OMHHGYJF-CDJfFYlp.js +1 -0
  73. package/dist/esm/{infoDiagram-42DDH7IO-Ce56qzjb.js → infoDiagram-42DDH7IO-aiwYT7Xb.js} +1 -1
  74. package/dist/esm/{ishikawaDiagram-UXIWVN3A-Cc0AgO_R.js → ishikawaDiagram-UXIWVN3A-adhn2Hxg.js} +1 -1
  75. package/dist/esm/{journeyDiagram-VCZTEJTY-BQAuB_0y.js → journeyDiagram-VCZTEJTY-w8F4Ngn_.js} +1 -1
  76. package/dist/esm/{kanban-definition-6JOO6SKY-CFfdKxrM.js → kanban-definition-6JOO6SKY-BUy-pXA5.js} +1 -1
  77. package/dist/esm/{layout-C9Uq7X58.js → layout-LXPx6gJv.js} +1 -1
  78. package/dist/esm/main.js +1 -1
  79. package/dist/esm/{mermaid-parser.core-B9BVFPAN.js → mermaid-parser.core-_V3e3eig.js} +1 -1
  80. package/dist/esm/{mermaid.core-Ch6a1N6x.js → mermaid.core-C89m9NSM.js} +1 -1
  81. package/dist/esm/{mindmap-definition-QFDTVHPH-BwtZAHVe.js → mindmap-definition-QFDTVHPH-DQor9UlS.js} +1 -1
  82. package/dist/esm/packet-4T2RLAQJ-DGgnF4xi.js +1 -0
  83. package/dist/esm/pie-ZZUOXDRM-jgrNXYlk.js +1 -0
  84. package/dist/esm/{pieDiagram-DEJITSTG-ChBY2XYY.js → pieDiagram-DEJITSTG-CFXV-DSu.js} +1 -1
  85. package/dist/esm/{quadrantDiagram-34T5L4WZ-CRGLfMnt.js → quadrantDiagram-34T5L4WZ-C5PWeOxe.js} +1 -1
  86. package/dist/esm/radar-PYXPWWZC-ZVxMZ3XM.js +1 -0
  87. package/dist/esm/{requirementDiagram-MS252O5E-qmbcV6Kf.js → requirementDiagram-MS252O5E-CAFUQ1SL.js} +1 -1
  88. package/dist/esm/{sankeyDiagram-XADWPNL6-DaL42Ehn.js → sankeyDiagram-XADWPNL6-D63_orrT.js} +1 -1
  89. package/dist/esm/{sequenceDiagram-FGHM5R23-D28F9BbZ.js → sequenceDiagram-FGHM5R23-DjI8jxRK.js} +1 -1
  90. package/dist/esm/server.js +1 -1
  91. package/dist/esm/{settings-BIQ7IqJl.js → settings-BONQQsPx.js} +1 -1
  92. package/dist/esm/settings.js +1 -1
  93. package/dist/esm/{stateDiagram-FHFEXIEX-RgoWlW1V.js → stateDiagram-FHFEXIEX-BeDx2Idm.js} +1 -1
  94. package/dist/esm/stateDiagram-v2-QKLJ7IA2-BSzNVn1D.js +1 -0
  95. package/dist/esm/{timeline-definition-GMOUNBTQ-BcOvpU4t.js → timeline-definition-GMOUNBTQ-BRHpffn4.js} +1 -1
  96. package/dist/esm/treeView-SZITEDCU-CMK4b3Hd.js +1 -0
  97. package/dist/esm/treemap-W4RFUUIX-DjdwA0Jd.js +1 -0
  98. package/dist/esm/{types-DI2OON_b.js → types-CsXckO56.js} +1 -1
  99. package/dist/esm/{vennDiagram-DHZGUBPP-CZrtDTUB.js → vennDiagram-DHZGUBPP-Cauja-PK.js} +1 -1
  100. package/dist/esm/wardley-RL74JXVD-DiOshmTl.js +1 -0
  101. package/dist/esm/{wardleyDiagram-NUSXRM2D-vlFiIB8t.js → wardleyDiagram-NUSXRM2D-CSY5_Vpk.js} +1 -1
  102. package/dist/esm/{websocket-CxbYBjHT.js → websocket-C4G3j9Rm.js} +1 -1
  103. package/dist/esm/{xychartDiagram-5P7HB3ND-DsCQdXVH.js → xychartDiagram-5P7HB3ND-Bkd1VEMW.js} +1 -1
  104. package/dist/module-types/src/components/molecules/TabsInline/TabsInlineButton.d.ts +1 -1
  105. package/dist/module-types/src/components/molecules/TabsInline/TabsInlineButtonLoader.d.ts +1 -1
  106. package/dist/module-types/src/components/molecules/TabsInline/utils.d.ts +3 -0
  107. package/dist/module-types/src/components/templates/UserViewLayout/ProfileSubmissions.d.ts +1 -1
  108. package/dist/module-types/src/components/templates/UserViewLayout/types.d.ts +1 -0
  109. package/package.json +2 -2
  110. package/src/styles/components/atoms/_tabs-inline.scss +12 -0
  111. package/dist/esm/ArrowForwardIcon-B6qJaqxW.js +0 -1
  112. package/dist/esm/ReplyIcon-CPGYEALJ.js +0 -1
  113. package/dist/esm/channel-B33C1-lx.js +0 -1
  114. package/dist/esm/classDiagram-6PBFFD2Q-BsMMZhRG.js +0 -1
  115. package/dist/esm/classDiagram-v2-HSJHXN6E-BsMMZhRG.js +0 -1
  116. package/dist/esm/clone-BDf6Yet-.js +0 -1
  117. package/dist/esm/gitGraph-7Q5UKJZL-B-fw09HA.js +0 -1
  118. package/dist/esm/index-rYUgz1LC.js +0 -1
  119. package/dist/esm/info-OMHHGYJF-fbv9Xw4D.js +0 -1
  120. package/dist/esm/packet-4T2RLAQJ-BGTrXSHu.js +0 -1
  121. package/dist/esm/pie-ZZUOXDRM-Dx3xGYkv.js +0 -1
  122. package/dist/esm/radar-PYXPWWZC-BYId5clz.js +0 -1
  123. package/dist/esm/stateDiagram-v2-QKLJ7IA2-DuyT41He.js +0 -1
  124. package/dist/esm/treeView-SZITEDCU-BjLEV1yZ.js +0 -1
  125. package/dist/esm/treemap-W4RFUUIX-Cuo2Y8dN.js +0 -1
  126. package/dist/esm/wardley-RL74JXVD-d0LkVT8_.js +0 -1
@@ -1,4 +1,4 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{P as n,S as o,ah as r,G as i,T as s,C as a,v as l}from"./settings-BIQ7IqJl.js";import{W as c,X as d,g as u,L as p,Y as h,Z as f,E as m,G as g,_ as v,z as y,$ as w,a0 as b,a1 as k,a2 as C,a3 as x,a4 as N,a5 as S,a6 as O,a7 as E,a8 as M,a9 as _,U as T,aa as D,ab as I,ac as A,ad as R,ae as P,af as L,ag as V,ah as j,ai as $,aj as B,ak as H,Q as F,K as z,M as q}from"./basic-setup-UGhpl5jF.js";import{f as W,e as U,g as K,h as G,p as J,z as Z,i as X,u as Y,r as Q,v as ee,S as te,j as ne,d as oe,k as re,c as ie,C as se}from"./types-DI2OON_b.js";import ae,{useRef as le,useState as ce,useMemo as de,createContext as ue,useContext as pe,useCallback as he,useLayoutEffect as fe,useEffect as me,forwardRef as ge,useImperativeHandle as ve,memo as ye}from"react";import{a as we,S as be,e as ke,l as Ce,T as xe,ad as Ne,a2 as Se,ae as Oe}from"./index-rYUgz1LC.js";import{c as Ee,d as Me}from"./commons-B_OozOv-.js";import"./enums.js";import"./constants.js";import{L as _e,s as Te,m as De,f as Ie}from"./LoaderLayer-D9O7WqFD.js";import"motion/react";import"react-dom";import"swr";import{c as Ae}from"./clsx-BeLtu-UY.js";import{p as Re}from"./purify.es-DBOWJxv3.js";import{c as Pe,f as Le,o as Ve,m as je,s as $e}from"./floating-ui.dom-BKnkJW47.js";import{t as Be,d as He}from"./throttle-BsCMUG1-.js";import{d as Fe,P as ze,Q as qe,x as We,R as Ue}from"./memoize-CPUrcYQl.js";import{i as Ke}from"./viz-CFEjElvl.js";import{au as Ge}from"./mermaid.core-Ch6a1N6x.js";import{y as Je}from"./websocket-CxbYBjHT.js";import"./index-CODLgwqm.js";import"@ably/spaces";import"@ably/spaces/react";import"ably";import"ably/liveobjects";import"ably/react";import"@ably/spaces/dist/mjs/react";import"./toNumber-Bh_HTlSx.js";import"./isSymbol-CATEdeai.js";import"./string-LeDn2fkG.js";const Ze={}.hasOwnProperty;function Xe(e,t){let n,o=-1;if(t.extensions)for(;++o<t.extensions.length;)Xe(e,t.extensions[o]);for(n in t)if(Ze.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":Ye(e[n],t[n]);break;case"handlers":Qe(e[n],t[n]);break;default:e.options[n]=t[n]}return e}function Ye(e,t){t&&e.push(...t)}function Qe(e,t){t&&Object.assign(e,t)}const et=[function(e,t,n,o){if("code"===t.type&&W(t,o)&&("list"===e.type||e.type===t.type&&W(e,o)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&U(t,o)))return;return n.spread?1:0}}];const tt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],nt=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:tt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:tt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:tt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"~"}];function ot(e){return e.label||!e.identifier?e.label||"":K(e.identifier)}function rt(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function it(e,t,n,o){let r=o.join.length;for(;r--;){const i=o.join[r](e,t,n,o);if(!0===i||1===i)break;if("number"==typeof i)return"\n".repeat(1+i);if(!1===i)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const st=/\r?\n|\r/g;function at(e,t){const n=[];let o,r=0,i=0;for(;o=st.exec(e);)s(e.slice(r,o.index)),n.push(o[0]),r=o.index+o[0].length,i++;return s(e.slice(r)),n.join("");function s(e){n.push(t(e,i,!e))}}function lt(e,t){return e-t}function ct(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,o=[],r=[],i=e+t;let s,a=-1,l=0;for(;s=n.exec(i);)o.push(s.index);for(;++a<o.length;)l!==o[a]&&r.push(e.slice(l,o[a])),r.push("\\"),l=o[a];return r.push(e.slice(l)),r.join("")}function dt(e){const t=e||{},n=t.now||{};let o=t.lineShift||0,r=n.line||1,i=n.column||1;return{move:function(e){const t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return r+=n.length-1,i=1===n.length?i+s.length:1+s.length+o,t},current:function(){return{now:{line:r,column:i},lineShift:o}},shift:function(e){o+=e}}}function ut(e,t){const n={associationId:ot,containerPhrasing:mt,containerFlow:gt,createTracker:dt,compilePattern:rt,enter:function(e){return n.stack.push(e),function(){n.stack.pop()}},handlers:{...X},handle:void 0,indentLines:at,indexStack:[],join:[...et],options:{},safe:vt,stack:[],unsafe:[...nt]};Xe(n,t||{}),n.options.tightDefinitions&&n.join.push(ft),n.handle=Z("type",{invalid:pt,unknown:ht,handlers:n.handlers});let o=n.handle(e,void 0,n,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return o&&10!==o.charCodeAt(o.length-1)&&13!==o.charCodeAt(o.length-1)&&(o+="\n"),o}function pt(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function ht(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function ft(e,t){if("definition"===e.type&&e.type===t.type)return 0}function mt(e,t){return function(e,t,n){const o=t.indexStack,r=e.children||[],i=[];let s,a=-1,l=n.before;o.push(-1);let c=t.createTracker(n);for(;++a<r.length;){const d=r[a];let u;if(o[o.length-1]=a,a+1<r.length){let n=t.handle.handlers[r[a+1].type];n&&n.peek&&(n=n.peek),u=n?n(r[a+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else u=n.after;i.length>0&&("\r"===l||"\n"===l)&&"html"===d.type&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),l=" ",c=t.createTracker(n),c.move(i.join("")));let p=t.handle(d,e,t,{...c.current(),after:u,before:l});s&&s===p.slice(0,1)&&(p=G(s.charCodeAt(0))+p.slice(1));const h=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,h&&(i.length>0&&h.before&&l===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+G(l.charCodeAt(0))),h.after&&(s=u)),c.move(p),i.push(p),l=p.slice(-1)}return o.pop(),i.join("")}(e,this,t)}function gt(e,t){return function(e,t,n){const o=t.indexStack,r=e.children||[],i=t.createTracker(n),s=[];let a=-1;for(o.push(-1);++a<r.length;){const n=r[a];o[o.length-1]=a,s.push(i.move(t.handle(n,e,t,{before:"\n",after:"\n",...i.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),a<r.length-1&&s.push(i.move(it(n,r[a+1],e,t)))}return o.pop(),s.join("")}(e,this,t)}function vt(e,t){return function(e,t,n){const o=(n.before||"")+(t||"")+(n.after||""),r=[],i=[],s={};let a=-1;for(;++a<e.unsafe.length;){const t=e.unsafe[a];if(!J(e.stack,t))continue;const n=e.compilePattern(t);let i;for(;i=n.exec(o);){const e="before"in t||Boolean(t.atBreak),n="after"in t,o=i.index+(e?i[1].length:0);r.includes(o)?(s[o].before&&!e&&(s[o].before=!1),s[o].after&&!n&&(s[o].after=!1)):(r.push(o),s[o]={before:e,after:n})}}r.sort(lt);let l=n.before?n.before.length:0;const c=o.length-(n.after?n.after.length:0);for(a=-1;++a<r.length;){const e=r[a];e<l||e>=c||e+1<c&&r[a+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||r[a-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(l!==e&&i.push(ct(o.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(o.charAt(e))||n.encode&&n.encode.includes(o.charAt(e))?(i.push(G(o.charCodeAt(e))),l++):i.push("\\"))}return i.push(ct(o.slice(l,c),n.after)),i.join("")}(this,e,t)}var yt=function(e){return e.docTypeError="docTypeError",e.contextNotFound="contextNotFound",e.timerNotFound="timerNotFound",e.ctxCallOutOfScope="ctxCallOutOfScope",e.createNodeInParserFail="createNodeInParserFail",e.stackOverFlow="stackOverFlow",e.parserMatchError="parserMatchError",e.serializerMatchError="serializerMatchError",e.getAtomFromSchemaFail="getAtomFromSchemaFail",e.expectDomTypeError="expectDomTypeError",e.callCommandBeforeEditorView="callCommandBeforeEditorView",e.missingRootElement="missingRootElement",e.missingNodeInSchema="missingNodeInSchema",e.missingMarkInSchema="missingMarkInSchema",e.ctxNotBind="ctxNotBind",e.missingYjsDoc="missingYjsDoc",e}({}),wt=class extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}},bt=(e,t)=>"function"==typeof t?"[Function]":t,kt=e=>JSON.stringify(e,bt);function Ct(){return new wt(yt.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function xt(){return new wt(yt.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Nt(e){return new wt(yt.expectDomTypeError,`Expect to be a dom, but get: ${kt(e)}.`)}function St(){return new wt(yt.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Ot(e){return new wt(yt.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}var Et=class{constructor(){this.sliceMap=new Map,this.get=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw n="string"==typeof e?e:e.name,new wt(yt.contextNotFound,`Context "${n}" not found, do you forget to inject it?`);var n;return t},this.remove=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},Mt=class{#e=[];#t;#n=()=>{this.#e.forEach(e=>e(this.#t))};constructor(e,t,n){this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){const t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},_t=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Ct()}}create(e,t=this._defaultValue){return new Mt(e,t,this)}},Tt=(e,t)=>new _t(e,t),Dt=class{#o;#r;#i;#s=new Set;#a=new Set;#l=new Map;#c=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#o,injectedSlices:[...this.#s].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),consumedSlices:[...this.#a].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),recordedTimers:[...this.#l].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)})),waitTimers:[...this.#c].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)}))}),this.onRecord=e=>{this.#l.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#l.delete(e)},this.onDone=e=>{const t=this.#l.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{const n=Date.now();t.finally(()=>{this.#c.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#s.add(e)},this.onRemove=e=>{this.#s.delete(e)},this.onUse=e=>{this.#a.add(e)},this.#r=e,this.#i=t,this.#o=n}#d=e=>this.#r.get(e).get();#u=e=>this.#i.get(e).status},It=class e{#r;#i;#o;#p;constructor(t,n,o){this.produce=t=>t&&Object.keys(t).length?new e(this.#r,this.#i,{...t}):this,this.inject=(e,t)=>{const n=e.create(this.#r.sliceMap);return null!=t&&n.set(t),this.#p?.onInject(e),this},this.remove=e=>(this.#r.remove(e),this.#p?.onRemove(e),this),this.record=e=>(e.create(this.#i.store),this.#p?.onRecord(e),this),this.clearTimer=e=>(this.#i.remove(e),this.#p?.onClear(e),this),this.isInjected=e=>this.#r.has(e),this.isRecorded=e=>this.#i.has(e),this.use=e=>(this.#p?.onUse(e),this.#r.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#i.get(e),this.done=e=>{this.timer(e).done(),this.#p?.onDone(e)},this.wait=e=>{const t=this.timer(e).start();return this.#p?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#r=t,this.#i=n,this.#o=o,o&&(this.#p=new Dt(t,n,o))}get meta(){return this.#o}get inspector(){return this.#p}},At=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw n=e.name,new wt(yt.timerNotFound,`Timer "${n}" not found, do you forget to record it?`);var n;return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},Rt=class{#h=null;#f=null;#m;#g="pending";constructor(e,t){this.start=()=>(this.#h??=new Promise((e,t)=>{this.#f=t=>{t instanceof CustomEvent&&t.detail.id===this.#m&&(this.#g="resolved",this.#v(),t.stopImmediatePropagation(),e())},this.#y(()=>{"pending"===this.#g&&(this.#g="rejected"),this.#v(),t(new Error(`Timing ${this.type.name} timeout.`))}),this.#g="pending",addEventListener(this.type.name,this.#f)}),this.#h),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:this.#m}});dispatchEvent(e)},this.#m=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#g}#v=()=>{this.#f&&removeEventListener(this.type.name,this.#f)};#y=e=>{setTimeout(()=>{e()},this.type.timeout)}},Pt=class{constructor(e,t=3e3){this.create=e=>new Rt(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Lt=(e,t=3e3)=>new Pt(e,t);function Vt(e){const t=this;t.compiler=function(n){return ut(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function jt(e){this.content=e}function $t(e,t,n){for(let o=0;;o++){if(o==e.childCount||o==t.childCount)return e.childCount==t.childCount?null:n;let r=e.child(o),i=t.child(o);if(r!=i){if(!r.sameMarkup(i))return n;if(r.isText&&r.text!=i.text){for(let e=0;r.text[e]==i.text[e];e++)n++;return n}if(r.content.size||i.content.size){let e=$t(r.content,i.content,n+1);if(null!=e)return e}n+=r.nodeSize}else n+=r.nodeSize}}function Bt(e,t,n,o){for(let r=e.childCount,i=t.childCount;;){if(0==r||0==i)return r==i?null:{a:n,b:o};let s=e.child(--r),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:o};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,o--;return{a:n,b:o}}if(s.content.size||a.content.size){let e=Bt(s.content,a.content,n-1,o-1);if(e)return e}n-=l,o-=l}else n-=l,o-=l}}jt.prototype={constructor:jt,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var o=n&&n!=e?this.remove(n):this,r=o.find(e),i=o.content.slice();return-1==r?i.push(n||e,t):(i[r+1]=t,n&&(i[r]=n)),new jt(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new jt(n)},addToStart:function(e,t){return new jt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new jt(n)},addBefore:function(e,t,n){var o=this.remove(t),r=o.content.slice(),i=o.find(e);return r.splice(-1==i?r.length:i,0,t,n),new jt(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=jt.from(e)).size?new jt(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=jt.from(e)).size?new jt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=jt.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},jt.from=function(e){if(e instanceof jt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new jt(t)};let Ht=class e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,o=0,r){for(let i=0,s=0;s<t;i++){let a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,o+s,r||null,i)&&a.content.size){let r=s+1;a.nodesBetween(Math.max(0,e-r),Math.min(a.content.size,t-r),n,o+r)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,o){let r="",i=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=l},0),r}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,o=t.firstChild,r=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(o)&&(r[r.length-1]=n.withText(n.text+o.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new e(r,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let o=[],r=0;if(n>t)for(let e=0,i=0;i<n;e++){let s=this.content[e],a=i+s.nodeSize;a>t&&((i<t||a>n)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,n-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,n-i-1))),o.push(s),r+=s.nodeSize),i=a}return new e(o,r)}cutByIndex(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let o=this.content[t];if(o==n)return this;let r=this.content.slice(),i=this.size+n.nodeSize-o.nodeSize;return r[t]=n,new e(r,i)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let o=this.content[t];e(o,n,t),n+=o.nodeSize}}findDiffStart(e,t=0){return $t(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Bt(this,e,t,n)}findIndex(e){if(0==e)return zt(0,e);if(e==this.size)return zt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let o=n+this.child(t).nodeSize;if(o>=e)return o==e?zt(t+1,o):zt(t,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,o=0;for(let e=0;e<t.length;e++){let r=t[e];o+=r.nodeSize,e&&r.isText&&t[e-1].sameMarkup(r)?(n||(n=t.slice(0,e)),n[n.length-1]=r.withText(n[n.length-1].text+r.text)):n&&n.push(r)}return new e(n||t,o)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};Ht.empty=new Ht([],0);const Ft={index:0,offset:0};function zt(e,t){return Ft.index=e,Ft.offset=t,Ft}function qt(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!qt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!qt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Wt{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let o=0;o<e.length;o++){let r=e[o];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,o));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&qt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=n.create(t.attrs);return n.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Wt.none;if(e instanceof Wt)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Wt.none=[];class Ut extends Error{}class Kt{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Jt(this.content,e+this.openStart,t);return n&&new Kt(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Kt(Gt(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Kt.empty;let n=t.openStart||0,o=t.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new Kt(Ht.fromJSON(e,t.content),n,o)}static maxOpen(e,t=!0){let n=0,o=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)o++;return new Kt(e,n,o)}}function Gt(e,t,n){let{index:o,offset:r}=e.findIndex(t),i=e.maybeChild(o),{index:s,offset:a}=e.findIndex(n);if(r==t||i.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(o,i.copy(Gt(i.content,t-r-1,n-r-1)))}function Jt(e,t,n,o){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r);if(i==t||s.isText)return o&&!o.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Jt(s.content,t-i-1,n,s);return a&&e.replaceChild(r,s.copy(a))}function Zt(e,t,n){if(n.openStart>e.depth)throw new Ut("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ut("Inconsistent open depths");return Xt(e,t,n,0)}function Xt(e,t,n,o){let r=e.index(o),i=e.node(o);if(r==t.index(o)&&o<e.depth-n.openStart){let s=Xt(e,t,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=o||t.depth!=o){let{start:r,end:s}=function(e,t){let n=t.depth-e.openStart,o=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)o=t.node(e).copy(Ht.from(o));return{start:o.resolveNoCache(e.openStart+n),end:o.resolveNoCache(o.content.size-e.openEnd-n)}}(n,e);return nn(i,on(e,r,s,t,o))}{let o=e.parent,r=o.content;return nn(o,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return nn(i,rn(e,t,o))}function Yt(e,t){if(!t.type.compatibleContent(e.type))throw new Ut("Cannot join "+t.type.name+" onto "+e.type.name)}function Qt(e,t,n){let o=e.node(n);return Yt(o,t.node(n)),o}function en(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function tn(e,t,n,o){let r=(t||e).node(n),i=0,s=t?t.index(n):r.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(en(e.nodeAfter,o),i++));for(let e=i;e<s;e++)en(r.child(e),o);t&&t.depth==n&&t.textOffset&&en(t.nodeBefore,o)}function nn(e,t){return e.type.checkContent(t),e.copy(t)}function on(e,t,n,o,r){let i=e.depth>r&&Qt(e,t,r+1),s=o.depth>r&&Qt(n,o,r+1),a=[];return tn(null,e,r,a),i&&s&&t.index(r)==n.index(r)?(Yt(i,s),en(nn(i,on(e,t,n,o,r+1)),a)):(i&&en(nn(i,rn(e,t,r+1)),a),tn(t,n,r,a),s&&en(nn(s,rn(n,o,r+1)),a)),tn(o,null,r,a),new Ht(a)}function rn(e,t,n){let o=[];if(tn(null,e,n,o),e.depth>n){en(nn(Qt(e,t,n+1),rn(e,t,n+1)),o)}return tn(t,null,n,o),new Ht(o)}Kt.empty=new Kt(Ht.empty,0,0);class sn{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=e.child(t);return n?e.child(t).cut(n):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],o=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)o+=n.child(t).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Wt.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),o=e.maybeChild(t);if(!n){let e=n;n=o,o=e}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,o=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new dn(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],o=0,r=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(r),s=r-i;if(n.push(t,e,o+i),!s)break;if(t=t.child(e),t.isText)break;r=s-1,o+=i+1}return new sn(t,n,r)}static resolveCached(e,t){let n=cn.get(e);if(n)for(let e=0;e<n.elts.length;e++){let o=n.elts[e];if(o.pos==t)return o}else cn.set(e,n=new an);let o=n.elts[n.i]=sn.resolve(e,t);return n.i=(n.i+1)%ln,o}}class an{constructor(){this.elts=[],this.i=0}}const ln=12,cn=new WeakMap;class dn{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const un=Object.create(null);class pn{constructor(e,t,n,o=Wt.none){this.type=e,this.attrs=t,this.marks=o,this.content=n||Ht.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,o=0){this.content.nodesBetween(e,t,n,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,o){return this.content.textBetween(e,t,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&qt(this.attrs,t||e.defaultAttrs||un)&&Wt.sameSet(this.marks,n||Wt.none)}copy(e=null){return e==this.content?this:new pn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new pn(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Kt.empty;let o=this.resolve(e),r=this.resolve(t),i=n?0:o.sharedDepth(t),s=o.start(i),a=o.node(i).content.cut(o.pos-s,r.pos-s);return new Kt(a,o.depth-i,r.depth-i)}replace(e,t,n){return Zt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let o=this.content.child(t-1);return{node:o,index:t-1,offset:n-o.nodeSize}}resolve(e){return sn.resolveCached(this,e)}resolveNoCache(e){return sn.resolve(this,e)}rangeHasMark(e,t,n){let o=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),fn(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=Ht.empty,o=0,r=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,o,r),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=o;e<r;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(e).matchType(n),i=r&&r.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Wt.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Wt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let o=Ht.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}pn.prototype.text=void 0;class hn extends pn{constructor(e,t,n,o){if(super(e,t,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fn(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new hn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new hn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function fn(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class mn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new gn(e,t);if(null==n.next)return mn.empty;let o=vn(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return n(xn(e,0));function n(o){let r=[];o.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let o;for(let e=0;e<r.length;e++)r[e][0]==t&&(o=r[e][1]);xn(e,n).forEach(e=>{o||r.push([t,o=[]]),-1==o.indexOf(e)&&o.push(e)})})});let i=t[o.join(",")]=new mn(o.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let o=r[e][1].sort(Cn);i.next.push({type:r[e][0],next:t[o.join(",")]||n(o)})}return i}}(function(e){let t=[[]];return r(i(e,0),n()),t;function n(){return t.push([])-1}function o(e,n,o){let r={term:o,to:n};return t[e].push(r),r}function r(e,t){e.forEach(e=>e.to=t)}function i(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(i(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(t,s),r(i(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(i(e.expr,t),s),r(i(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();r(i(e.expr,s),t),s=t}if(-1==e.max)r(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();o(s,t),r(i(e.expr,s),t),s=t}return[o(s)]}if("name"==e.type)return[o(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=i(e.exprs[o],t);if(o==e.exprs.length-1)return s;r(s,t=n())}}}(o));return function(e,t){for(let n=0,o=[e];n<o.length;n++){let e=o[n],r=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let o=this;for(let r=t;o&&r<n;r++)o=o.matchType(e.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let o=[this];return function r(i,s){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return Ht.from(s.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let e=r(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(e)){let e=[];for(let t=o;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:i,next:s}=r.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let o=0;o<n.next.length;o++)-1==e.indexOf(n.next[o].next)&&t(n.next[o].next)}(this),e.map((t,n)=>{let o=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)o+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return o}).join("\n")}}mn.empty=new mn(!0);class gn{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function vn(e){let t=[];do{t.push(yn(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function yn(e){let t=[];do{t.push(wn(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function wn(e){let t=function(e){if(e.eat("(")){let t=vn(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let r=[];for(let e in n){let o=n[e];o.isInGroup(t)&&r.push(o)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=kn(e,t)}return t}function bn(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function kn(e,t){let n=bn(e),o=n;return e.eat(",")&&(o="}"!=e.next?bn(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function Cn(e,t){return t-e}function xn(e,t){let n=[];return function t(o){let r=e[o];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(o);for(let e=0;e<r.length;e++){let{term:o,to:i}=r[e];o||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Cn)}function Nn(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function Sn(e,t){let n=Object.create(null);for(let o in e){let r=t&&t[o];if(void 0===r){let t=e[o];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=t.default}n[o]=r}return n}function On(e,t,n,o){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in e){let o=e[n];o.validate&&o.validate(t[n])}}function En(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new _n(e,o,t[o]);return n}let Mn=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=En(e,n.attrs),this.defaultAttrs=Nn(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==mn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Sn(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pn(this,this.computeAttrs(e),Ht.from(t),Wt.setFrom(n))}createChecked(e=null,t,n){return t=Ht.from(t),this.checkContent(t),new pn(this,this.computeAttrs(e),t,Wt.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Ht.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let o=this.contentMatch.matchFragment(t),r=o&&o.fillBefore(Ht.empty,!0);return r?new pn(this,e,t.append(r),Wt.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){On(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Wt.none:e}static compile(t,n){let o=Object.create(null);t.forEach((t,r)=>o[t]=new e(t,n,r));let r=n.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let e in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};class _n{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${r}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Tn{constructor(e,t,n,o){this.name=e,this.rank=t,this.schema=n,this.spec=o,this.attrs=En(e,o.attrs),this.excluded=null;let r=Nn(this.attrs);this.instance=r?new Wt(this,r):null}create(e=null){return!e&&this.instance?this.instance:new Wt(this,Sn(this.attrs,e))}static compile(e,t){let n=Object.create(null),o=0;return e.forEach((e,r)=>n[e]=new Tn(e,o++,t,r)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){On(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Dn{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=jt.from(e.nodes),t.marks=jt.from(e.marks||{}),this.nodes=Mn.compile(this.spec.nodes,this),this.marks=Tn.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],o=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=n[o]||(n[o]=mn.parse(o,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?In(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:In(this,n.split(" "))}this.nodeFromJSON=e=>pn.fromJSON(this,e),this.markFromJSON=e=>Wt.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,o){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Mn))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,o)}text(e,t){let n=this.nodes.text;return new hn(n,n.defaultAttrs,e,Wt.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function In(e,t){let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e.marks[r],s=i;if(i)n.push(i);else for(let t in e.marks){let o=e.marks[t];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}class An{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new $n(this,t,!1);return n.addAll(e,Wt.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new $n(this,t,!0);return n.addAll(e,Wt.none,t.from,t.to),Kt.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(Bn(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(e)||o.context&&!n.matchesContext(o.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(o.getAttrs){let e=o.getAttrs(t);if(!1===e)continue;o.attrs=e||void 0}return o}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,o=0;for(;o<t.length;o++){let e=t[o];if((null==e.priority?50:e.priority)<n)break}t.splice(o,0,e)}for(let t in e.marks){let o=e.marks[t].spec.parseDOM;o&&o.forEach(e=>{n(e=Hn(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let o=e.nodes[t].spec.parseDOM;o&&o.forEach(e=>{n(e=Hn(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new An(e,An.schemaRules(e)))}}const Rn={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Pn={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ln={ol:!0,ul:!0};function Vn(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class jn{constructor(e,t,n,o,r,i){this.type=e,this.attrs=t,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=Wt.none,this.match=r||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Ht.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Ht.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Ht.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Rn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $n{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=t.topNode,i=Vn(null,t.preserveWhitespace,0)|(n?4:0);o=r?new jn(r.type,r.attrs,Wt.none,!0,t.topMatch||r.type.contentMatch,i):new jn(n?null:e.schema.topNodeType,null,Wt.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0,{schema:i}=this.parser;if("full"===r||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)if("full"===r)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=o.content[o.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let o=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Ln.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Ln.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Pn.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,o=this.needsBlock;if(Rn.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=a&&a.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let o=this.parser.matchedStyles[e],r=n.getPropertyValue(o);if(r)for(let e;;){let n=this.parser.matchStyle(o,r,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,o){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,n,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let o=e;"string"==typeof t.contentElement?o=e.querySelector(t.contentElement):"function"==typeof t.contentElement?o=t.contentElement(e):t.contentElement&&(o=t.contentElement),this.findAround(e,o,!0),this.addAll(o,n),this.findAround(e,o,!1)}r&&this.sync(s)&&this.open--}addAll(e,t,n,o){let r=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==o?null:e.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t,n){let o,r;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!o||o.length>a.length+i)&&(o=a,r=s,!a.length))break;if(s.solid){if(n)break;i+=2}}if(!o)return null;this.sync(r);for(let e=0;e<o.length;e++)t=this.enterInner(o[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let o=this.findPlace(e,t,n);if(o){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Wt.none;for(let r of o.concat(e.marks))(t.type?t.type.allowsMarkType(r.type):Fn(r.type,e.type))&&(n=r.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,o){let r=this.findPlace(e.create(t),n,!1);return r&&(r=this.enterInner(e,t,n,!0,o)),r}enterInner(e,t,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=Vn(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=Wt.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):Fn(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new jn(e,t,a,o,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)if(null==this.find[o].pos&&1==e.nodeType&&e.contains(this.find[o].node)){t.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function Bn(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Hn(e){let t={};for(let n in e)t[n]=e[n];return t}function Fn(e,t){let n=t.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:o,next:r}=e.edge(n);if(o==t)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class zn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Wn(t).createDocumentFragment());let o=n,r=[];return e.forEach(e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:o}=Gn(Wn(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let o=this.marks[e.type.name];return o&&Gn(Wn(n),o(e,t),null,e.attrs)}static renderSpec(e,t,n=null,o){return Gn(e,t,n,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new zn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=qn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return qn(e.marks)}}function qn(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function Wn(e){return e.document||window.document}const Un=new WeakMap;function Kn(e){let t=Un.get(e);return void 0===t&&Un.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function Gn(e,t,n,o){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=Kn(o))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let l=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&l.style?l.style.cssText=c[e]:l.setAttribute(e,c[e])}}for(let r=d;r<t.length;r++){let i=t[r];if(0===i){if(r<t.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}{let{dom:t,contentDOM:r}=Gn(e,i,n,o);if(l.appendChild(t),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:l,contentDOM:s}}const Jn=Math.pow(2,16);function Zn(e,t){return e+t*Jn}function Xn(e){return 65535&e}class Yn{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Qn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Qn.empty)return Qn.empty}recover(e){let t=0,n=Xn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Jn}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?o:0);if(a>e)break;let l=this.ranges[s+r],c=this.ranges[s+i],d=a+l;if(e<=d){let r=a+o+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return r;let i=e==(t<0?a:d)?null:Zn(s/3,e-a),u=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(u|=8),new Yn(r,u,i)}o+=c-l}return n?e+o:new Yn(e+o,0,null)}touches(e,t){let n=0,o=Xn(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+r];if(e<=s+a&&t==3*o)return!0;n+=this.ranges[t+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),a=i+(this.inverted?0:r),l=this.ranges[o+t],c=this.ranges[o+n];e(s,s+l,a,a+c),r+=c-l}}invert(){return new Qn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?Qn.empty:new Qn(e<0?[0,-e,0]:[0,0,e])}}Qn.empty=new Qn([]);class eo{constructor(e,t,n=0,o=(e?e.length:0)){this.mirror=t,this.from=n,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new eo(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],null!=o&&o<t?n+o:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=o&&o>t?n-o-1:void 0)}}invert(){let e=new eo;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(r.recover);continue}}o|=r.delInfo,e=r.pos}return n?e:new Yn(e,o,null)}}const to=Object.create(null);class no{getMap(){return Qn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=to[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in to)throw new RangeError("Duplicate use of step JSON ID "+e);return to[e]=t,t.prototype.jsonID=e,t}}class oo{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new oo(e,null)}static fail(e){return new oo(null,e)}static fromReplace(e,t,n,o){try{return oo.ok(e.replace(t,n,o))}catch(e){if(e instanceof Ut)return oo.fail(e.message);throw e}}}function ro(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(ro(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return Ht.fromArray(o)}class io extends no{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new Kt(ro(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,o),t.openStart,t.openEnd);return oo.fromReplace(e,this.from,this.to,r)}invert(){return new so(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new io(t.pos,n.pos,this.mark)}merge(e){return e instanceof io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new io(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new io(t.from,t.to,e.markFromJSON(t.mark))}}no.jsonID("addMark",io);class so extends no{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Kt(ro(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return oo.fromReplace(e,this.from,this.to,n)}invert(){return new io(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new so(t.pos,n.pos,this.mark)}merge(e){return e instanceof so&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new so(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new so(t.from,t.to,e.markFromJSON(t.mark))}}no.jsonID("removeMark",so);class ao extends no{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return oo.fromReplace(e,this.pos,this.pos+1,new Kt(Ht.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new ao(this.pos,t.marks[n]);return new ao(this.pos,this.mark)}}return new lo(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ao(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ao(t.pos,e.markFromJSON(t.mark))}}no.jsonID("addNodeMark",ao);class lo extends no{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return oo.fromReplace(e,this.pos,this.pos+1,new Kt(Ht.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ao(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new lo(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new lo(t.pos,e.markFromJSON(t.mark))}}no.jsonID("removeNodeMark",lo);class co extends no{constructor(e,t,n,o=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=o}apply(e){return this.structure&&po(e,this.from,this.to)?oo.fail("Structure replace would overwrite content"):oo.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Qn([this.from,this.to-this.from,this.slice.size])}invert(e){return new co(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&co.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new co(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof co)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new co(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new co(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new co(t.from,t.to,Kt.fromJSON(e,t.slice),!!t.structure)}}co.MAP_BIAS=1,no.jsonID("replace",co);class uo extends no{constructor(e,t,n,o,r,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(e){if(this.structure&&(po(e,this.from,this.gapFrom)||po(e,this.gapTo,this.to)))return oo.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return oo.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?oo.fromReplace(e,this.from,this.to,n):oo.fail("Content does not fit in gap")}getMap(){return new Qn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new uo(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||o<t.pos||r>n.pos?null:new uo(t.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new uo(t.from,t.to,t.gapFrom,t.gapTo,Kt.fromJSON(e,t.slice),t.insert,!!t.structure)}}function po(e,t,n){let o=e.resolve(t),r=n-t,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let e=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function ho(e,t,n,o=n.contentMatch,r=!0){let i=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<i.childCount;t++){let l=i.child(t),c=a+l.nodeSize,d=o.matchType(l.type);if(d){o=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new so(a,c,l.marks[t]));if(r&&l.isText&&"pre"!=n.whitespace){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(l.text);)t||(t=new Kt(Ht.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new co(a+e.index,a+e.index+e[0].length,t))}}else s.push(new co(a,c,Kt.empty));a=c}if(!o.validEnd){let t=o.fillBefore(Ht.empty,!0);e.replace(a,a,new Kt(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function fo(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function mo(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,o=0,r=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+o,a=e.$to.indexAfter(n)-r;if(n<e.depth&&i.canReplace(s,a,t))return n;if(0==n||i.type.spec.isolating||!fo(i,s,a))break;s&&(o=1),a<i.childCount&&(r=1)}return null}function go(e,t,n=null,o=e){let r=function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.contentMatchAt(o).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(o,r,s)?i:null}(e,t),i=r&&function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.child(o),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=o;a&&e<r;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(o,t);return i?r.map(vo).concat({type:t,attrs:n}).concat(i.map(vo)):null}function vo(e){return{type:e,attrs:null}}function yo(e,t,n,o){t.forEach((r,i)=>{if(r.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(r.text);){let r=e.mapping.slice(o).map(n+1+i+s.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}})}function wo(e,t,n,o){t.forEach((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(o).map(n+1+i);e.replaceWith(r,r+1,t.type.schema.text("\n"))}})}function bo(e,t,n=1,o){let r=e.resolve(t),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>i;e--,t--){let n=r.node(e),i=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=o&&o[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=o&&o[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=r.indexAfter(i),l=o&&o[0];return r.node(i).canReplaceWith(a,a,l?l.type:r.node(i+1).type)}function ko(e,t){let n=e.resolve(t),o=n.index();return r=n.nodeBefore,i=n.nodeAfter,!(!r||!i||r.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=i.type==o?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(r,i))&&n.parent.canReplace(o,o+1);var r,i}function Co(e,t,n=t,o=Kt.empty){if(t==n&&!o.size)return null;let r=e.resolve(t),i=e.resolve(n);return xo(r,i,o)?new co(t,n,o):new No(r,i,o).fit()}function xo(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}no.jsonID("replaceAround",uo);class No{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Ht.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Ht.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let a=new Kt(r,i,s);return e>-1?new uo(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new co(n.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<e;n++){let r=t.firstChild;if(t.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,o=null;n?(o=Eo(this.unplaced.content,n-1).firstChild,e=o.content):e=this.unplaced.content;let r=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(r?a.matchType(r.type)||(l=a.fillBefore(Ht.from(r),!1)):o&&s.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:e,parent:o,inject:l};if(2==t&&r&&(i=a.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:e,parent:o,wrap:i};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Eo(e,t);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new Kt(e,t+1,Math.max(n,o.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Eo(e,t);if(o.childCount<=1&&t>0){let r=e.size-t<=t+o.size;this.unplaced=new Kt(So(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new Kt(So(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let e=0;e<r.length;e++)this.openFrontierNode(r[e]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-e,l=0,c=[],{match:d,type:u}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)c.push(o.child(e));d=d.matchFragment(o)}let p=s.size+e-(i.content.size-i.openEnd);for(;l<s.childCount;){let e=s.child(l),t=d.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(d=t,c.push(Mo(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?p:-1)))}let h=l==s.childCount;h||(p=-1),this.placed=Oo(this.placed,t,Ht.from(c)),this.frontier[t].match=d,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?0==e?Kt.empty:new Kt(So(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new Kt(So(i.content,e,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!_o(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:o}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=_o(e,t,o,n,r);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:o}=this.frontier[n],r=_o(e,n,o,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Oo(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),o=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,o)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Oo(this.placed,this.depth,Ht.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Ht.empty,!0);e.childCount&&(this.placed=Oo(this.placed,this.frontier.length,e))}}function So(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(So(e.firstChild.content,t-1,n)))}function Oo(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Oo(e.lastChild.content,t-1,n)))}function Eo(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Mo(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,Mo(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(Ht.empty,!0)))),e.copy(o)}function _o(e,t,n,o,r){let i=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=o.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}(n,i.content,s)?a:null}function To(e){return e.spec.defining||e.spec.definingForContent}function Do(e,t,n,o,r){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Do(r.content,t+1,n,o,r)))}if(t>o){let t=r.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Ht.empty,!0))}return e}function Io(e,t){let n=[];for(let o=Math.min(e.depth,t.depth);o>=0;o--){let r=e.start(o);if(r<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(r==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==r-1)&&n.push(o)}return n}class Ao extends no{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let o=t.type.create(n,null,t.marks);return oo.fromReplace(e,this.pos,this.pos+1,new Kt(Ht.from(o),0,t.isLeaf?0:1))}getMap(){return Qn.empty}invert(e){return new Ao(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ao(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ao(t.pos,t.attr,t.value)}}no.jsonID("attr",Ao);class Ro extends no{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return oo.ok(n)}getMap(){return Qn.empty}invert(e){return new Ro(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ro(t.attr,t.value)}}no.jsonID("docAttr",Ro);let Po=class extends Error{};Po=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Po.prototype=Object.create(Error.prototype)).constructor=Po,Po.prototype.name="TransformError";class Lo{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new eo}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Po(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let o=this.mapping.maps[n];n&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((n,o,r,i)=>{e=Math.min(e,r),t=Math.max(t,i)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Kt.empty){let o=Co(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new Kt(Ht.from(n),0,0))}delete(e,t){return this.replace(e,t,Kt.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),i=e.doc.resolve(n);if(xo(r,i,o))return e.step(new co(t,n,o));let s=Io(r,i);0==s[s.length-1]&&s.pop();let a=-(r.depth+1);s.unshift(a);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:r.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==o.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=To(t.type);if(n&&!t.sameMarkup(r.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=o.openStart;t>=0;t--){let a=(t+d+1)%(o.openStart+1),u=c[a];if(u)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let p=r.node(c-1),h=r.index(c-1);if(p.canReplaceWith(h,h,u.type,u.marks))return e.replace(r.before(c),d?i.after(c):n,new Kt(Do(o.content,0,o.openStart,a),a,o.openEnd))}}let u=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,o),!(e.steps.length>u));a--){let e=s[a];e<0||(t=r.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=function(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(0==o.parentOffset)for(let e=o.depth-1;e>=0;e--){let t=o.index(e);if(o.node(e).canReplaceWith(t,t,n))return o.before(e+1);if(t>0)return null}if(o.parentOffset==o.parent.content.size)for(let e=o.depth-1;e>=0;e--){let t=o.indexAfter(e);if(o.node(e).canReplaceWith(t,t,n))return o.after(e+1);if(t<o.node(e).childCount)return null}return null}(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new Kt(Ht.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let o=e.doc.resolve(t),r=e.doc.resolve(n);if(o.parent.isTextblock&&r.parent.isTextblock&&o.start()!=r.start()&&0==o.parentOffset&&0==r.parentOffset){let i=o.sharedDepth(n),s=!1;for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=o.depth;e>0&&t==o.start(e);e--)t=o.before(e);for(let e=r.depth;e>0&&n==r.start(e);e--)n=r.before(e);o=e.doc.resolve(t),r=e.doc.resolve(n)}}let i=Io(o,r);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return e.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return e.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(t-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return e.delete(o.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:o,$to:r,depth:i}=t,s=o.before(i+1),a=r.after(i+1),l=s,c=a,d=Ht.empty,u=0;for(let e=i,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,d=Ht.from(o.node(e).copy(d)),u++):l--;let p=Ht.empty,h=0;for(let e=i,t=!1;e>n;e--)t||r.after(e+1)<r.end(e)?(t=!0,p=Ht.from(r.node(e).copy(p)),h++):c++;e.step(new uo(l,c,s,a,new Kt(d.append(p),u,h),d.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=null,{linebreakReplacement:r}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(r&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(r);e&&!t?o=!1:!e&&t&&(o=!0)}let a=e.steps.length;if(!1===o){let o=e.doc.resolve(t+n);wo(e,o.node(),o.before(),a)}s.inlineContent&&ho(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==o);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new co(c,l.map(t+n,-1),Kt.empty,!0)),!0===o){let t=e.doc.resolve(c);yo(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=Ht.empty;for(let e=n.length-1;e>=0;e--){if(o.size){let t=n[e].type.contentMatch.matchFragment(o);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=Ht.from(n[e].type.create(n[e].attrs,o))}let r=t.start,i=t.end;e.step(new uo(r,i,r,i,new Kt(o,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,o=null){return function(e,t,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let s="function"==typeof r?r(t):r;if(t.isTextblock&&!t.hasMarkup(o,s)&&function(e,t,n){let o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(o.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&wo(e,t,n,i),ho(e,e.mapping.slice(i).map(n,1),o,void 0,null===r);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new uo(l,c,l+1,c-1,new Kt(Ht.from(o.create(s,null,t.marks)),0,0),1,!0)),!0===r&&yo(e,t,n,i),!1}})}(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return function(e,t,n,o,r){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(o,null,r||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new uo(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Kt(Ht.from(s),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new Ao(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ro(e,t)),this}addNodeMark(e,t){return this.step(new ao(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Wt)t.isInSet(n.marks)&&this.step(new lo(e,t));else{let o,r=n.marks,i=[];for(;o=t.isInSet(r);)i.push(new lo(e,o)),r=o.removeFromSet(r);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,o){let r=e.doc.resolve(t),i=Ht.empty,s=Ht.empty;for(let e=r.depth,t=r.depth-n,a=n-1;e>t;e--,a--){i=Ht.from(r.node(e).copy(i));let t=o&&o[a];s=Ht.from(t?t.type.create(t.attrs,s):r.node(e).copy(s))}e.step(new co(t,t,new Kt(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,o){let r,i,s=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(l,t),u=Math.min(l+e.nodeSize,n),p=o.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[e])?r.to=u:s.push(r=new so(c,u,d[e])));i&&i.to==c?i.to=u:a.push(i=new io(c,u,o))}}),s.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,o){let r=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let a=null;if(o instanceof Tn){let t,n=e.marks;for(;t=o.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(a=[o]):a=e.marks;if(a&&a.length){let o=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==i-1&&l.eq(r[e].style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:l,from:Math.max(s,t),to:o,step:i})}}}),r.forEach(t=>e.step(new so(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return ho(this,e,t,n),this}}const Vo=Object.create(null);class jo{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new $o(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Kt.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=e.mapping.slice(r);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Kt.empty:t),0==s&&Jo(e,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);r?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Jo(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let o=e.parent.inlineContent?new Fo(e):Go(e.node(0),e.parent,e.pos,e.index(),t,n);if(o)return o;for(let o=e.depth-1;o>=0;o--){let r=t<0?Go(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Go(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Uo(e.node(0))}static atStart(e){return Go(e,e,0,0,1)||new Uo(e)}static atEnd(e){return Go(e,e,e.content.size,e.childCount,-1)||new Uo(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Vo[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Vo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Fo.between(this.$anchor,this.$head).getBookmark()}}jo.prototype.visible=!0;class $o{constructor(e,t){this.$from=e,this.$to=t}}let Bo=!1;function Ho(e){Bo||e.parent.inlineContent||(Bo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Fo extends jo{constructor(e,t=e){Ho(e),Ho(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return jo.near(n);let o=e.resolve(t.map(this.anchor));return new Fo(o.parent.inlineContent?o:n,n)}replace(e,t=Kt.empty){if(super.replace(e,t),t==Kt.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Fo&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Fo(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let o=e.resolve(t);return new this(o,n==t?o:e.resolve(n))}static between(e,t,n){let o=e.pos-t.pos;if(n&&!o||(n=o>=0?1:-1),!t.parent.inlineContent){let e=jo.findFrom(t,n,!0)||jo.findFrom(t,-n,!0);if(!e)return jo.near(t,n);t=e.$head}return e.parent.inlineContent||(0==o||(e=(jo.findFrom(e,-n,!0)||jo.findFrom(e,n,!0)).$anchor).pos<t.pos!=o<0)&&(e=t),new Fo(e,t)}}jo.jsonID("text",Fo);class zo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new zo(e.map(this.anchor),e.map(this.head))}resolve(e){return Fo.between(e.resolve(this.anchor),e.resolve(this.head))}}class qo extends jo{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:o}=t.mapResult(this.anchor),r=e.resolve(o);return n?jo.near(r):new qo(r)}content(){return new Kt(Ht.from(this.node),0,0)}eq(e){return e instanceof qo&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Wo(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new qo(e.resolve(t.anchor))}static create(e,t){return new qo(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}qo.prototype.visible=!1,jo.jsonID("node",qo);class Wo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new zo(n,n):new Wo(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&qo.isSelectable(n)?new qo(t):jo.near(t)}}class Uo extends jo{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Kt.empty){if(t==Kt.empty){e.delete(0,e.doc.content.size);let t=jo.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Uo(e)}map(e){return new Uo(e)}eq(e){return e instanceof Uo}getBookmark(){return Ko}}jo.jsonID("all",Uo);const Ko={map(){return this},resolve:e=>new Uo(e)};function Go(e,t,n,o,r,i=!1){if(t.inlineContent)return Fo.create(e,n);for(let s=o-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let o=t.child(s);if(o.isAtom){if(!i&&qo.isSelectable(o))return qo.create(e,n-(r<0?o.nodeSize:0))}else{let t=Go(e,o,n+r,r<0?o.childCount:0,r,i);if(t)return t}n+=o.nodeSize*r}return null}function Jo(e,t,n){let o=e.steps.length-1;if(o<t)return;let r,i=e.steps[o];(i instanceof co||i instanceof uo)&&(e.mapping.maps[o].forEach((e,t,n,o)=>{null==r&&(r=o)}),e.setSelection(jo.near(e.doc.resolve(r),n)))}class Zo extends Lo{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Wt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Wt.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let o=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,o.text(e,r)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(jo.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Xo(e,t){return t&&e?e.bind(t):e}class Yo{constructor(e,t,n){this.name=e,this.init=Xo(t.init,n),this.apply=Xo(t.apply,n)}}const Qo=[new Yo("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Yo("selection",{init:(e,t)=>e.selection||jo.atStart(t.doc),apply:e=>e.selection}),new Yo("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,o)=>o.selection.$cursor?e.storedMarks:null}),new Yo("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class er{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qo.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Yo(e.key,e.spec.state,e))})}}class tr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=o?o[i].n:0,l=o?o[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!o){o=[];for(let e=0;e<this.config.plugins.length;e++)o.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new tr(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Zo(this)}static create(e){let t=new er(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new tr(t);for(let o=0;o<t.fields.length;o++)n[t.fields[o].name]=t.fields[o].init(e,n);return n}reconfigure(e){let t=new er(this.schema,e.plugins),n=t.fields,o=new tr(t);for(let t=0;t<n.length;t++){let r=n[t].name;o[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[n],r=o.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new er(e.schema,e.plugins),r=new tr(o);return o.fields.forEach(o=>{if("doc"==o.name)r.doc=pn.fromJSON(e.schema,t.doc);else if("selection"==o.name)r.selection=jo.fromJSON(r.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==o.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(r[o.name]=a.fromJSON.call(s,e,t[i],r))}r[o.name]=o.init(e,r)}}),r}}function nr(e,t,n){for(let o in e){let r=e[o];r instanceof Function?r=r.bind(t):"handleDOMEvents"==o&&(r=nr(r,t,{})),n[o]=r}return n}class or{constructor(e){this.spec=e,this.props={},e.props&&nr(e.props,this,this.props),this.key=e.key?e.key.key:ir("plugin")}getState(e){return e[this.key]}}const rr=Object.create(null);function ir(e){return e in rr?e+"$"+ ++rr[e]:(rr[e]=0,e+"$")}class sr{constructor(e="key"){this.key=ir(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ar=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lr(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const cr=(e,t,n)=>{let o=lr(e,n);if(!o)return!1;let r=hr(o);if(!r){let n=o.blockRange(),r=n&&mo(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(yr(e,r,t,-1))return!0;if(0==o.parent.content.size&&(ur(i,"end")||qo.isSelectable(i)))for(let n=o.depth;;n--){let s=Co(e.doc,o.before(n),o.after(n),Kt.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ur(i,"end")?jo.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):qo.create(n.doc,r.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),!0)},dr=(e,t,n)=>{let o=lr(e,n);if(!o)return!1;let r=hr(o);return!!r&&function(e,t,n){let o=t.nodeBefore,r=o,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let s=t.nodeAfter,a=s,l=t.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let c=Co(e.doc,i,l,Kt.empty);if(!c||c.from!=i||c instanceof co&&c.slice.size>=l-i)return!1;if(n){let t=e.tr.step(c);t.setSelection(Fo.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,r,t)};function ur(e,t,n=!1){for(let o=e;o;o="start"==t?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const pr=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=hr(o)}let s=i&&i.nodeBefore;return!(!s||!qo.isSelectable(s))&&(t&&t(e.tr.setSelection(qo.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function hr(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fr(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function mr(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const gr=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=mr(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(t){let o=n.after(),r=e.tr.replaceWith(o,o,s.createAndFill());r.setSelection(jo.near(r.doc.resolve(o),1)),t(r.scrollIntoView())}return!0};const vr=(e,t)=>{let{$from:n,$to:o}=e.selection;if(e.selection instanceof qo&&e.selection.node.isBlock)return!(!n.parentOffset||!bo(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let r,i,s=[],a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),i=mr(n.node(e-1).contentMatchAt(n.indexAfter(e-1))),s.unshift(a&&i?{type:i}:null),r=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof Fo||e.selection instanceof Uo)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=bo(c.doc,d,s.length,s);if(u||(s[0]=i?{type:i}:null,u=bo(c.doc,d,s.length,s)),!u)return!1;if(c.split(d,s.length,s),!a&&l&&n.node(r).type!=i){let e=c.mapping.map(n.before(r)),t=c.doc.resolve(e);i&&n.node(r-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(r)),i)}return t&&t(c.scrollIntoView()),!0};function yr(e,t,n,o){let r,i,s=t.nodeBefore,a=t.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let o=t.nodeBefore,r=t.nodeAfter,i=t.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!r.isTextblock&&!ko(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(r[0]||a.type).validEnd){if(n){let o=t.pos+a.nodeSize,i=Ht.empty;for(let e=r.length-1;e>=0;e--)i=Ht.from(r[e].create(null,i));i=Ht.from(s.copy(i));let l=e.tr.step(new uo(t.pos-1,o,t.pos,o,new Kt(i,1,0),r.length,!0)),c=l.doc.resolve(o+2*r.length);c.nodeAfter&&c.nodeAfter.type==s.type&&ko(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||o>0&&l?null:jo.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),p=u&&mo(u);if(null!=p&&p>=t.depth)return n&&n(e.tr.lift(u,p).scrollIntoView()),!0;if(c&&ur(a,"start",!0)&&ur(s,"end")){let o=s,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=Ht.empty;for(let e=r.length-1;e>=0;e--)o=Ht.from(r[e].copy(o));n(e.tr.step(new uo(t.pos-r.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new Kt(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function wr(e){return function(t,n){let o=t.selection,r=e<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(t.tr.setSelection(Fo.create(t.doc,e<0?r.start(i):r.end(i)))),!0)}}const br=wr(-1),kr=wr(1);function Cr(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),a=s&&go(s,e,t);return!!a&&(o&&o(n.tr.wrap(s,a).scrollIntoView()),!0)}}function xr(e,t=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,(o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(e,t))if(o.type==e)r=!0;else{let t=n.doc.resolve(i),o=t.index();r=t.parent.canReplaceWith(o,o+1,e)}})}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,e,t)}o(r.scrollIntoView())}return!0}}function Nr(e,t=null,n){return function(n,o){let{empty:r,$cursor:i,ranges:s}=n.selection;if(r&&!i||!function(e,t,n){for(let o=0;o<t.length;o++){let{$from:r,$to:i}=t[o],s=0==r.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(r.pos,i.pos,(e,t)=>{if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}(n.doc,s,e))return!1;if(o)if(i)e.isInSet(n.storedMarks||i.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let r,i=n.tr;r=!s.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e));for(let n=0;n<s.length;n++){let{$from:o,$to:a}=s[n];if(r){let n=o.pos,r=a.pos,s=o.nodeAfter,l=a.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+c<r&&(n+=c,r-=d),i.addMark(n,r,e.create(t))}else i.removeMark(o.pos,a.pos,e)}o(i.scrollIntoView())}return!0}}function Sr(...e){return function(t,n,o){for(let r=0;r<e.length;r++)if(e[r](t,n,o))return!0;return!1}}let Or=Sr(ar,cr,pr),Er=Sr(ar,(e,t,n)=>{let o=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!o)return!1;let r=fr(o);if(!r)return!1;let i=r.nodeAfter;if(yr(e,r,t,1))return!0;if(0==o.parent.content.size&&(ur(i,"start")||qo.isSelectable(i))){let n=Co(e.doc,o.before(),o.after(),Kt.empty);if(n&&n.slice.size<n.to-n.from){if(t){let o=e.tr.step(n);o.setSelection(ur(i,"start")?jo.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):qo.create(o.doc,o.mapping.map(r.pos))),t(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=fr(o)}let s=i&&i.nodeAfter;return!(!s||!qo.isSelectable(s))&&(t&&t(e.tr.setSelection(qo.create(e.doc,i.pos)).scrollIntoView()),!0)});const Mr={Enter:Sr((e,t)=>{let{$head:n,$anchor:o}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(o))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:o,$to:r}=n;if(n instanceof Uo||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=mr(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(Fo.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(bo(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&mo(o);return null!=r&&(t&&t(e.tr.lift(o,r).scrollIntoView()),!0)},vr),"Mod-Enter":gr,Backspace:Or,"Mod-Backspace":Or,"Shift-Backspace":Or,Delete:Er,"Mod-Delete":Er,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Uo(e.doc))),!0)},_r={"Ctrl-h":Mr.Backspace,"Alt-Backspace":Mr["Mod-Backspace"],"Ctrl-d":Mr.Delete,"Ctrl-Alt-Backspace":Mr["Mod-Delete"],"Alt-Delete":Mr["Mod-Delete"],"Alt-d":Mr["Mod-Delete"],"Ctrl-a":br,"Ctrl-e":kr};for(let e in Mr)_r[e]=Mr[e];const Tr=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?_r:Mr;class Dr{constructor(e,t,n={}){var o;this.match=e,this.match=e,this.handler="string"==typeof t?(o=t,function(e,t,n,r){let i=o;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let o=(n+=e)-r;o>0&&(i=t[0].slice(e-o,e)+i,n=r)}return e.tr.insertText(i,n,r)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const Ir=(e,t)=>{let n=e.plugins;for(let o=0;o<n.length;o++){let r,i=n[o];if(i.spec.isInputRules&&(r=i.getState(e))){if(t){let n=e.tr,o=r.transform;for(let e=o.steps.length-1;e>=0;e--)n.step(o.steps[e].invert(o.docs[e]));if(r.text){let t=n.doc.resolve(r.from).marks();n.replaceWith(r.from,r.to,e.schema.text(r.text,t))}else n.delete(r.from,r.to);t(n)}return!0}}return!1};function Ar(e,t,n=null,o){return new Dr(e,(e,r,i,s)=>{let a=n instanceof Function?n(r):n,l=e.tr.delete(i,s),c=l.doc.resolve(i).blockRange(),d=c&&go(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(i-1).nodeBefore;return u&&u.type==t&&ko(l.doc,i-1)&&(!o||o(r,u))&&l.join(i-1),l})}function Rr(e,t,n=null){return new Dr(e,(e,o,r,i)=>{let s=e.doc.resolve(r),a=n instanceof Function?n(o):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(r,i).setBlockType(r,r,t,a):null})}new Dr(/--$/,"—",{inCodeMark:!1}),new Dr(/\.\.\.$/,"…",{inCodeMark:!1}),new Dr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new Dr(/"$/,"”",{inCodeMark:!1}),new Dr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new Dr(/'$/,"’",{inCodeMark:!1});const Pr="undefined"!=typeof navigator?navigator:null,Lr="undefined"!=typeof document?document:null,Vr=Pr&&Pr.userAgent||"",jr=/Edge\/(\d+)/.exec(Vr),$r=/MSIE \d/.exec(Vr),Br=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vr),Hr=!!($r||Br||jr),Fr=$r?document.documentMode:Br?+Br[1]:jr?+jr[1]:0,zr=!Hr&&/gecko\/(\d+)/i.test(Vr),qr=zr&&+(/Firefox\/(\d+)/.exec(Vr)||[0,0])[1],Wr=!Hr&&/Chrome\/(\d+)/.exec(Vr),Ur=!!Wr,Kr=Wr?+Wr[1]:0,Gr=!Hr&&!!Pr&&/Apple Computer/.test(Pr.vendor),Jr=Gr&&(/Mobile\/\w+/.test(Vr)||!!Pr&&Pr.maxTouchPoints>2),Zr=Jr||!!Pr&&/Mac/.test(Pr.platform),Xr=/Android \d/.test(Vr),Yr=!!Lr&&"webkitFontSmoothing"in Lr.documentElement.style,Qr=Yr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var ei=Object.freeze({__proto__:null,android:Xr,chrome:Ur,chrome_version:Kr,gecko:zr,gecko_version:qr,ie:Hr,ie_version:Fr,ios:Jr,mac:Zr,safari:Gr,webkit:Yr,webkit_version:Qr});function ti(e,t,n,o,r,i){if(e.composing)return!1;const s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;const l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+o;for(let a of r){const r=a,c=r.match.exec(l),d=c&&c[0]&&r.handler(s,c,t-(c[0].length-o.length),n);if(d)return!1!==r.undoable&&d.setMeta(i,{transform:d,from:t,to:n,text:o}),e.dispatch(d),!0}return!1}const ni=new sr("MILKDOWN_CUSTOM_INPUTRULES");function oi({rules:e}){const t=new or({key:ni,isInputRules:!0,state:{init:()=>null,apply(e,t){const n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,o,r,i)=>ti(n,o,r,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:o}=n.state.selection;o&&ti(n,o.pos,o.pos,"",e,t)}),!1),keydown:(e,t)=>!(!Xr||!Ur||"Enter"!==t.key)&&(!e.composing&&(!!e.someProp("handleKeyDown",n=>n(e,t))&&(t.preventDefault(),!0)))},handleKeyDown(n,o){if("Enter"!==o.key)return!1;const{$cursor:r}=n.state.selection;return!!r&&ti(n,r.pos,r.pos,"\n",e,t)}}});return t}function ri(e,t,n={}){return new Dr(e,(e,o,r,i)=>{var s,a,l,c;const{tr:d}=e;let u,p=o[o.length-1],h=o[0],f=[];const m={group:p,fullMatch:h,start:r,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:p,fullMatch:h,start:r,end:i}=m),null===h)return null;if(""===(null==p?void 0:p.trim()))return null;if(p){const e=h.search(/\S/),s=r+h.indexOf(p),m=s+p.length;f=null!=(a=d.storedMarks)?a:[],m<i&&d.delete(m,i),s>r&&d.delete(r+e,s),u=r+e+p.length;const g=null==(l=n.getAttr)?void 0:l.call(n,o);d.addMark(r,u,t.create(g)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:o,start:r,end:i,tr:d})}return d})}var ii=Object.defineProperty,si=Object.defineProperties,ai=Object.getOwnPropertyDescriptors,li=Object.getOwnPropertySymbols,ci=Object.prototype.hasOwnProperty,di=Object.prototype.propertyIsEnumerable,ui=(e,t,n)=>t in e?ii(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function pi(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function hi(e,t,n){const o=e.state.doc.content.size,r=pi(t,0,o),i=pi(n,0,o),s=e.coordsAtPos(r),a=e.coordsAtPos(i,-1),l=Math.min(s.top,a.top),c=Math.max(s.bottom,a.bottom),d=Math.min(s.left,a.left),u=Math.max(s.right,a.right),p={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return h=((e,t)=>{for(var n in t||(t={}))ci.call(t,n)&&ui(e,n,t[n]);if(li)for(var n of li(t))di.call(t,n)&&ui(e,n,t[n]);return e})({},p),si(h,ai({toJSON:()=>p}));var h}function fi(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function mi(e){if(1===e.content.childCount){const t=e.content.firstChild;if("text"===(null==t?void 0:t.type.name)&&0===t.marks.length)return t;if("paragraph"===(null==t?void 0:t.type.name)&&1===t.childCount){const e=t.firstChild;if("text"===(null==e?void 0:e.type.name)&&0===e.marks.length)return e}}return!1}function gi(e){return t=>{for(let n=t.depth;n>0;n-=1){const o=t.node(n);if(e(o)){return{from:t.before(n),to:t.after(n),node:o}}}}}function vi(e,t){const n=t.nodes[e];if(!n)throw function(e,t){return new wt(yt.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}("node",e);return n}function yi(e){return t=>{for(let n=t.depth;n>0;n--){const o=t.node(n);if(e(o))return{pos:t.before(n),start:t.start(n),depth:n,node:o}}}}function wi(e,t){if(!(e instanceof qo))return;const{node:n,$from:o}=e;return function(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}(t,n)?{node:n,pos:o.pos,start:o.start(o.depth),depth:o.depth}:void 0}const bi=(e,t)=>{const{selection:n,doc:o}=e;if(n instanceof qo)return{hasNode:n.node.type===t,pos:n.from,target:n.node};const{from:r,to:i}=n;let s=!1,a=-1,l=null;return o.nodesBetween(r,i,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}},ki="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ci="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function xi(e){let t,n,o,r,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);ki?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function Ni(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Si(e){return new or({props:{handleKeyDown:Oi(e)}})}function Oi(e){let t=function(e){let t=Object.create(null);for(let n in e)t[xi(n)]=e[n];return t}(e);return function(e,n){let o,r=c(n),i=t[Ni(r,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=t[Ni(r,n,!1)];if(o&&o(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ci&&n.ctrlKey&&n.altKey)&&(o=d[n.keyCode])&&o!=r){let r=t[Ni(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Ei=class{},Mi=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw xt();return e}}},_i=class e extends Ei{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,o){return new e(t,n,o)}},Ti=class extends Mi{#w=Wt.none;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(_i.create(e,[],t)),this),this.closeNode=()=>{try{this.#b()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#k(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#w=e.create(t).addToSet(this.#w),this),this.closeMark=e=>(this.#w=e.removeFromSet(this.#w),this),this.addText=e=>{try{const t=this.top();if(!t)throw xt();const n=t.pop(),o=this.schema.text(e,this.#w);if(!n)return t.push(o),this;const r=this.#C(n,o);return r?(t.push(r),this):(t.push(n,o),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do{e=this.#b()}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#x(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{const n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#N=e=>e.isText;#C=(e,t)=>{if(this.#N(e)&&this.#N(t)&&Wt.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)};#S=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw function(e){return new wt(yt.parserMatchError,`Cannot match target parser for node: ${kt(e)}.`)}(e);return t};#x=e=>{const t=this.#S(e);t.spec.parseMarkdown.runner(this,e,t)};#b=()=>{this.#w=Wt.none;const e=this.close();return this.#k(e.type,e.attrs,e.content)};#k=(e,t,n)=>{const o=e.createAndFill(t,n,this.#w);if(!o)throw function(e,t,n){const o=`Cannot create node for ${"name"in e?e.name:e}`,r=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(r).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},i=[["[Description]",o],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:r(e):"null")]].reduce((e,[t,n])=>{const o=`${t}: ${r(n)}.`;return e.concat(o)},[]);return new wt(yt.createNodeInParserFail,i.join("\n"))}(e,t,n);return this.push(o),o}},Di=class e extends Ei{constructor(e,t,n,o={}){super(),this.type=e,this.children=t,this.value=n,this.props=o,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,o,r={})=>new e(t,n,o,r)}},Ii=class extends Mi{#w=Wt.none;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(Di.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#b(),this),this.addNode=(e,t,n,o)=>(this.#k(e,t,n,o),this),this.withMark=(e,t,n,o)=>(this.#O(e,t,n,o),this),this.closeMark=e=>(this.#E(e),this),this.build=()=>{let e=null;do{e=this.#b()}while(this.size());return e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach(e=>{this.#x(e)}),this):(this.#x(e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#S=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw function(e){return new wt(yt.serializerMatchError,`Cannot match target serializer for node: ${kt(e)}.`)}(e.type);return t};#M=e=>this.#S(e).spec.toMarkdown.runner(this,e);#_=(e,t)=>this.#S(e).spec.toMarkdown.runner(this,e,t);#x=e=>{const{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#_(t,e))&&this.#M(e),t.forEach(e=>this.#E(e))};#T=(e,t)=>{if(e.type===t)return e;if(1!==e.children?.length)return e;const n=e=>{if(e.type===t)return null!=e.value?null:e;if(1!==e.children?.length)return null;const[o]=e.children;return o?n(o):null},o=n(e);if(!o)return e;const r=o.children?[...o.children]:void 0,i={...e,children:r};return i.children=r,o.children=[i],o};#D=e=>{const{children:t}=e;return t?(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];const o=e.at(-1);if(o&&o.isMark&&t.isMark){t=this.#T(t,o.type);const{children:n,...r}=t,{children:i,...s}=o;if(t.type===o.type&&n&&i&&JSON.stringify(r)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(this.#D(t))}}return e.concat(t)},[]),e):e};#I=e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#A=(e,t)=>{let n="",o="";const r=e.children;let i=-1,s=-1;if(r){(a=r)&&a.forEach((e,t)=>{"text"===e.type&&e.value&&(i<0&&(i=t),s=t)});const e=r?.[s],t=r?.[i];if(e&&e.value.endsWith(" ")){const t=e.value,n=t.trimEnd();o=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){const e=t.value,o=e.trimStart();n=e.slice(0,e.length-o.length),t.value=o}}var a;n.length&&this.#k("text",void 0,n);const l=t();return o.length&&this.#k("text",void 0,o),l};#b=(e=!1)=>{const t=this.close(),n=()=>this.#k(t.type,t.children,t.value,t.props);return e?this.#A(t,n):n()};#k=(e,t,n,o)=>{const r=Di.create(e,t,n,o),i=this.#D(this.#I(r));return this.push(i),i};#O=(e,t,n,o)=>e.isInSet(this.#w)?this:(this.#w=e.addToSet(this.#w),this.openNode(t,n,{...o,isMark:!0}));#E=e=>{e.isInSet(this.#w)&&(this.#w=e.type.removeFromSet(this.#w),this.#b(!0))}};const Ai=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Ri=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Pi=null;const Li=function(e,t,n){let o=Pi||(Pi=document.createRange());return o.setEnd(e,null==n?e.nodeValue.length:n),o.setStart(e,t||0),o},Vi=function(e,t,n,o){return n&&($i(e,t,n,o,-1)||$i(e,t,n,o,1))},ji=/^(img|br|input|textarea|hr)$/i;function $i(e,t,n,o,r){for(var i;;){if(e==n&&t==o)return!0;if(t==(r<0?0:Bi(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Hi(e)||ji.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ai(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=r}else e=n,t=r<0?Bi(e):0}}}}function Bi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Hi(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Fi=function(e){return e.focusNode&&Vi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function zi(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const qi="undefined"!=typeof navigator?navigator:null,Wi="undefined"!=typeof document?document:null,Ui=qi&&qi.userAgent||"",Ki=/Edge\/(\d+)/.exec(Ui),Gi=/MSIE \d/.exec(Ui),Ji=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ui),Zi=!!(Gi||Ji||Ki),Xi=Gi?document.documentMode:Ji?+Ji[1]:Ki?+Ki[1]:0,Yi=!Zi&&/gecko\/(\d+)/i.test(Ui);Yi&&(/Firefox\/(\d+)/.exec(Ui)||[0,0])[1];const Qi=!Zi&&/Chrome\/(\d+)/.exec(Ui),es=!!Qi,ts=Qi?+Qi[1]:0,ns=!Zi&&!!qi&&/Apple Computer/.test(qi.vendor),rs=ns&&(/Mobile\/\w+/.test(Ui)||!!qi&&qi.maxTouchPoints>2),is=rs||!!qi&&/Mac/.test(qi.platform),ss=!!qi&&/Win/.test(qi.platform),as=/Android \d/.test(Ui),ls=!!Wi&&"webkitFontSmoothing"in Wi.documentElement.style,cs=ls?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ds(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function us(e,t){return"number"==typeof e?e:e[t]}function ps(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function hs(e,t,n){let o=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=Ri(s);continue}let e=s,n=e==i.body,a=n?ds(i):ps(e),l=0,c=0;if(t.top<a.top+us(o,"top")?c=-(a.top-t.top+us(r,"top")):t.bottom>a.bottom-us(o,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+us(r,"top")-a.top:t.bottom-a.bottom+us(r,"bottom")),t.left<a.left+us(o,"left")?l=-(a.left-t.left+us(r,"left")):t.right>a.right-us(o,"right")&&(l=t.right-a.right+us(r,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,o=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let r=e.scrollLeft-n,i=e.scrollTop-o;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Ri(s)}}function fs(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=Ri(o));return t}function ms(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:r,left:i}=e[n];o.scrollTop!=r+t&&(o.scrollTop=r+t),o.scrollLeft!=i&&(o.scrollLeft=i)}}let gs=null;function vs(e,t){let n,o,r,i,s=2e8,a=0,l=t.top,c=t.top;for(let d=e.firstChild,u=0;d;d=d.nextSibling,u++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=Li(d).getClientRects()}for(let p=0;p<e.length;p++){let h=e[p];if(h.top<=l&&h.bottom>=c){l=Math.max(h.bottom,l),c=Math.min(h.top,c);let e=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(e<s){n=d,s=e,o=e&&3==n.nodeType?{left:h.right<t.left?h.right:h.left,top:t.top}:t,1==d.nodeType&&e&&(a=u+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!r&&h.left<=t.left&&h.right>=t.left&&(r=d,i={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(a=u+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(e,t){let n,o=e.nodeValue.length,r=document.createRange();for(let i=0;i<o;i++){r.setEnd(e,i+1),r.setStart(e,i);let o=Cs(r,1);if(o.top!=o.bottom&&ys(t,o)){n={node:e,offset:i+(t.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),n||{node:e,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:e,offset:a}:vs(n,o)}function ys(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function ws(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let o=0;o<e.length;o++){let r=e[o];if(ys(t,r))return ws(n,t,r)}}if((i=(i+1)%o)==r)break}return e}function bs(e,t){let n,o=e.dom.ownerDocument,r=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(Bi(o.offsetNode),o.offset)}}catch(e){}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(Bi(o.startContainer),o.startOffset)}}}(o,t.left,t.top);i&&({node:n,offset:r}=i);let s,a=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!ys(t,n))return null;if(a=ws(e.dom,t,n),!a)return null}if(ns)for(let e=a;n&&e;e=Ri(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(Yi&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,o=n.childNodes[r];"IMG"==o.nodeName&&(e=o.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}let o;ls&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(e,t,n,o){let r=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>o.left||t.top>o.top?r=s.posBefore:(!i&&t.right<o.left||t.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(t.top+t.bottom)/2:o.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==s&&(s=function(e,t,n){let{node:o,offset:r}=vs(t,n),i=-1;if(1==o.nodeType&&!o.firstChild){let e=o.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(o,r,i)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function ks(e){return e.top<e.bottom||e.left<e.right}function Cs(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(ks(e))return e}return Array.prototype.find.call(n,ks)||e.getBoundingClientRect()}const xs=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ns(e,t,n){let{node:o,offset:r,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=ls||Yi;if(3==o.nodeType){if(!s||!xs.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let e=r,t=r,i=n<0?1:-1;return n<0&&!r?(t++,i=-1):n>=0&&r==o.nodeValue.length?(e--,i=1):n<0?e--:t++,Ss(Cs(Li(o,e,t),i),i<0)}{let e=Cs(Li(o,r,r),n);if(Yi&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let t=Cs(Li(o,r-1,r-1),-1);if(t.top==e.top){let n=Cs(Li(o,r,r+1),-1);if(n.top!=e.top)return Ss(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==Bi(o))){let e=o.childNodes[r-1];if(1==e.nodeType)return Os(e.getBoundingClientRect(),!1)}if(null==i&&r<Bi(o)){let e=o.childNodes[r];if(1==e.nodeType)return Os(e.getBoundingClientRect(),!0)}return Os(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==Bi(o))){let e=o.childNodes[r-1],t=3==e.nodeType?Li(e,Bi(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ss(Cs(t,1),!1)}if(null==i&&r<Bi(o)){let e=o.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Li(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Ss(Cs(t,-1),!0)}return Ss(Cs(3==o.nodeType?Li(o):o,-n),n>=0)}function Ss(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Os(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Es(e,t,n){let o=e.state,r=e.root.activeElement;o!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),r!=e.dom&&r&&r.focus()}}const Ms=/[\u0590-\u08ac]/;let _s=null,Ts=null,Ds=!1;function Is(e,t,n){return _s==t&&Ts==n?Ds:(_s=t,Ts=n,Ds="up"==n||"down"==n?function(e,t,n){let o=t.selection,r="up"==n?o.$from:o.$to;return Es(e,t,()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let o=Ns(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Li(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,a=e.domSelection();return a?Ms.test(o.parent.textContent)&&a.modify?Es(e,t,()=>{let{focusNode:t,focusOffset:r,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&r==u;try{a.collapse(i,s),t&&(t!=i||r!=s)&&a.extend&&a.extend(t,r)}catch(e){}return null!=l&&(a.caretBidiLevel=l),p}):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(e,t,n))}class As{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let o=this.children[t];if(o==e)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,o;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(e==this.dom&&this.contentDOM)o=t>Ai(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!1;break}if(t.previousSibling)break}if(null==o&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!0;break}if(t.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!t||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],r=n+o.size;if(n==e&&r!=n){for(;!o.border&&o.children.length;)for(let e=0;e<o.children.length;e++){let t=o.children[e];if(t.size){o=t;break}}return o}if(e<r)return o.descAt(e-n-o.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let t=0;n<this.children.length;n++){let r=this.children[n],i=t+r.size;if(i>e||r instanceof Bs){o=e-t;break}t=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Rs&&e.side>=0;n--);if(t<=0){let e,o=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,o=!1);return e&&t&&o&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Ai(e.dom)+1:0}}{let e,o=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,o=!1);return e&&o&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Ai(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==o&&e<=a){let r=i+n.border;if(e>=r&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=Ai(n.dom)+1;break}e-=n.size}-1==o&&(o=0)}if(o>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=Ai(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,o=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(r>a&&i<c)return l.setSelection(e-a-l.border,t-a-l.border,n,o);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((Yi||ns)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:Ai(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Yi&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(o=!0)}if(!(o||d&&ns)&&Vi(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Vi(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!d||!Yi)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let o=n+r.border,s=i-r.border;if(e>=o&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=o||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-o,t-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Rs extends As{constructor(e,t,n,o){let r,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ps extends As{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Ls extends As{constructor(e,t,n,o,r){super(e,[],n,o),this.mark=t,this.spec=r}static create(e,t,n,o){let r=o.nodeViews[t.type.name],i=r&&r(t,o,n);return i&&i.dom||(i=zn.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Ls(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let o=Ls.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;t<i&&(r=Qs(r,t,i,n)),e>0&&(r=Qs(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Vs extends As{constructor(e,t,n,o,r,i,s,a,l){super(e,[],r,i),this.node=t,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(e,t,n,o,r,i){let s,a=r.nodeViews[t.type.name],l=a&&a(t,r,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,o),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=zn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=Gs(c,n,t),l?s=new Hs(e,t,n,o,c,d||null,u,l,r,i+1):t.isText?new $s(e,t,n,o,c,u,r):new Vs(e,t,n,o,c,d||null,u,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ht.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Js(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,a=new Xs(this,i&&i.node,e);!function(e,t,n,o){let r=t.locals(e),i=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);o(s,r,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,p,h;for(;s<r.length&&r[s].to==i;){let e=r[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(Ys);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)h=-1,p=l,l=null;else{if(!(c<e.childCount))break;h=c,p=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)a.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=p.cut(e-i),p=p.cut(0,e-i),f=e,h=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(i,p),h),i=f}}(this.node,this.innerDeco,(t,r,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,r):t.type.side>=0&&!i&&a.syncToMarks(r==this.node.childCount?Wt.none:this.node.child(r).marks,n,e,r),a.placeWidget(t,e,o)},(t,i,l,c)=>{let d;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,i,l,c)||s&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(d=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(t,i,l,d,e)||a.updateNextNode(t,i,l,e,c,o)||a.addNode(t,i,l,e,o),o+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Fs(this.contentDOM,this.children,e),rs&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:o}=e.state.selection;if(!(e.state.selection instanceof Fo)||n<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let e=r.nodeValue,i=function(e,t,n,o){for(let r=0,i=0;r<e.childCount&&i<=o;){let s=e.child(r++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;r<e.childCount;){let t=e.child(r++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=o&&l.slice(o-t.length-a,o-a)==t)return o-t.length;let e=a<o?l.lastIndexOf(t,o-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==o&&l.length>=o+t.length-a&&l.slice(o-a,o-a+t.length)==t)return o}}return-1}(this.node.content,e,n-t,o-t);return i<0?null:{node:r,pos:i,text:e}}return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new Ps(this,r,t,o);e.input.compositionNodes.push(i),this.children=Qs(this.children,n,n+o.length,e,i)}update(e,t,n,o){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,o),!0)}updateInner(e,t,n,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Js(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Us(this.dom,this.nodeDOM,Ws(this.outerDeco,this.node,t),Ws(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function js(e,t,n,o,r){Gs(o,t,e);let i=new Vs(void 0,e,t,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class $s extends Vs{constructor(e,t,n,o,r,i,s){super(e,t,n,o,r,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new $s(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Bs extends As{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Hs extends Vs{constructor(e,t,n,o,r,i,s,a,l,c){super(e,t,n,o,r,i,s,l,c),this.spec=a}update(e,t,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,o),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Fs(e,t,n){let o=e.firstChild,r=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=o;)o=Zs(o),r=!0;o=o.nextSibling}else r=!0,e.insertBefore(a,o);if(s instanceof Ls){let t=o?o.previousSibling:e.lastChild;Fs(s.contentDOM,s.children,n),o=t?t.nextSibling:e.firstChild}}for(;o;)o=Zs(o),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const zs=function(e){e&&(this.nodeName=e)};zs.prototype=Object.create(null);const qs=[new zs];function Ws(e,t,n){if(0==e.length)return qs;let o=n?qs[0]:new zs,r=[o];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&r.push(o=new zs(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==r.length&&r.push(o=new zs(t.isInline?"span":"div")),"class"==e?o.class=(o.class?o.class+" ":"")+i:"style"==e?o.style=(o.style?o.style+";":"")+i:"nodeName"!=e&&(o[e]=i))}}}return r}function Us(e,t,n,o){if(n==qs&&o==qs)return t;let r=t;for(let t=0;t<o.length;t++){let i=o[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=qs[0]),r=t}Ks(r,s||qs[0],i)}return r}function Ks(e,t,n){for(let o in t)"class"==o||"style"==o||"nodeName"==o||o in n||e.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.remove(o[t]);for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Gs(e,t,n){return Us(e,e,qs,Ws(t,n,1!=e.nodeType))}function Js(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Zs(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Xs{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,o=n.children.length,r=e.childCount,i=new Map,s=[];e:for(;r>0;){let a;for(;;)if(o){let e=n.children[o-1];if(!(e instanceof Ls)){a=e,o--;break}n=e,o=e.children.length}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(r-1))break;--r,i.set(a,r),s.push(a)}}return{index:r,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,o){let r=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let r=-1,s=this.top.children.length;o<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[i])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let o=Ls.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof Vs){let l=this.preMatch.matched.get(a);if(null!=l&&l!=r)return!1;let c,d=a.dom,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&Js(t,a.outerDeco));if(!u&&a.update(e,t,n,o))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(a,e,t,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Js(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let s=Vs.create(this.top,t,n,o,r,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,o,r){let i=Vs.create(this.top,e,t,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){let o=new Rs(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ls;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof $s)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ns||es)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let o=new Bs(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Ys(e,t){return e.type.side-t.type.side}function Qs(e,t,n,o,r){let i=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,d=a+=l.size;c>=n||d<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(l.slice(n-c,l.size,o)))}return i}function ea(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=o.resolve(s);if(Fi(n)){for(a=s;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&qo.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let o=0==t,r=t==Bi(e);o||r;){if(e==n)return!0;let t=Ai(e);if(!(e=e.parentNode))return!1;o=o&&0==t,r=r&&t==Bi(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;l=new qo(s==e?c:o.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[a,s]=r==e.state.selection.anchor?[r,t]:[t,r],c=o.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!l){l=ca(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return l}function ta(e){return e.editable?e.hasFocus():ua(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function na(e,t=!1){let n=e.state.selection;if(aa(e,n),ta(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&es){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Vi(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,o="IMG"==n.nodeName;o?t.collapse(n.parentNode,Ai(n)+1):t.collapse(n,0);!o&&!e.state.selection.visible&&Zi&&Xi<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let o,r,{anchor:i,head:s}=n;!oa||n instanceof Fo||(n.$from.parent.inlineContent||(o=ra(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=ra(e,n.to))),e.docView.setSelection(i,s,e,t),oa&&(o&&sa(o),r&&sa(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{ta(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const oa=ns||es&&ts<63;function ra(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(ns&&r&&"false"==r.contentEditable)return ia(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return ia(r);if(i)return ia(i)}}function ia(e){return e.contentEditable="true",ns&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function sa(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function aa(e,t){if(t instanceof qo){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(la(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else la(e)}function la(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function ca(e,t,n,o){return e.someProp("createSelectionBetween",o=>o(e,t,n))||Fo.between(t,n,o)}function da(e){return!(e.editable&&!e.hasFocus())&&ua(e)}function ua(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function pa(e,t){let{$anchor:n,$head:o}=e.selection,r=t>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return i&&jo.findFrom(i,t)}function ha(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function fa(e,t,n){let o=e.state.selection;if(!(o instanceof Fo)){if(o instanceof qo&&o.node.isInline)return ha(e,new Fo(t>0?o.$to:o.$from));{let n=pa(e.state,t);return!!n&&ha(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+r.nodeSize*(t<0?-1:1));return ha(e,new Fo(o.$anchor,i))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=pa(e.state,t);return!!(n&&n instanceof qo)&&ha(e,n)}if(!(is&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=t<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(qo.isSelectable(i)?ha(e,new qo(t<0?e.state.doc.resolve(r.pos-i.nodeSize):r)):!!ls&&ha(e,new Fo(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function ma(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ga(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function va(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=!1;Yi&&1==n.nodeType&&o<ma(n)&&ga(n.childNodes[o],-1)&&(s=!0);for(;;)if(o>0){if(1!=n.nodeType)break;{let e=n.childNodes[o-1];if(ga(e,-1))r=n,i=--o;else{if(3!=e.nodeType)break;n=e,o=n.nodeValue.length}}}else{if(ya(n))break;{let t=n.previousSibling;for(;t&&ga(t,-1);)r=n.parentNode,i=Ai(t),t=t.previousSibling;if(t)n=t,o=ma(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}s?wa(e,n,o):r&&wa(e,r,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=ma(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!ga(n.childNodes[o],1))break;r=n,i=++o}else{if(ya(n))break;{let t=n.nextSibling;for(;t&&ga(t,1);)r=t.parentNode,i=Ai(t)+1,t=t.nextSibling;if(t)n=t,o=0,s=ma(n);else{if(n=n.parentNode,n==e.dom)break;o=s=0}}}r&&wa(e,r,i)}(e)}function ya(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function wa(e,t,n){if(3!=t.nodeType){let e,o;(o=function(e,t){for(;e&&t==e.childNodes.length&&!Hi(e);)t=Ai(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(e=function(e,t){for(;e&&!t&&!Hi(e);)t=Ai(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let o=e.domSelection();if(!o)return;if(Fi(o)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),o.removeAllRanges(),o.addRange(e)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout(()=>{e.state==r&&na(e)},50)}function ba(e,t){let n=e.state.doc.resolve(t);if(!es&&!ss&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ka(e,t,n){let o=e.state.selection;if(o instanceof Fo&&!o.empty||n.indexOf("s")>-1)return!1;if(is&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=pa(e.state,t);if(n&&n instanceof qo)return ha(e,n)}if(!r.parent.inlineContent){let n=t<0?r:i,s=o instanceof Uo?jo.near(n,t):jo.findFrom(n,t);return!!s&&ha(e,s)}return!1}function Ca(e,t){if(!(e.state.selection instanceof Fo))return!0;let{$head:n,$anchor:o,empty:r}=e.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=e.state.tr;return t<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),e.dispatch(o),!0}return!1}function xa(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Na(e,t){let n=t.keyCode,o=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||is&&72==n&&"c"==o)return Ca(e,-1)||va(e,-1);if(46==n&&!t.shiftKey||is&&68==n&&"c"==o)return Ca(e,1)||va(e,1);if(13==n||27==n)return!0;if(37==n||is&&66==n&&"c"==o){let t=37==n?"ltr"==ba(e,e.state.selection.from)?-1:1:-1;return fa(e,t,o)||va(e,t)}if(39==n||is&&70==n&&"c"==o){let t=39==n?"ltr"==ba(e,e.state.selection.from)?1:-1:1;return fa(e,t,o)||va(e,t)}return 38==n||is&&80==n&&"c"==o?ka(e,-1,o)||va(e,-1):40==n||is&&78==n&&"c"==o?function(e){if(!ns||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;xa(e,n,"true"),setTimeout(()=>xa(e,n,"false"),20)}return!1}(e)||ka(e,1,o)||va(e,1):o==(is?"m":"c")&&(66==n||73==n||89==n||90==n)}function Sa(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:o,openStart:r,openEnd:i}=t;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let e=o.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),o=e.content}let s=e.someProp("clipboardSerializer")||zn.fromSchema(e.state.schema),a=Pa(),l=a.createElement("div");l.appendChild(s.serializeFragment(o,{document:a}));let c,d=l.firstChild,u=0;for(;d&&1==d.nodeType&&(c=Aa[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Oa(e,t,n,o,r){let i,s,a=r.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(o||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||o,e)}),a)return s=new Kt(Ht.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,r,o,e));if(n)s=n;else{let n=r.marks(),{schema:o}=e.state,s=zn.fromSchema(o);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(o.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,o=Pa().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&Aa[r[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;La||(La=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return La.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;return o}(n),ls&&function(e){let t=e.querySelectorAll(es?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||An.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:r,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ea.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(e,t){if(!e.size)return e;let n,o=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:r,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=o.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;r=Ht.from(t.create(n[e+1],r)),i++,s++}return new Kt(r,i,s)}(Ia(s,+d[1],+d[2]),d[4]);else if(s=Kt.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o,r=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=r.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&o.length&&_a(n,o,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Ta(i[i.length-1],o.length));let t=Ma(e,n);i.push(t),r=r.matchType(t.type),o=n}}),i)return Ht.from(i)}return e}(s.content,r),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=Ia(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const Ea=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Ma(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,Ht.from(e));return e}function _a(e,t,n,o,r){if(r<e.length&&r<t.length&&e[r]==t[r]){let i=_a(e,t,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==e.length-1?n.type:e[r+1]))return o.copy(o.content.append(Ht.from(Ma(n,e,r+1))))}}function Ta(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Ta(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(Ht.empty,!0);return e.copy(n.append(o))}function Da(e,t,n,o,r,i){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),r<o-1&&(a=Da(a,t,n,o,r+1,i)),r>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=r).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(Ht.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function Ia(e,t,n){return t<e.openStart&&(e=new Kt(Da(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Kt(Da(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Aa={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ra=null;function Pa(){return Ra||(Ra=document.implementation.createHTMLDocument("title"))}let La=null;const Va={},ja={},$a={touchstart:!0,touchmove:!0};class Ba{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ha(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Fa(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>za(e,t))})}function za(e,t){return e.someProp("handleDOMEvents",n=>{let o=n[t.type];return!!o&&(o(e,t)||t.defaultPrevented)})}function qa(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Wa(e){return{left:e.clientX,top:e.clientY}}function Ua(e,t,n,o,r){if(-1==o)return!1;let i=e.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),r,!0):t(e,n,i.node(o),i.before(o),r,!1)))return!0;return!1}function Ka(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function Ga(e,t,n,o,r){return Ua(e,"handleClickOn",t,n,o)||e.someProp("handleClick",n=>n(e,t,o))||(r?function(e,t){if(-1==t)return!1;let n,o,r=e.state.selection;r instanceof qo&&(n=r.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(qo.isSelectable(t)){o=n&&r.$from.depth>0&&e>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(e);break}}return null!=o&&(Ka(e,qo.create(e.state.doc,o)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&qo.isSelectable(o))&&(Ka(e,new qo(n)),!0)}(e,n))}function Ja(e,t,n,o){return Ua(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",n=>n(e,t,o))}function Za(e,t,n,o){return Ua(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",n=>n(e,t,o))||function(e,t,n){if(0!=n.button)return!1;let o=e.state.doc;if(-1==t)return!!o.inlineContent&&(Ka(e,Fo.create(o,0,o.content.size)),!0);let r=o.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),i=r.before(t);if(n.inlineContent)Ka(e,Fo.create(o,i+1,i+1+n.content.size));else{if(!qo.isSelectable(n))continue;Ka(e,qo.create(o,i))}return!0}}(e,n,o)}function Xa(e){return il(e)}ja.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!el(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!as||!es||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!rs||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Na(e,n)?n.preventDefault():Ha(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},ja.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ja.keypress=(e,t)=>{let n=t;if(el(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||is&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof Fo&&o.$from.sameParent(o.$to))){let t=String.fromCharCode(n.charCode),r=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,o.$from.pos,o.$to.pos,t,r))||e.dispatch(r()),n.preventDefault()}};const Ya=is?"metaKey":"ctrlKey";Va.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=Xa(e),r=Date.now(),i="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}(n,e.input.lastClick)&&!n[Ya]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=e.posAtCoords(Wa(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Qa(e,s,n,!!o)):("doubleClick"==i?Ja:Za)(e,s.pos,s.inside,n)?n.preventDefault():Ha(e,"pointer"))};class Qa{constructor(e,t,n,o){let r,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Ya],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(r.type.spec.draggable&&!1!==r.type.spec.selectable||l instanceof qo&&l.from<=i&&l.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Yi||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ha(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>na(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Wa(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ha(this.view,"pointer"):Ga(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||ns&&this.mightDrag&&!this.mightDrag.node.isAtom||es&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ka(this.view,jo.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ha(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ha(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function el(e,t){return!!e.composing||!!(ns&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Va.touchstart=e=>{e.input.lastTouch=Date.now(),Xa(e),Ha(e,"pointer")},Va.touchmove=e=>{e.input.lastTouch=Date.now(),Ha(e,"pointer")},Va.contextmenu=e=>Xa(e);const tl=as?5e3:-1;function nl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>il(e),t))}function ol(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function rl(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Bi(e=e.childNodes[t-1])}else{if(!e.parentNode||Hi(e))return null;t=Ai(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),o=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Hi(e))return null;t=Ai(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let t=o.pmViewDesc,r=e.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!t||!t.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return o}}return n||o}function il(e,t=!1){if(!(as&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ol(e),t||e.docView&&e.docView.dirty){let n=ea(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}ja.compositionstart=ja.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Fo&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||es&&ss&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let o=t.childNodes[n];return 1==o.nodeType&&"false"==o.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),il(e,!0),e.markCursor=null;else if(il(e,!t.selection.empty),Yi&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,o=t.focusOffset;n&&1==n.nodeType&&0!=o;){let t=o<0?n.lastChild:n.childNodes[o-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,o=-1}}e.input.composing=!0}nl(e,tl)},ja.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,nl(e,20))};const sl=Zi&&Xi<15||rs&&cs<604;function al(e,t,n,o,r){let i=Oa(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,r,i||Kt.empty)))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=s?e.state.tr.replaceSelectionWith(s,o):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ll(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Va.copy=ja.cut=(e,t)=>{let n=t,o=e.state.selection,r="cut"==n.type;if(o.empty)return;let i=sl?null:n.clipboardData,s=o.content(),{dom:a,text:l}=Sa(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ja.paste=(e,t)=>{let n=t;if(e.composing&&!as)return;let o=sl?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;o&&al(e,ll(o),o.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?al(e,o.value,null,r,t):al(e,o.textContent,o.innerHTML,r,t)},50)}(e,n)};class cl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const dl=is?"altKey":"ctrlKey";function ul(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[dl]}Va.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=e.state.selection,s=i.empty?null:e.posAtCoords(Wa(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof qo?i.to-1:i.to));else if(o&&o.mightDrag)r=qo.create(e.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(r=qo.create(e.state.doc,t.posBefore))}let a=(r||e.state.selection).content(),{dom:l,text:c,slice:d}=Sa(e,a);(!n.dataTransfer.files.length||!es||ts>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(sl?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",sl||n.dataTransfer.setData("text/plain",c),e.dragging=new cl(d,ul(e,n),r)},Va.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ja.dragover=ja.dragenter=(e,t)=>t.preventDefault(),ja.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let o=e.posAtCoords(Wa(t));if(!o)return;let r=e.state.doc.resolve(o.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Oa(e,ll(t.dataTransfer),sl?null:t.dataTransfer.getData("text/html"),!1,r);let s=!(!n||!ul(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||Kt.empty,s)))return void t.preventDefault();if(!i)return;t.preventDefault();let a=i?function(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=o.depth;t>=0;t--){let n=t==o.depth?0:o.pos<=(o.start(t+1)+o.end(t+1))/2?-1:1,i=o.index(t)+(n>0?1:0),s=o.node(t),a=!1;if(1==e)a=s.canReplace(i,i,r);else{let e=s.contentMatchAt(i).findWrapping(r.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?o.pos:n<0?o.before(t+1):o.after(t+1)}return null}(e.state.doc,r.pos,i):r.pos;null==a&&(a=r.pos);let l=e.state.tr;if(s){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,u=l.doc;d?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i);if(l.doc.eq(u))return;let p=l.doc.resolve(c);if(d&&qo.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new qo(p));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,o,r)=>t=r),l.setSelection(ca(e,p,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Va.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&na(e)},20))},Va.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Va.beforeinput=(e,t)=>{if(es&&as&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,zi(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in ja)Va[e]=ja[e];function pl(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class hl{constructor(e,t){this.toDOM=e,this.spec=t||yl,this.side=this.spec.side||0}map(e,t,n,o){let{pos:r,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new gl(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof hl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class fl{constructor(e,t){this.attrs=e,this.spec=t||yl}map(e,t,n,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new gl(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof fl&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}static is(e){return e.type instanceof fl}destroy(){}}class ml{constructor(e,t){this.attrs=e,this.spec=t||yl}map(e,t,n,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=r.pos?null:new gl(r.pos-n,i.pos-n,this)}valid(e,t){let n,{index:o,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(o)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof ml&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}destroy(){}}class gl{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new gl(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new gl(e,e,new hl(t,n))}static inline(e,t,n,o){return new gl(e,t,new fl(n,o))}static node(e,t,n,o){return new gl(e,t,new ml(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof fl}get widget(){return this.type instanceof hl}}const vl=[],yl={};class wl{constructor(e,t){this.local=e.length?e:vl,this.children=t.length?t:vl}static create(e,t){return t.length?Sl(t,e,0,yl):bl}find(e,t,n){let o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,n),o}findInner(e,t,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,o+s,r)}}map(e,t,n){return this==bl||0==e.maps.length?this:this.mapInner(e,t,0,0,n||yl)}mapInner(e,t,n,o,r){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,o,r,i,s){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let o=0;n.maps[e].forEach((e,n,r,i)=>{let s=i-r-(n-e);for(let r=0;r<a.length;r+=3){let i=a[r+1];if(i<0||e>i+t-o)continue;let l=a[r]+t-o;n>=l?a[r+1]=e<=l?-2:-1:e>=t&&s&&(a[r]+=s,a[r+1]+=s)}o+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-r;if(d<0||d>=o.content.size){l=!0;continue}let u=n.map(e[t+1]+i,-1)-r,{index:p,offset:h}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&h==d&&h+f.nodeSize==u){let o=a[t+2].mapInner(n,f,c+1,e[t]+i+1,s);o!=bl?(a[t]=d,a[t+1]=u,a[t+2]=o):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,o,r,i,s){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(o,r,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+i+1);return n}(a,e,t,n,r,i,s),c=Sl(l,o,0,s);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new wl(t.sort(Ol),a)}(this.children,i||[],e,t,n,o,r):i?new wl(i.sort(Ol),vl):bl}add(e,t){return t.length?this==bl?wl.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let o,r=0;e.forEach((e,i)=>{let s,a=i+n;if(s=xl(t,e,a)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(e,s,a+1):o.splice(r,0,i,i+e.nodeSize,Sl(s,e,a+1,yl)),r+=3}});let i=Cl(r?Nl(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new wl(i.length?this.local.concat(i).sort(Ol):this.local,o||this.children)}remove(e){return 0==e.length||this==bl?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+t,s=n[o+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[o+2].removeInner(r,i+1);a!=bl?n[o+2]=a:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<o.length;e++)o[e].eq(n,t)&&(o==this.local&&(o=this.local.slice()),o.splice(e--,1));return n==this.children&&o==this.local?this:o.length||n.length?new wl(o,n):bl}forChild(e,t){if(this==bl)return this;if(t.isLeaf)return wl.empty;let n,o;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,i=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>r&&t.type instanceof fl){let e=Math.max(r,t.from)-r,n=Math.min(i,t.to)-r;e<n&&(o||(o=[])).push(t.copy(e,n))}}if(o){let e=new wl(o.sort(Ol),vl);return n?new kl([e,n]):e}return n||bl}eq(e){if(this==e)return!0;if(!(e instanceof wl)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return El(this.localsInner(e))}localsInner(e){if(this==bl)return vl;if(e.inlineContent||!this.local.some(fl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof fl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}wl.empty=new wl([],[]),wl.removeOverlap=El;const bl=wl.empty;class kl{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,yl));return kl.from(n)}forChild(e,t){if(t.isLeaf)return wl.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=bl&&(r instanceof kl?n=n.concat(r.members):n.push(r))}return kl.from(n)}eq(e){if(!(e instanceof kl)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?El(n?t:t.sort(Ol)):vl}static from(e){switch(e.length){case 0:return bl;case 1:return e[0];default:return new kl(e.every(e=>e instanceof wl)?e:e.reduce((e,t)=>e.concat(t instanceof wl?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Cl(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let r=e[o];n.push(new gl(r.from+t,r.to+t,r.type))}return n}function xl(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,r=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<o&&((r||(r=[])).push(t),e[i]=null);return r}function Nl(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Sl(e,t,n,o){let r=[],i=!1;t.forEach((t,s)=>{let a=xl(e,t,s+n);if(a){i=!0;let e=Sl(a,t,n+s+1,o);e!=bl&&r.push(s,s+t.nodeSize,e)}});let s=Cl(i?Nl(e):e,-n).sort(Ol);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(o.onRemove&&o.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new wl(s,r):bl}function Ol(e,t){return e.from-t.from||e.to-t.to}function El(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let r=n+1;r<t.length;r++){let i=t[r];if(i.from!=o.from){i.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,i.from),Ml(t,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(t==e&&(t=e.slice()),t[r]=i.copy(i.from,o.to),Ml(t,r+1,i.copy(o.to,i.to)))}}return t}function Ml(e,t,n){for(;t<e.length&&Ol(n,e[t])>0;)t++;e.splice(t,0,n)}function _l(e){let t=[];return e.someProp("decorations",n=>{let o=n(e.state);o&&o!=bl&&t.push(o)}),e.cursorWrapper&&t.push(wl.create(e.state.doc,[e.cursorWrapper.deco])),kl.from(t)}const Tl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dl=Zi&&Xi<=11;class Il{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Al{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Il,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Zi&&Xi<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():ns&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Dl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Tl)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(da(this.view)){if(this.suppressingSelectionUpdates)return na(this.view);if(Zi&&Xi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=Ri(t))n.add(t);for(let o=e.anchorNode;o;o=Ri(o))if(n.has(o)){t=o;break}let o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&da(e)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(!a.some(e=>"BR"==e.nodeName)||8!=e.input.lastKeyCode&&46!=e.input.lastKeyCode){if(Yi&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of t){let t=o.parentNode;!t||"LI"!=t.nodeName||n&&Vl(e,n)==t||o.remove()}}}}else for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}let l=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fi(n)&&(l=ea(e))&&l.eq(jo.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,na(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,i),function(e){if(Rl.has(e))return;if(Rl.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Yi,Pl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Pl=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:o,focusOffset:r}=e.domSelectionRange();for(let i of t)if("TR"==(null===(n=i.parentNode)||void 0===n?void 0:n.nodeName)){let t=i.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),o==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}(e,a)),this.handleDOMChange(r,i,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||na(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let o=e.addedNodes[n];t.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,r=e.nextSibling;if(Zi&&Xi<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==e.target?Ai(o)+1:0,s=n.localPosFromDOM(e.target,i,-1),a=r&&r.parentNode==e.target?Ai(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Rl=new WeakMap,Pl=!1;function Ll(e,t){let n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Vi(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function Vl(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function jl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(ns&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||ns&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const $l=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Bl(e,t,n,o,r){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ea(e,t);if(n&&!e.state.selection.eq(n)){if(es&&as&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))))return;let o=e.state.tr.setSelection(n);"pointer"==t?o.setMeta("pointer",!0):"key"==t&&o.scrollIntoView(),i&&o.setMeta("composition",i),e.dispatch(o)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(n);t=s.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,c,d=e.state.selection,u=function(e,t,n){let o,{node:r,fromOffset:i,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],Fi(c)||o.push({node:c.focusNode,offset:c.focusOffset})),es&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let u=e.state.doc,p=e.someProp("domParser")||An.fromSchema(e.state.schema),h=u.resolve(a),f=null,m=p.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:o,ruleFromNode:jl,context:h});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,h=p.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,c="end"):(l=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,o,r){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r){o-=s+Math.max(0,i-Math.min(s,a))-i}if(s<i&&e.size<t.size){let e=o<=i&&o>=s?i-o:0;i-=e,i&&i<t.size&&zl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),a=i+(a-s),s=i}else if(a<i){let t=o<=i&&o>=a?i-o:0;i-=t,i&&i<e.size&&zl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(h.content,u.doc.content,u.from,l,c);if(f&&e.input.domChangeCount++,(rs&&e.input.lastIOSEnter>Date.now()-225||as)&&r.some(e=>1==e.nodeType&&!$l.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(o&&d instanceof Fo&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=Hl(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof Fo&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),Zi&&Xi<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>u.from&&"  "==u.doc.textBetween(f.start-u.from-1,f.start-u.from+1)&&(f.start--,f.endA--,f.endB--);let m=u.doc.resolveNoCache(f.start-u.from),g=u.doc.resolveNoCache(f.endB-u.from),v=p.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA;if((rs&&e.input.lastIOSEnter>Date.now()-225&&(!y||r.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&m.pos<u.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(u.doc.textBetween(m.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,o,r){if(n-t<=r.pos-o.pos||Fl(o,!0,!1)<r.pos)return!1;let i=e.resolve(t);if(!o.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Fl(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Fl(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(p,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",t=>t(e,zi(8,"Backspace"))))return void(as&&es&&e.domObserver.suppressSelectionUpdates());es&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),as&&!y&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==f.endA&&(f.endB-=2,g=u.doc.resolveNoCache(f.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,zi(13,"Enter"))})},20));let w,b=f.start,k=f.endA,C=t=>{let n=t||e.state.tr.replace(b,k,u.doc.slice(f.start-u.from,f.endB-u.from));if(u.sel){let t=Hl(e,n.doc,u.sel);t&&!(es&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(k)-1)||Zi&&t.empty&&t.head==b)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(y)if(m.pos==g.pos){Zi&&Xi<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>na(e),20));let t=C(e.state.tr.delete(b,k)),n=p.resolve(f.start).marksAcross(p.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(w=function(e,t){let n,o,r,i=e.firstChild.marks,s=t.firstChild.marks,a=i,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<i.length;e++)l=i[e].removeFromSet(l);if(1==a.length&&0==l.length)o=a[0],n="add",r=e=>e.mark(o.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;o=l[0],n="remove",r=e=>e.mark(o.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(r(t.child(e)));if(Ht.from(c).eq(e))return{mark:o,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start())))){let t=C(e.state.tr);"add"==w.type?t.addMark(b,k,w.mark):t.removeMark(b,k,w.mark),e.dispatch(t)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset),n=()=>C(e.state.tr.insertText(t,b,k));e.someProp("handleTextInput",o=>o(e,b,k,t,n))||e.dispatch(n())}else e.dispatch(C());else e.dispatch(C())}function Hl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:ca(e,t.resolve(n.anchor),t.resolve(n.head))}function Fl(e,t,n){let o=e.depth,r=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,r++,t=!1;if(n){let t=e.node(o).maybeChild(e.indexAfter(o));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function zl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class ql{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ba,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Jl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Kl(this),Ul(this),this.nodeViews=Gl(this),this.docView=js(this.state.doc,Wl(this),_l(this),this.dom,this),this.domObserver=new Al(this,(e,t,n,o)=>Bl(this,e,t,n,o)),this.domObserver.start(),function(e){for(let t in Va){let n=Va[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!qa(e,t)||za(e,t)||!e.editable&&t.type in ja||n(e,t)},$a[t]?{passive:!0}:void 0)}ns&&e.dom.addEventListener("input",()=>null),Fa(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Fa(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Jl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let o=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(ol(this),i=!0),this.state=e;let s=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Gl(this);(function(e,t){let n=0,o=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let e in t)o++;return n!=o})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Fa(this),this.editable=Kl(this),Ul(this);let a=_l(this),l=Wl(this),c=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(o.selection)||(i=!0);let u="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,o=e.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=e.root.elementFromPoint(i,s);if(!o||o==e.dom||!e.dom.contains(o))continue;let a=o.getBoundingClientRect();if(a.top>=r-20){t=o,n=a.top;break}}return{refDOM:t,refTop:n,stack:fs(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(Zi||es)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(o.selection,e.selection);if(d){let n=es?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=rl(this)),!r&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=js(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Vi(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?na(this,t):(aa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;ms(n,0==o?0:o-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof qo){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&hs(this,t.getBoundingClientRect(),e)}else hs(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,o=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(o=e)}this.dragging=new cl(e.slice,e.move,o<0?void 0:qo.create(this.state.doc,o))}someProp(e,t){let n,o=this._props&&this._props[e];if(null!=o&&(n=t?t(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(Zi){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(gs)return e.focus(gs);let t=fs(e);e.focus(null==gs?{get preventScroll(){return gs={preventScroll:!0},!0}}:void 0),gs||(gs=!1,ms(t,0))}(this.dom),na(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return bs(this,e)}coordsAtPos(e,t=1){return Ns(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let o=this.docView.posFromDOM(e,t,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Is(this,t||this.state,e)}pasteHTML(e,t){return al(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return al(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Sa(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_l(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Pi=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){za(e,t)||!Va[t.type]||!e.editable&&t.type in ja||Va[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?ns&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Ll(e,n)}let n;function o(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?Ll(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Wl(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[gl.node(0,e.state.doc.content.size,t)]}function Ul(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:gl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Kl(e){return!e.someProp("editable",t=>!1===t(e.state))}function Gl(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Jl(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function Zl(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}ql.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};var Xl={text:(e,t,n,o)=>{const r=e.value;return/^[^*_\\]*\s+$/.test(r)?r:n.safe(r,{...o,encode:[]})},strong:(e,t,n,o)=>{const r=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(o);let a=s.move(r+r);return a+=s.move(n.containerPhrasing(e,{before:a,after:r,...s.current()})),a+=s.move(r+r),i(),a},emphasis:(e,t,n,o)=>{const r=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(o);let a=s.move(r);return a+=s.move(n.containerPhrasing(e,{before:a,after:r,...s.current()})),a+=s.move(r),i(),a}},Yl=Tt({},"editorView"),Ql=Tt({},"editorState"),ec=Tt([],"initTimer"),tc=Tt({},"editor"),nc=Tt([],"inputRules"),oc=Tt([],"prosePlugins"),rc=Tt([],"remarkPlugins"),ic=Tt([],"nodeView"),sc=Tt([],"markView"),ac=Tt(Y().use(Q).use(Vt),"remark"),lc=Tt({handlers:Xl,encode:[]},"remarkStringifyOptions"),cc=Lt("ConfigReady");var dc=Lt("InitReady");function uc(e){const t=t=>(t.inject(tc,e).inject(oc,[]).inject(rc,[]).inject(nc,[]).inject(ic,[]).inject(sc,[]).inject(lc,{handlers:Xl,encode:[]}).inject(ac,Y().use(Q).use(Vt)).inject(ec,[cc]).record(dc),async()=>{await t.waitTimers(ec);const e=t.get(lc);return t.set(ac,Y().use(Q).use(Vt,e)),t.done(dc),()=>{t.remove(tc).remove(oc).remove(rc).remove(nc).remove(ic).remove(sc).remove(lc).remove(ac).remove(ec).clearTimer(dc)}});return Zl(t,{displayName:"Init"}),t}var pc=Lt("SchemaReady"),hc=Tt([],"schemaTimer"),fc=Tt({},"schema"),mc=Tt([],"nodes"),gc=Tt([],"marks");function vc(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var yc=e=>(e.inject(fc,{}).inject(mc,[]).inject(gc,[]).inject(hc,[dc]).record(pc),async()=>{await e.waitTimers(hc);const t=e.get(ac),n=e.get(rc).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(ac,n);const o=new Dn({nodes:Object.fromEntries(e.get(mc).map(([e,t])=>[e,vc(t)])),marks:Object.fromEntries(e.get(gc).map(([e,t])=>[e,vc(t)]))});return e.set(fc,o),e.done(pc),()=>{e.remove(fc).remove(mc).remove(gc).remove(hc).clearTimer(pc)}});Zl(yc,{displayName:"Schema"});var wc=class{constructor(){this.setCtx=e=>{this.#R=e},this.chain=()=>{if(null==this.#R)throw St();const e=this.#R,t=[],n=this.get.bind(this),o={run:()=>{const n=Sr(...t),o=e.get(Yl);return n(o.state,o.dispatch,o)},inline:e=>(t.push(e),o),pipe:function(e,r){const i=n(e);return t.push(i(r)),o}.bind(this)};return o}}#r=new Et;#R=null;get ctx(){return this.#R}create(e,t){const n=e.create(this.#r.sliceMap);return n.set(t),n}get(e){return this.#r.get(e).get()}remove(e){return this.#r.remove(e)}call(e,t){if(null==this.#R)throw St();const n=this.get(e)(t),o=this.#R.get(Yl);return n(o.state,o.dispatch,o)}inline(e){if(null==this.#R)throw St();const t=this.#R.get(Yl);return e(t.state,t.dispatch,t)}};var bc=Tt(new wc,"commands"),kc=Tt([pc],"commandsTimer"),Cc=Lt("CommandsReady"),xc=e=>{const t=new wc;return t.setCtx(e),e.inject(bc,t).inject(kc,[pc]).record(Cc),async()=>(await e.waitTimers(kc),e.done(Cc),()=>{e.remove(bc).remove(kc).clearTimer(Cc)})};Zl(xc,{displayName:"Commands"});var Nc=class{constructor(){this.setCtx=e=>{this.#R=e},this.add=e=>(this.#P.push(e),()=>{this.#P=this.#P.filter(t=>t!==e)}),this.addObjectKeymap=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){const o={key:e,onRun:()=>n};this.#P.push(o),t.push(()=>{this.#P=this.#P.filter(e=>e!==o)})}else this.#P.push(n),t.push(()=>{this.#P=this.#P.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{const e=function(e){return e.Backspace=Sr(Ir,ar,dr,pr),e}(Tr);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#P.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{const n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,o)=>{const r=this.#R;if(null==r)throw Ct();return Sr(...n.map(e=>e.onRun(r)))(e,t,o)}]}))}}#R=null;#P=[];get ctx(){return this.#R}},Sc=Tt(new Nc,"keymap"),Oc=Tt([pc],"keymapTimer"),Ec=Lt("KeymapReady"),Mc=e=>{const t=new Nc;return t.setCtx(e),e.inject(Sc,t).inject(Oc,[pc]).record(Ec),async()=>(await e.waitTimers(Oc),e.done(Ec),()=>{e.remove(Sc).remove(Oc).clearTimer(Ec)})},_c=Lt("ParserReady"),Tc=()=>{throw Ct()},Dc=Tt(Tc,"parser"),Ic=Tt([],"parserTimer"),Ac=e=>(e.inject(Dc,Tc).inject(Ic,[pc]).record(_c),async()=>{await e.waitTimers(Ic);const t=e.get(ac),n=e.get(fc);return e.set(Dc,Ti.create(n,t)),e.done(_c),()=>{e.remove(Dc).remove(Ic).clearTimer(_c)}});Zl(Ac,{displayName:"Parser"});var Rc=Lt("SerializerReady"),Pc=Tt([],"serializerTimer"),Lc=()=>{throw Ct()},Vc=Tt(Lc,"serializer"),jc=e=>(e.inject(Vc,Lc).inject(Pc,[pc]).record(Rc),async()=>{await e.waitTimers(Pc);const t=e.get(ac),n=e.get(fc);return e.set(Vc,Ii.create(n,t)),e.done(Rc),()=>{e.remove(Vc).remove(Pc).clearTimer(Rc)}});Zl(jc,{displayName:"Serializer"});var $c=Tt("","defaultValue"),Bc=Tt(e=>e,"stateOptions"),Hc=Tt([],"editorStateTimer"),Fc=Lt("EditorStateReady");function zc(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return An.fromSchema(n).parse(e.dom);if("json"===e.type)return pn.fromJSON(n,e.value);throw o=e,new wt(yt.docTypeError,`Doc type error, unsupported type: ${kt(o)}`);var o}var qc=new sr("MILKDOWN_STATE_TRACKER"),Wc=e=>(e.inject($c,"").inject(Ql,{}).inject(Bc,e=>e).inject(Hc,[_c,Rc,Cc,Ec]).record(Fc),async()=>{await e.waitTimers(Hc);const t=e.get(fc),n=e.get(Dc),o=e.get(nc),r=e.get(Bc),i=e.get(oc),s=zc(e.get($c),n,t),a=e.get(Sc),l=a.addBaseKeymap(),c=[...i,new or({key:qc,state:{init:()=>{},apply:(t,n,o,r)=>{e.set(Ql,r)}}}),oi({rules:o}),Si(a.build())];e.set(oc,c);const d=r({schema:t,doc:s,plugins:c}),u=tr.create(d);return e.set(Ql,u),e.done(Fc),()=>{l(),e.remove($c).remove(Ql).remove(Bc).remove(Hc).clearTimer(Fc)}});Zl(Wc,{displayName:"EditorState"});var Uc=Tt([],"pasteRule"),Kc=Tt([pc],"pasteRuleTimer"),Gc=Lt("PasteRuleReady"),Jc=e=>(e.inject(Uc,[]).inject(Kc,[pc]).record(Gc),async()=>(await e.waitTimers(Kc),e.done(Gc),()=>{e.remove(Uc).remove(Kc).clearTimer(Gc)}));Zl(Jc,{displayName:"PasteRule"});var Zc=Lt("EditorViewReady"),Xc=Tt([],"editorViewTimer"),Yc=Tt({},"editorViewOptions"),Qc=Tt(null,"root"),ed=Tt(null,"rootDOM"),td=Tt({},"rootAttrs");var nd=new sr("MILKDOWN_VIEW_CLEAR"),od=e=>(e.inject(Qc,document.body).inject(Yl,{}).inject(Yc,{}).inject(ed,null).inject(td,{}).inject(Xc,[Fc,Gc]).record(Zc),async()=>{await e.wait(dc);const t=e.get(Qc)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(oc,t=>[new or({key:nd,view:t=>{const o=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(ed,n);const o=t.get(td);return Object.entries(o).forEach(([e,t])=>n.setAttribute(e,t)),n}(n,e):void 0;return(()=>{if(o&&n){const e=t.dom;n.replaceChild(o,e),o.appendChild(e)}})(),{destroy:()=>{o?.parentNode&&o?.parentNode.replaceChild(t.dom,o),o?.remove()}}}}),...t]),await e.waitTimers(Xc);const o=e.get(Ql),r=e.get(Yc),i=new ql(n,{state:o,nodeViews:Object.fromEntries(e.get(ic)),markViews:Object.fromEntries(e.get(sc)),transformPasted:(t,n,o)=>(e.get(Uc).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,o)}),t),...r});var s;return(s=i.dom).classList.add("editor"),s.setAttribute("role","textbox"),e.set(Yl,i),e.done(Zc),()=>{i?.destroy(),e.remove(Qc).remove(Yl).remove(Yc).remove(ed).remove(td).remove(Xc).clearTimer(Zc)}});Zl(od,{displayName:"EditorView"});var rd=function(e){return e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e}({}),id=class e{constructor(){this.enableInspector=(e=!0)=>(this.#L=e,this),this.onStatusChange=e=>(this.#V=e,this),this.config=e=>(this.#j.push(e),this),this.removeConfig=e=>(this.#j=this.#j.filter(t=>t!==e),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(e=>{this.#$.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#g===rd.Created&&this.#B(t,this.#$),this},this.remove=async e=>this.#g===rd.OnCreate?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#H([e].flat(),!0),this),this.create=async()=>(this.#g===rd.OnCreate||(this.#g===rd.Created&&await this.destroy(),this.#F(rd.OnCreate),this.#z(),this.#B([...this.#$.keys()],this.#$),await Promise.all([this.#q(this.#W),this.#q(this.#$)].flat()),this.#F(rd.Created)),this),this.destroy=async(e=!1)=>this.#g===rd.Destroyed||this.#g===rd.OnDestroy?this:this.#g===rd.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#j=[]),this.#F(rd.OnDestroy),await this.#H([...this.#$.keys()],e),await this.#U(),this.#F(rd.Destroyed),this),this.action=e=>e(this.#R),this.inspect=()=>this.#L?[...this.#W.values(),...this.#$.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>Boolean(e)):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#L=!1;#g=rd.Idle;#j=[];#V=()=>{};#r=new Et;#i=new At;#$=new Map;#W=new Map;#R=new It(this.#r,this.#i);#z=()=>{const e=function(e){const t=t=>(t.record(cc),async()=>(await e(t),t.done(cc),()=>{t.clearTimer(cc)}));return Zl(t,{displayName:"Config"}),t}(async e=>{await Promise.all(this.#j.map(t=>Promise.resolve(t(e))))}),t=[yc,Ac,jc,xc,Mc,Jc,Wc,od,uc(this),e];this.#B(t,this.#W)};#B=(e,t)=>{e.forEach(e=>{const n=this.#R.produce(this.#L?e.meta:void 0),o=e(n);t.set(e,{ctx:n,handler:o,cleanup:void 0})})};#H=(e,t=!1)=>Promise.all([e].flat().map(async e=>{const n=this.#$.get(e)?.cleanup;return t?this.#$.delete(e):this.#$.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof n?n():n}));#U=async()=>{await Promise.all([...this.#W.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#W.clear()};#F=e=>{this.#g=e,this.#V(e)};#q=e=>[...e.entries()].map(async([t,n])=>{const{ctx:o,handler:r}=n;if(!r)return;const i=await r();e.set(t,{ctx:o,handler:r,cleanup:i})});get ctx(){return this.#R}get status(){return this.#g}};let sd=e=>crypto.getRandomValues(new Uint8Array(e)),ad=(e,t=21)=>((e,t,n)=>{let o=(2<<Math.log2(e.length-1))-1,r=-~(1.6*o*t/e.length);return(i=t)=>{let s="";for(;;){let t=n(r),a=0|r;for(;a--;)if(s+=e[t[a]&o]||"",s.length>=i)return s}}})(e,0|t,sd);function ld(e,t){const n=function(e="cmdKey"){return Tt(()=>()=>!1,e)}(e),o=r=>async()=>{o.key=n,await r.wait(Cc);const i=t(r);return r.get(bc).create(n,i),o.run=t=>r.get(bc).call(e,t),()=>{r.get(bc).remove(n)}};return o}function cd(e){const t=n=>async()=>{await n.wait(pc);const o=e(n);return n.update(nc,e=>[...e,o]),t.inputRule=o,()=>{n.update(nc,e=>e.filter(e=>e!==o))}};return t}function dd(e,t){const n=o=>async()=>{const r=t(o);return o.update(gc,t=>[...t.filter(t=>t[0]!==e),[e,r]]),n.id=e,n.schema=r,()=>{o.update(gc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(fc).marks[e];if(!n)throw o=e,new wt(yt.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${o}" in schema.`);var o;return n},n}function ud(e,t){const n=o=>async()=>{const r=t(o);return o.update(mc,t=>[...t.filter(t=>t[0]!==e),[e,r]]),n.id=e,n.schema=r,()=>{o.update(mc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(fc).nodes[e];if(!n)throw Ot(e);return n},n}function pd(e){let t;const n=n=>async()=>(await n.wait(pc),t=e(n),n.update(oc,e=>[...e,t]),()=>{n.update(oc,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function hd(e){const t=n=>async()=>{await n.wait(Ec);const o=n.get(Sc),r=e(n),i=o.addObjectKeymap(r);return t.keymap=r,()=>{i()}};return t}function fd(e,t){const n=o=>async()=>{await o.wait(pc);const r=t(o);return e.type(o)instanceof Mn?o.update(ic,t=>[...t,[e.id,r]]):o.update(sc,t=>[...t,[e.id,r]]),n.view=r,n.type=e,()=>{e.type(o)instanceof Mn?o.update(ic,t=>t.filter(t=>t[0]!==e.id)):o.update(sc,t=>t.filter(t=>t[0]!==e.id))}};return n}function md(e,t){const n=Tt(e,t),o=e=>(e.inject(n),()=>()=>{e.remove(n)});return o.key=n,o}function gd(e,t){const n=md(t,e),o=ud(e,e=>e.get(n.key)(e)),r=[n,o];return r.id=o.id,r.node=o,r.type=e=>o.type(e),r.ctx=n,r.key=n.key,r.extendSchema=n=>gd(e,n(t)),r}function vd(e,t){const n=md(t,e),o=dd(e,e=>e.get(n.key)(e)),r=[n,o];return r.id=o.id,r.mark=o,r.type=e=>o.type(e),r.ctx=n,r.key=n.key,r.extendSchema=n=>vd(e,n(t)),r}function yd(e,t){const n=md(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),o=hd(e=>{const o=e.get(n.key),r=Object.entries(t).flatMap(([e,{command:t}])=>{const n=o[e],r=[n.shortcuts].flat(),i=n.priority;return r.map(e=>[e,{key:e,onRun:t,priority:i}])});return Object.fromEntries(r)}),r=[n,o];return r.ctx=n,r.shortcuts=o,r.key=n.key,r.keymap=o.keymap,r}ad("abcedfghicklmn",10);var wd=(e,t=()=>({}))=>md(t,`${e}Attr`),bd=(e,t=()=>({}))=>md(t,`${e}Attr`);function kd(e,t,n){const o=md({},e),r=e=>async()=>{await e.wait(dc);const n={plugin:t(e),options:e.get(o.key)};return e.update(rc,e=>[...e,n]),()=>{e.update(rc,e=>e.filter(e=>e!==n))}},i=[o,r];return i.id=e,i.plugin=r,i.options=o,i}function Cd(e){return e=>{const t=e.get(Yl);e.get(fc);return e.get(Vc)(t.state.doc)}}var xd=ue({});var Nd=()=>{const e=function(){const{dom:e,editor:t,setLoading:n,editorFactory:o}=pe(xd),r=le(null);return me(()=>{const i=r.current;if(!o)return;if(!i)return;e.current=i;const s=o(i);return s?(n(!0),s.create().then(e=>{t.current=e}).finally(()=>{n(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}):void 0},[e,t,o,n]),r}();return ae.createElement("div",{"data-milkdown-root":!0,ref:e})},Sd=({children:e})=>{const t=le(void 0),[n,o]=ce(void 0),r=le(void 0),[i,s]=ce(!0),a=de(()=>({loading:i,dom:t,editor:r,setLoading:s,editorFactory:n,setEditorFactory:o}),[i,n]);return ae.createElement(xd.Provider,{value:a},e)};function Od(){const e=pe(xd),t=he(()=>e.editor.current,[e.editor]);return[e.loading,t]}function Ed(e){return new p(h.define(e))}function Md(e){return import("./index-Ck9BxS1f.js").then(t=>t.sql({dialect:t[e]}))}const _d=[u.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-CtTbnbzM.js").then(e=>e.cpp())}),u.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-CtTbnbzM.js").then(e=>e.cpp())}),u.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Md("Cassandra")}),u.of({name:"CSS",extensions:["css"],load:()=>import("./index-CB1_GL3t.js").then(e=>e.css())}),u.of({name:"Go",extensions:["go"],load:()=>import("./index-C9_5xd3V.js").then(e=>e.go())}),u.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-xaEdDd13.js").then(e=>e.html())}),u.of({name:"Java",extensions:["java"],load:()=>import("./index-CRfRlH9U.js").then(e=>e.java())}),u.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript())}),u.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-BR16hIbn.js").then(e=>e.jinja())}),u.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-QhLowdpF.js").then(e=>e.json())}),u.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript({jsx:!0}))}),u.of({name:"LESS",extensions:["less"],load:()=>import("./index-Ccq-5wm6.js").then(e=>e.less())}),u.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index--PWk-3Ol.js").then(e=>e.liquid())}),u.of({name:"MariaDB SQL",load:()=>Md("MariaSQL")}),u.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-Bw2EofiE.js").then(e=>e.markdown())}),u.of({name:"MS SQL",load:()=>Md("MSSQL")}),u.of({name:"MySQL",load:()=>Md("MySQL")}),u.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-DAJdettS.js").then(e=>e.php())}),u.of({name:"PLSQL",extensions:["pls"],load:()=>Md("PLSQL")}),u.of({name:"PostgreSQL",load:()=>Md("PostgreSQL")}),u.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-B3fb7Ita.js").then(e=>e.python())}),u.of({name:"Rust",extensions:["rs"],load:()=>import("./index-D5NvcxPc.js").then(e=>e.rust())}),u.of({name:"Sass",extensions:["sass"],load:()=>import("./index-D8zPYs0m.js").then(e=>e.sass({indented:!0}))}),u.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-D8zPYs0m.js").then(e=>e.sass())}),u.of({name:"SQL",extensions:["sql"],load:()=>Md("StandardSQL")}),u.of({name:"SQLite",load:()=>Md("SQLite")}),u.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript({jsx:!0,typescript:!0}))}),u.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript({typescript:!0}))}),u.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-CQbc3KUq.js").then(e=>e.wast())}),u.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-GoUUn3QE.js").then(e=>e.xml())}),u.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-CpRfyO85.js").then(e=>e.yaml())}),u.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-CXdQSnD-.js").then(e=>Ed(e.apl))}),u.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-D5V0T9Cu.js").then(e=>Ed(e.asciiArmor))}),u.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-DWPaVWf6.js").then(e=>Ed(e.asn1({})))}),u.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-B46aRdXb.js").then(e=>Ed(e.asterisk))}),u.of({name:"Brainfuck",extensions:["b","bf"],load:()=>import("./brainfuck-CtZaYBKt.js").then(e=>Ed(e.brainfuck))}),u.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-stawOqaz.js").then(e=>Ed(e.cobol))}),u.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.csharp))}),u.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Ed(e.clojure))}),u.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Ed(e.clojure))}),u.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-C4GSMmGA.js").then(e=>Ed(e.gss))}),u.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-DXn5xaP-.js").then(e=>Ed(e.cmake))}),u.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-BTDxI-eT.js").then(e=>Ed(e.coffeeScript))}),u.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-vq6DHwts.js").then(e=>Ed(e.commonLisp))}),u.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-gJDei3ni.js").then(e=>Ed(e.cypher))}),u.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-On6Xi21R.js").then(e=>Ed(e.cython))}),u.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-CRzZ78HM.js").then(e=>Ed(e.crystal))}),u.of({name:"D",extensions:["d"],load:()=>import("./d-BShv7fp-.js").then(e=>Ed(e.d))}),u.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.dart))}),u.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-UJJ5BM9S.js").then(e=>Ed(e.diff))}),u.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-DVQ9Q8O9.js").then(e=>Ed(e.dockerFile))}),u.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-DI9Herc-.js").then(e=>Ed(e.dtd))}),u.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-DkEP81N9.js").then(e=>Ed(e.dylan))}),u.of({name:"EBNF",load:()=>import("./ebnf-B-Df8AvO.js").then(e=>Ed(e.ebnf))}),u.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-DPFc0Uaf.js").then(e=>Ed(e.ecl))}),u.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Ed(e.clojure))}),u.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-DR5c0IrL.js").then(e=>Ed(e.eiffel))}),u.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-DompmV0j.js").then(e=>Ed(e.elm))}),u.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-BuqgqA5h.js").then(e=>Ed(e.erlang))}),u.of({name:"Esper",load:()=>import("./sql-ByLYq2fX.js").then(e=>Ed(e.esper))}),u.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-Bk9_H-XT.js").then(e=>Ed(e.factor))}),u.of({name:"FCL",load:()=>import("./fcl-CVaBTCzQ.js").then(e=>Ed(e.fcl))}),u.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-POgR1ypr.js").then(e=>Ed(e.forth))}),u.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-DL7KluxX.js").then(e=>Ed(e.fortran))}),u.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Ed(e.fSharp))}),u.of({name:"Gas",extensions:["s"],load:()=>import("./gas-8mz5Q3qN.js").then(e=>Ed(e.gas))}),u.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-B6X1vGSW.js").then(e=>Ed(e.gherkin))}),u.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-DnIzCrpZ.js").then(e=>Ed(e.groovy))}),u.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-CLQs6EAM.js").then(e=>Ed(e.haskell))}),u.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Ed(e.haxe))}),u.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Ed(e.hxml))}),u.of({name:"HTTP",load:()=>import("./http-BKJkqRj4.js").then(e=>Ed(e.http))}),u.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-pcmmZuaN.js").then(e=>Ed(e.idl))}),u.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-BVaBnk3P.js").then(e=>Ed(e.jsonld))}),u.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-DjdwvFuI.js").then(e=>Ed(e.julia))}),u.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.kotlin))}),u.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-HO6ttBFx.js").then(e=>Ed(e.liveScript))}),u.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-8DXOpKDz.js").then(e=>Ed(e.lua))}),u.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-DkvFAiy5.js").then(e=>Ed(e.mirc))}),u.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-IIbmv7SK.js").then(e=>Ed(e.mathematica))}),u.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-DSrSSXCg.js").then(e=>Ed(e.modelica))}),u.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-zvxmGV4l.js").then(e=>Ed(e.mumps))}),u.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-z_N2Mo3d.js").then(e=>Ed(e.mbox))}),u.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-B4hAVlXN.js").then(e=>Ed(e.nginx))}),u.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-Cx8FAvMN.js").then(e=>Ed(e.nsis))}),u.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-BSwWqoLa.js").then(e=>Ed(e.ntriples))}),u.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.objectiveC))}),u.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.objectiveCpp))}),u.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Ed(e.oCaml))}),u.of({name:"Octave",extensions:["m"],load:()=>import("./octave-C4hdQ5Hf.js").then(e=>Ed(e.octave))}),u.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-qQq7irPq.js").then(e=>Ed(e.oz))}),u.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-CafrKXZF.js").then(e=>Ed(e.pascal))}),u.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-tdMlh9QA.js").then(e=>Ed(e.perl))}),u.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CwGJVRC4.js").then(e=>Ed(e.pig))}),u.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-D1ly3AHC.js").then(e=>Ed(e.powerShell))}),u.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-_nPj978X.js").then(e=>Ed(e.properties))}),u.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-B4y9do6W.js").then(e=>Ed(e.protobuf))}),u.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-Dlfivyh-.js").then(e=>Ed(e.pug))}),u.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-Bc-yJKzi.js").then(e=>Ed(e.puppet))}),u.of({name:"Q",extensions:["q"],load:()=>import("./q-mUfi2b_o.js").then(e=>Ed(e.q))}),u.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-BA4EbLKE.js").then(e=>Ed(e.r))}),u.of({name:"RPM Changes",load:()=>import("./rpm-DI_rRufH.js").then(e=>Ed(e.rpmChanges))}),u.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-DI_rRufH.js").then(e=>Ed(e.rpmSpec))}),u.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-CR-u2WLS.js").then(e=>Ed(e.ruby))}),u.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-Bqaci40L.js").then(e=>Ed(e.sas))}),u.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.scala))}),u.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-qjP0V5Ag.js").then(e=>Ed(e.scheme))}),u.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-BLav31RL.js").then(e=>Ed(e.shell))}),u.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-r025o_jW.js").then(e=>Ed(e.sieve))}),u.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-C7J3IyEP.js").then(e=>Ed(e.smalltalk))}),u.of({name:"Solr",load:()=>import("./solr-78MBEUkU.js").then(e=>Ed(e.solr))}),u.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Ed(e.sml))}),u.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-BRLJFz69.js").then(e=>Ed(e.sparql))}),u.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-CGlWr0eM.js").then(e=>Ed(e.spreadsheet))}),u.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.squirrel))}),u.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-Bdo_Aemu.js").then(e=>Ed(e.stylus))}),u.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-B_XXVlXX.js").then(e=>Ed(e.swift))}),u.of({name:"sTeX",load:()=>Promise.resolve().then(function(){return Id}).then(e=>Ed(e.stex))}),u.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>Promise.resolve().then(function(){return Id}).then(e=>Ed(e.stex))}),u.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Ed(e.verilog))}),u.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-B2fODqDH.js").then(e=>Ed(e.tcl))}),u.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-BuVhTOzU.js").then(e=>Ed(e.textile))}),u.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-BgR6AEZu.js").then(e=>Ed(e.tiddlyWiki))}),u.of({name:"Tiki wiki",load:()=>import("./tiki-CI-ztowC.js").then(e=>Ed(e.tiki))}),u.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-BVJm5Fzd.js").then(e=>Ed(e.toml))}),u.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-Ce85hlLp.js").then(e=>Ed(e.troff))}),u.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-BxnYHtq8.js").then(e=>Ed(e.ttcn))}),u.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-CKJxb-l2.js").then(e=>Ed(e.ttcnCfg))}),u.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-BkSuIpt-.js").then(e=>Ed(e.turtle))}),u.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-CGwyPRYs.js").then(e=>Ed(e.webIDL))}),u.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-BHgjm0DN.js").then(e=>Ed(e.vb))}),u.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-VzWlGt02.js").then(e=>Ed(e.vbScript))}),u.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-BdD_26Jv.js").then(e=>Ed(e.velocity))}),u.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Ed(e.verilog))}),u.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-CWWH2SUo.js").then(e=>Ed(e.vhdl))}),u.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-CVDBqZPY.js").then(e=>Ed(e.xQuery))}),u.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-I8QjZlxf.js").then(e=>Ed(e.yacas))}),u.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-DMVFMNEx.js").then(e=>Ed(e.z80))}),u.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Ed(e.mscgen))}),u.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Ed(e.xu))}),u.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Ed(e.msgenny))}),u.of({name:"Vue",extensions:["vue"],load:()=>import("./index-Y09lLL_e.js").then(e=>e.vue())}),u.of({name:"Angular Template",load:()=>import("./index-D_AOS7Yx.js").then(e=>e.angular())})];function Td(e){function t(e,t){e.cmdState.push(t)}function n(e){return e.cmdState.length>0?e.cmdState[e.cmdState.length-1]:null}function o(e,t,n){return function(){this.name=e,this.bracketNo=0,this.style=t,this.styles=n,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var r={};function i(e,t){e.f=t}function s(e,o){var s;if(e.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var c=e.current().slice(1);return t(o,s=new(s=r.hasOwnProperty(c)?r[c]:r.DEFAULT)),i(o,l),s.style}if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/\\]/))return"tag";if(e.match("\\["))return i(o,function(e,t){return a(e,t,"\\]")}),"keyword";if(e.match("\\("))return i(o,function(e,t){return a(e,t,"\\)")}),"keyword";if(e.match("$$"))return i(o,function(e,t){return a(e,t,"$$")}),"keyword";if(e.match("$"))return i(o,function(e,t){return a(e,t,"$")}),"keyword";var d=e.next();return"%"==d?(e.skipToEnd(),"comment"):"}"==d||"]"==d?(s=n(o))?(s.closeBracket(d),i(o,l),"bracket"):"error":"{"==d||"["==d?(t(o,s=new(s=r.DEFAULT)),"bracket"):/\d/.test(d)?(e.eatWhile(/[\w.%]/),"atom"):(e.eatWhile(/[\w\-_]/),s=function(e){for(var t=e.cmdState,n=t.length-1;n>=0;n--){var o=t[n];if("DEFAULT"!=o.name)return o}return{styleIdentifier:function(){return null}}}(o),"begin"==s.name&&(s.argument=e.current()),s.styleIdentifier())}function a(e,t,n){if(e.eatSpace())return null;if(n&&e.match(n))return i(t,s),"keyword";if(e.match(/^\\[a-zA-Z@]+/))return"tag";if(e.match(/^[a-zA-Z]+/))return"variableName.special";if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/]/))return"tag";if(e.match(/^[\^_&]/))return"tag";if(e.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(e.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var o=e.next();return"{"==o||"}"==o||"["==o||"]"==o||"("==o||")"==o?"bracket":"%"==o?(e.skipToEnd(),"comment"):"error"}function l(e,t){var o=e.peek();return"{"==o||"["==o?(n(t).openBracket(o),e.eat(o),i(t,s),"bracket"):/[ \t\r]/.test(o)?(e.eat(o),null):(i(t,s),function(e){var t=e.cmdState.pop();t&&t.closeBracket()}(t),s(e,t))}return r.importmodule=o("importmodule","tag",["string","builtin"]),r.documentclass=o("documentclass","tag",["","atom"]),r.usepackage=o("usepackage","tag",["atom"]),r.begin=o("begin","tag",["atom"]),r.end=o("end","tag",["atom"]),r.label=o("label","tag",["atom"]),r.ref=o("ref","tag",["atom"]),r.eqref=o("eqref","tag",["atom"]),r.cite=o("cite","tag",["atom"]),r.bibitem=o("bibitem","tag",["atom"]),r.Bibitem=o("Bibitem","tag",["atom"]),r.RBibitem=o("RBibitem","tag",["atom"]),r.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{name:"stex",startState:function(){return{cmdState:[],f:e?function(e,t){return a(e,t)}:s}},copyState:function(e){return{cmdState:e.cmdState.slice(),f:e.f}},token:function(e,t){return t.f(e,t)},blankLine:function(e){e.f=s,e.cmdState.length=0},languageData:{commentTokens:{line:"%"}}}}const Dd=Td(!1);Td(!0);var Id=Object.freeze({__proto__:null,stex:Dd});function Ad(e){return function(t,n){let{$from:o,$to:r}=t.selection,i=o.blockRange(r,t=>t.childCount>0&&t.firstChild.type==e);return!!i&&(!n||(o.node(i.depth-1).type==e?function(e,t,n,o){let r=e.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(r.step(new uo(i-1,s,i,s,new Kt(Ht.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new dn(r.doc.resolve(o.$from.pos),r.doc.resolve(s),o.depth));const a=mo(o);if(null==a)return!1;r.lift(o,a);let l=r.doc.resolve(r.mapping.map(i,-1)-1);ko(r.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&r.join(l.pos);return t(r.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let o=e.tr,r=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=r.child(t).nodeSize,o.delete(e-1,e+1);let i=o.doc.resolve(n.start),s=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==r.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?Ht.empty:Ht.from(r))))return!1;let u=i.pos,p=u+s.nodeSize;return o.step(new uo(u-(a?1:0),p+(l?1:0),u+1,p-1,new Kt((a?Ht.empty:Ht.from(r.copy(Ht.empty))).append(l?Ht.empty:Ht.from(r.copy(Ht.empty))),a?0:1,l?0:1),a?0:1)),t(o.scrollIntoView()),!0}(t,n,i)))}}function Rd(e){return String(e||"").toUpperCase()}function Pd(){return function(e){const t=function(e){const t=new Map;if(!e||!e.type)throw new Error("mdast-util-definitions expected node");return ee(e,"definition",function(e){const n=Rd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){const n=Rd(e);return t.get(n)}}(e);ee(e,function(e,n,o){if("definition"===e.type&&void 0!==o&&"number"==typeof n)return o.children.splice(n,1),[te,n];if("imageReference"===e.type||"linkReference"===e.type){const r=t(e.identifier);if(r&&o&&"number"==typeof n)return o.children[n]="imageReference"===e.type?{type:"image",url:r.url,title:r.title,alt:e.alt}:{type:"link",url:r.url,title:r.title,children:e.children},[te,n]}})}}function Ld(e,t){if(!(t.childCount>=1&&"hardbreak"===t.lastChild?.type.name))return void e.next(t.content);const n=[];t.content.forEach((e,o,r)=>{r!==t.childCount-1&&n.push(e)}),e.next(Ht.fromArray(n))}function Vd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}var jd=bd("emphasis");Vd(jd,{displayName:"Attr<emphasis>",group:"Emphasis"});var $d=vd("emphasis",e=>({attrs:{marker:{default:e.get(lc).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(jd.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));Vd($d.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),Vd($d.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Bd=ld("ToggleEmphasis",e=>()=>Nr($d.type(e)));Vd(Bd,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var Hd=cd(e=>ri(/(?:^|[^*])\*([^*]+)\*$/,$d.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));Vd(Hd,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var Fd=cd(e=>ri(/\b_(?![_\s])(.*?[^_\s])_\b/,$d.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));Vd(Fd,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var zd=yd("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(bc);return()=>t.call(Bd.key)}}});Vd(zd.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),Vd(zd.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var qd=bd("strong");Vd(qd,{displayName:"Attr<strong>",group:"Strong"});var Wd=vd("strong",e=>({attrs:{marker:{default:e.get(lc).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>"normal"!=e.style.fontWeight&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e},{style:"font-weight=400",clearMark:e=>"strong"==e.type.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>["strong",e.get(qd.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));Vd(Wd.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),Vd(Wd.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Ud=ld("ToggleStrong",e=>()=>Nr(Wd.type(e)));Vd(Ud,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var Kd=cd(e=>ri(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Wd.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));Vd(Kd,{displayName:"InputRule<strong>",group:"Strong"});var Gd=yd("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(bc);return()=>t.call(Ud.key)}}});Vd(Gd.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),Vd(Gd.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var Jd=bd("inlineCode");Vd(Jd,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Zd=vd("inlineCode",e=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(Jd.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>(e.withMark(t,"inlineCode",n.text||""),!0)}}));Vd(Zd.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),Vd(Zd.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Xd=ld("ToggleInlineCode",e=>()=>(t,n)=>{const{selection:o,tr:r}=t;if(o.empty)return!1;const{from:i,to:s}=o;return t.doc.rangeHasMark(i,s,Zd.type(e))?(n?.(r.removeMark(i,s,Zd.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==Zd.type.name).map(e=>t.schema.marks[e]).forEach(e=>{r.removeMark(i,s,e)}),n?.(r.addMark(i,s,Zd.type(e).create())),!0)});Vd(Xd,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var Yd=cd(e=>ri(/(?:`)([^`]+)(?:`)$/,Zd.type(e)));Vd(Yd,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var Qd=yd("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(bc);return()=>t.call(Xd.key)}}});Vd(Qd.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),Vd(Qd.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var eu=bd("link");Vd(eu,{displayName:"Attr<link>",group:"Link"});var tu=vd("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(eu.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const o=t.url,r=t.title;e.openMark(n,{href:o,title:r}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));Vd(tu.mark,{displayName:"MarkSchema<link>",group:"Link"});var nu=ld("ToggleLink",e=>(t={})=>Nr(tu.type(e),t));Vd(nu,{displayName:"Command<toggleLinkCommand>",group:"Link"});var ou=ld("UpdateLink",e=>(t={})=>(n,o)=>{if(!o)return!1;let r,i=-1;const{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(tu.type(e).isInSet(t.marks))return r=t,i=n,!1}),!r)return!1;const c=r.marks.find(({type:t})=>t===tu.type(e));if(!c)return!1;const d=i,u=i+r.nodeSize,{tr:p}=n,h=tu.type(e).create({...c.attrs,...t});return!!h&&(o(p.removeMark(d,u,c).addMark(d,u,h).setSelection(new Fo(p.selection.$anchor)).scrollIntoView()),!0)});Vd(ou,{displayName:"Command<updateLinkCommand>",group:"Link"});var ru=ud("doc",()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}}));function iu(e){return ne(e,e=>"html"===e.type&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;const n=t[t.length-1];if(!n)return;const o=n.children.indexOf(e);-1!==o&&n.children.splice(o,1)},!0)}Vd(ru,{displayName:"NodeSchema<doc>",group:"Doc"});var su=kd("remark-preserve-empty-line",()=>()=>iu);Vd(su.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),Vd(su.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var au=wd("paragraph");Vd(au,{displayName:"Attr<paragraph>",group:"Paragraph"});var lu=gd("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(au.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(t,n)=>{const o=e.get(Yl).state?.doc.lastChild;t.openNode("paragraph"),n.content&&0!==n.content.size||n===o||!function(e){let t=!1;try{e.get(su.id),t=!0}catch{t=!1}return t}(e)?Ld(t,n):t.addNode("html",void 0,"<br />"),t.closeNode()}}}));Vd(lu.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),Vd(lu.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var cu=ld("TurnIntoText",e=>()=>xr(lu.type(e)));Vd(cu,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var du=yd("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(bc);return()=>t.call(cu.key)}}});Vd(du.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),Vd(du.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var uu=Array(6).fill(0).map((e,t)=>t+1);var pu=md(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");Vd(pu,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var hu=wd("heading");Vd(hu,{displayName:"Attr<heading>",group:"Heading"});var fu=gd("heading",e=>{const t=e.get(pu.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:uu.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Nt(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(hu.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const o=t.depth;e.openNode(n,{level:o}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),Ld(e,t),e.closeNode()}}}});Vd(fu.node,{displayName:"NodeSchema<heading>",group:"Heading"}),Vd(fu.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var mu=cd(e=>Rr(/^(?<hashes>#+)\s$/,fu.type(e),t=>{const n=t.groups?.hashes?.length||0,{$from:o}=e.get(Yl).state.selection,r=o.node();if("heading"===r.type.name){let e=Number(r.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));Vd(mu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var gu=ld("WrapInHeading",e=>t=>(t??=1,t<1?xr(lu.type(e)):xr(fu.type(e),{level:t})));Vd(gu,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var vu=ld("DowngradeHeading",e=>()=>(t,n,o)=>{const{$from:r}=t.selection,i=r.node();if(i.type!==fu.type(e)||!t.selection.empty||0!==r.parentOffset)return!1;const s=i.attrs.level-1;return s?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...i.attrs,level:s})),!0):xr(lu.type(e))(t,n,o)});Vd(vu,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var yu=yd("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(bc);return()=>t.call(vu.key)}}});Vd(yu.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),Vd(yu.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var wu=wd("blockquote");Vd(wu,{displayName:"Attr<blockquote>",group:"Blockquote"});var bu=gd("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(wu.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));Vd(bu.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),Vd(bu.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var ku=cd(e=>Ar(/^\s*>\s$/,bu.type(e)));Vd(ku,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Cu=ld("WrapInBlockquote",e=>()=>Cr(bu.type(e)));Vd(Cu,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var xu=yd("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(bc);return()=>t.call(Cu.key)}}});Vd(xu.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),Vd(xu.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Nu=wd("codeBlock",()=>({pre:{},code:{}}));Vd(Nu,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Su=gd("code_block",e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(Nu.key)(t),o=t.attrs.language,r=o&&o.length>0?{"data-language":o}:void 0;return["pre",{...n.pre,...r},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const o=t.lang??"",r=t.value;e.openNode(n,{language:o}),r&&e.addText(r),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));Vd(Su.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),Vd(Su.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Ou=cd(e=>Rr(/^```(?<language>[a-z]*)?[\s\n]$/,Su.type(e),e=>({language:e.groups?.language??""})));Vd(Ou,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Eu=ld("CreateCodeBlock",e=>(t="")=>xr(Su.type(e),{language:t}));Vd(Eu,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),Vd(ld("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,o)=>e>=0&&(o?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Mu=yd("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(bc);return()=>t.call(Eu.key)}}});Vd(Mu.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),Vd(Mu.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var _u=wd("image");Vd(_u,{displayName:"Attr<image>",group:"Image"});var Tu=gd("image",e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(_u.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const o=t.url,r=t.alt,i=t.title;e.addNode(n,{src:o,alt:r,title:i})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));Vd(Tu.node,{displayName:"NodeSchema<image>",group:"Image"}),Vd(Tu.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Du=ld("InsertImage",e=>(t={})=>(n,o)=>{if(!o)return!0;const{src:r="",alt:i="",title:s=""}=t,a=Tu.type(e).create({src:r,alt:i,title:s});return!a||(o(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});Vd(Du,{displayName:"Command<insertImageCommand>",group:"Image"});var Iu=ld("UpdateImage",e=>(t={})=>(n,o)=>{const r=wi(n.selection,Tu.type(e));if(!r)return!1;const{node:i,pos:s}=r,a={...i.attrs},{src:l,alt:c,title:d}=t;return void 0!==l&&(a.src=l),void 0!==c&&(a.alt=c),void 0!==d&&(a.title=d),o?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});Vd(Iu,{displayName:"Command<updateImageCommand>",group:"Image"}),Vd(cd(e=>new Dr(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,o,r)=>{const[i,s,a="",l]=n;return i?t.tr.replaceWith(o,r,Tu.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Au=wd("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));Vd(Au,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Ru=gd("hardbreak",e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(Au.key)(t)," "]:["br",e.get(Au.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{e.addNode(n,{isInline:Boolean(t.data?.isInline)})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}}));Vd(Ru.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),Vd(Ru.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Pu=ld("InsertHardbreak",e=>()=>(t,n)=>{const{selection:o,tr:r}=t;if(!(o instanceof Fo))return!1;if(o.empty){const e=o.$from.node();if(e.childCount>0&&"hardbreak"===e.lastChild?.type.name)return n?.(r.replaceRangeWith(o.to-1,o.to,t.schema.node("paragraph")).setSelection(jo.near(r.doc.resolve(o.to))).scrollIntoView()),!0}return n?.(r.setMeta("hardbreak",!0).replaceSelectionWith(Ru.type(e).create()).scrollIntoView()),!0});Vd(Pu,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Lu=yd("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(bc);return()=>t.call(Pu.key)}}});Vd(Lu.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),Vd(Lu.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Vu=wd("hr");Vd(Vu,{displayName:"Attr<hr>",group:"Hr"});var ju=gd("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(Vu.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}}));Vd(ju.node,{displayName:"NodeSchema<hr>",group:"Hr"}),Vd(ju.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var $u=cd(e=>new Dr(/^(?:---|___\s|\*\*\*\s)$/,(t,n,o,r)=>{const{tr:i}=t;return n[0]&&i.replaceWith(o-1,r,ju.type(e).create()),i}));Vd($u,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var Bu=ld("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;const o=lu.node.type(e).create(),{tr:r,selection:i}=t,{from:s}=i,a=ju.type(e).create();if(!a)return!0;const l=r.replaceSelectionWith(a).insert(s,o),c=jo.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});Vd(Bu,{displayName:"Command<insertHrCommand>",group:"Hr"});var Hu=wd("bulletList");Vd(Hu,{displayName:"Attr<bulletList>",group:"BulletList"});var Fu=gd("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(Hu.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const o=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:o}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));Vd(Fu.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),Vd(Fu.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var zu=cd(e=>Ar(/^\s*([-+*])\s$/,Fu.type(e)));Vd(zu,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var qu=ld("WrapInBulletList",e=>()=>Cr(Fu.type(e)));Vd(qu,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Wu=yd("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(bc);return()=>t.call(qu.key)}}});Vd(Wu.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),Vd(Wu.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Uu=wd("orderedList");Vd(Uu,{displayName:"Attr<orderedList>",group:"OrderedList"});var Ku=gd("ordered_list",e=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(Uu.key)(t),...1===t.attrs.order?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{const o=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:o,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Vd(Ku.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),Vd(Ku.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var Gu=cd(e=>Ar(/^\s*(\d+)\.\s$/,Ku.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));Vd(Gu,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Ju=ld("WrapInOrderedList",e=>()=>Cr(Ku.type(e)));Vd(Ju,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Zu=yd("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(bc);return()=>t.call(Ju.key)}}});Vd(Zu.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),Vd(Zu.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Xu=wd("listItem");Vd(Xu,{displayName:"Attr<listItem>",group:"ListItem"});var Yu=gd("list_item",e=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(Xu.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{const o=null!=t.label?`${t.label}.`:"•",r=null!=t.label?"ordered":"bullet",i=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:o,listType:r,spread:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Vd(Yu.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),Vd(Yu.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Qu=ld("SinkListItem",e=>()=>{return t=Yu.type(e),function(e,n){let{$from:o,$to:r}=e.selection,i=o.blockRange(r,e=>e.childCount>0&&e.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let o=l.lastChild&&l.lastChild.type==a.type,r=Ht.from(o?t.create():null),s=new Kt(Ht.from(t.create(null,Ht.from(a.type.create(null,r)))),o?3:1,0),c=i.start,d=i.end;n(e.tr.step(new uo(c-(o?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0};var t});Vd(Qu,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var ep=ld("LiftListItem",e=>()=>Ad(Yu.type(e)));Vd(ep,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var tp=ld("SplitListItem",e=>()=>{return t=Yu.type(e),function(e,n){let{$from:o,$to:r,node:i}=e.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(r))return!1;let s=o.node(-1);if(s.type!=t)return!1;if(0==o.parent.content.size&&o.node(-1).childCount==o.indexAfter(-1)){if(3==o.depth||o.node(-3).type!=t||o.index(-2)!=o.node(-2).childCount-1)return!1;if(n){let r=Ht.empty,i=o.index(-1)?1:o.index(-2)?2:3;for(let e=o.depth-i;e>=o.depth-3;e--)r=Ht.from(o.node(e).copy(r));let s=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;r=r.append(Ht.from(t.createAndFill()));let a=o.before(o.depth-(i-1)),l=e.tr.replace(a,o.after(-s),new Kt(r,4-i,0)),c=-1;l.doc.nodesBetween(a,l.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)}),c>-1&&l.setSelection(jo.near(l.doc.resolve(c))),n(l.scrollIntoView())}return!0}let a=r.pos==o.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(o.pos,r.pos),c=a?[null,{type:a}]:void 0;return!!bo(l.doc,o.pos,2,c)&&(n&&n(l.split(o.pos,2,c).scrollIntoView()),!0)};var t});Vd(tp,{displayName:"Command<splitListItemCommand>",group:"ListItem"});var np=ld("LiftFirstListItem",e=>()=>function(e){return(t,n,o)=>{const{selection:r}=t;if(!(r instanceof Fo))return!1;const{empty:i,$from:s}=r;return!(!i||0!==s.parentOffset)&&s.node(-1).type===Yu.type(e)&&cr(t,n,o)}}(e));Vd(np,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var op=yd("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(bc);return()=>t.call(tp.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(bc);return()=>t.call(Qu.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(bc);return()=>t.call(ep.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(bc);return()=>t.call(np.key)}}});Vd(op.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),Vd(op.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var rp=ud("text",()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}}));Vd(rp,{displayName:"NodeSchema<text>",group:"Text"});var ip=wd("html");Vd(ip,{displayName:"Attr<html>",group:"Html"});var sp=gd("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{const n=document.createElement("span"),o={...e.get(ip.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",o,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>Boolean("html"===e),runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));Vd(sp.node,{displayName:"NodeSchema<html>",group:"Html"}),Vd(sp.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var ap=[ru,au,lu,pu,hu,fu,Au,Ru,wu,bu,Nu,Su,Vu,ju,_u,Tu,Hu,Fu,Uu,Ku,Xu,Yu,jd,$d,qd,Wd,Jd,Zd,eu,tu,ip,sp,rp].flat(),lp=[ku,zu,Gu,Ou,$u,mu].flat(),cp=[Hd,Fd,Yd,Kd],dp=ld("IsMarkSelected",()=>e=>t=>{if(!e)return!1;const{doc:n,selection:o}=t;return n.rangeHasMark(o.from,o.to,e)}),up=ld("IsNoteSelected",()=>e=>t=>!!e&&bi(t,e).hasNode),pp=ld("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr;const{$from:o,$to:r}=n.selection,{pos:i}=o,{pos:s}=r,a=i-o.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),hp=ld("SetBlockType",()=>e=>(t,n)=>{const{nodeType:o,attrs:r=null}=e??{};if(!o)return!1;const i=t.tr,{from:s,to:a}=i.selection;try{i.setBlockType(s,a,o,r)}catch{return!1}return n?.(i),!0}),fp=ld("WrapInBlockType",()=>e=>(t,n)=>{const{nodeType:o,attrs:r=null}=e??{};if(!o)return!1;let i=t.tr;try{const{$from:e,$to:t}=i.selection,n=e.blockRange(t),s=n&&go(n,o,r);if(!s)return!1;i=i.wrap(n,s)}catch{return!1}return n?.(i),!0}),mp=ld("AddBlockType",()=>e=>(t,n)=>{const{nodeType:o,attrs:r=null}=e??{};if(!o)return!1;const i=t.tr;try{const e=o instanceof pn?o:o.createAndFill(r);if(!e)return!1;i.replaceSelectionWith(e)}catch{return!1}return n?.(i),!0}),gp=ld("SelectTextNearPos",()=>e=>(t,n)=>{const{pos:o}=e??{};if(null==o)return!1;const r=t.tr;try{const e=t.doc.resolve((i=o,s=0,a=t.doc.content.size,Math.min(Math.max(i,s),a)));r.setSelection(Fo.near(e))}catch{return!1}var i,s,a;return n?.(r.scrollIntoView()),!0}),vp=[cu,Cu,gu,vu,Eu,Pu,Bu,Du,Iu,Ju,qu,Qu,tp,ep,np,Bd,Xd,Ud,nu,ou,dp,up,pp,hp,fp,mp,gp],yp=[xu,Mu,Lu,yu,op,Zu,Wu,du,zd,Qd,Gd].flat(),wp=kd("remarkAddOrderInList",()=>()=>e=>{ee(e,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});Vd(wp.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),Vd(wp.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var bp=kd("remarkLineBreak",()=>()=>e=>{const t=/[\t ]*(?:\r?\n|\r)/g;ee(e,"text",(e,n,o)=>{if(!e.value||"string"!=typeof e.value)return;const r=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&r.push({type:"text",value:e.value.slice(i,n)}),r.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return r.length>0&&o&&"number"==typeof n?(i<e.value.length&&r.push({type:"text",value:e.value.slice(i)}),o.children.splice(n,1,...r),n+r.length):void 0})});Vd(bp.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),Vd(bp.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var kp=kd("remarkInlineLink",()=>Pd);Vd(kp.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),Vd(kp.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var Cp=["root","blockquote","listItem"],xp=kd("remarkHTMLTransformer",()=>()=>e=>{var t;t=(e,t,n)=>(e=>"html"===e.type)(e)?(n&&Cp.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e],function e(n,o,r){if((e=>!!e.children)(n)){const t=[];for(let o=0,r=n.children.length;o<r;o++){const r=n.children[o];if(r){const i=e(r,o,n);if(i)for(let e=0,n=i.length;e<n;e++){const n=i[e];n&&t.push(n)}}}n.children=t}return t(n,o,r)}(e,0,null)[0]});Vd(xp.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),Vd(xp.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var Np=kd("remarkMarker",()=>()=>(e,t)=>{ee(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)})});Vd(Np.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),Vd(Np.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Sp=pd(()=>{let e=!1;const t=new or({key:new sr("MILKDOWN_INLINE_NODES_CURSOR"),state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,o=t.nodeAfter;return!(!(n&&o&&n.isInline&&!n.isText&&o.isInline)||o.isText)}},props:{handleDOMEvents:{compositionend:(n,o)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){const e=n.state.selection.from;o.preventDefault(),n.dispatch(n.state.tr.insertText(o.data||"",e))}}),!0),compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,o)=>{if(t.getState(n.state)&&o instanceof InputEvent&&o.data&&!e){const e=n.state.selection.from;return o.preventDefault(),n.dispatch(n.state.tr.insertText(o.data||"",e)),!0}return!1}},decorations(e){if(t.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),o=gl.widget(t,n,{side:-1}),r=document.createElement("span"),i=gl.widget(t,r);return setTimeout(()=>{n.contentEditable="true",r.contentEditable="true"}),wl.create(e.doc,[o,i])}return wl.empty}}});return t});Vd(Sp,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var Op=pd(e=>new or({key:new sr("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,o)=>{if(!t.length)return;const[r]=t;if(!r)return;const[i]=r.steps;if(r.getMeta("hardbreak")){if(!(i instanceof co))return;const{from:t}=i;return o.tr.setNodeMarkup(t,Ru.type(e),void 0,[])}if(i instanceof io){let t=o.tr;const{from:n,to:r}=i;return o.doc.nodesBetween(n,r,(n,o)=>{n.type===Ru.type(e)&&(t=t.setNodeMarkup(o,Ru.type(e),void 0,[]))}),t}}}));Vd(Op,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Ep=md(["table","code_block"],"hardbreakFilterNodes");Vd(Ep,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Mp=pd(e=>{const t=e.get(Ep.key);return new or({key:new sr("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const o=e.getMeta("hardbreak"),[r]=e.steps;if(o&&r){const{from:e}=r,o=n.doc.resolve(e);let i=o.depth,s=!0;for(;i>0;)t.includes(o.node(i).type.name)&&(s=!1),i--;return s}return!0}})});Vd(Mp,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var _p=pd(e=>{const t=new sr("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const o=e.get(pu.key),r=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants((n,a)=>{if(n.type===fu.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let l=o(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(i=!0,r.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),i&&n.dispatch(r)};return new or({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});Vd(_p,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Tp=pd(e=>new or({key:new sr("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,o)=>{if(!o.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;const r=Ku.type(e),i=Fu.type(e),s=Yu.type(e),a=(e,t,n=1)=>{let o=!1;const r=`${t+n}.`;return e.label!==r&&(e.label=r,o=!0),o};let l=o.tr,c=!1;return o.doc.descendants((e,t,n,o)=>{if(e.type===i){const n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,r,{spread:"true"}),e.descendants((e,t,n,o)=>{if(e.type===s){const n={...e.attrs};a(n,o)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===r){const r={...e.attrs};let i=!1;"ordered"!==r.listType&&(r.listType="ordered",i=!0),n?.maybeChild(0)&&(i=a(r,o,n?.attrs.order??1)),i&&(l=l.setNodeMarkup(t,void 0,r),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));Vd(Tp,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var Dp=[ap,lp,cp,vp,yp,[Op,Ep,Mp,Sp,wp,kp,bp,xp,Np,su,_p,Tp].flat()].flat(),Ip=200,Ap=function(){};Ap.prototype.append=function(e){return e.length?(e=Ap.from(e),!this.length&&e||e.length<Ip&&this.leafAppend(e)||this.length<Ip&&e.leafPrepend(this)||this.appendInner(e)):this},Ap.prototype.prepend=function(e){return e.length?Ap.from(e).append(this):this},Ap.prototype.appendInner=function(e){return new Pp(this,e)},Ap.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Ap.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ap.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ap.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Ap.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var o=[];return this.forEach(function(t,n){return o.push(e(t,n))},t,n),o},Ap.from=function(e){return e instanceof Ap?e:e&&e.length?new Rp(e):Ap.empty};var Rp=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,o){for(var r=t;r<n;r++)if(!1===e(this.values[r],o+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,o){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],o+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Ip)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ip)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Ap);Ap.empty=new Rp([]);var Pp=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,o){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),o))&&(!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,o+r))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,o){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,o+r))&&(!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,o))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Ap);class Lp{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--){if(this.items.get(r-1).selection){--r;break}}t&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,a=e.tr,l=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(r,t+1),o=n.maps.length),o--,void c.push(e);if(n){c.push(new Vp(e.map));let t,r=e.step.map(n.slice(o));r&&a.maybeStep(r).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new Vp(t,void 0,void 0,l.length+c.length))),o--,t&&n.appendMap(t,o)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(o)):e.selection,s=new Lp(this.items.slice(0,r).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(e,t,n,o){let r=[],i=this.eventCount,s=this.items,a=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),d=new Vp(e.mapping.maps[n],c,t);(l=a&&a.merge(d))&&(d=l,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),t&&(i++,t=void 0),o||(a=d)}let l=i-n.depth;return l>$p&&(s=function(e,t){let n;return e.forEach((e,o)=>{if(e.selection&&0==t--)return n=o,!1}),e.slice(n)}(s,l),i-=l),new Lp(s.append(r),i)}remapping(e,t){let n=new eo;return this.items.forEach((t,o)=>{let r=null!=t.mirrorOffset&&o-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)},e,t),n}addMaps(e){return 0==this.eventCount?this:new Lp(this.items.append(e.map(e=>new Vp(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},o);let a=t;this.items.forEach(t=>{let o=r.getMirror(--a);if(null==o)return;i=Math.min(i,o);let l=r.maps[o];if(t.step){let i=e.steps[o].invert(e.docs[o]),c=t.selection&&t.selection.map(r.slice(a+1,o));c&&s++,n.push(new Vp(l,i,c))}else n.push(new Vp(l))},o);let l=[];for(let e=t;e<i;e++)l.push(new Vp(r.maps[e]));let c=this.items.slice(0,o).append(l).append(n),d=new Lp(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,o=[],r=0;return this.items.forEach((i,s)=>{if(s>=e)o.push(i),i.selection&&r++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&r++;let l,c=new Vp(s.invert(),e,a),d=o.length-1;(l=o.length&&o[d].merge(c))?o[d]=l:o.push(c)}}else i.map&&n--},this.items.length,0),new Lp(Ap.from(o.reverse()),r)}}Lp.empty=new Lp(Ap.empty,0);class Vp{constructor(e,t,n,o){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Vp(t.getMap().invert(),t,this.selection)}}}class jp{constructor(e,t,n,o,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const $p=20;function Bp(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,o,r)=>t.push(o,r));return t}function Hp(e,t){if(!e)return null;let n=[];for(let o=0;o<e.length;o+=2){let r=t.map(e[o],1),i=t.map(e[o+1],-1);r<=i&&n.push(r,i)}return n}let Fp=!1,zp=null;function qp(e){let t=e.plugins;if(zp!=t){Fp=!1,zp=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Fp=!0;break}}return Fp}const Wp=new sr("history"),Up=new sr("closeHistory");function Kp(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new or({key:Wp,state:{init:()=>new jp(Lp.empty,Lp.empty,null,0,-1),apply:(t,n,o)=>function(e,t,n,o){let r,i=n.getMeta(Wp);if(i)return i.historyState;n.getMeta(Up)&&(e=new jp(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Wp))return s.getMeta(Wp).redo?new jp(e.done.addTransform(n,void 0,o,qp(t)),e.undone,Bp(n.mapping.maps),e.prevTime,e.prevComposition):new jp(e.done,e.undone.addTransform(n,void 0,o,qp(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new jp(e.done.rebased(n,r),e.undone.rebased(n,r),Hp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new jp(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Hp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let r=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-o.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,o)=>{for(let r=0;r<t.length;r+=2)e<=t[r+1]&&o>=t[r]&&(n=!0)}),n}(n,e.prevRanges)),a=s?Hp(e.prevRanges,n.mapping):Bp(n.mapping.maps);return new jp(e.done.addTransform(n,i?t.selection.getBookmark():void 0,o,qp(t)),Lp.empty,a,n.time,null==r?e.prevComposition:r)}}(n,o,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,o="historyUndo"==n?Jp:"historyRedo"==n?Zp:null;return!(!o||!e.editable)&&(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Gp(e,t){return(n,o)=>{let r=Wp.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(o){let i=function(e,t,n){let o=qp(t),r=Wp.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),r,o),l=new jp(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(Wp,{redo:n,historyState:l})}(r,n,e);i&&o(t?i.scrollIntoView():i)}return!0}}const Jp=Gp(!1,!0),Zp=Gp(!0,!0);
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{P as n,S as o,ah as r,G as i,T as s,C as a,v as l}from"./settings-BONQQsPx.js";import{W as c,X as d,g as u,L as p,Y as h,Z as f,E as m,G as g,_ as v,z as y,$ as w,a0 as b,a1 as k,a2 as C,a3 as x,a4 as N,a5 as S,a6 as O,a7 as E,a8 as M,a9 as _,U as T,aa as D,ab as I,ac as A,ad as R,ae as P,af as L,ag as V,ah as j,ai as $,aj as B,ak as H,Q as F,K as z,M as q}from"./basic-setup-UGhpl5jF.js";import{f as W,e as U,g as K,h as G,p as J,z as Z,i as X,u as Y,r as Q,v as ee,S as te,j as ne,d as oe,k as re,c as ie,C as se}from"./types-CsXckO56.js";import ae,{useRef as le,useState as ce,useMemo as de,createContext as ue,useContext as pe,useCallback as he,useLayoutEffect as fe,useEffect as me,forwardRef as ge,useImperativeHandle as ve,memo as ye}from"react";import{a as we,S as be,e as ke,l as Ce,T as xe,ad as Ne,a2 as Se,ae as Oe}from"./index-TeLD_8PN.js";import{c as Ee,d as Me}from"./commons-D9Mh1s5L.js";import"./enums.js";import"./constants.js";import{L as _e,s as Te,m as De,f as Ie}from"./LoaderLayer-CXFK-kAz.js";import"motion/react";import"react-dom";import"swr";import{c as Ae}from"./clsx-BeLtu-UY.js";import{p as Re}from"./purify.es-DBOWJxv3.js";import{c as Pe,f as Le,o as Ve,m as je,s as $e}from"./floating-ui.dom-BKnkJW47.js";import{t as Be,d as He}from"./throttle-BsCMUG1-.js";import{d as Fe,P as ze,Q as qe,x as We,R as Ue}from"./memoize-CPUrcYQl.js";import{i as Ke}from"./viz-CFEjElvl.js";import{au as Ge}from"./mermaid.core-C89m9NSM.js";import{y as Je}from"./websocket-C4G3j9Rm.js";import"./index-o2jBRnrQ.js";import"@ably/spaces";import"@ably/spaces/react";import"ably";import"ably/liveobjects";import"ably/react";import"@ably/spaces/dist/mjs/react";import"./toNumber-Bh_HTlSx.js";import"./isSymbol-CATEdeai.js";import"./string-LeDn2fkG.js";const Ze={}.hasOwnProperty;function Xe(e,t){let n,o=-1;if(t.extensions)for(;++o<t.extensions.length;)Xe(e,t.extensions[o]);for(n in t)if(Ze.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":Ye(e[n],t[n]);break;case"handlers":Qe(e[n],t[n]);break;default:e.options[n]=t[n]}return e}function Ye(e,t){t&&e.push(...t)}function Qe(e,t){t&&Object.assign(e,t)}const et=[function(e,t,n,o){if("code"===t.type&&W(t,o)&&("list"===e.type||e.type===t.type&&W(e,o)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&U(t,o)))return;return n.spread?1:0}}];const tt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],nt=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:tt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:tt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:tt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"~"}];function ot(e){return e.label||!e.identifier?e.label||"":K(e.identifier)}function rt(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function it(e,t,n,o){let r=o.join.length;for(;r--;){const i=o.join[r](e,t,n,o);if(!0===i||1===i)break;if("number"==typeof i)return"\n".repeat(1+i);if(!1===i)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const st=/\r?\n|\r/g;function at(e,t){const n=[];let o,r=0,i=0;for(;o=st.exec(e);)s(e.slice(r,o.index)),n.push(o[0]),r=o.index+o[0].length,i++;return s(e.slice(r)),n.join("");function s(e){n.push(t(e,i,!e))}}function lt(e,t){return e-t}function ct(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,o=[],r=[],i=e+t;let s,a=-1,l=0;for(;s=n.exec(i);)o.push(s.index);for(;++a<o.length;)l!==o[a]&&r.push(e.slice(l,o[a])),r.push("\\"),l=o[a];return r.push(e.slice(l)),r.join("")}function dt(e){const t=e||{},n=t.now||{};let o=t.lineShift||0,r=n.line||1,i=n.column||1;return{move:function(e){const t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return r+=n.length-1,i=1===n.length?i+s.length:1+s.length+o,t},current:function(){return{now:{line:r,column:i},lineShift:o}},shift:function(e){o+=e}}}function ut(e,t){const n={associationId:ot,containerPhrasing:mt,containerFlow:gt,createTracker:dt,compilePattern:rt,enter:function(e){return n.stack.push(e),function(){n.stack.pop()}},handlers:{...X},handle:void 0,indentLines:at,indexStack:[],join:[...et],options:{},safe:vt,stack:[],unsafe:[...nt]};Xe(n,t||{}),n.options.tightDefinitions&&n.join.push(ft),n.handle=Z("type",{invalid:pt,unknown:ht,handlers:n.handlers});let o=n.handle(e,void 0,n,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return o&&10!==o.charCodeAt(o.length-1)&&13!==o.charCodeAt(o.length-1)&&(o+="\n"),o}function pt(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function ht(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function ft(e,t){if("definition"===e.type&&e.type===t.type)return 0}function mt(e,t){return function(e,t,n){const o=t.indexStack,r=e.children||[],i=[];let s,a=-1,l=n.before;o.push(-1);let c=t.createTracker(n);for(;++a<r.length;){const d=r[a];let u;if(o[o.length-1]=a,a+1<r.length){let n=t.handle.handlers[r[a+1].type];n&&n.peek&&(n=n.peek),u=n?n(r[a+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else u=n.after;i.length>0&&("\r"===l||"\n"===l)&&"html"===d.type&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),l=" ",c=t.createTracker(n),c.move(i.join("")));let p=t.handle(d,e,t,{...c.current(),after:u,before:l});s&&s===p.slice(0,1)&&(p=G(s.charCodeAt(0))+p.slice(1));const h=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,h&&(i.length>0&&h.before&&l===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+G(l.charCodeAt(0))),h.after&&(s=u)),c.move(p),i.push(p),l=p.slice(-1)}return o.pop(),i.join("")}(e,this,t)}function gt(e,t){return function(e,t,n){const o=t.indexStack,r=e.children||[],i=t.createTracker(n),s=[];let a=-1;for(o.push(-1);++a<r.length;){const n=r[a];o[o.length-1]=a,s.push(i.move(t.handle(n,e,t,{before:"\n",after:"\n",...i.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),a<r.length-1&&s.push(i.move(it(n,r[a+1],e,t)))}return o.pop(),s.join("")}(e,this,t)}function vt(e,t){return function(e,t,n){const o=(n.before||"")+(t||"")+(n.after||""),r=[],i=[],s={};let a=-1;for(;++a<e.unsafe.length;){const t=e.unsafe[a];if(!J(e.stack,t))continue;const n=e.compilePattern(t);let i;for(;i=n.exec(o);){const e="before"in t||Boolean(t.atBreak),n="after"in t,o=i.index+(e?i[1].length:0);r.includes(o)?(s[o].before&&!e&&(s[o].before=!1),s[o].after&&!n&&(s[o].after=!1)):(r.push(o),s[o]={before:e,after:n})}}r.sort(lt);let l=n.before?n.before.length:0;const c=o.length-(n.after?n.after.length:0);for(a=-1;++a<r.length;){const e=r[a];e<l||e>=c||e+1<c&&r[a+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||r[a-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(l!==e&&i.push(ct(o.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(o.charAt(e))||n.encode&&n.encode.includes(o.charAt(e))?(i.push(G(o.charCodeAt(e))),l++):i.push("\\"))}return i.push(ct(o.slice(l,c),n.after)),i.join("")}(this,e,t)}var yt=function(e){return e.docTypeError="docTypeError",e.contextNotFound="contextNotFound",e.timerNotFound="timerNotFound",e.ctxCallOutOfScope="ctxCallOutOfScope",e.createNodeInParserFail="createNodeInParserFail",e.stackOverFlow="stackOverFlow",e.parserMatchError="parserMatchError",e.serializerMatchError="serializerMatchError",e.getAtomFromSchemaFail="getAtomFromSchemaFail",e.expectDomTypeError="expectDomTypeError",e.callCommandBeforeEditorView="callCommandBeforeEditorView",e.missingRootElement="missingRootElement",e.missingNodeInSchema="missingNodeInSchema",e.missingMarkInSchema="missingMarkInSchema",e.ctxNotBind="ctxNotBind",e.missingYjsDoc="missingYjsDoc",e}({}),wt=class extends Error{constructor(e,t){super(t),this.name="MilkdownError",this.code=e}},bt=(e,t)=>"function"==typeof t?"[Function]":t,kt=e=>JSON.stringify(e,bt);function Ct(){return new wt(yt.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function xt(){return new wt(yt.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Nt(e){return new wt(yt.expectDomTypeError,`Expect to be a dom, but get: ${kt(e)}.`)}function St(){return new wt(yt.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Ot(e){return new wt(yt.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}var Et=class{constructor(){this.sliceMap=new Map,this.get=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw n="string"==typeof e?e:e.name,new wt(yt.contextNotFound,`Context "${n}" not found, do you forget to inject it?`);var n;return t},this.remove=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},Mt=class{#e=[];#t;#n=()=>{this.#e.forEach(e=>e(this.#t))};constructor(e,t,n){this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){const t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},_t=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw Ct()}}create(e,t=this._defaultValue){return new Mt(e,t,this)}},Tt=(e,t)=>new _t(e,t),Dt=class{#o;#r;#i;#s=new Set;#a=new Set;#l=new Map;#c=new Map;constructor(e,t,n){this.read=()=>({metadata:this.#o,injectedSlices:[...this.#s].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),consumedSlices:[...this.#a].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),recordedTimers:[...this.#l].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)})),waitTimers:[...this.#c].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)}))}),this.onRecord=e=>{this.#l.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#l.delete(e)},this.onDone=e=>{const t=this.#l.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{const n=Date.now();t.finally(()=>{this.#c.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#s.add(e)},this.onRemove=e=>{this.#s.delete(e)},this.onUse=e=>{this.#a.add(e)},this.#r=e,this.#i=t,this.#o=n}#d=e=>this.#r.get(e).get();#u=e=>this.#i.get(e).status},It=class e{#r;#i;#o;#p;constructor(t,n,o){this.produce=t=>t&&Object.keys(t).length?new e(this.#r,this.#i,{...t}):this,this.inject=(e,t)=>{const n=e.create(this.#r.sliceMap);return null!=t&&n.set(t),this.#p?.onInject(e),this},this.remove=e=>(this.#r.remove(e),this.#p?.onRemove(e),this),this.record=e=>(e.create(this.#i.store),this.#p?.onRecord(e),this),this.clearTimer=e=>(this.#i.remove(e),this.#p?.onClear(e),this),this.isInjected=e=>this.#r.has(e),this.isRecorded=e=>this.#i.has(e),this.use=e=>(this.#p?.onUse(e),this.#r.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#i.get(e),this.done=e=>{this.timer(e).done(),this.#p?.onDone(e)},this.wait=e=>{const t=this.timer(e).start();return this.#p?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#r=t,this.#i=n,this.#o=o,o&&(this.#p=new Dt(t,n,o))}get meta(){return this.#o}get inspector(){return this.#p}},At=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw n=e.name,new wt(yt.timerNotFound,`Timer "${n}" not found, do you forget to record it?`);var n;return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},Rt=class{#h=null;#f=null;#m;#g="pending";constructor(e,t){this.start=()=>(this.#h??=new Promise((e,t)=>{this.#f=t=>{t instanceof CustomEvent&&t.detail.id===this.#m&&(this.#g="resolved",this.#v(),t.stopImmediatePropagation(),e())},this.#y(()=>{"pending"===this.#g&&(this.#g="rejected"),this.#v(),t(new Error(`Timing ${this.type.name} timeout.`))}),this.#g="pending",addEventListener(this.type.name,this.#f)}),this.#h),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:this.#m}});dispatchEvent(e)},this.#m=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#g}#v=()=>{this.#f&&removeEventListener(this.type.name,this.#f)};#y=e=>{setTimeout(()=>{e()},this.type.timeout)}},Pt=class{constructor(e,t=3e3){this.create=e=>new Rt(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Lt=(e,t=3e3)=>new Pt(e,t);function Vt(e){const t=this;t.compiler=function(n){return ut(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function jt(e){this.content=e}function $t(e,t,n){for(let o=0;;o++){if(o==e.childCount||o==t.childCount)return e.childCount==t.childCount?null:n;let r=e.child(o),i=t.child(o);if(r!=i){if(!r.sameMarkup(i))return n;if(r.isText&&r.text!=i.text){for(let e=0;r.text[e]==i.text[e];e++)n++;return n}if(r.content.size||i.content.size){let e=$t(r.content,i.content,n+1);if(null!=e)return e}n+=r.nodeSize}else n+=r.nodeSize}}function Bt(e,t,n,o){for(let r=e.childCount,i=t.childCount;;){if(0==r||0==i)return r==i?null:{a:n,b:o};let s=e.child(--r),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:o};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,o--;return{a:n,b:o}}if(s.content.size||a.content.size){let e=Bt(s.content,a.content,n-1,o-1);if(e)return e}n-=l,o-=l}else n-=l,o-=l}}jt.prototype={constructor:jt,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var o=n&&n!=e?this.remove(n):this,r=o.find(e),i=o.content.slice();return-1==r?i.push(n||e,t):(i[r+1]=t,n&&(i[r]=n)),new jt(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new jt(n)},addToStart:function(e,t){return new jt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new jt(n)},addBefore:function(e,t,n){var o=this.remove(t),r=o.content.slice(),i=o.find(e);return r.splice(-1==i?r.length:i,0,t,n),new jt(r)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=jt.from(e)).size?new jt(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=jt.from(e)).size?new jt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=jt.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},jt.from=function(e){if(e instanceof jt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new jt(t)};let Ht=class e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,o=0,r){for(let i=0,s=0;s<t;i++){let a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,o+s,r||null,i)&&a.content.size){let r=s+1;a.nodesBetween(Math.max(0,e-r),Math.min(a.content.size,t-r),n,o+r)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,o){let r="",i=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=l},0),r}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,o=t.firstChild,r=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(o)&&(r[r.length-1]=n.withText(n.text+o.text),i=1);i<t.content.length;i++)r.push(t.content[i]);return new e(r,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let o=[],r=0;if(n>t)for(let e=0,i=0;i<n;e++){let s=this.content[e],a=i+s.nodeSize;a>t&&((i<t||a>n)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,n-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,n-i-1))),o.push(s),r+=s.nodeSize),i=a}return new e(o,r)}cutByIndex(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let o=this.content[t];if(o==n)return this;let r=this.content.slice(),i=this.size+n.nodeSize-o.nodeSize;return r[t]=n,new e(r,i)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let o=this.content[t];e(o,n,t),n+=o.nodeSize}}findDiffStart(e,t=0){return $t(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Bt(this,e,t,n)}findIndex(e){if(0==e)return zt(0,e);if(e==this.size)return zt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let o=n+this.child(t).nodeSize;if(o>=e)return o==e?zt(t+1,o):zt(t,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,o=0;for(let e=0;e<t.length;e++){let r=t[e];o+=r.nodeSize,e&&r.isText&&t[e-1].sameMarkup(r)?(n||(n=t.slice(0,e)),n[n.length-1]=r.withText(n[n.length-1].text+r.text)):n&&n.push(r)}return new e(n||t,o)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};Ht.empty=new Ht([],0);const Ft={index:0,offset:0};function zt(e,t){return Ft.index=e,Ft.offset=t,Ft}function qt(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!qt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!qt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Wt{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let o=0;o<e.length;o++){let r=e[o];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,o));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&qt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=n.create(t.attrs);return n.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Wt.none;if(e instanceof Wt)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Wt.none=[];class Ut extends Error{}class Kt{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Jt(this.content,e+this.openStart,t);return n&&new Kt(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Kt(Gt(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Kt.empty;let n=t.openStart||0,o=t.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new Kt(Ht.fromJSON(e,t.content),n,o)}static maxOpen(e,t=!0){let n=0,o=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)o++;return new Kt(e,n,o)}}function Gt(e,t,n){let{index:o,offset:r}=e.findIndex(t),i=e.maybeChild(o),{index:s,offset:a}=e.findIndex(n);if(r==t||i.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(o,i.copy(Gt(i.content,t-r-1,n-r-1)))}function Jt(e,t,n,o){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r);if(i==t||s.isText)return o&&!o.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let a=Jt(s.content,t-i-1,n,s);return a&&e.replaceChild(r,s.copy(a))}function Zt(e,t,n){if(n.openStart>e.depth)throw new Ut("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ut("Inconsistent open depths");return Xt(e,t,n,0)}function Xt(e,t,n,o){let r=e.index(o),i=e.node(o);if(r==t.index(o)&&o<e.depth-n.openStart){let s=Xt(e,t,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=o||t.depth!=o){let{start:r,end:s}=function(e,t){let n=t.depth-e.openStart,o=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)o=t.node(e).copy(Ht.from(o));return{start:o.resolveNoCache(e.openStart+n),end:o.resolveNoCache(o.content.size-e.openEnd-n)}}(n,e);return nn(i,on(e,r,s,t,o))}{let o=e.parent,r=o.content;return nn(o,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return nn(i,rn(e,t,o))}function Yt(e,t){if(!t.type.compatibleContent(e.type))throw new Ut("Cannot join "+t.type.name+" onto "+e.type.name)}function Qt(e,t,n){let o=e.node(n);return Yt(o,t.node(n)),o}function en(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function tn(e,t,n,o){let r=(t||e).node(n),i=0,s=t?t.index(n):r.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(en(e.nodeAfter,o),i++));for(let e=i;e<s;e++)en(r.child(e),o);t&&t.depth==n&&t.textOffset&&en(t.nodeBefore,o)}function nn(e,t){return e.type.checkContent(t),e.copy(t)}function on(e,t,n,o,r){let i=e.depth>r&&Qt(e,t,r+1),s=o.depth>r&&Qt(n,o,r+1),a=[];return tn(null,e,r,a),i&&s&&t.index(r)==n.index(r)?(Yt(i,s),en(nn(i,on(e,t,n,o,r+1)),a)):(i&&en(nn(i,rn(e,t,r+1)),a),tn(t,n,r,a),s&&en(nn(s,rn(n,o,r+1)),a)),tn(o,null,r,a),new Ht(a)}function rn(e,t,n){let o=[];if(tn(null,e,n,o),e.depth>n){en(nn(Qt(e,t,n+1),rn(e,t,n+1)),o)}return tn(t,null,n,o),new Ht(o)}Kt.empty=new Kt(Ht.empty,0,0);class sn{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=e.child(t);return n?e.child(t).cut(n):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],o=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)o+=n.child(t).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Wt.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),o=e.maybeChild(t);if(!n){let e=n;n=o,o=e}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,o=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new dn(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],o=0,r=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(r),s=r-i;if(n.push(t,e,o+i),!s)break;if(t=t.child(e),t.isText)break;r=s-1,o+=i+1}return new sn(t,n,r)}static resolveCached(e,t){let n=cn.get(e);if(n)for(let e=0;e<n.elts.length;e++){let o=n.elts[e];if(o.pos==t)return o}else cn.set(e,n=new an);let o=n.elts[n.i]=sn.resolve(e,t);return n.i=(n.i+1)%ln,o}}class an{constructor(){this.elts=[],this.i=0}}const ln=12,cn=new WeakMap;class dn{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const un=Object.create(null);class pn{constructor(e,t,n,o=Wt.none){this.type=e,this.attrs=t,this.marks=o,this.content=n||Ht.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,o=0){this.content.nodesBetween(e,t,n,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,o){return this.content.textBetween(e,t,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&qt(this.attrs,t||e.defaultAttrs||un)&&Wt.sameSet(this.marks,n||Wt.none)}copy(e=null){return e==this.content?this:new pn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new pn(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Kt.empty;let o=this.resolve(e),r=this.resolve(t),i=n?0:o.sharedDepth(t),s=o.start(i),a=o.node(i).content.cut(o.pos-s,r.pos-s);return new Kt(a,o.depth-i,r.depth-i)}replace(e,t,n){return Zt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let o=this.content.child(t-1);return{node:o,index:t-1,offset:n-o.nodeSize}}resolve(e){return sn.resolveCached(this,e)}resolveNoCache(e){return sn.resolve(this,e)}rangeHasMark(e,t,n){let o=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),fn(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=Ht.empty,o=0,r=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,o,r),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=o;e<r;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(e).matchType(n),i=r&&r.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Wt.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Wt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let o=Ht.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}pn.prototype.text=void 0;class hn extends pn{constructor(e,t,n,o){if(super(e,t,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fn(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new hn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new hn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function fn(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class mn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new gn(e,t);if(null==n.next)return mn.empty;let o=vn(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return n(xn(e,0));function n(o){let r=[];o.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let o;for(let e=0;e<r.length;e++)r[e][0]==t&&(o=r[e][1]);xn(e,n).forEach(e=>{o||r.push([t,o=[]]),-1==o.indexOf(e)&&o.push(e)})})});let i=t[o.join(",")]=new mn(o.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let o=r[e][1].sort(Cn);i.next.push({type:r[e][0],next:t[o.join(",")]||n(o)})}return i}}(function(e){let t=[[]];return r(i(e,0),n()),t;function n(){return t.push([])-1}function o(e,n,o){let r={term:o,to:n};return t[e].push(r),r}function r(e,t){e.forEach(e=>e.to=t)}function i(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(i(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return o(t,s),r(i(e.expr,s),s),[o(s)]}if("plus"==e.type){let s=n();return r(i(e.expr,t),s),r(i(e.expr,s),s),[o(s)]}if("opt"==e.type)return[o(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();r(i(e.expr,s),t),s=t}if(-1==e.max)r(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();o(s,t),r(i(e.expr,s),t),s=t}return[o(s)]}if("name"==e.type)return[o(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=i(e.exprs[o],t);if(o==e.exprs.length-1)return s;r(s,t=n())}}}(o));return function(e,t){for(let n=0,o=[e];n<o.length;n++){let e=o[n],r=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let o=this;for(let r=t;o&&r<n;r++)o=o.matchType(e.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let o=[this];return function r(i,s){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return Ht.from(s.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let e=r(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(e)){let e=[];for(let t=o;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:i,next:s}=r.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let o=0;o<n.next.length;o++)-1==e.indexOf(n.next[o].next)&&t(n.next[o].next)}(this),e.map((t,n)=>{let o=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)o+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return o}).join("\n")}}mn.empty=new mn(!0);class gn{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function vn(e){let t=[];do{t.push(yn(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function yn(e){let t=[];do{t.push(wn(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function wn(e){let t=function(e){if(e.eat("(")){let t=vn(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let r=[];for(let e in n){let o=n[e];o.isInGroup(t)&&r.push(o)}0==r.length&&e.err("No node type or group '"+t+"' found");return r}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=kn(e,t)}return t}function bn(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function kn(e,t){let n=bn(e),o=n;return e.eat(",")&&(o="}"!=e.next?bn(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function Cn(e,t){return t-e}function xn(e,t){let n=[];return function t(o){let r=e[o];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(o);for(let e=0;e<r.length;e++){let{term:o,to:i}=r[e];o||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Cn)}function Nn(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function Sn(e,t){let n=Object.create(null);for(let o in e){let r=t&&t[o];if(void 0===r){let t=e[o];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=t.default}n[o]=r}return n}function On(e,t,n,o){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in e){let o=e[n];o.validate&&o.validate(t[n])}}function En(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new _n(e,o,t[o]);return n}let Mn=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=En(e,n.attrs),this.defaultAttrs=Nn(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==mn.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Sn(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pn(this,this.computeAttrs(e),Ht.from(t),Wt.setFrom(n))}createChecked(e=null,t,n){return t=Ht.from(t),this.checkContent(t),new pn(this,this.computeAttrs(e),t,Wt.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=Ht.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let o=this.contentMatch.matchFragment(t),r=o&&o.fillBefore(Ht.empty,!0);return r?new pn(this,e,t.append(r),Wt.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){On(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Wt.none:e}static compile(t,n){let o=Object.create(null);t.forEach((t,r)=>o[t]=new e(t,n,r));let r=n.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let e in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};class _n{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${r}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Tn{constructor(e,t,n,o){this.name=e,this.rank=t,this.schema=n,this.spec=o,this.attrs=En(e,o.attrs),this.excluded=null;let r=Nn(this.attrs);this.instance=r?new Wt(this,r):null}create(e=null){return!e&&this.instance?this.instance:new Wt(this,Sn(this.attrs,e))}static compile(e,t){let n=Object.create(null),o=0;return e.forEach((e,r)=>n[e]=new Tn(e,o++,t,r)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){On(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Dn{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=jt.from(e.nodes),t.marks=jt.from(e.marks||{}),this.nodes=Mn.compile(this.spec.nodes,this),this.marks=Tn.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],o=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=n[o]||(n[o]=mn.parse(o,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?In(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:In(this,n.split(" "))}this.nodeFromJSON=e=>pn.fromJSON(this,e),this.markFromJSON=e=>Wt.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,o){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Mn))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,o)}text(e,t){let n=this.nodes.text;return new hn(n,n.defaultAttrs,e,Wt.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function In(e,t){let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e.marks[r],s=i;if(i)n.push(i);else for(let t in e.marks){let o=e.marks[t];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}class An{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new $n(this,t,!1);return n.addAll(e,Wt.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new $n(this,t,!0);return n.addAll(e,Wt.none,t.from,t.to),Kt.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(Bn(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(e)||o.context&&!n.matchesContext(o.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(o.getAttrs){let e=o.getAttrs(t);if(!1===e)continue;o.attrs=e||void 0}return o}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,o=0;for(;o<t.length;o++){let e=t[o];if((null==e.priority?50:e.priority)<n)break}t.splice(o,0,e)}for(let t in e.marks){let o=e.marks[t].spec.parseDOM;o&&o.forEach(e=>{n(e=Hn(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let o=e.nodes[t].spec.parseDOM;o&&o.forEach(e=>{n(e=Hn(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new An(e,An.schemaRules(e)))}}const Rn={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Pn={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ln={ol:!0,ul:!0};function Vn(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class jn{constructor(e,t,n,o,r,i){this.type=e,this.attrs=t,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=Wt.none,this.match=r||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Ht.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=Ht.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Ht.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Rn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $n{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=t.topNode,i=Vn(null,t.preserveWhitespace,0)|(n?4:0);o=r?new jn(r.type,r.attrs,Wt.none,!0,t.topMatch||r.type.contentMatch,i):new jn(n?null:e.schema.topNodeType,null,Wt.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0,{schema:i}=this.parser;if("full"===r||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)if("full"===r)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=o.content[o.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let o=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Ln.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Ln.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Pn.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,o=this.needsBlock;if(Rn.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=a&&a.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let o=this.parser.matchedStyles[e],r=n.getPropertyValue(o);if(r)for(let e;;){let n=this.parser.matchStyle(o,r,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,o){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,n,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let o=e;"string"==typeof t.contentElement?o=e.querySelector(t.contentElement):"function"==typeof t.contentElement?o=t.contentElement(e):t.contentElement&&(o=t.contentElement),this.findAround(e,o,!0),this.addAll(o,n),this.findAround(e,o,!1)}r&&this.sync(s)&&this.open--}addAll(e,t,n,o){let r=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==o?null:e.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t,n){let o,r;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!o||o.length>a.length+i)&&(o=a,r=s,!a.length))break;if(s.solid){if(n)break;i+=2}}if(!o)return null;this.sync(r);for(let e=0;e<o.length;e++)t=this.enterInner(o[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let o=this.findPlace(e,t,n);if(o){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Wt.none;for(let r of o.concat(e.marks))(t.type?t.type.allowsMarkType(r.type):Fn(r.type,e.type))&&(n=r.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,o){let r=this.findPlace(e.create(t),n,!1);return r&&(r=this.enterInner(e,t,n,!0,o)),r}enterInner(e,t,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=Vn(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=Wt.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):Fn(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new jn(e,t,a,o,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)if(null==this.find[o].pos&&1==e.nodeType&&e.contains(this.find[o].node)){t.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function Bn(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Hn(e){let t={};for(let n in e)t[n]=e[n];return t}function Fn(e,t){let n=t.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:o,next:r}=e.edge(n);if(o==t)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class zn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Wn(t).createDocumentFragment());let o=n,r=[];return e.forEach(e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:o}=Gn(Wn(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let o=this.marks[e.type.name];return o&&Gn(Wn(n),o(e,t),null,e.attrs)}static renderSpec(e,t,n=null,o){return Gn(e,t,n,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new zn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=qn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return qn(e.marks)}}function qn(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function Wn(e){return e.document||window.document}const Un=new WeakMap;function Kn(e){let t=Un.get(e);return void 0===t&&Un.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function Gn(e,t,n,o){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=Kn(o))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let l=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&l.style?l.style.cssText=c[e]:l.setAttribute(e,c[e])}}for(let r=d;r<t.length;r++){let i=t[r];if(0===i){if(r<t.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}{let{dom:t,contentDOM:r}=Gn(e,i,n,o);if(l.appendChild(t),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:l,contentDOM:s}}const Jn=Math.pow(2,16);function Zn(e,t){return e+t*Jn}function Xn(e){return 65535&e}class Yn{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Qn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Qn.empty)return Qn.empty}recover(e){let t=0,n=Xn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Jn}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?o:0);if(a>e)break;let l=this.ranges[s+r],c=this.ranges[s+i],d=a+l;if(e<=d){let r=a+o+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return r;let i=e==(t<0?a:d)?null:Zn(s/3,e-a),u=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(u|=8),new Yn(r,u,i)}o+=c-l}return n?e+o:new Yn(e+o,0,null)}touches(e,t){let n=0,o=Xn(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+r];if(e<=s+a&&t==3*o)return!0;n+=this.ranges[t+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),a=i+(this.inverted?0:r),l=this.ranges[o+t],c=this.ranges[o+n];e(s,s+l,a,a+c),r+=c-l}}invert(){return new Qn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?Qn.empty:new Qn(e<0?[0,-e,0]:[0,0,e])}}Qn.empty=new Qn([]);class eo{constructor(e,t,n=0,o=(e?e.length:0)){this.mirror=t,this.from=n,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new eo(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],null!=o&&o<t?n+o:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=o&&o>t?n-o-1:void 0)}}invert(){let e=new eo;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(r.recover);continue}}o|=r.delInfo,e=r.pos}return n?e:new Yn(e,o,null)}}const to=Object.create(null);class no{getMap(){return Qn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=to[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in to)throw new RangeError("Duplicate use of step JSON ID "+e);return to[e]=t,t.prototype.jsonID=e,t}}class oo{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new oo(e,null)}static fail(e){return new oo(null,e)}static fromReplace(e,t,n,o){try{return oo.ok(e.replace(t,n,o))}catch(e){if(e instanceof Ut)return oo.fail(e.message);throw e}}}function ro(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(ro(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return Ht.fromArray(o)}class io extends no{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new Kt(ro(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,o),t.openStart,t.openEnd);return oo.fromReplace(e,this.from,this.to,r)}invert(){return new so(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new io(t.pos,n.pos,this.mark)}merge(e){return e instanceof io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new io(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new io(t.from,t.to,e.markFromJSON(t.mark))}}no.jsonID("addMark",io);class so extends no{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Kt(ro(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return oo.fromReplace(e,this.from,this.to,n)}invert(){return new io(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new so(t.pos,n.pos,this.mark)}merge(e){return e instanceof so&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new so(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new so(t.from,t.to,e.markFromJSON(t.mark))}}no.jsonID("removeMark",so);class ao extends no{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return oo.fromReplace(e,this.pos,this.pos+1,new Kt(Ht.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new ao(this.pos,t.marks[n]);return new ao(this.pos,this.mark)}}return new lo(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ao(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ao(t.pos,e.markFromJSON(t.mark))}}no.jsonID("addNodeMark",ao);class lo extends no{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return oo.fromReplace(e,this.pos,this.pos+1,new Kt(Ht.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new ao(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new lo(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new lo(t.pos,e.markFromJSON(t.mark))}}no.jsonID("removeNodeMark",lo);class co extends no{constructor(e,t,n,o=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=o}apply(e){return this.structure&&po(e,this.from,this.to)?oo.fail("Structure replace would overwrite content"):oo.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Qn([this.from,this.to-this.from,this.slice.size])}invert(e){return new co(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&co.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new co(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof co)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new co(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new co(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new co(t.from,t.to,Kt.fromJSON(e,t.slice),!!t.structure)}}co.MAP_BIAS=1,no.jsonID("replace",co);class uo extends no{constructor(e,t,n,o,r,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(e){if(this.structure&&(po(e,this.from,this.gapFrom)||po(e,this.gapTo,this.to)))return oo.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return oo.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?oo.fromReplace(e,this.from,this.to,n):oo.fail("Content does not fit in gap")}getMap(){return new Qn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new uo(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||o<t.pos||r>n.pos?null:new uo(t.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new uo(t.from,t.to,t.gapFrom,t.gapTo,Kt.fromJSON(e,t.slice),t.insert,!!t.structure)}}function po(e,t,n){let o=e.resolve(t),r=n-t,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let e=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function ho(e,t,n,o=n.contentMatch,r=!0){let i=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<i.childCount;t++){let l=i.child(t),c=a+l.nodeSize,d=o.matchType(l.type);if(d){o=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new so(a,c,l.marks[t]));if(r&&l.isText&&"pre"!=n.whitespace){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(l.text);)t||(t=new Kt(Ht.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new co(a+e.index,a+e.index+e[0].length,t))}}else s.push(new co(a,c,Kt.empty));a=c}if(!o.validEnd){let t=o.fillBefore(Ht.empty,!0);e.replace(a,a,new Kt(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function fo(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function mo(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,o=0,r=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+o,a=e.$to.indexAfter(n)-r;if(n<e.depth&&i.canReplace(s,a,t))return n;if(0==n||i.type.spec.isolating||!fo(i,s,a))break;s&&(o=1),a<i.childCount&&(r=1)}return null}function go(e,t,n=null,o=e){let r=function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.contentMatchAt(o).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(o,r,s)?i:null}(e,t),i=r&&function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.child(o),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=o;a&&e<r;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(o,t);return i?r.map(vo).concat({type:t,attrs:n}).concat(i.map(vo)):null}function vo(e){return{type:e,attrs:null}}function yo(e,t,n,o){t.forEach((r,i)=>{if(r.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(r.text);){let r=e.mapping.slice(o).map(n+1+i+s.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}})}function wo(e,t,n,o){t.forEach((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(o).map(n+1+i);e.replaceWith(r,r+1,t.type.schema.text("\n"))}})}function bo(e,t,n=1,o){let r=e.resolve(t),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>i;e--,t--){let n=r.node(e),i=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=o&&o[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=o&&o[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=r.indexAfter(i),l=o&&o[0];return r.node(i).canReplaceWith(a,a,l?l.type:r.node(i+1).type)}function ko(e,t){let n=e.resolve(t),o=n.index();return r=n.nodeBefore,i=n.nodeAfter,!(!r||!i||r.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=i.type==o?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(r,i))&&n.parent.canReplace(o,o+1);var r,i}function Co(e,t,n=t,o=Kt.empty){if(t==n&&!o.size)return null;let r=e.resolve(t),i=e.resolve(n);return xo(r,i,o)?new co(t,n,o):new No(r,i,o).fit()}function xo(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}no.jsonID("replaceAround",uo);class No{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=Ht.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=Ht.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let a=new Kt(r,i,s);return e>-1?new uo(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new co(n.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<e;n++){let r=t.firstChild;if(t.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,o=null;n?(o=Eo(this.unplaced.content,n-1).firstChild,e=o.content):e=this.unplaced.content;let r=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(r?a.matchType(r.type)||(l=a.fillBefore(Ht.from(r),!1)):o&&s.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:e,parent:o,inject:l};if(2==t&&r&&(i=a.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:e,parent:o,wrap:i};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Eo(e,t);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new Kt(e,t+1,Math.max(n,o.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Eo(e,t);if(o.childCount<=1&&t>0){let r=e.size-t<=t+o.size;this.unplaced=new Kt(So(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new Kt(So(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let e=0;e<r.length;e++)this.openFrontierNode(r[e]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-e,l=0,c=[],{match:d,type:u}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)c.push(o.child(e));d=d.matchFragment(o)}let p=s.size+e-(i.content.size-i.openEnd);for(;l<s.childCount;){let e=s.child(l),t=d.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(d=t,c.push(Mo(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?p:-1)))}let h=l==s.childCount;h||(p=-1),this.placed=Oo(this.placed,t,Ht.from(c)),this.frontier[t].match=d,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<p;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=h?0==e?Kt.empty:new Kt(So(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new Kt(So(i.content,e,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!_o(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:o}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=_o(e,t,o,n,r);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:o}=this.frontier[n],r=_o(e,n,o,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:i,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Oo(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),o=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,o)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Oo(this.placed,this.depth,Ht.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(Ht.empty,!0);e.childCount&&(this.placed=Oo(this.placed,this.frontier.length,e))}}function So(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(So(e.firstChild.content,t-1,n)))}function Oo(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Oo(e.lastChild.content,t-1,n)))}function Eo(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Mo(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,Mo(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(Ht.empty,!0)))),e.copy(o)}function _o(e,t,n,o,r){let i=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=o.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}(n,i.content,s)?a:null}function To(e){return e.spec.defining||e.spec.definingForContent}function Do(e,t,n,o,r){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Do(r.content,t+1,n,o,r)))}if(t>o){let t=r.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(Ht.empty,!0))}return e}function Io(e,t){let n=[];for(let o=Math.min(e.depth,t.depth);o>=0;o--){let r=e.start(o);if(r<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(r==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==r-1)&&n.push(o)}return n}class Ao extends no{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return oo.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let o=t.type.create(n,null,t.marks);return oo.fromReplace(e,this.pos,this.pos+1,new Kt(Ht.from(o),0,t.isLeaf?0:1))}getMap(){return Qn.empty}invert(e){return new Ao(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ao(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ao(t.pos,t.attr,t.value)}}no.jsonID("attr",Ao);class Ro extends no{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return oo.ok(n)}getMap(){return Qn.empty}invert(e){return new Ro(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ro(t.attr,t.value)}}no.jsonID("docAttr",Ro);let Po=class extends Error{};Po=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Po.prototype=Object.create(Error.prototype)).constructor=Po,Po.prototype.name="TransformError";class Lo{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new eo}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Po(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let o=this.mapping.maps[n];n&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((n,o,r,i)=>{e=Math.min(e,r),t=Math.max(t,i)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Kt.empty){let o=Co(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new Kt(Ht.from(n),0,0))}delete(e,t){return this.replace(e,t,Kt.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),i=e.doc.resolve(n);if(xo(r,i,o))return e.step(new co(t,n,o));let s=Io(r,i);0==s[s.length-1]&&s.pop();let a=-(r.depth+1);s.unshift(a);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:r.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==o.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=To(t.type);if(n&&!t.sameMarkup(r.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=o.openStart;t>=0;t--){let a=(t+d+1)%(o.openStart+1),u=c[a];if(u)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let p=r.node(c-1),h=r.index(c-1);if(p.canReplaceWith(h,h,u.type,u.marks))return e.replace(r.before(c),d?i.after(c):n,new Kt(Do(o.content,0,o.openStart,a),a,o.openEnd))}}let u=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,o),!(e.steps.length>u));a--){let e=s[a];e<0||(t=r.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=function(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(0==o.parentOffset)for(let e=o.depth-1;e>=0;e--){let t=o.index(e);if(o.node(e).canReplaceWith(t,t,n))return o.before(e+1);if(t>0)return null}if(o.parentOffset==o.parent.content.size)for(let e=o.depth-1;e>=0;e--){let t=o.indexAfter(e);if(o.node(e).canReplaceWith(t,t,n))return o.after(e+1);if(t<o.node(e).childCount)return null}return null}(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new Kt(Ht.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let o=e.doc.resolve(t),r=e.doc.resolve(n);if(o.parent.isTextblock&&r.parent.isTextblock&&o.start()!=r.start()&&0==o.parentOffset&&0==r.parentOffset){let i=o.sharedDepth(n),s=!1;for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=o.depth;e>0&&t==o.start(e);e--)t=o.before(e);for(let e=r.depth;e>0&&n==r.start(e);e--)n=r.before(e);o=e.doc.resolve(t),r=e.doc.resolve(n)}}let i=Io(o,r);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return e.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return e.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(t-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return e.delete(o.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:o,$to:r,depth:i}=t,s=o.before(i+1),a=r.after(i+1),l=s,c=a,d=Ht.empty,u=0;for(let e=i,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,d=Ht.from(o.node(e).copy(d)),u++):l--;let p=Ht.empty,h=0;for(let e=i,t=!1;e>n;e--)t||r.after(e+1)<r.end(e)?(t=!0,p=Ht.from(r.node(e).copy(p)),h++):c++;e.step(new uo(l,c,s,a,new Kt(d.append(p),u,h),d.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=null,{linebreakReplacement:r}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(r&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(r);e&&!t?o=!1:!e&&t&&(o=!0)}let a=e.steps.length;if(!1===o){let o=e.doc.resolve(t+n);wo(e,o.node(),o.before(),a)}s.inlineContent&&ho(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==o);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new co(c,l.map(t+n,-1),Kt.empty,!0)),!0===o){let t=e.doc.resolve(c);yo(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=Ht.empty;for(let e=n.length-1;e>=0;e--){if(o.size){let t=n[e].type.contentMatch.matchFragment(o);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=Ht.from(n[e].type.create(n[e].attrs,o))}let r=t.start,i=t.end;e.step(new uo(r,i,r,i,new Kt(o,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,o=null){return function(e,t,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let s="function"==typeof r?r(t):r;if(t.isTextblock&&!t.hasMarkup(o,s)&&function(e,t,n){let o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(o.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&wo(e,t,n,i),ho(e,e.mapping.slice(i).map(n,1),o,void 0,null===r);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new uo(l,c,l+1,c-1,new Kt(Ht.from(o.create(s,null,t.marks)),0,0),1,!0)),!0===r&&yo(e,t,n,i),!1}})}(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return function(e,t,n,o,r){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(o,null,r||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new uo(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Kt(Ht.from(s),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new Ao(e,t,n)),this}setDocAttribute(e,t){return this.step(new Ro(e,t)),this}addNodeMark(e,t){return this.step(new ao(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Wt)t.isInSet(n.marks)&&this.step(new lo(e,t));else{let o,r=n.marks,i=[];for(;o=t.isInSet(r);)i.push(new lo(e,o)),r=o.removeFromSet(r);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,o){let r=e.doc.resolve(t),i=Ht.empty,s=Ht.empty;for(let e=r.depth,t=r.depth-n,a=n-1;e>t;e--,a--){i=Ht.from(r.node(e).copy(i));let t=o&&o[a];s=Ht.from(t?t.type.create(t.attrs,s):r.node(e).copy(s))}e.step(new co(t,t,new Kt(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,o){let r,i,s=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(l,t),u=Math.min(l+e.nodeSize,n),p=o.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[e])?r.to=u:s.push(r=new so(c,u,d[e])));i&&i.to==c?i.to=u:a.push(i=new io(c,u,o))}}),s.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,o){let r=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let a=null;if(o instanceof Tn){let t,n=e.marks;for(;t=o.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(a=[o]):a=e.marks;if(a&&a.length){let o=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==i-1&&l.eq(r[e].style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:l,from:Math.max(s,t),to:o,step:i})}}}),r.forEach(t=>e.step(new so(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return ho(this,e,t,n),this}}const Vo=Object.create(null);class jo{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new $o(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Kt.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=e.mapping.slice(r);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Kt.empty:t),0==s&&Jo(e,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);r?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Jo(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let o=e.parent.inlineContent?new Fo(e):Go(e.node(0),e.parent,e.pos,e.index(),t,n);if(o)return o;for(let o=e.depth-1;o>=0;o--){let r=t<0?Go(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Go(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Uo(e.node(0))}static atStart(e){return Go(e,e,0,0,1)||new Uo(e)}static atEnd(e){return Go(e,e,e.content.size,e.childCount,-1)||new Uo(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Vo[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Vo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Fo.between(this.$anchor,this.$head).getBookmark()}}jo.prototype.visible=!0;class $o{constructor(e,t){this.$from=e,this.$to=t}}let Bo=!1;function Ho(e){Bo||e.parent.inlineContent||(Bo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Fo extends jo{constructor(e,t=e){Ho(e),Ho(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return jo.near(n);let o=e.resolve(t.map(this.anchor));return new Fo(o.parent.inlineContent?o:n,n)}replace(e,t=Kt.empty){if(super.replace(e,t),t==Kt.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof Fo&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Fo(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let o=e.resolve(t);return new this(o,n==t?o:e.resolve(n))}static between(e,t,n){let o=e.pos-t.pos;if(n&&!o||(n=o>=0?1:-1),!t.parent.inlineContent){let e=jo.findFrom(t,n,!0)||jo.findFrom(t,-n,!0);if(!e)return jo.near(t,n);t=e.$head}return e.parent.inlineContent||(0==o||(e=(jo.findFrom(e,-n,!0)||jo.findFrom(e,n,!0)).$anchor).pos<t.pos!=o<0)&&(e=t),new Fo(e,t)}}jo.jsonID("text",Fo);class zo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new zo(e.map(this.anchor),e.map(this.head))}resolve(e){return Fo.between(e.resolve(this.anchor),e.resolve(this.head))}}class qo extends jo{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:o}=t.mapResult(this.anchor),r=e.resolve(o);return n?jo.near(r):new qo(r)}content(){return new Kt(Ht.from(this.node),0,0)}eq(e){return e instanceof qo&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Wo(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new qo(e.resolve(t.anchor))}static create(e,t){return new qo(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}qo.prototype.visible=!1,jo.jsonID("node",qo);class Wo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new zo(n,n):new Wo(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&qo.isSelectable(n)?new qo(t):jo.near(t)}}class Uo extends jo{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Kt.empty){if(t==Kt.empty){e.delete(0,e.doc.content.size);let t=jo.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Uo(e)}map(e){return new Uo(e)}eq(e){return e instanceof Uo}getBookmark(){return Ko}}jo.jsonID("all",Uo);const Ko={map(){return this},resolve:e=>new Uo(e)};function Go(e,t,n,o,r,i=!1){if(t.inlineContent)return Fo.create(e,n);for(let s=o-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let o=t.child(s);if(o.isAtom){if(!i&&qo.isSelectable(o))return qo.create(e,n-(r<0?o.nodeSize:0))}else{let t=Go(e,o,n+r,r<0?o.childCount:0,r,i);if(t)return t}n+=o.nodeSize*r}return null}function Jo(e,t,n){let o=e.steps.length-1;if(o<t)return;let r,i=e.steps[o];(i instanceof co||i instanceof uo)&&(e.mapping.maps[o].forEach((e,t,n,o)=>{null==r&&(r=o)}),e.setSelection(jo.near(e.doc.resolve(r),n)))}class Zo extends Lo{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Wt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Wt.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let o=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,o.text(e,r)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(jo.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Xo(e,t){return t&&e?e.bind(t):e}class Yo{constructor(e,t,n){this.name=e,this.init=Xo(t.init,n),this.apply=Xo(t.apply,n)}}const Qo=[new Yo("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Yo("selection",{init:(e,t)=>e.selection||jo.atStart(t.doc),apply:e=>e.selection}),new Yo("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,o)=>o.selection.$cursor?e.storedMarks:null}),new Yo("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class er{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qo.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Yo(e.key,e.spec.state,e))})}}class tr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=o?o[i].n:0,l=o?o[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!o){o=[];for(let e=0;e<this.config.plugins.length;e++)o.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new tr(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new Zo(this)}static create(e){let t=new er(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new tr(t);for(let o=0;o<t.fields.length;o++)n[t.fields[o].name]=t.fields[o].init(e,n);return n}reconfigure(e){let t=new er(this.schema,e.plugins),n=t.fields,o=new tr(t);for(let t=0;t<n.length;t++){let r=n[t].name;o[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[n],r=o.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new er(e.schema,e.plugins),r=new tr(o);return o.fields.forEach(o=>{if("doc"==o.name)r.doc=pn.fromJSON(e.schema,t.doc);else if("selection"==o.name)r.selection=jo.fromJSON(r.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==o.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(r[o.name]=a.fromJSON.call(s,e,t[i],r))}r[o.name]=o.init(e,r)}}),r}}function nr(e,t,n){for(let o in e){let r=e[o];r instanceof Function?r=r.bind(t):"handleDOMEvents"==o&&(r=nr(r,t,{})),n[o]=r}return n}class or{constructor(e){this.spec=e,this.props={},e.props&&nr(e.props,this,this.props),this.key=e.key?e.key.key:ir("plugin")}getState(e){return e[this.key]}}const rr=Object.create(null);function ir(e){return e in rr?e+"$"+ ++rr[e]:(rr[e]=0,e+"$")}class sr{constructor(e="key"){this.key=ir(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ar=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lr(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const cr=(e,t,n)=>{let o=lr(e,n);if(!o)return!1;let r=hr(o);if(!r){let n=o.blockRange(),r=n&&mo(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(yr(e,r,t,-1))return!0;if(0==o.parent.content.size&&(ur(i,"end")||qo.isSelectable(i)))for(let n=o.depth;;n--){let s=Co(e.doc,o.before(n),o.after(n),Kt.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ur(i,"end")?jo.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):qo.create(n.doc,r.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),!0)},dr=(e,t,n)=>{let o=lr(e,n);if(!o)return!1;let r=hr(o);return!!r&&function(e,t,n){let o=t.nodeBefore,r=o,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let s=t.nodeAfter,a=s,l=t.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let c=Co(e.doc,i,l,Kt.empty);if(!c||c.from!=i||c instanceof co&&c.slice.size>=l-i)return!1;if(n){let t=e.tr.step(c);t.setSelection(Fo.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,r,t)};function ur(e,t,n=!1){for(let o=e;o;o="start"==t?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const pr=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=hr(o)}let s=i&&i.nodeBefore;return!(!s||!qo.isSelectable(s))&&(t&&t(e.tr.setSelection(qo.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function hr(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fr(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function mr(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const gr=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=mr(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(t){let o=n.after(),r=e.tr.replaceWith(o,o,s.createAndFill());r.setSelection(jo.near(r.doc.resolve(o),1)),t(r.scrollIntoView())}return!0};const vr=(e,t)=>{let{$from:n,$to:o}=e.selection;if(e.selection instanceof qo&&e.selection.node.isBlock)return!(!n.parentOffset||!bo(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let r,i,s=[],a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),i=mr(n.node(e-1).contentMatchAt(n.indexAfter(e-1))),s.unshift(a&&i?{type:i}:null),r=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof Fo||e.selection instanceof Uo)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=bo(c.doc,d,s.length,s);if(u||(s[0]=i?{type:i}:null,u=bo(c.doc,d,s.length,s)),!u)return!1;if(c.split(d,s.length,s),!a&&l&&n.node(r).type!=i){let e=c.mapping.map(n.before(r)),t=c.doc.resolve(e);i&&n.node(r-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(r)),i)}return t&&t(c.scrollIntoView()),!0};function yr(e,t,n,o){let r,i,s=t.nodeBefore,a=t.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let o=t.nodeBefore,r=t.nodeAfter,i=t.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!r.isTextblock&&!ko(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(r=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(r[0]||a.type).validEnd){if(n){let o=t.pos+a.nodeSize,i=Ht.empty;for(let e=r.length-1;e>=0;e--)i=Ht.from(r[e].create(null,i));i=Ht.from(s.copy(i));let l=e.tr.step(new uo(t.pos-1,o,t.pos,o,new Kt(i,1,0),r.length,!0)),c=l.doc.resolve(o+2*r.length);c.nodeAfter&&c.nodeAfter.type==s.type&&ko(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||o>0&&l?null:jo.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),p=u&&mo(u);if(null!=p&&p>=t.depth)return n&&n(e.tr.lift(u,p).scrollIntoView()),!0;if(c&&ur(a,"start",!0)&&ur(s,"end")){let o=s,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=Ht.empty;for(let e=r.length-1;e>=0;e--)o=Ht.from(r[e].copy(o));n(e.tr.step(new uo(t.pos-r.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new Kt(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function wr(e){return function(t,n){let o=t.selection,r=e<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(t.tr.setSelection(Fo.create(t.doc,e<0?r.start(i):r.end(i)))),!0)}}const br=wr(-1),kr=wr(1);function Cr(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),a=s&&go(s,e,t);return!!a&&(o&&o(n.tr.wrap(s,a).scrollIntoView()),!0)}}function xr(e,t=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,(o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(e,t))if(o.type==e)r=!0;else{let t=n.doc.resolve(i),o=t.index();r=t.parent.canReplaceWith(o,o+1,e)}})}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,e,t)}o(r.scrollIntoView())}return!0}}function Nr(e,t=null,n){return function(n,o){let{empty:r,$cursor:i,ranges:s}=n.selection;if(r&&!i||!function(e,t,n){for(let o=0;o<t.length;o++){let{$from:r,$to:i}=t[o],s=0==r.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(r.pos,i.pos,(e,t)=>{if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}(n.doc,s,e))return!1;if(o)if(i)e.isInSet(n.storedMarks||i.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let r,i=n.tr;r=!s.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e));for(let n=0;n<s.length;n++){let{$from:o,$to:a}=s[n];if(r){let n=o.pos,r=a.pos,s=o.nodeAfter,l=a.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+c<r&&(n+=c,r-=d),i.addMark(n,r,e.create(t))}else i.removeMark(o.pos,a.pos,e)}o(i.scrollIntoView())}return!0}}function Sr(...e){return function(t,n,o){for(let r=0;r<e.length;r++)if(e[r](t,n,o))return!0;return!1}}let Or=Sr(ar,cr,pr),Er=Sr(ar,(e,t,n)=>{let o=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!o)return!1;let r=fr(o);if(!r)return!1;let i=r.nodeAfter;if(yr(e,r,t,1))return!0;if(0==o.parent.content.size&&(ur(i,"start")||qo.isSelectable(i))){let n=Co(e.doc,o.before(),o.after(),Kt.empty);if(n&&n.slice.size<n.to-n.from){if(t){let o=e.tr.step(n);o.setSelection(ur(i,"start")?jo.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):qo.create(o.doc,o.mapping.map(r.pos))),t(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1)&&(t&&t(e.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=fr(o)}let s=i&&i.nodeAfter;return!(!s||!qo.isSelectable(s))&&(t&&t(e.tr.setSelection(qo.create(e.doc,i.pos)).scrollIntoView()),!0)});const Mr={Enter:Sr((e,t)=>{let{$head:n,$anchor:o}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(o))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:o,$to:r}=n;if(n instanceof Uo||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=mr(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(Fo.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(bo(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&mo(o);return null!=r&&(t&&t(e.tr.lift(o,r).scrollIntoView()),!0)},vr),"Mod-Enter":gr,Backspace:Or,"Mod-Backspace":Or,"Shift-Backspace":Or,Delete:Er,"Mod-Delete":Er,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Uo(e.doc))),!0)},_r={"Ctrl-h":Mr.Backspace,"Alt-Backspace":Mr["Mod-Backspace"],"Ctrl-d":Mr.Delete,"Ctrl-Alt-Backspace":Mr["Mod-Delete"],"Alt-Delete":Mr["Mod-Delete"],"Alt-d":Mr["Mod-Delete"],"Ctrl-a":br,"Ctrl-e":kr};for(let e in Mr)_r[e]=Mr[e];const Tr=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?_r:Mr;class Dr{constructor(e,t,n={}){var o;this.match=e,this.match=e,this.handler="string"==typeof t?(o=t,function(e,t,n,r){let i=o;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let o=(n+=e)-r;o>0&&(i=t[0].slice(e-o,e)+i,n=r)}return e.tr.insertText(i,n,r)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const Ir=(e,t)=>{let n=e.plugins;for(let o=0;o<n.length;o++){let r,i=n[o];if(i.spec.isInputRules&&(r=i.getState(e))){if(t){let n=e.tr,o=r.transform;for(let e=o.steps.length-1;e>=0;e--)n.step(o.steps[e].invert(o.docs[e]));if(r.text){let t=n.doc.resolve(r.from).marks();n.replaceWith(r.from,r.to,e.schema.text(r.text,t))}else n.delete(r.from,r.to);t(n)}return!0}}return!1};function Ar(e,t,n=null,o){return new Dr(e,(e,r,i,s)=>{let a=n instanceof Function?n(r):n,l=e.tr.delete(i,s),c=l.doc.resolve(i).blockRange(),d=c&&go(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(i-1).nodeBefore;return u&&u.type==t&&ko(l.doc,i-1)&&(!o||o(r,u))&&l.join(i-1),l})}function Rr(e,t,n=null){return new Dr(e,(e,o,r,i)=>{let s=e.doc.resolve(r),a=n instanceof Function?n(o):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(r,i).setBlockType(r,r,t,a):null})}new Dr(/--$/,"—",{inCodeMark:!1}),new Dr(/\.\.\.$/,"…",{inCodeMark:!1}),new Dr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new Dr(/"$/,"”",{inCodeMark:!1}),new Dr(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new Dr(/'$/,"’",{inCodeMark:!1});const Pr="undefined"!=typeof navigator?navigator:null,Lr="undefined"!=typeof document?document:null,Vr=Pr&&Pr.userAgent||"",jr=/Edge\/(\d+)/.exec(Vr),$r=/MSIE \d/.exec(Vr),Br=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Vr),Hr=!!($r||Br||jr),Fr=$r?document.documentMode:Br?+Br[1]:jr?+jr[1]:0,zr=!Hr&&/gecko\/(\d+)/i.test(Vr),qr=zr&&+(/Firefox\/(\d+)/.exec(Vr)||[0,0])[1],Wr=!Hr&&/Chrome\/(\d+)/.exec(Vr),Ur=!!Wr,Kr=Wr?+Wr[1]:0,Gr=!Hr&&!!Pr&&/Apple Computer/.test(Pr.vendor),Jr=Gr&&(/Mobile\/\w+/.test(Vr)||!!Pr&&Pr.maxTouchPoints>2),Zr=Jr||!!Pr&&/Mac/.test(Pr.platform),Xr=/Android \d/.test(Vr),Yr=!!Lr&&"webkitFontSmoothing"in Lr.documentElement.style,Qr=Yr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var ei=Object.freeze({__proto__:null,android:Xr,chrome:Ur,chrome_version:Kr,gecko:zr,gecko_version:qr,ie:Hr,ie_version:Fr,ios:Jr,mac:Zr,safari:Gr,webkit:Yr,webkit_version:Qr});function ti(e,t,n,o,r,i){if(e.composing)return!1;const s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;const l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+o;for(let a of r){const r=a,c=r.match.exec(l),d=c&&c[0]&&r.handler(s,c,t-(c[0].length-o.length),n);if(d)return!1!==r.undoable&&d.setMeta(i,{transform:d,from:t,to:n,text:o}),e.dispatch(d),!0}return!1}const ni=new sr("MILKDOWN_CUSTOM_INPUTRULES");function oi({rules:e}){const t=new or({key:ni,isInputRules:!0,state:{init:()=>null,apply(e,t){const n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,o,r,i)=>ti(n,o,r,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:o}=n.state.selection;o&&ti(n,o.pos,o.pos,"",e,t)}),!1),keydown:(e,t)=>!(!Xr||!Ur||"Enter"!==t.key)&&(!e.composing&&(!!e.someProp("handleKeyDown",n=>n(e,t))&&(t.preventDefault(),!0)))},handleKeyDown(n,o){if("Enter"!==o.key)return!1;const{$cursor:r}=n.state.selection;return!!r&&ti(n,r.pos,r.pos,"\n",e,t)}}});return t}function ri(e,t,n={}){return new Dr(e,(e,o,r,i)=>{var s,a,l,c;const{tr:d}=e;let u,p=o[o.length-1],h=o[0],f=[];const m={group:p,fullMatch:h,start:r,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:p,fullMatch:h,start:r,end:i}=m),null===h)return null;if(""===(null==p?void 0:p.trim()))return null;if(p){const e=h.search(/\S/),s=r+h.indexOf(p),m=s+p.length;f=null!=(a=d.storedMarks)?a:[],m<i&&d.delete(m,i),s>r&&d.delete(r+e,s),u=r+e+p.length;const g=null==(l=n.getAttr)?void 0:l.call(n,o);d.addMark(r,u,t.create(g)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:o,start:r,end:i,tr:d})}return d})}var ii=Object.defineProperty,si=Object.defineProperties,ai=Object.getOwnPropertyDescriptors,li=Object.getOwnPropertySymbols,ci=Object.prototype.hasOwnProperty,di=Object.prototype.propertyIsEnumerable,ui=(e,t,n)=>t in e?ii(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function pi(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function hi(e,t,n){const o=e.state.doc.content.size,r=pi(t,0,o),i=pi(n,0,o),s=e.coordsAtPos(r),a=e.coordsAtPos(i,-1),l=Math.min(s.top,a.top),c=Math.max(s.bottom,a.bottom),d=Math.min(s.left,a.left),u=Math.max(s.right,a.right),p={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return h=((e,t)=>{for(var n in t||(t={}))ci.call(t,n)&&ui(e,n,t[n]);if(li)for(var n of li(t))di.call(t,n)&&ui(e,n,t[n]);return e})({},p),si(h,ai({toJSON:()=>p}));var h}function fi(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function mi(e){if(1===e.content.childCount){const t=e.content.firstChild;if("text"===(null==t?void 0:t.type.name)&&0===t.marks.length)return t;if("paragraph"===(null==t?void 0:t.type.name)&&1===t.childCount){const e=t.firstChild;if("text"===(null==e?void 0:e.type.name)&&0===e.marks.length)return e}}return!1}function gi(e){return t=>{for(let n=t.depth;n>0;n-=1){const o=t.node(n);if(e(o)){return{from:t.before(n),to:t.after(n),node:o}}}}}function vi(e,t){const n=t.nodes[e];if(!n)throw function(e,t){return new wt(yt.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}("node",e);return n}function yi(e){return t=>{for(let n=t.depth;n>0;n--){const o=t.node(n);if(e(o))return{pos:t.before(n),start:t.start(n),depth:n,node:o}}}}function wi(e,t){if(!(e instanceof qo))return;const{node:n,$from:o}=e;return function(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}(t,n)?{node:n,pos:o.pos,start:o.start(o.depth),depth:o.depth}:void 0}const bi=(e,t)=>{const{selection:n,doc:o}=e;if(n instanceof qo)return{hasNode:n.node.type===t,pos:n.from,target:n.node};const{from:r,to:i}=n;let s=!1,a=-1,l=null;return o.nodesBetween(r,i,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}},ki="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ci="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function xi(e){let t,n,o,r,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);ki?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function Ni(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Si(e){return new or({props:{handleKeyDown:Oi(e)}})}function Oi(e){let t=function(e){let t=Object.create(null);for(let n in e)t[xi(n)]=e[n];return t}(e);return function(e,n){let o,r=c(n),i=t[Ni(r,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=t[Ni(r,n,!1)];if(o&&o(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ci&&n.ctrlKey&&n.altKey)&&(o=d[n.keyCode])&&o!=r){let r=t[Ni(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Ei=class{},Mi=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw xt();return e}}},_i=class e extends Ei{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,o){return new e(t,n,o)}},Ti=class extends Mi{#w=Wt.none;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(_i.create(e,[],t)),this),this.closeNode=()=>{try{this.#b()}catch(e){console.error(e)}return this},this.addNode=(e,t,n)=>{try{this.#k(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>(this.#w=e.create(t).addToSet(this.#w),this),this.closeMark=e=>(this.#w=e.removeFromSet(this.#w),this),this.addText=e=>{try{const t=this.top();if(!t)throw xt();const n=t.pop(),o=this.schema.text(e,this.#w);if(!n)return t.push(o),this;const r=this.#C(n,o);return r?(t.push(r),this):(t.push(n,o),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do{e=this.#b()}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#x(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{const n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#N=e=>e.isText;#C=(e,t)=>{if(this.#N(e)&&this.#N(t)&&Wt.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)};#S=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw function(e){return new wt(yt.parserMatchError,`Cannot match target parser for node: ${kt(e)}.`)}(e);return t};#x=e=>{const t=this.#S(e);t.spec.parseMarkdown.runner(this,e,t)};#b=()=>{this.#w=Wt.none;const e=this.close();return this.#k(e.type,e.attrs,e.content)};#k=(e,t,n)=>{const o=e.createAndFill(t,n,this.#w);if(!o)throw function(e,t,n){const o=`Cannot create node for ${"name"in e?e.name:e}`,r=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(r).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},i=[["[Description]",o],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:r(e):"null")]].reduce((e,[t,n])=>{const o=`${t}: ${r(n)}.`;return e.concat(o)},[]);return new wt(yt.createNodeInParserFail,i.join("\n"))}(e,t,n);return this.push(o),o}},Di=class e extends Ei{constructor(e,t,n,o={}){super(),this.type=e,this.children=t,this.value=n,this.props=o,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,o,r={})=>new e(t,n,o,r)}},Ii=class extends Mi{#w=Wt.none;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.openNode=(e,t,n)=>(this.open(Di.create(e,void 0,t,n)),this),this.closeNode=()=>(this.#b(),this),this.addNode=(e,t,n,o)=>(this.#k(e,t,n,o),this),this.withMark=(e,t,n,o)=>(this.#O(e,t,n,o),this),this.closeMark=e=>(this.#E(e),this),this.build=()=>{let e=null;do{e=this.#b()}while(this.size());return e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach(e=>{this.#x(e)}),this):(this.#x(e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#S=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw function(e){return new wt(yt.serializerMatchError,`Cannot match target serializer for node: ${kt(e)}.`)}(e.type);return t};#M=e=>this.#S(e).spec.toMarkdown.runner(this,e);#_=(e,t)=>this.#S(e).spec.toMarkdown.runner(this,e,t);#x=e=>{const{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#_(t,e))&&this.#M(e),t.forEach(e=>this.#E(e))};#T=(e,t)=>{if(e.type===t)return e;if(1!==e.children?.length)return e;const n=e=>{if(e.type===t)return null!=e.value?null:e;if(1!==e.children?.length)return null;const[o]=e.children;return o?n(o):null},o=n(e);if(!o)return e;const r=o.children?[...o.children]:void 0,i={...e,children:r};return i.children=r,o.children=[i],o};#D=e=>{const{children:t}=e;return t?(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];const o=e.at(-1);if(o&&o.isMark&&t.isMark){t=this.#T(t,o.type);const{children:n,...r}=t,{children:i,...s}=o;if(t.type===o.type&&n&&i&&JSON.stringify(r)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(this.#D(t))}}return e.concat(t)},[]),e):e};#I=e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t};#A=(e,t)=>{let n="",o="";const r=e.children;let i=-1,s=-1;if(r){(a=r)&&a.forEach((e,t)=>{"text"===e.type&&e.value&&(i<0&&(i=t),s=t)});const e=r?.[s],t=r?.[i];if(e&&e.value.endsWith(" ")){const t=e.value,n=t.trimEnd();o=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){const e=t.value,o=e.trimStart();n=e.slice(0,e.length-o.length),t.value=o}}var a;n.length&&this.#k("text",void 0,n);const l=t();return o.length&&this.#k("text",void 0,o),l};#b=(e=!1)=>{const t=this.close(),n=()=>this.#k(t.type,t.children,t.value,t.props);return e?this.#A(t,n):n()};#k=(e,t,n,o)=>{const r=Di.create(e,t,n,o),i=this.#D(this.#I(r));return this.push(i),i};#O=(e,t,n,o)=>e.isInSet(this.#w)?this:(this.#w=e.addToSet(this.#w),this.openNode(t,n,{...o,isMark:!0}));#E=e=>{e.isInSet(this.#w)&&(this.#w=e.type.removeFromSet(this.#w),this.#b(!0))}};const Ai=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Ri=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Pi=null;const Li=function(e,t,n){let o=Pi||(Pi=document.createRange());return o.setEnd(e,null==n?e.nodeValue.length:n),o.setStart(e,t||0),o},Vi=function(e,t,n,o){return n&&($i(e,t,n,o,-1)||$i(e,t,n,o,1))},ji=/^(img|br|input|textarea|hr)$/i;function $i(e,t,n,o,r){for(var i;;){if(e==n&&t==o)return!0;if(t==(r<0?0:Bi(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Hi(e)||ji.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ai(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=r}else e=n,t=r<0?Bi(e):0}}}}function Bi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Hi(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Fi=function(e){return e.focusNode&&Vi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function zi(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const qi="undefined"!=typeof navigator?navigator:null,Wi="undefined"!=typeof document?document:null,Ui=qi&&qi.userAgent||"",Ki=/Edge\/(\d+)/.exec(Ui),Gi=/MSIE \d/.exec(Ui),Ji=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ui),Zi=!!(Gi||Ji||Ki),Xi=Gi?document.documentMode:Ji?+Ji[1]:Ki?+Ki[1]:0,Yi=!Zi&&/gecko\/(\d+)/i.test(Ui);Yi&&(/Firefox\/(\d+)/.exec(Ui)||[0,0])[1];const Qi=!Zi&&/Chrome\/(\d+)/.exec(Ui),es=!!Qi,ts=Qi?+Qi[1]:0,ns=!Zi&&!!qi&&/Apple Computer/.test(qi.vendor),rs=ns&&(/Mobile\/\w+/.test(Ui)||!!qi&&qi.maxTouchPoints>2),is=rs||!!qi&&/Mac/.test(qi.platform),ss=!!qi&&/Win/.test(qi.platform),as=/Android \d/.test(Ui),ls=!!Wi&&"webkitFontSmoothing"in Wi.documentElement.style,cs=ls?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ds(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function us(e,t){return"number"==typeof e?e:e[t]}function ps(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function hs(e,t,n){let o=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=Ri(s);continue}let e=s,n=e==i.body,a=n?ds(i):ps(e),l=0,c=0;if(t.top<a.top+us(o,"top")?c=-(a.top-t.top+us(r,"top")):t.bottom>a.bottom-us(o,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+us(r,"top")-a.top:t.bottom-a.bottom+us(r,"bottom")),t.left<a.left+us(o,"left")?l=-(a.left-t.left+us(r,"left")):t.right>a.right-us(o,"right")&&(l=t.right-a.right+us(r,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,o=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let r=e.scrollLeft-n,i=e.scrollTop-o;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Ri(s)}}function fs(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=Ri(o));return t}function ms(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:r,left:i}=e[n];o.scrollTop!=r+t&&(o.scrollTop=r+t),o.scrollLeft!=i&&(o.scrollLeft=i)}}let gs=null;function vs(e,t){let n,o,r,i,s=2e8,a=0,l=t.top,c=t.top;for(let d=e.firstChild,u=0;d;d=d.nextSibling,u++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=Li(d).getClientRects()}for(let p=0;p<e.length;p++){let h=e[p];if(h.top<=l&&h.bottom>=c){l=Math.max(h.bottom,l),c=Math.min(h.top,c);let e=h.left>t.left?h.left-t.left:h.right<t.left?t.left-h.right:0;if(e<s){n=d,s=e,o=e&&3==n.nodeType?{left:h.right<t.left?h.right:h.left,top:t.top}:t,1==d.nodeType&&e&&(a=u+(t.left>=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!r&&h.left<=t.left&&h.right>=t.left&&(r=d,i={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!n&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(a=u+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(e,t){let n,o=e.nodeValue.length,r=document.createRange();for(let i=0;i<o;i++){r.setEnd(e,i+1),r.setStart(e,i);let o=Cs(r,1);if(o.top!=o.bottom&&ys(t,o)){n={node:e,offset:i+(t.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),n||{node:e,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:e,offset:a}:vs(n,o)}function ys(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function ws(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let o=0;o<e.length;o++){let r=e[o];if(ys(t,r))return ws(n,t,r)}}if((i=(i+1)%o)==r)break}return e}function bs(e,t){let n,o=e.dom.ownerDocument,r=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(Bi(o.offsetNode),o.offset)}}catch(e){}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(Bi(o.startContainer),o.startOffset)}}}(o,t.left,t.top);i&&({node:n,offset:r}=i);let s,a=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!ys(t,n))return null;if(a=ws(e.dom,t,n),!a)return null}if(ns)for(let e=a;n&&e;e=Ri(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(Yi&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,o=n.childNodes[r];"IMG"==o.nodeName&&(e=o.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}let o;ls&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(e,t,n,o){let r=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>o.left||t.top>o.top?r=s.posBefore:(!i&&t.right<o.left||t.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(t.top+t.bottom)/2:o.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==s&&(s=function(e,t,n){let{node:o,offset:r}=vs(t,n),i=-1;if(1==o.nodeType&&!o.firstChild){let e=o.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(o,r,i)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function ks(e){return e.top<e.bottom||e.left<e.right}function Cs(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(ks(e))return e}return Array.prototype.find.call(n,ks)||e.getBoundingClientRect()}const xs=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ns(e,t,n){let{node:o,offset:r,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=ls||Yi;if(3==o.nodeType){if(!s||!xs.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let e=r,t=r,i=n<0?1:-1;return n<0&&!r?(t++,i=-1):n>=0&&r==o.nodeValue.length?(e--,i=1):n<0?e--:t++,Ss(Cs(Li(o,e,t),i),i<0)}{let e=Cs(Li(o,r,r),n);if(Yi&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let t=Cs(Li(o,r-1,r-1),-1);if(t.top==e.top){let n=Cs(Li(o,r,r+1),-1);if(n.top!=e.top)return Ss(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==Bi(o))){let e=o.childNodes[r-1];if(1==e.nodeType)return Os(e.getBoundingClientRect(),!1)}if(null==i&&r<Bi(o)){let e=o.childNodes[r];if(1==e.nodeType)return Os(e.getBoundingClientRect(),!0)}return Os(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==Bi(o))){let e=o.childNodes[r-1],t=3==e.nodeType?Li(e,Bi(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ss(Cs(t,1),!1)}if(null==i&&r<Bi(o)){let e=o.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Li(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Ss(Cs(t,-1),!0)}return Ss(Cs(3==o.nodeType?Li(o):o,-n),n>=0)}function Ss(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Os(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Es(e,t,n){let o=e.state,r=e.root.activeElement;o!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),r!=e.dom&&r&&r.focus()}}const Ms=/[\u0590-\u08ac]/;let _s=null,Ts=null,Ds=!1;function Is(e,t,n){return _s==t&&Ts==n?Ds:(_s=t,Ts=n,Ds="up"==n||"down"==n?function(e,t,n){let o=t.selection,r="up"==n?o.$from:o.$to;return Es(e,t,()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let o=Ns(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Li(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,a=e.domSelection();return a?Ms.test(o.parent.textContent)&&a.modify?Es(e,t,()=>{let{focusNode:t,focusOffset:r,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&r==u;try{a.collapse(i,s),t&&(t!=i||r!=s)&&a.extend&&a.extend(t,r)}catch(e){}return null!=l&&(a.caretBidiLevel=l),p}):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(e,t,n))}class As{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let o=this.children[t];if(o==e)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,o;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(e==this.dom&&this.contentDOM)o=t>Ai(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!1;break}if(t.previousSibling)break}if(null==o&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!0;break}if(t.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!t||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],r=n+o.size;if(n==e&&r!=n){for(;!o.border&&o.children.length;)for(let e=0;e<o.children.length;e++){let t=o.children[e];if(t.size){o=t;break}}return o}if(e<r)return o.descAt(e-n-o.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let t=0;n<this.children.length;n++){let r=this.children[n],i=t+r.size;if(i>e||r instanceof Bs){o=e-t;break}t=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Rs&&e.side>=0;n--);if(t<=0){let e,o=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,o=!1);return e&&t&&o&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Ai(e.dom)+1:0}}{let e,o=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,o=!1);return e&&o&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Ai(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==o&&e<=a){let r=i+n.border;if(e>=r&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=Ai(n.dom)+1;break}e-=n.size}-1==o&&(o=0)}if(o>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=Ai(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,o=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(r>a&&i<c)return l.setSelection(e-a-l.border,t-a-l.border,n,o);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((Yi||ns)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:Ai(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Yi&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(o=!0)}if(!(o||d&&ns)&&Vi(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Vi(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!d||!Yi)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let o=n+r.border,s=i-r.border;if(e>=o&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=o||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-o,t-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Rs extends As{constructor(e,t,n,o){let r,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ps extends As{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Ls extends As{constructor(e,t,n,o,r){super(e,[],n,o),this.mark=t,this.spec=r}static create(e,t,n,o){let r=o.nodeViews[t.type.name],i=r&&r(t,o,n);return i&&i.dom||(i=zn.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Ls(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let o=Ls.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;t<i&&(r=Qs(r,t,i,n)),e>0&&(r=Qs(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Vs extends As{constructor(e,t,n,o,r,i,s,a,l){super(e,[],r,i),this.node=t,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(e,t,n,o,r,i){let s,a=r.nodeViews[t.type.name],l=a&&a(t,r,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,o),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=zn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=Gs(c,n,t),l?s=new Hs(e,t,n,o,c,d||null,u,l,r,i+1):t.isText?new $s(e,t,n,o,c,u,r):new Vs(e,t,n,o,c,d||null,u,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ht.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Js(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,a=new Xs(this,i&&i.node,e);!function(e,t,n,o){let r=t.locals(e),i=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);o(s,r,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,p,h;for(;s<r.length&&r[s].to==i;){let e=r[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(Ys);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)h=-1,p=l,l=null;else{if(!(c<e.childCount))break;h=c,p=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)a.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=p.cut(e-i),p=p.cut(0,e-i),f=e,h=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(i,p),h),i=f}}(this.node,this.innerDeco,(t,r,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,r):t.type.side>=0&&!i&&a.syncToMarks(r==this.node.childCount?Wt.none:this.node.child(r).marks,n,e,r),a.placeWidget(t,e,o)},(t,i,l,c)=>{let d;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,i,l,c)||s&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(d=a.findIndexWithChild(r.node))>-1&&a.updateNodeAt(t,i,l,d,e)||a.updateNextNode(t,i,l,e,c,o)||a.addNode(t,i,l,e,o),o+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Fs(this.contentDOM,this.children,e),rs&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:o}=e.state.selection;if(!(e.state.selection instanceof Fo)||n<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let e=r.nodeValue,i=function(e,t,n,o){for(let r=0,i=0;r<e.childCount&&i<=o;){let s=e.child(r++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;r<e.childCount;){let t=e.child(r++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=o&&l.slice(o-t.length-a,o-a)==t)return o-t.length;let e=a<o?l.lastIndexOf(t,o-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==o&&l.length>=o+t.length-a&&l.slice(o-a,o-a+t.length)==t)return o}}return-1}(this.node.content,e,n-t,o-t);return i<0?null:{node:r,pos:i,text:e}}return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new Ps(this,r,t,o);e.input.compositionNodes.push(i),this.children=Qs(this.children,n,n+o.length,e,i)}update(e,t,n,o){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,o),!0)}updateInner(e,t,n,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Js(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Us(this.dom,this.nodeDOM,Ws(this.outerDeco,this.node,t),Ws(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function js(e,t,n,o,r){Gs(o,t,e);let i=new Vs(void 0,e,t,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class $s extends Vs{constructor(e,t,n,o,r,i,s){super(e,t,n,o,r,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new $s(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Bs extends As{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Hs extends Vs{constructor(e,t,n,o,r,i,s,a,l,c){super(e,t,n,o,r,i,s,l,c),this.spec=a}update(e,t,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,o),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Fs(e,t,n){let o=e.firstChild,r=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=o;)o=Zs(o),r=!0;o=o.nextSibling}else r=!0,e.insertBefore(a,o);if(s instanceof Ls){let t=o?o.previousSibling:e.lastChild;Fs(s.contentDOM,s.children,n),o=t?t.nextSibling:e.firstChild}}for(;o;)o=Zs(o),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const zs=function(e){e&&(this.nodeName=e)};zs.prototype=Object.create(null);const qs=[new zs];function Ws(e,t,n){if(0==e.length)return qs;let o=n?qs[0]:new zs,r=[o];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&r.push(o=new zs(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==r.length&&r.push(o=new zs(t.isInline?"span":"div")),"class"==e?o.class=(o.class?o.class+" ":"")+i:"style"==e?o.style=(o.style?o.style+";":"")+i:"nodeName"!=e&&(o[e]=i))}}}return r}function Us(e,t,n,o){if(n==qs&&o==qs)return t;let r=t;for(let t=0;t<o.length;t++){let i=o[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=qs[0]),r=t}Ks(r,s||qs[0],i)}return r}function Ks(e,t,n){for(let o in t)"class"==o||"style"==o||"nodeName"==o||o in n||e.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.remove(o[t]);for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Gs(e,t,n){return Us(e,e,qs,Ws(t,n,1!=e.nodeType))}function Js(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Zs(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Xs{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,o=n.children.length,r=e.childCount,i=new Map,s=[];e:for(;r>0;){let a;for(;;)if(o){let e=n.children[o-1];if(!(e instanceof Ls)){a=e,o--;break}n=e,o=e.children.length}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(r-1))break;--r,i.set(a,r),s.push(a)}}return{index:r,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,o){let r=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;r<s&&(r==i-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&!1!==e[r].type.spec.spanning;)r++;for(;r<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let r=-1,s=this.top.children.length;o<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[i])&&!this.isLocked(n.dom)){r=t;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let o=Ls.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof Vs){let l=this.preMatch.matched.get(a);if(null!=l&&l!=r)return!1;let c,d=a.dom,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&Js(t,a.outerDeco));if(!u&&a.update(e,t,n,o))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(a,e,t,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Js(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let s=Vs.create(this.top,t,n,o,r,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,o,r){let i=Vs.create(this.top,e,t,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){let o=new Rs(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ls;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof $s)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ns||es)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let o=new Bs(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Ys(e,t){return e.type.side-t.type.side}function Qs(e,t,n,o,r){let i=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,d=a+=l.size;c>=n||d<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(l.slice(n-c,l.size,o)))}return i}function ea(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=o.resolve(s);if(Fi(n)){for(a=s;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&qo.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let o=0==t,r=t==Bi(e);o||r;){if(e==n)return!0;let t=Ai(e);if(!(e=e.parentNode))return!1;o=o&&0==t,r=r&&t==Bi(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;l=new qo(s==e?c:o.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[a,s]=r==e.state.selection.anchor?[r,t]:[t,r],c=o.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=o.resolve(a);if(!l){l=ca(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return l}function ta(e){return e.editable?e.hasFocus():ua(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function na(e,t=!1){let n=e.state.selection;if(aa(e,n),ta(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&es){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Vi(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,o="IMG"==n.nodeName;o?t.collapse(n.parentNode,Ai(n)+1):t.collapse(n,0);!o&&!e.state.selection.visible&&Zi&&Xi<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let o,r,{anchor:i,head:s}=n;!oa||n instanceof Fo||(n.$from.parent.inlineContent||(o=ra(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=ra(e,n.to))),e.docView.setSelection(i,s,e,t),oa&&(o&&sa(o),r&&sa(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{ta(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const oa=ns||es&&ts<63;function ra(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(ns&&r&&"false"==r.contentEditable)return ia(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return ia(r);if(i)return ia(i)}}function ia(e){return e.contentEditable="true",ns&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function sa(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function aa(e,t){if(t instanceof qo){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(la(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else la(e)}function la(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function ca(e,t,n,o){return e.someProp("createSelectionBetween",o=>o(e,t,n))||Fo.between(t,n,o)}function da(e){return!(e.editable&&!e.hasFocus())&&ua(e)}function ua(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function pa(e,t){let{$anchor:n,$head:o}=e.selection,r=t>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return i&&jo.findFrom(i,t)}function ha(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function fa(e,t,n){let o=e.state.selection;if(!(o instanceof Fo)){if(o instanceof qo&&o.node.isInline)return ha(e,new Fo(t>0?o.$to:o.$from));{let n=pa(e.state,t);return!!n&&ha(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+r.nodeSize*(t<0?-1:1));return ha(e,new Fo(o.$anchor,i))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=pa(e.state,t);return!!(n&&n instanceof qo)&&ha(e,n)}if(!(is&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=t<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(qo.isSelectable(i)?ha(e,new qo(t<0?e.state.doc.resolve(r.pos-i.nodeSize):r)):!!ls&&ha(e,new Fo(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function ma(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ga(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function va(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=!1;Yi&&1==n.nodeType&&o<ma(n)&&ga(n.childNodes[o],-1)&&(s=!0);for(;;)if(o>0){if(1!=n.nodeType)break;{let e=n.childNodes[o-1];if(ga(e,-1))r=n,i=--o;else{if(3!=e.nodeType)break;n=e,o=n.nodeValue.length}}}else{if(ya(n))break;{let t=n.previousSibling;for(;t&&ga(t,-1);)r=n.parentNode,i=Ai(t),t=t.previousSibling;if(t)n=t,o=ma(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}s?wa(e,n,o):r&&wa(e,r,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=ma(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!ga(n.childNodes[o],1))break;r=n,i=++o}else{if(ya(n))break;{let t=n.nextSibling;for(;t&&ga(t,1);)r=t.parentNode,i=Ai(t)+1,t=t.nextSibling;if(t)n=t,o=0,s=ma(n);else{if(n=n.parentNode,n==e.dom)break;o=s=0}}}r&&wa(e,r,i)}(e)}function ya(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function wa(e,t,n){if(3!=t.nodeType){let e,o;(o=function(e,t){for(;e&&t==e.childNodes.length&&!Hi(e);)t=Ai(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(e=function(e,t){for(;e&&!t&&!Hi(e);)t=Ai(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let o=e.domSelection();if(!o)return;if(Fi(o)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),o.removeAllRanges(),o.addRange(e)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout(()=>{e.state==r&&na(e)},50)}function ba(e,t){let n=e.state.doc.resolve(t);if(!es&&!ss&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ka(e,t,n){let o=e.state.selection;if(o instanceof Fo&&!o.empty||n.indexOf("s")>-1)return!1;if(is&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=pa(e.state,t);if(n&&n instanceof qo)return ha(e,n)}if(!r.parent.inlineContent){let n=t<0?r:i,s=o instanceof Uo?jo.near(n,t):jo.findFrom(n,t);return!!s&&ha(e,s)}return!1}function Ca(e,t){if(!(e.state.selection instanceof Fo))return!0;let{$head:n,$anchor:o,empty:r}=e.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=e.state.tr;return t<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),e.dispatch(o),!0}return!1}function xa(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Na(e,t){let n=t.keyCode,o=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||is&&72==n&&"c"==o)return Ca(e,-1)||va(e,-1);if(46==n&&!t.shiftKey||is&&68==n&&"c"==o)return Ca(e,1)||va(e,1);if(13==n||27==n)return!0;if(37==n||is&&66==n&&"c"==o){let t=37==n?"ltr"==ba(e,e.state.selection.from)?-1:1:-1;return fa(e,t,o)||va(e,t)}if(39==n||is&&70==n&&"c"==o){let t=39==n?"ltr"==ba(e,e.state.selection.from)?1:-1:1;return fa(e,t,o)||va(e,t)}return 38==n||is&&80==n&&"c"==o?ka(e,-1,o)||va(e,-1):40==n||is&&78==n&&"c"==o?function(e){if(!ns||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;xa(e,n,"true"),setTimeout(()=>xa(e,n,"false"),20)}return!1}(e)||ka(e,1,o)||va(e,1):o==(is?"m":"c")&&(66==n||73==n||89==n||90==n)}function Sa(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:o,openStart:r,openEnd:i}=t;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let e=o.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),o=e.content}let s=e.someProp("clipboardSerializer")||zn.fromSchema(e.state.schema),a=Pa(),l=a.createElement("div");l.appendChild(s.serializeFragment(o,{document:a}));let c,d=l.firstChild,u=0;for(;d&&1==d.nodeType&&(c=Aa[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Oa(e,t,n,o,r){let i,s,a=r.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(o||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||o,e)}),a)return s=new Kt(Ht.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,r,o,e));if(n)s=n;else{let n=r.marks(),{schema:o}=e.state,s=zn.fromSchema(o);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(o.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,o=Pa().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);(n=r&&Aa[r[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;La||(La=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return La.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;return o}(n),ls&&function(e){let t=e.querySelectorAll(es?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||An.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:r,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ea.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(e,t){if(!e.size)return e;let n,o=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:r,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=o.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;r=Ht.from(t.create(n[e+1],r)),i++,s++}return new Kt(r,i,s)}(Ia(s,+d[1],+d[2]),d[4]);else if(s=Kt.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o,r=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=r.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&o.length&&_a(n,o,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Ta(i[i.length-1],o.length));let t=Ma(e,n);i.push(t),r=r.matchType(t.type),o=n}}),i)return Ht.from(i)}return e}(s.content,r),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=Ia(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const Ea=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Ma(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,Ht.from(e));return e}function _a(e,t,n,o,r){if(r<e.length&&r<t.length&&e[r]==t[r]){let i=_a(e,t,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==e.length-1?n.type:e[r+1]))return o.copy(o.content.append(Ht.from(Ma(n,e,r+1))))}}function Ta(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Ta(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(Ht.empty,!0);return e.copy(n.append(o))}function Da(e,t,n,o,r,i){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),r<o-1&&(a=Da(a,t,n,o,r+1,i)),r>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=r).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(Ht.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function Ia(e,t,n){return t<e.openStart&&(e=new Kt(Da(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Kt(Da(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Aa={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ra=null;function Pa(){return Ra||(Ra=document.implementation.createHTMLDocument("title"))}let La=null;const Va={},ja={},$a={touchstart:!0,touchmove:!0};class Ba{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ha(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Fa(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>za(e,t))})}function za(e,t){return e.someProp("handleDOMEvents",n=>{let o=n[t.type];return!!o&&(o(e,t)||t.defaultPrevented)})}function qa(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Wa(e){return{left:e.clientX,top:e.clientY}}function Ua(e,t,n,o,r){if(-1==o)return!1;let i=e.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),r,!0):t(e,n,i.node(o),i.before(o),r,!1)))return!0;return!1}function Ka(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);o.setMeta("pointer",!0),e.dispatch(o)}function Ga(e,t,n,o,r){return Ua(e,"handleClickOn",t,n,o)||e.someProp("handleClick",n=>n(e,t,o))||(r?function(e,t){if(-1==t)return!1;let n,o,r=e.state.selection;r instanceof qo&&(n=r.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(qo.isSelectable(t)){o=n&&r.$from.depth>0&&e>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(e);break}}return null!=o&&(Ka(e,qo.create(e.state.doc,o)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&qo.isSelectable(o))&&(Ka(e,new qo(n)),!0)}(e,n))}function Ja(e,t,n,o){return Ua(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",n=>n(e,t,o))}function Za(e,t,n,o){return Ua(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",n=>n(e,t,o))||function(e,t,n){if(0!=n.button)return!1;let o=e.state.doc;if(-1==t)return!!o.inlineContent&&(Ka(e,Fo.create(o,0,o.content.size)),!0);let r=o.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),i=r.before(t);if(n.inlineContent)Ka(e,Fo.create(o,i+1,i+1+n.content.size));else{if(!qo.isSelectable(n))continue;Ka(e,qo.create(o,i))}return!0}}(e,n,o)}function Xa(e){return il(e)}ja.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!el(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!as||!es||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!rs||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Na(e,n)?n.preventDefault():Ha(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},ja.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ja.keypress=(e,t)=>{let n=t;if(el(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||is&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof Fo&&o.$from.sameParent(o.$to))){let t=String.fromCharCode(n.charCode),r=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,o.$from.pos,o.$to.pos,t,r))||e.dispatch(r()),n.preventDefault()}};const Ya=is?"metaKey":"ctrlKey";Va.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=Xa(e),r=Date.now(),i="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}(n,e.input.lastClick)&&!n[Ya]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=e.posAtCoords(Wa(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Qa(e,s,n,!!o)):("doubleClick"==i?Ja:Za)(e,s.pos,s.inside,n)?n.preventDefault():Ha(e,"pointer"))};class Qa{constructor(e,t,n,o){let r,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Ya],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(r.type.spec.draggable&&!1!==r.type.spec.selectable||l instanceof qo&&l.from<=i&&l.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Yi||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ha(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>na(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Wa(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ha(this.view,"pointer"):Ga(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||ns&&this.mightDrag&&!this.mightDrag.node.isAtom||es&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ka(this.view,jo.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ha(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ha(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function el(e,t){return!!e.composing||!!(ns&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Va.touchstart=e=>{e.input.lastTouch=Date.now(),Xa(e),Ha(e,"pointer")},Va.touchmove=e=>{e.input.lastTouch=Date.now(),Ha(e,"pointer")},Va.contextmenu=e=>Xa(e);const tl=as?5e3:-1;function nl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>il(e),t))}function ol(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function rl(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Bi(e=e.childNodes[t-1])}else{if(!e.parentNode||Hi(e))return null;t=Ai(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),o=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Hi(e))return null;t=Ai(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let t=o.pmViewDesc,r=e.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!t||!t.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return o}}return n||o}function il(e,t=!1){if(!(as&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ol(e),t||e.docView&&e.docView.dirty){let n=ea(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}ja.compositionstart=ja.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Fo&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||es&&ss&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let o=t.childNodes[n];return 1==o.nodeType&&"false"==o.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),il(e,!0),e.markCursor=null;else if(il(e,!t.selection.empty),Yi&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,o=t.focusOffset;n&&1==n.nodeType&&0!=o;){let t=o<0?n.lastChild:n.childNodes[o-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,o=-1}}e.input.composing=!0}nl(e,tl)},ja.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,nl(e,20))};const sl=Zi&&Xi<15||rs&&cs<604;function al(e,t,n,o,r){let i=Oa(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,r,i||Kt.empty)))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=s?e.state.tr.replaceSelectionWith(s,o):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ll(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Va.copy=ja.cut=(e,t)=>{let n=t,o=e.state.selection,r="cut"==n.type;if(o.empty)return;let i=sl?null:n.clipboardData,s=o.content(),{dom:a,text:l}=Sa(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ja.paste=(e,t)=>{let n=t;if(e.composing&&!as)return;let o=sl?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;o&&al(e,ll(o),o.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?al(e,o.value,null,r,t):al(e,o.textContent,o.innerHTML,r,t)},50)}(e,n)};class cl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const dl=is?"altKey":"ctrlKey";function ul(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[dl]}Va.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=e.state.selection,s=i.empty?null:e.posAtCoords(Wa(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof qo?i.to-1:i.to));else if(o&&o.mightDrag)r=qo.create(e.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(r=qo.create(e.state.doc,t.posBefore))}let a=(r||e.state.selection).content(),{dom:l,text:c,slice:d}=Sa(e,a);(!n.dataTransfer.files.length||!es||ts>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(sl?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",sl||n.dataTransfer.setData("text/plain",c),e.dragging=new cl(d,ul(e,n),r)},Va.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ja.dragover=ja.dragenter=(e,t)=>t.preventDefault(),ja.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let o=e.posAtCoords(Wa(t));if(!o)return;let r=e.state.doc.resolve(o.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Oa(e,ll(t.dataTransfer),sl?null:t.dataTransfer.getData("text/html"),!1,r);let s=!(!n||!ul(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||Kt.empty,s)))return void t.preventDefault();if(!i)return;t.preventDefault();let a=i?function(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=o.depth;t>=0;t--){let n=t==o.depth?0:o.pos<=(o.start(t+1)+o.end(t+1))/2?-1:1,i=o.index(t)+(n>0?1:0),s=o.node(t),a=!1;if(1==e)a=s.canReplace(i,i,r);else{let e=s.contentMatchAt(i).findWrapping(r.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?o.pos:n<0?o.before(t+1):o.after(t+1)}return null}(e.state.doc,r.pos,i):r.pos;null==a&&(a=r.pos);let l=e.state.tr;if(s){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,u=l.doc;d?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i);if(l.doc.eq(u))return;let p=l.doc.resolve(c);if(d&&qo.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new qo(p));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,o,r)=>t=r),l.setSelection(ca(e,p,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Va.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&na(e)},20))},Va.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Va.beforeinput=(e,t)=>{if(es&&as&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,zi(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in ja)Va[e]=ja[e];function pl(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class hl{constructor(e,t){this.toDOM=e,this.spec=t||yl,this.side=this.spec.side||0}map(e,t,n,o){let{pos:r,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new gl(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof hl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class fl{constructor(e,t){this.attrs=e,this.spec=t||yl}map(e,t,n,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new gl(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof fl&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}static is(e){return e.type instanceof fl}destroy(){}}class ml{constructor(e,t){this.attrs=e,this.spec=t||yl}map(e,t,n,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=r.pos?null:new gl(r.pos-n,i.pos-n,this)}valid(e,t){let n,{index:o,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(o)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof ml&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}destroy(){}}class gl{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new gl(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new gl(e,e,new hl(t,n))}static inline(e,t,n,o){return new gl(e,t,new fl(n,o))}static node(e,t,n,o){return new gl(e,t,new ml(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof fl}get widget(){return this.type instanceof hl}}const vl=[],yl={};class wl{constructor(e,t){this.local=e.length?e:vl,this.children=t.length?t:vl}static create(e,t){return t.length?Sl(t,e,0,yl):bl}find(e,t,n){let o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,n),o}findInner(e,t,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,o+s,r)}}map(e,t,n){return this==bl||0==e.maps.length?this:this.mapInner(e,t,0,0,n||yl)}mapInner(e,t,n,o,r){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,o,r,i,s){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let o=0;n.maps[e].forEach((e,n,r,i)=>{let s=i-r-(n-e);for(let r=0;r<a.length;r+=3){let i=a[r+1];if(i<0||e>i+t-o)continue;let l=a[r]+t-o;n>=l?a[r+1]=e<=l?-2:-1:e>=t&&s&&(a[r]+=s,a[r+1]+=s)}o+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-r;if(d<0||d>=o.content.size){l=!0;continue}let u=n.map(e[t+1]+i,-1)-r,{index:p,offset:h}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&h==d&&h+f.nodeSize==u){let o=a[t+2].mapInner(n,f,c+1,e[t]+i+1,s);o!=bl?(a[t]=d,a[t+1]=u,a[t+2]=o):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,o,r,i,s){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(o,r,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+i+1);return n}(a,e,t,n,r,i,s),c=Sl(l,o,0,s);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new wl(t.sort(Ol),a)}(this.children,i||[],e,t,n,o,r):i?new wl(i.sort(Ol),vl):bl}add(e,t){return t.length?this==bl?wl.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let o,r=0;e.forEach((e,i)=>{let s,a=i+n;if(s=xl(t,e,a)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(e,s,a+1):o.splice(r,0,i,i+e.nodeSize,Sl(s,e,a+1,yl)),r+=3}});let i=Cl(r?Nl(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new wl(i.length?this.local.concat(i).sort(Ol):this.local,o||this.children)}remove(e){return 0==e.length||this==bl?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+t,s=n[o+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let a=n[o+2].removeInner(r,i+1);a!=bl?n[o+2]=a:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<o.length;e++)o[e].eq(n,t)&&(o==this.local&&(o=this.local.slice()),o.splice(e--,1));return n==this.children&&o==this.local?this:o.length||n.length?new wl(o,n):bl}forChild(e,t){if(this==bl)return this;if(t.isLeaf)return wl.empty;let n,o;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,i=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>r&&t.type instanceof fl){let e=Math.max(r,t.from)-r,n=Math.min(i,t.to)-r;e<n&&(o||(o=[])).push(t.copy(e,n))}}if(o){let e=new wl(o.sort(Ol),vl);return n?new kl([e,n]):e}return n||bl}eq(e){if(this==e)return!0;if(!(e instanceof wl)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return El(this.localsInner(e))}localsInner(e){if(this==bl)return vl;if(e.inlineContent||!this.local.some(fl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof fl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}wl.empty=new wl([],[]),wl.removeOverlap=El;const bl=wl.empty;class kl{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,yl));return kl.from(n)}forChild(e,t){if(t.isLeaf)return wl.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=bl&&(r instanceof kl?n=n.concat(r.members):n.push(r))}return kl.from(n)}eq(e){if(!(e instanceof kl)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?El(n?t:t.sort(Ol)):vl}static from(e){switch(e.length){case 0:return bl;case 1:return e[0];default:return new kl(e.every(e=>e instanceof wl)?e:e.reduce((e,t)=>e.concat(t instanceof wl?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Cl(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let r=e[o];n.push(new gl(r.from+t,r.to+t,r.type))}return n}function xl(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,r=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<o&&((r||(r=[])).push(t),e[i]=null);return r}function Nl(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Sl(e,t,n,o){let r=[],i=!1;t.forEach((t,s)=>{let a=xl(e,t,s+n);if(a){i=!0;let e=Sl(a,t,n+s+1,o);e!=bl&&r.push(s,s+t.nodeSize,e)}});let s=Cl(i?Nl(e):e,-n).sort(Ol);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(o.onRemove&&o.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new wl(s,r):bl}function Ol(e,t){return e.from-t.from||e.to-t.to}function El(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let r=n+1;r<t.length;r++){let i=t[r];if(i.from!=o.from){i.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,i.from),Ml(t,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(t==e&&(t=e.slice()),t[r]=i.copy(i.from,o.to),Ml(t,r+1,i.copy(o.to,i.to)))}}return t}function Ml(e,t,n){for(;t<e.length&&Ol(n,e[t])>0;)t++;e.splice(t,0,n)}function _l(e){let t=[];return e.someProp("decorations",n=>{let o=n(e.state);o&&o!=bl&&t.push(o)}),e.cursorWrapper&&t.push(wl.create(e.state.doc,[e.cursorWrapper.deco])),kl.from(t)}const Tl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dl=Zi&&Xi<=11;class Il{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Al{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Il,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Zi&&Xi<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():ns&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Dl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Tl)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(da(this.view)){if(this.suppressingSelectionUpdates)return na(this.view);if(Zi&&Xi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=Ri(t))n.add(t);for(let o=e.anchorNode;o;o=Ri(o))if(n.has(o)){t=o;break}let o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&da(e)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(!a.some(e=>"BR"==e.nodeName)||8!=e.input.lastKeyCode&&46!=e.input.lastKeyCode){if(Yi&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of t){let t=o.parentNode;!t||"LI"!=t.nodeName||n&&Vl(e,n)==t||o.remove()}}}}else for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}let l=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fi(n)&&(l=ea(e))&&l.eq(jo.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,na(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,i),function(e){if(Rl.has(e))return;if(Rl.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Yi,Pl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Pl=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:o,focusOffset:r}=e.domSelectionRange();for(let i of t)if("TR"==(null===(n=i.parentNode)||void 0===n?void 0:n.nodeName)){let t=i.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),o==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}(e,a)),this.handleDOMChange(r,i,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||na(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let o=e.addedNodes[n];t.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,r=e.nextSibling;if(Zi&&Xi<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==e.target?Ai(o)+1:0,s=n.localPosFromDOM(e.target,i,-1),a=r&&r.parentNode==e.target?Ai(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Rl=new WeakMap,Pl=!1;function Ll(e,t){let n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Vi(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function Vl(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function jl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(ns&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||ns&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const $l=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Bl(e,t,n,o,r){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ea(e,t);if(n&&!e.state.selection.eq(n)){if(es&&as&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))))return;let o=e.state.tr.setSelection(n);"pointer"==t?o.setMeta("pointer",!0):"key"==t&&o.scrollIntoView(),i&&o.setMeta("composition",i),e.dispatch(o)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(n);t=s.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,c,d=e.state.selection,u=function(e,t,n){let o,{node:r,fromOffset:i,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],Fi(c)||o.push({node:c.focusNode,offset:c.focusOffset})),es&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let u=e.state.doc,p=e.someProp("domParser")||An.fromSchema(e.state.schema),h=u.resolve(a),f=null,m=p.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=h.parent.type.whitespace||"full",findPositions:o,ruleFromNode:jl,context:h});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),p=e.state.doc,h=p.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,c="end"):(l=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,o,r){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r){o-=s+Math.max(0,i-Math.min(s,a))-i}if(s<i&&e.size<t.size){let e=o<=i&&o>=s?i-o:0;i-=e,i&&i<t.size&&zl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),a=i+(a-s),s=i}else if(a<i){let t=o<=i&&o>=a?i-o:0;i-=t,i&&i<e.size&&zl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(h.content,u.doc.content,u.from,l,c);if(f&&e.input.domChangeCount++,(rs&&e.input.lastIOSEnter>Date.now()-225||as)&&r.some(e=>1==e.nodeType&&!$l.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(o&&d instanceof Fo&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=Hl(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof Fo&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),Zi&&Xi<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>u.from&&"  "==u.doc.textBetween(f.start-u.from-1,f.start-u.from+1)&&(f.start--,f.endA--,f.endB--);let m=u.doc.resolveNoCache(f.start-u.from),g=u.doc.resolveNoCache(f.endB-u.from),v=p.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA;if((rs&&e.input.lastIOSEnter>Date.now()-225&&(!y||r.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&m.pos<u.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(u.doc.textBetween(m.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,zi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,o,r){if(n-t<=r.pos-o.pos||Fl(o,!0,!1)<r.pos)return!1;let i=e.resolve(t);if(!o.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Fl(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Fl(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(p,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",t=>t(e,zi(8,"Backspace"))))return void(as&&es&&e.domObserver.suppressSelectionUpdates());es&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),as&&!y&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==f.endA&&(f.endB-=2,g=u.doc.resolveNoCache(f.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,zi(13,"Enter"))})},20));let w,b=f.start,k=f.endA,C=t=>{let n=t||e.state.tr.replace(b,k,u.doc.slice(f.start-u.from,f.endB-u.from));if(u.sel){let t=Hl(e,n.doc,u.sel);t&&!(es&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(k)-1)||Zi&&t.empty&&t.head==b)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(y)if(m.pos==g.pos){Zi&&Xi<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>na(e),20));let t=C(e.state.tr.delete(b,k)),n=p.resolve(f.start).marksAcross(p.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(w=function(e,t){let n,o,r,i=e.firstChild.marks,s=t.firstChild.marks,a=i,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<i.length;e++)l=i[e].removeFromSet(l);if(1==a.length&&0==l.length)o=a[0],n="add",r=e=>e.mark(o.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;o=l[0],n="remove",r=e=>e.mark(o.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(r(t.child(e)));if(Ht.from(c).eq(e))return{mark:o,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start())))){let t=C(e.state.tr);"add"==w.type?t.addMark(b,k,w.mark):t.removeMark(b,k,w.mark),e.dispatch(t)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset),n=()=>C(e.state.tr.insertText(t,b,k));e.someProp("handleTextInput",o=>o(e,b,k,t,n))||e.dispatch(n())}else e.dispatch(C());else e.dispatch(C())}function Hl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:ca(e,t.resolve(n.anchor),t.resolve(n.head))}function Fl(e,t,n){let o=e.depth,r=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,r++,t=!1;if(n){let t=e.node(o).maybeChild(e.indexAfter(o));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function zl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class ql{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ba,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Jl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Kl(this),Ul(this),this.nodeViews=Gl(this),this.docView=js(this.state.doc,Wl(this),_l(this),this.dom,this),this.domObserver=new Al(this,(e,t,n,o)=>Bl(this,e,t,n,o)),this.domObserver.start(),function(e){for(let t in Va){let n=Va[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!qa(e,t)||za(e,t)||!e.editable&&t.type in ja||n(e,t)},$a[t]?{passive:!0}:void 0)}ns&&e.dom.addEventListener("input",()=>null),Fa(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Fa(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Jl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let o=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(ol(this),i=!0),this.state=e;let s=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Gl(this);(function(e,t){let n=0,o=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let e in t)o++;return n!=o})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Fa(this),this.editable=Kl(this),Ul(this);let a=_l(this),l=Wl(this),c=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(o.selection)||(i=!0);let u="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,o=e.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=e.root.elementFromPoint(i,s);if(!o||o==e.dom||!e.dom.contains(o))continue;let a=o.getBoundingClientRect();if(a.top>=r-20){t=o,n=a.top;break}}return{refDOM:t,refTop:n,stack:fs(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(Zi||es)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(o.selection,e.selection);if(d){let n=es?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=rl(this)),!r&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=js(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Vi(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?na(this,t):(aa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;ms(n,0==o?0:o-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof qo){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&hs(this,t.getBoundingClientRect(),e)}else hs(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,o=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(o=e)}this.dragging=new cl(e.slice,e.move,o<0?void 0:qo.create(this.state.doc,o))}someProp(e,t){let n,o=this._props&&this._props[e];if(null!=o&&(n=t?t(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(Zi){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(gs)return e.focus(gs);let t=fs(e);e.focus(null==gs?{get preventScroll(){return gs={preventScroll:!0},!0}}:void 0),gs||(gs=!1,ms(t,0))}(this.dom),na(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return bs(this,e)}coordsAtPos(e,t=1){return Ns(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let o=this.docView.posFromDOM(e,t,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Is(this,t||this.state,e)}pasteHTML(e,t){return al(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return al(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Sa(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_l(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Pi=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){za(e,t)||!Va[t.type]||!e.editable&&t.type in ja||Va[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?ns&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Ll(e,n)}let n;function o(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?Ll(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Wl(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[gl.node(0,e.state.doc.content.size,t)]}function Ul(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:gl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Kl(e){return!e.someProp("editable",t=>!1===t(e.state))}function Gl(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Jl(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function Zl(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}ql.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};var Xl={text:(e,t,n,o)=>{const r=e.value;return/^[^*_\\]*\s+$/.test(r)?r:n.safe(r,{...o,encode:[]})},strong:(e,t,n,o)=>{const r=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(o);let a=s.move(r+r);return a+=s.move(n.containerPhrasing(e,{before:a,after:r,...s.current()})),a+=s.move(r+r),i(),a},emphasis:(e,t,n,o)=>{const r=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(o);let a=s.move(r);return a+=s.move(n.containerPhrasing(e,{before:a,after:r,...s.current()})),a+=s.move(r),i(),a}},Yl=Tt({},"editorView"),Ql=Tt({},"editorState"),ec=Tt([],"initTimer"),tc=Tt({},"editor"),nc=Tt([],"inputRules"),oc=Tt([],"prosePlugins"),rc=Tt([],"remarkPlugins"),ic=Tt([],"nodeView"),sc=Tt([],"markView"),ac=Tt(Y().use(Q).use(Vt),"remark"),lc=Tt({handlers:Xl,encode:[]},"remarkStringifyOptions"),cc=Lt("ConfigReady");var dc=Lt("InitReady");function uc(e){const t=t=>(t.inject(tc,e).inject(oc,[]).inject(rc,[]).inject(nc,[]).inject(ic,[]).inject(sc,[]).inject(lc,{handlers:Xl,encode:[]}).inject(ac,Y().use(Q).use(Vt)).inject(ec,[cc]).record(dc),async()=>{await t.waitTimers(ec);const e=t.get(lc);return t.set(ac,Y().use(Q).use(Vt,e)),t.done(dc),()=>{t.remove(tc).remove(oc).remove(rc).remove(nc).remove(ic).remove(sc).remove(lc).remove(ac).remove(ec).clearTimer(dc)}});return Zl(t,{displayName:"Init"}),t}var pc=Lt("SchemaReady"),hc=Tt([],"schemaTimer"),fc=Tt({},"schema"),mc=Tt([],"nodes"),gc=Tt([],"marks");function vc(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var yc=e=>(e.inject(fc,{}).inject(mc,[]).inject(gc,[]).inject(hc,[dc]).record(pc),async()=>{await e.waitTimers(hc);const t=e.get(ac),n=e.get(rc).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(ac,n);const o=new Dn({nodes:Object.fromEntries(e.get(mc).map(([e,t])=>[e,vc(t)])),marks:Object.fromEntries(e.get(gc).map(([e,t])=>[e,vc(t)]))});return e.set(fc,o),e.done(pc),()=>{e.remove(fc).remove(mc).remove(gc).remove(hc).clearTimer(pc)}});Zl(yc,{displayName:"Schema"});var wc=class{constructor(){this.setCtx=e=>{this.#R=e},this.chain=()=>{if(null==this.#R)throw St();const e=this.#R,t=[],n=this.get.bind(this),o={run:()=>{const n=Sr(...t),o=e.get(Yl);return n(o.state,o.dispatch,o)},inline:e=>(t.push(e),o),pipe:function(e,r){const i=n(e);return t.push(i(r)),o}.bind(this)};return o}}#r=new Et;#R=null;get ctx(){return this.#R}create(e,t){const n=e.create(this.#r.sliceMap);return n.set(t),n}get(e){return this.#r.get(e).get()}remove(e){return this.#r.remove(e)}call(e,t){if(null==this.#R)throw St();const n=this.get(e)(t),o=this.#R.get(Yl);return n(o.state,o.dispatch,o)}inline(e){if(null==this.#R)throw St();const t=this.#R.get(Yl);return e(t.state,t.dispatch,t)}};var bc=Tt(new wc,"commands"),kc=Tt([pc],"commandsTimer"),Cc=Lt("CommandsReady"),xc=e=>{const t=new wc;return t.setCtx(e),e.inject(bc,t).inject(kc,[pc]).record(Cc),async()=>(await e.waitTimers(kc),e.done(Cc),()=>{e.remove(bc).remove(kc).clearTimer(Cc)})};Zl(xc,{displayName:"Commands"});var Nc=class{constructor(){this.setCtx=e=>{this.#R=e},this.add=e=>(this.#P.push(e),()=>{this.#P=this.#P.filter(t=>t!==e)}),this.addObjectKeymap=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){const o={key:e,onRun:()=>n};this.#P.push(o),t.push(()=>{this.#P=this.#P.filter(e=>e!==o)})}else this.#P.push(n),t.push(()=>{this.#P=this.#P.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{const e=function(e){return e.Backspace=Sr(Ir,ar,dr,pr),e}(Tr);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#P.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{const n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,o)=>{const r=this.#R;if(null==r)throw Ct();return Sr(...n.map(e=>e.onRun(r)))(e,t,o)}]}))}}#R=null;#P=[];get ctx(){return this.#R}},Sc=Tt(new Nc,"keymap"),Oc=Tt([pc],"keymapTimer"),Ec=Lt("KeymapReady"),Mc=e=>{const t=new Nc;return t.setCtx(e),e.inject(Sc,t).inject(Oc,[pc]).record(Ec),async()=>(await e.waitTimers(Oc),e.done(Ec),()=>{e.remove(Sc).remove(Oc).clearTimer(Ec)})},_c=Lt("ParserReady"),Tc=()=>{throw Ct()},Dc=Tt(Tc,"parser"),Ic=Tt([],"parserTimer"),Ac=e=>(e.inject(Dc,Tc).inject(Ic,[pc]).record(_c),async()=>{await e.waitTimers(Ic);const t=e.get(ac),n=e.get(fc);return e.set(Dc,Ti.create(n,t)),e.done(_c),()=>{e.remove(Dc).remove(Ic).clearTimer(_c)}});Zl(Ac,{displayName:"Parser"});var Rc=Lt("SerializerReady"),Pc=Tt([],"serializerTimer"),Lc=()=>{throw Ct()},Vc=Tt(Lc,"serializer"),jc=e=>(e.inject(Vc,Lc).inject(Pc,[pc]).record(Rc),async()=>{await e.waitTimers(Pc);const t=e.get(ac),n=e.get(fc);return e.set(Vc,Ii.create(n,t)),e.done(Rc),()=>{e.remove(Vc).remove(Pc).clearTimer(Rc)}});Zl(jc,{displayName:"Serializer"});var $c=Tt("","defaultValue"),Bc=Tt(e=>e,"stateOptions"),Hc=Tt([],"editorStateTimer"),Fc=Lt("EditorStateReady");function zc(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return An.fromSchema(n).parse(e.dom);if("json"===e.type)return pn.fromJSON(n,e.value);throw o=e,new wt(yt.docTypeError,`Doc type error, unsupported type: ${kt(o)}`);var o}var qc=new sr("MILKDOWN_STATE_TRACKER"),Wc=e=>(e.inject($c,"").inject(Ql,{}).inject(Bc,e=>e).inject(Hc,[_c,Rc,Cc,Ec]).record(Fc),async()=>{await e.waitTimers(Hc);const t=e.get(fc),n=e.get(Dc),o=e.get(nc),r=e.get(Bc),i=e.get(oc),s=zc(e.get($c),n,t),a=e.get(Sc),l=a.addBaseKeymap(),c=[...i,new or({key:qc,state:{init:()=>{},apply:(t,n,o,r)=>{e.set(Ql,r)}}}),oi({rules:o}),Si(a.build())];e.set(oc,c);const d=r({schema:t,doc:s,plugins:c}),u=tr.create(d);return e.set(Ql,u),e.done(Fc),()=>{l(),e.remove($c).remove(Ql).remove(Bc).remove(Hc).clearTimer(Fc)}});Zl(Wc,{displayName:"EditorState"});var Uc=Tt([],"pasteRule"),Kc=Tt([pc],"pasteRuleTimer"),Gc=Lt("PasteRuleReady"),Jc=e=>(e.inject(Uc,[]).inject(Kc,[pc]).record(Gc),async()=>(await e.waitTimers(Kc),e.done(Gc),()=>{e.remove(Uc).remove(Kc).clearTimer(Gc)}));Zl(Jc,{displayName:"PasteRule"});var Zc=Lt("EditorViewReady"),Xc=Tt([],"editorViewTimer"),Yc=Tt({},"editorViewOptions"),Qc=Tt(null,"root"),ed=Tt(null,"rootDOM"),td=Tt({},"rootAttrs");var nd=new sr("MILKDOWN_VIEW_CLEAR"),od=e=>(e.inject(Qc,document.body).inject(Yl,{}).inject(Yc,{}).inject(ed,null).inject(td,{}).inject(Xc,[Fc,Gc]).record(Zc),async()=>{await e.wait(dc);const t=e.get(Qc)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(oc,t=>[new or({key:nd,view:t=>{const o=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(ed,n);const o=t.get(td);return Object.entries(o).forEach(([e,t])=>n.setAttribute(e,t)),n}(n,e):void 0;return(()=>{if(o&&n){const e=t.dom;n.replaceChild(o,e),o.appendChild(e)}})(),{destroy:()=>{o?.parentNode&&o?.parentNode.replaceChild(t.dom,o),o?.remove()}}}}),...t]),await e.waitTimers(Xc);const o=e.get(Ql),r=e.get(Yc),i=new ql(n,{state:o,nodeViews:Object.fromEntries(e.get(ic)),markViews:Object.fromEntries(e.get(sc)),transformPasted:(t,n,o)=>(e.get(Uc).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,o)}),t),...r});var s;return(s=i.dom).classList.add("editor"),s.setAttribute("role","textbox"),e.set(Yl,i),e.done(Zc),()=>{i?.destroy(),e.remove(Qc).remove(Yl).remove(Yc).remove(ed).remove(td).remove(Xc).clearTimer(Zc)}});Zl(od,{displayName:"EditorView"});var rd=function(e){return e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e}({}),id=class e{constructor(){this.enableInspector=(e=!0)=>(this.#L=e,this),this.onStatusChange=e=>(this.#V=e,this),this.config=e=>(this.#j.push(e),this),this.removeConfig=e=>(this.#j=this.#j.filter(t=>t!==e),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(e=>{this.#$.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#g===rd.Created&&this.#B(t,this.#$),this},this.remove=async e=>this.#g===rd.OnCreate?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#H([e].flat(),!0),this),this.create=async()=>(this.#g===rd.OnCreate||(this.#g===rd.Created&&await this.destroy(),this.#F(rd.OnCreate),this.#z(),this.#B([...this.#$.keys()],this.#$),await Promise.all([this.#q(this.#W),this.#q(this.#$)].flat()),this.#F(rd.Created)),this),this.destroy=async(e=!1)=>this.#g===rd.Destroyed||this.#g===rd.OnDestroy?this:this.#g===rd.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#j=[]),this.#F(rd.OnDestroy),await this.#H([...this.#$.keys()],e),await this.#U(),this.#F(rd.Destroyed),this),this.action=e=>e(this.#R),this.inspect=()=>this.#L?[...this.#W.values(),...this.#$.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>Boolean(e)):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#L=!1;#g=rd.Idle;#j=[];#V=()=>{};#r=new Et;#i=new At;#$=new Map;#W=new Map;#R=new It(this.#r,this.#i);#z=()=>{const e=function(e){const t=t=>(t.record(cc),async()=>(await e(t),t.done(cc),()=>{t.clearTimer(cc)}));return Zl(t,{displayName:"Config"}),t}(async e=>{await Promise.all(this.#j.map(t=>Promise.resolve(t(e))))}),t=[yc,Ac,jc,xc,Mc,Jc,Wc,od,uc(this),e];this.#B(t,this.#W)};#B=(e,t)=>{e.forEach(e=>{const n=this.#R.produce(this.#L?e.meta:void 0),o=e(n);t.set(e,{ctx:n,handler:o,cleanup:void 0})})};#H=(e,t=!1)=>Promise.all([e].flat().map(async e=>{const n=this.#$.get(e)?.cleanup;return t?this.#$.delete(e):this.#$.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof n?n():n}));#U=async()=>{await Promise.all([...this.#W.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#W.clear()};#F=e=>{this.#g=e,this.#V(e)};#q=e=>[...e.entries()].map(async([t,n])=>{const{ctx:o,handler:r}=n;if(!r)return;const i=await r();e.set(t,{ctx:o,handler:r,cleanup:i})});get ctx(){return this.#R}get status(){return this.#g}};let sd=e=>crypto.getRandomValues(new Uint8Array(e)),ad=(e,t=21)=>((e,t,n)=>{let o=(2<<Math.log2(e.length-1))-1,r=-~(1.6*o*t/e.length);return(i=t)=>{let s="";for(;;){let t=n(r),a=0|r;for(;a--;)if(s+=e[t[a]&o]||"",s.length>=i)return s}}})(e,0|t,sd);function ld(e,t){const n=function(e="cmdKey"){return Tt(()=>()=>!1,e)}(e),o=r=>async()=>{o.key=n,await r.wait(Cc);const i=t(r);return r.get(bc).create(n,i),o.run=t=>r.get(bc).call(e,t),()=>{r.get(bc).remove(n)}};return o}function cd(e){const t=n=>async()=>{await n.wait(pc);const o=e(n);return n.update(nc,e=>[...e,o]),t.inputRule=o,()=>{n.update(nc,e=>e.filter(e=>e!==o))}};return t}function dd(e,t){const n=o=>async()=>{const r=t(o);return o.update(gc,t=>[...t.filter(t=>t[0]!==e),[e,r]]),n.id=e,n.schema=r,()=>{o.update(gc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(fc).marks[e];if(!n)throw o=e,new wt(yt.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${o}" in schema.`);var o;return n},n}function ud(e,t){const n=o=>async()=>{const r=t(o);return o.update(mc,t=>[...t.filter(t=>t[0]!==e),[e,r]]),n.id=e,n.schema=r,()=>{o.update(mc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(fc).nodes[e];if(!n)throw Ot(e);return n},n}function pd(e){let t;const n=n=>async()=>(await n.wait(pc),t=e(n),n.update(oc,e=>[...e,t]),()=>{n.update(oc,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function hd(e){const t=n=>async()=>{await n.wait(Ec);const o=n.get(Sc),r=e(n),i=o.addObjectKeymap(r);return t.keymap=r,()=>{i()}};return t}function fd(e,t){const n=o=>async()=>{await o.wait(pc);const r=t(o);return e.type(o)instanceof Mn?o.update(ic,t=>[...t,[e.id,r]]):o.update(sc,t=>[...t,[e.id,r]]),n.view=r,n.type=e,()=>{e.type(o)instanceof Mn?o.update(ic,t=>t.filter(t=>t[0]!==e.id)):o.update(sc,t=>t.filter(t=>t[0]!==e.id))}};return n}function md(e,t){const n=Tt(e,t),o=e=>(e.inject(n),()=>()=>{e.remove(n)});return o.key=n,o}function gd(e,t){const n=md(t,e),o=ud(e,e=>e.get(n.key)(e)),r=[n,o];return r.id=o.id,r.node=o,r.type=e=>o.type(e),r.ctx=n,r.key=n.key,r.extendSchema=n=>gd(e,n(t)),r}function vd(e,t){const n=md(t,e),o=dd(e,e=>e.get(n.key)(e)),r=[n,o];return r.id=o.id,r.mark=o,r.type=e=>o.type(e),r.ctx=n,r.key=n.key,r.extendSchema=n=>vd(e,n(t)),r}function yd(e,t){const n=md(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),o=hd(e=>{const o=e.get(n.key),r=Object.entries(t).flatMap(([e,{command:t}])=>{const n=o[e],r=[n.shortcuts].flat(),i=n.priority;return r.map(e=>[e,{key:e,onRun:t,priority:i}])});return Object.fromEntries(r)}),r=[n,o];return r.ctx=n,r.shortcuts=o,r.key=n.key,r.keymap=o.keymap,r}ad("abcedfghicklmn",10);var wd=(e,t=()=>({}))=>md(t,`${e}Attr`),bd=(e,t=()=>({}))=>md(t,`${e}Attr`);function kd(e,t,n){const o=md({},e),r=e=>async()=>{await e.wait(dc);const n={plugin:t(e),options:e.get(o.key)};return e.update(rc,e=>[...e,n]),()=>{e.update(rc,e=>e.filter(e=>e!==n))}},i=[o,r];return i.id=e,i.plugin=r,i.options=o,i}function Cd(e){return e=>{const t=e.get(Yl);e.get(fc);return e.get(Vc)(t.state.doc)}}var xd=ue({});var Nd=()=>{const e=function(){const{dom:e,editor:t,setLoading:n,editorFactory:o}=pe(xd),r=le(null);return me(()=>{const i=r.current;if(!o)return;if(!i)return;e.current=i;const s=o(i);return s?(n(!0),s.create().then(e=>{t.current=e}).finally(()=>{n(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}):void 0},[e,t,o,n]),r}();return ae.createElement("div",{"data-milkdown-root":!0,ref:e})},Sd=({children:e})=>{const t=le(void 0),[n,o]=ce(void 0),r=le(void 0),[i,s]=ce(!0),a=de(()=>({loading:i,dom:t,editor:r,setLoading:s,editorFactory:n,setEditorFactory:o}),[i,n]);return ae.createElement(xd.Provider,{value:a},e)};function Od(){const e=pe(xd),t=he(()=>e.editor.current,[e.editor]);return[e.loading,t]}function Ed(e){return new p(h.define(e))}function Md(e){return import("./index-Ck9BxS1f.js").then(t=>t.sql({dialect:t[e]}))}const _d=[u.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-CtTbnbzM.js").then(e=>e.cpp())}),u.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-CtTbnbzM.js").then(e=>e.cpp())}),u.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Md("Cassandra")}),u.of({name:"CSS",extensions:["css"],load:()=>import("./index-CB1_GL3t.js").then(e=>e.css())}),u.of({name:"Go",extensions:["go"],load:()=>import("./index-C9_5xd3V.js").then(e=>e.go())}),u.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-xaEdDd13.js").then(e=>e.html())}),u.of({name:"Java",extensions:["java"],load:()=>import("./index-CRfRlH9U.js").then(e=>e.java())}),u.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript())}),u.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-BR16hIbn.js").then(e=>e.jinja())}),u.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-QhLowdpF.js").then(e=>e.json())}),u.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript({jsx:!0}))}),u.of({name:"LESS",extensions:["less"],load:()=>import("./index-Ccq-5wm6.js").then(e=>e.less())}),u.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index--PWk-3Ol.js").then(e=>e.liquid())}),u.of({name:"MariaDB SQL",load:()=>Md("MariaSQL")}),u.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-Bw2EofiE.js").then(e=>e.markdown())}),u.of({name:"MS SQL",load:()=>Md("MSSQL")}),u.of({name:"MySQL",load:()=>Md("MySQL")}),u.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-DAJdettS.js").then(e=>e.php())}),u.of({name:"PLSQL",extensions:["pls"],load:()=>Md("PLSQL")}),u.of({name:"PostgreSQL",load:()=>Md("PostgreSQL")}),u.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-B3fb7Ita.js").then(e=>e.python())}),u.of({name:"Rust",extensions:["rs"],load:()=>import("./index-D5NvcxPc.js").then(e=>e.rust())}),u.of({name:"Sass",extensions:["sass"],load:()=>import("./index-D8zPYs0m.js").then(e=>e.sass({indented:!0}))}),u.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-D8zPYs0m.js").then(e=>e.sass())}),u.of({name:"SQL",extensions:["sql"],load:()=>Md("StandardSQL")}),u.of({name:"SQLite",load:()=>Md("SQLite")}),u.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript({jsx:!0,typescript:!0}))}),u.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-DSGuayJy.js").then(e=>e.javascript({typescript:!0}))}),u.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-CQbc3KUq.js").then(e=>e.wast())}),u.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-GoUUn3QE.js").then(e=>e.xml())}),u.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-CpRfyO85.js").then(e=>e.yaml())}),u.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-CXdQSnD-.js").then(e=>Ed(e.apl))}),u.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-D5V0T9Cu.js").then(e=>Ed(e.asciiArmor))}),u.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-DWPaVWf6.js").then(e=>Ed(e.asn1({})))}),u.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-B46aRdXb.js").then(e=>Ed(e.asterisk))}),u.of({name:"Brainfuck",extensions:["b","bf"],load:()=>import("./brainfuck-CtZaYBKt.js").then(e=>Ed(e.brainfuck))}),u.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-stawOqaz.js").then(e=>Ed(e.cobol))}),u.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.csharp))}),u.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Ed(e.clojure))}),u.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Ed(e.clojure))}),u.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-C4GSMmGA.js").then(e=>Ed(e.gss))}),u.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-DXn5xaP-.js").then(e=>Ed(e.cmake))}),u.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-BTDxI-eT.js").then(e=>Ed(e.coffeeScript))}),u.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-vq6DHwts.js").then(e=>Ed(e.commonLisp))}),u.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-gJDei3ni.js").then(e=>Ed(e.cypher))}),u.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-On6Xi21R.js").then(e=>Ed(e.cython))}),u.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-CRzZ78HM.js").then(e=>Ed(e.crystal))}),u.of({name:"D",extensions:["d"],load:()=>import("./d-BShv7fp-.js").then(e=>Ed(e.d))}),u.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.dart))}),u.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-UJJ5BM9S.js").then(e=>Ed(e.diff))}),u.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-DVQ9Q8O9.js").then(e=>Ed(e.dockerFile))}),u.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-DI9Herc-.js").then(e=>Ed(e.dtd))}),u.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-DkEP81N9.js").then(e=>Ed(e.dylan))}),u.of({name:"EBNF",load:()=>import("./ebnf-B-Df8AvO.js").then(e=>Ed(e.ebnf))}),u.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-DPFc0Uaf.js").then(e=>Ed(e.ecl))}),u.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Ed(e.clojure))}),u.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-DR5c0IrL.js").then(e=>Ed(e.eiffel))}),u.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-DompmV0j.js").then(e=>Ed(e.elm))}),u.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-BuqgqA5h.js").then(e=>Ed(e.erlang))}),u.of({name:"Esper",load:()=>import("./sql-ByLYq2fX.js").then(e=>Ed(e.esper))}),u.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-Bk9_H-XT.js").then(e=>Ed(e.factor))}),u.of({name:"FCL",load:()=>import("./fcl-CVaBTCzQ.js").then(e=>Ed(e.fcl))}),u.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-POgR1ypr.js").then(e=>Ed(e.forth))}),u.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-DL7KluxX.js").then(e=>Ed(e.fortran))}),u.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Ed(e.fSharp))}),u.of({name:"Gas",extensions:["s"],load:()=>import("./gas-8mz5Q3qN.js").then(e=>Ed(e.gas))}),u.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-B6X1vGSW.js").then(e=>Ed(e.gherkin))}),u.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-DnIzCrpZ.js").then(e=>Ed(e.groovy))}),u.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-CLQs6EAM.js").then(e=>Ed(e.haskell))}),u.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Ed(e.haxe))}),u.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Ed(e.hxml))}),u.of({name:"HTTP",load:()=>import("./http-BKJkqRj4.js").then(e=>Ed(e.http))}),u.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-pcmmZuaN.js").then(e=>Ed(e.idl))}),u.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-BVaBnk3P.js").then(e=>Ed(e.jsonld))}),u.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-DjdwvFuI.js").then(e=>Ed(e.julia))}),u.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.kotlin))}),u.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-HO6ttBFx.js").then(e=>Ed(e.liveScript))}),u.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-8DXOpKDz.js").then(e=>Ed(e.lua))}),u.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-DkvFAiy5.js").then(e=>Ed(e.mirc))}),u.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-IIbmv7SK.js").then(e=>Ed(e.mathematica))}),u.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-DSrSSXCg.js").then(e=>Ed(e.modelica))}),u.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-zvxmGV4l.js").then(e=>Ed(e.mumps))}),u.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-z_N2Mo3d.js").then(e=>Ed(e.mbox))}),u.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-B4hAVlXN.js").then(e=>Ed(e.nginx))}),u.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-Cx8FAvMN.js").then(e=>Ed(e.nsis))}),u.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-BSwWqoLa.js").then(e=>Ed(e.ntriples))}),u.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.objectiveC))}),u.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.objectiveCpp))}),u.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Ed(e.oCaml))}),u.of({name:"Octave",extensions:["m"],load:()=>import("./octave-C4hdQ5Hf.js").then(e=>Ed(e.octave))}),u.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-qQq7irPq.js").then(e=>Ed(e.oz))}),u.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-CafrKXZF.js").then(e=>Ed(e.pascal))}),u.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-tdMlh9QA.js").then(e=>Ed(e.perl))}),u.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CwGJVRC4.js").then(e=>Ed(e.pig))}),u.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-D1ly3AHC.js").then(e=>Ed(e.powerShell))}),u.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-_nPj978X.js").then(e=>Ed(e.properties))}),u.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-B4y9do6W.js").then(e=>Ed(e.protobuf))}),u.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-Dlfivyh-.js").then(e=>Ed(e.pug))}),u.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-Bc-yJKzi.js").then(e=>Ed(e.puppet))}),u.of({name:"Q",extensions:["q"],load:()=>import("./q-mUfi2b_o.js").then(e=>Ed(e.q))}),u.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-BA4EbLKE.js").then(e=>Ed(e.r))}),u.of({name:"RPM Changes",load:()=>import("./rpm-DI_rRufH.js").then(e=>Ed(e.rpmChanges))}),u.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-DI_rRufH.js").then(e=>Ed(e.rpmSpec))}),u.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-CR-u2WLS.js").then(e=>Ed(e.ruby))}),u.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-Bqaci40L.js").then(e=>Ed(e.sas))}),u.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.scala))}),u.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-qjP0V5Ag.js").then(e=>Ed(e.scheme))}),u.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-BLav31RL.js").then(e=>Ed(e.shell))}),u.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-r025o_jW.js").then(e=>Ed(e.sieve))}),u.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-C7J3IyEP.js").then(e=>Ed(e.smalltalk))}),u.of({name:"Solr",load:()=>import("./solr-78MBEUkU.js").then(e=>Ed(e.solr))}),u.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Ed(e.sml))}),u.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-BRLJFz69.js").then(e=>Ed(e.sparql))}),u.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-CGlWr0eM.js").then(e=>Ed(e.spreadsheet))}),u.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Ed(e.squirrel))}),u.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-Bdo_Aemu.js").then(e=>Ed(e.stylus))}),u.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-B_XXVlXX.js").then(e=>Ed(e.swift))}),u.of({name:"sTeX",load:()=>Promise.resolve().then(function(){return Id}).then(e=>Ed(e.stex))}),u.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>Promise.resolve().then(function(){return Id}).then(e=>Ed(e.stex))}),u.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Ed(e.verilog))}),u.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-B2fODqDH.js").then(e=>Ed(e.tcl))}),u.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-BuVhTOzU.js").then(e=>Ed(e.textile))}),u.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-BgR6AEZu.js").then(e=>Ed(e.tiddlyWiki))}),u.of({name:"Tiki wiki",load:()=>import("./tiki-CI-ztowC.js").then(e=>Ed(e.tiki))}),u.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-BVJm5Fzd.js").then(e=>Ed(e.toml))}),u.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-Ce85hlLp.js").then(e=>Ed(e.troff))}),u.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-BxnYHtq8.js").then(e=>Ed(e.ttcn))}),u.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-CKJxb-l2.js").then(e=>Ed(e.ttcnCfg))}),u.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-BkSuIpt-.js").then(e=>Ed(e.turtle))}),u.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-CGwyPRYs.js").then(e=>Ed(e.webIDL))}),u.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-BHgjm0DN.js").then(e=>Ed(e.vb))}),u.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-VzWlGt02.js").then(e=>Ed(e.vbScript))}),u.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-BdD_26Jv.js").then(e=>Ed(e.velocity))}),u.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Ed(e.verilog))}),u.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-CWWH2SUo.js").then(e=>Ed(e.vhdl))}),u.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-CVDBqZPY.js").then(e=>Ed(e.xQuery))}),u.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-I8QjZlxf.js").then(e=>Ed(e.yacas))}),u.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-DMVFMNEx.js").then(e=>Ed(e.z80))}),u.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Ed(e.mscgen))}),u.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Ed(e.xu))}),u.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Ed(e.msgenny))}),u.of({name:"Vue",extensions:["vue"],load:()=>import("./index-Y09lLL_e.js").then(e=>e.vue())}),u.of({name:"Angular Template",load:()=>import("./index-D_AOS7Yx.js").then(e=>e.angular())})];function Td(e){function t(e,t){e.cmdState.push(t)}function n(e){return e.cmdState.length>0?e.cmdState[e.cmdState.length-1]:null}function o(e,t,n){return function(){this.name=e,this.bracketNo=0,this.style=t,this.styles=n,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var r={};function i(e,t){e.f=t}function s(e,o){var s;if(e.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var c=e.current().slice(1);return t(o,s=new(s=r.hasOwnProperty(c)?r[c]:r.DEFAULT)),i(o,l),s.style}if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/\\]/))return"tag";if(e.match("\\["))return i(o,function(e,t){return a(e,t,"\\]")}),"keyword";if(e.match("\\("))return i(o,function(e,t){return a(e,t,"\\)")}),"keyword";if(e.match("$$"))return i(o,function(e,t){return a(e,t,"$$")}),"keyword";if(e.match("$"))return i(o,function(e,t){return a(e,t,"$")}),"keyword";var d=e.next();return"%"==d?(e.skipToEnd(),"comment"):"}"==d||"]"==d?(s=n(o))?(s.closeBracket(d),i(o,l),"bracket"):"error":"{"==d||"["==d?(t(o,s=new(s=r.DEFAULT)),"bracket"):/\d/.test(d)?(e.eatWhile(/[\w.%]/),"atom"):(e.eatWhile(/[\w\-_]/),s=function(e){for(var t=e.cmdState,n=t.length-1;n>=0;n--){var o=t[n];if("DEFAULT"!=o.name)return o}return{styleIdentifier:function(){return null}}}(o),"begin"==s.name&&(s.argument=e.current()),s.styleIdentifier())}function a(e,t,n){if(e.eatSpace())return null;if(n&&e.match(n))return i(t,s),"keyword";if(e.match(/^\\[a-zA-Z@]+/))return"tag";if(e.match(/^[a-zA-Z]+/))return"variableName.special";if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/]/))return"tag";if(e.match(/^[\^_&]/))return"tag";if(e.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(e.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var o=e.next();return"{"==o||"}"==o||"["==o||"]"==o||"("==o||")"==o?"bracket":"%"==o?(e.skipToEnd(),"comment"):"error"}function l(e,t){var o=e.peek();return"{"==o||"["==o?(n(t).openBracket(o),e.eat(o),i(t,s),"bracket"):/[ \t\r]/.test(o)?(e.eat(o),null):(i(t,s),function(e){var t=e.cmdState.pop();t&&t.closeBracket()}(t),s(e,t))}return r.importmodule=o("importmodule","tag",["string","builtin"]),r.documentclass=o("documentclass","tag",["","atom"]),r.usepackage=o("usepackage","tag",["atom"]),r.begin=o("begin","tag",["atom"]),r.end=o("end","tag",["atom"]),r.label=o("label","tag",["atom"]),r.ref=o("ref","tag",["atom"]),r.eqref=o("eqref","tag",["atom"]),r.cite=o("cite","tag",["atom"]),r.bibitem=o("bibitem","tag",["atom"]),r.Bibitem=o("Bibitem","tag",["atom"]),r.RBibitem=o("RBibitem","tag",["atom"]),r.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{name:"stex",startState:function(){return{cmdState:[],f:e?function(e,t){return a(e,t)}:s}},copyState:function(e){return{cmdState:e.cmdState.slice(),f:e.f}},token:function(e,t){return t.f(e,t)},blankLine:function(e){e.f=s,e.cmdState.length=0},languageData:{commentTokens:{line:"%"}}}}const Dd=Td(!1);Td(!0);var Id=Object.freeze({__proto__:null,stex:Dd});function Ad(e){return function(t,n){let{$from:o,$to:r}=t.selection,i=o.blockRange(r,t=>t.childCount>0&&t.firstChild.type==e);return!!i&&(!n||(o.node(i.depth-1).type==e?function(e,t,n,o){let r=e.tr,i=o.end,s=o.$to.end(o.depth);i<s&&(r.step(new uo(i-1,s,i,s,new Kt(Ht.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new dn(r.doc.resolve(o.$from.pos),r.doc.resolve(s),o.depth));const a=mo(o);if(null==a)return!1;r.lift(o,a);let l=r.doc.resolve(r.mapping.map(i,-1)-1);ko(r.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&r.join(l.pos);return t(r.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let o=e.tr,r=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=r.child(t).nodeSize,o.delete(e-1,e+1);let i=o.doc.resolve(n.start),s=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==r.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?Ht.empty:Ht.from(r))))return!1;let u=i.pos,p=u+s.nodeSize;return o.step(new uo(u-(a?1:0),p+(l?1:0),u+1,p-1,new Kt((a?Ht.empty:Ht.from(r.copy(Ht.empty))).append(l?Ht.empty:Ht.from(r.copy(Ht.empty))),a?0:1,l?0:1),a?0:1)),t(o.scrollIntoView()),!0}(t,n,i)))}}function Rd(e){return String(e||"").toUpperCase()}function Pd(){return function(e){const t=function(e){const t=new Map;if(!e||!e.type)throw new Error("mdast-util-definitions expected node");return ee(e,"definition",function(e){const n=Rd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){const n=Rd(e);return t.get(n)}}(e);ee(e,function(e,n,o){if("definition"===e.type&&void 0!==o&&"number"==typeof n)return o.children.splice(n,1),[te,n];if("imageReference"===e.type||"linkReference"===e.type){const r=t(e.identifier);if(r&&o&&"number"==typeof n)return o.children[n]="imageReference"===e.type?{type:"image",url:r.url,title:r.title,alt:e.alt}:{type:"link",url:r.url,title:r.title,children:e.children},[te,n]}})}}function Ld(e,t){if(!(t.childCount>=1&&"hardbreak"===t.lastChild?.type.name))return void e.next(t.content);const n=[];t.content.forEach((e,o,r)=>{r!==t.childCount-1&&n.push(e)}),e.next(Ht.fromArray(n))}function Vd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}var jd=bd("emphasis");Vd(jd,{displayName:"Attr<emphasis>",group:"Emphasis"});var $d=vd("emphasis",e=>({attrs:{marker:{default:e.get(lc).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(jd.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));Vd($d.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),Vd($d.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Bd=ld("ToggleEmphasis",e=>()=>Nr($d.type(e)));Vd(Bd,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var Hd=cd(e=>ri(/(?:^|[^*])\*([^*]+)\*$/,$d.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));Vd(Hd,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var Fd=cd(e=>ri(/\b_(?![_\s])(.*?[^_\s])_\b/,$d.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));Vd(Fd,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var zd=yd("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(bc);return()=>t.call(Bd.key)}}});Vd(zd.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),Vd(zd.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var qd=bd("strong");Vd(qd,{displayName:"Attr<strong>",group:"Strong"});var Wd=vd("strong",e=>({attrs:{marker:{default:e.get(lc).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>"normal"!=e.style.fontWeight&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e},{style:"font-weight=400",clearMark:e=>"strong"==e.type.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>["strong",e.get(qd.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));Vd(Wd.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),Vd(Wd.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Ud=ld("ToggleStrong",e=>()=>Nr(Wd.type(e)));Vd(Ud,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var Kd=cd(e=>ri(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Wd.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));Vd(Kd,{displayName:"InputRule<strong>",group:"Strong"});var Gd=yd("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(bc);return()=>t.call(Ud.key)}}});Vd(Gd.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),Vd(Gd.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var Jd=bd("inlineCode");Vd(Jd,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Zd=vd("inlineCode",e=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(Jd.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>(e.withMark(t,"inlineCode",n.text||""),!0)}}));Vd(Zd.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),Vd(Zd.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Xd=ld("ToggleInlineCode",e=>()=>(t,n)=>{const{selection:o,tr:r}=t;if(o.empty)return!1;const{from:i,to:s}=o;return t.doc.rangeHasMark(i,s,Zd.type(e))?(n?.(r.removeMark(i,s,Zd.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==Zd.type.name).map(e=>t.schema.marks[e]).forEach(e=>{r.removeMark(i,s,e)}),n?.(r.addMark(i,s,Zd.type(e).create())),!0)});Vd(Xd,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var Yd=cd(e=>ri(/(?:`)([^`]+)(?:`)$/,Zd.type(e)));Vd(Yd,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var Qd=yd("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(bc);return()=>t.call(Xd.key)}}});Vd(Qd.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),Vd(Qd.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var eu=bd("link");Vd(eu,{displayName:"Attr<link>",group:"Link"});var tu=vd("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(eu.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const o=t.url,r=t.title;e.openMark(n,{href:o,title:r}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));Vd(tu.mark,{displayName:"MarkSchema<link>",group:"Link"});var nu=ld("ToggleLink",e=>(t={})=>Nr(tu.type(e),t));Vd(nu,{displayName:"Command<toggleLinkCommand>",group:"Link"});var ou=ld("UpdateLink",e=>(t={})=>(n,o)=>{if(!o)return!1;let r,i=-1;const{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(tu.type(e).isInSet(t.marks))return r=t,i=n,!1}),!r)return!1;const c=r.marks.find(({type:t})=>t===tu.type(e));if(!c)return!1;const d=i,u=i+r.nodeSize,{tr:p}=n,h=tu.type(e).create({...c.attrs,...t});return!!h&&(o(p.removeMark(d,u,c).addMark(d,u,h).setSelection(new Fo(p.selection.$anchor)).scrollIntoView()),!0)});Vd(ou,{displayName:"Command<updateLinkCommand>",group:"Link"});var ru=ud("doc",()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}}));function iu(e){return ne(e,e=>"html"===e.type&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;const n=t[t.length-1];if(!n)return;const o=n.children.indexOf(e);-1!==o&&n.children.splice(o,1)},!0)}Vd(ru,{displayName:"NodeSchema<doc>",group:"Doc"});var su=kd("remark-preserve-empty-line",()=>()=>iu);Vd(su.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),Vd(su.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var au=wd("paragraph");Vd(au,{displayName:"Attr<paragraph>",group:"Paragraph"});var lu=gd("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(au.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(t,n)=>{const o=e.get(Yl).state?.doc.lastChild;t.openNode("paragraph"),n.content&&0!==n.content.size||n===o||!function(e){let t=!1;try{e.get(su.id),t=!0}catch{t=!1}return t}(e)?Ld(t,n):t.addNode("html",void 0,"<br />"),t.closeNode()}}}));Vd(lu.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),Vd(lu.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var cu=ld("TurnIntoText",e=>()=>xr(lu.type(e)));Vd(cu,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var du=yd("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(bc);return()=>t.call(cu.key)}}});Vd(du.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),Vd(du.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var uu=Array(6).fill(0).map((e,t)=>t+1);var pu=md(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");Vd(pu,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var hu=wd("heading");Vd(hu,{displayName:"Attr<heading>",group:"Heading"});var fu=gd("heading",e=>{const t=e.get(pu.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:uu.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Nt(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(hu.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const o=t.depth;e.openNode(n,{level:o}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),Ld(e,t),e.closeNode()}}}});Vd(fu.node,{displayName:"NodeSchema<heading>",group:"Heading"}),Vd(fu.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var mu=cd(e=>Rr(/^(?<hashes>#+)\s$/,fu.type(e),t=>{const n=t.groups?.hashes?.length||0,{$from:o}=e.get(Yl).state.selection,r=o.node();if("heading"===r.type.name){let e=Number(r.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));Vd(mu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var gu=ld("WrapInHeading",e=>t=>(t??=1,t<1?xr(lu.type(e)):xr(fu.type(e),{level:t})));Vd(gu,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var vu=ld("DowngradeHeading",e=>()=>(t,n,o)=>{const{$from:r}=t.selection,i=r.node();if(i.type!==fu.type(e)||!t.selection.empty||0!==r.parentOffset)return!1;const s=i.attrs.level-1;return s?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...i.attrs,level:s})),!0):xr(lu.type(e))(t,n,o)});Vd(vu,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var yu=yd("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(bc);return()=>t.call(gu.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(bc);return()=>t.call(vu.key)}}});Vd(yu.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),Vd(yu.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var wu=wd("blockquote");Vd(wu,{displayName:"Attr<blockquote>",group:"Blockquote"});var bu=gd("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(wu.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));Vd(bu.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),Vd(bu.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var ku=cd(e=>Ar(/^\s*>\s$/,bu.type(e)));Vd(ku,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Cu=ld("WrapInBlockquote",e=>()=>Cr(bu.type(e)));Vd(Cu,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var xu=yd("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(bc);return()=>t.call(Cu.key)}}});Vd(xu.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),Vd(xu.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Nu=wd("codeBlock",()=>({pre:{},code:{}}));Vd(Nu,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Su=gd("code_block",e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(Nu.key)(t),o=t.attrs.language,r=o&&o.length>0?{"data-language":o}:void 0;return["pre",{...n.pre,...r},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const o=t.lang??"",r=t.value;e.openNode(n,{language:o}),r&&e.addText(r),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));Vd(Su.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),Vd(Su.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Ou=cd(e=>Rr(/^```(?<language>[a-z]*)?[\s\n]$/,Su.type(e),e=>({language:e.groups?.language??""})));Vd(Ou,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Eu=ld("CreateCodeBlock",e=>(t="")=>xr(Su.type(e),{language:t}));Vd(Eu,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),Vd(ld("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,o)=>e>=0&&(o?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Mu=yd("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(bc);return()=>t.call(Eu.key)}}});Vd(Mu.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),Vd(Mu.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var _u=wd("image");Vd(_u,{displayName:"Attr<image>",group:"Image"});var Tu=gd("image",e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(_u.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const o=t.url,r=t.alt,i=t.title;e.addNode(n,{src:o,alt:r,title:i})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));Vd(Tu.node,{displayName:"NodeSchema<image>",group:"Image"}),Vd(Tu.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Du=ld("InsertImage",e=>(t={})=>(n,o)=>{if(!o)return!0;const{src:r="",alt:i="",title:s=""}=t,a=Tu.type(e).create({src:r,alt:i,title:s});return!a||(o(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});Vd(Du,{displayName:"Command<insertImageCommand>",group:"Image"});var Iu=ld("UpdateImage",e=>(t={})=>(n,o)=>{const r=wi(n.selection,Tu.type(e));if(!r)return!1;const{node:i,pos:s}=r,a={...i.attrs},{src:l,alt:c,title:d}=t;return void 0!==l&&(a.src=l),void 0!==c&&(a.alt=c),void 0!==d&&(a.title=d),o?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});Vd(Iu,{displayName:"Command<updateImageCommand>",group:"Image"}),Vd(cd(e=>new Dr(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,o,r)=>{const[i,s,a="",l]=n;return i?t.tr.replaceWith(o,r,Tu.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Au=wd("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));Vd(Au,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Ru=gd("hardbreak",e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(Au.key)(t)," "]:["br",e.get(Au.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{e.addNode(n,{isInline:Boolean(t.data?.isInline)})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}}));Vd(Ru.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),Vd(Ru.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Pu=ld("InsertHardbreak",e=>()=>(t,n)=>{const{selection:o,tr:r}=t;if(!(o instanceof Fo))return!1;if(o.empty){const e=o.$from.node();if(e.childCount>0&&"hardbreak"===e.lastChild?.type.name)return n?.(r.replaceRangeWith(o.to-1,o.to,t.schema.node("paragraph")).setSelection(jo.near(r.doc.resolve(o.to))).scrollIntoView()),!0}return n?.(r.setMeta("hardbreak",!0).replaceSelectionWith(Ru.type(e).create()).scrollIntoView()),!0});Vd(Pu,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Lu=yd("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(bc);return()=>t.call(Pu.key)}}});Vd(Lu.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),Vd(Lu.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Vu=wd("hr");Vd(Vu,{displayName:"Attr<hr>",group:"Hr"});var ju=gd("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(Vu.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}}));Vd(ju.node,{displayName:"NodeSchema<hr>",group:"Hr"}),Vd(ju.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var $u=cd(e=>new Dr(/^(?:---|___\s|\*\*\*\s)$/,(t,n,o,r)=>{const{tr:i}=t;return n[0]&&i.replaceWith(o-1,r,ju.type(e).create()),i}));Vd($u,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var Bu=ld("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;const o=lu.node.type(e).create(),{tr:r,selection:i}=t,{from:s}=i,a=ju.type(e).create();if(!a)return!0;const l=r.replaceSelectionWith(a).insert(s,o),c=jo.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});Vd(Bu,{displayName:"Command<insertHrCommand>",group:"Hr"});var Hu=wd("bulletList");Vd(Hu,{displayName:"Attr<bulletList>",group:"BulletList"});var Fu=gd("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(Hu.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const o=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:o}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));Vd(Fu.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),Vd(Fu.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var zu=cd(e=>Ar(/^\s*([-+*])\s$/,Fu.type(e)));Vd(zu,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var qu=ld("WrapInBulletList",e=>()=>Cr(Fu.type(e)));Vd(qu,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Wu=yd("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(bc);return()=>t.call(qu.key)}}});Vd(Wu.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),Vd(Wu.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Uu=wd("orderedList");Vd(Uu,{displayName:"Attr<orderedList>",group:"OrderedList"});var Ku=gd("ordered_list",e=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(Uu.key)(t),...1===t.attrs.order?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{const o=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:o,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Vd(Ku.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),Vd(Ku.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var Gu=cd(e=>Ar(/^\s*(\d+)\.\s$/,Ku.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));Vd(Gu,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Ju=ld("WrapInOrderedList",e=>()=>Cr(Ku.type(e)));Vd(Ju,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Zu=yd("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(bc);return()=>t.call(Ju.key)}}});Vd(Zu.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),Vd(Zu.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Xu=wd("listItem");Vd(Xu,{displayName:"Attr<listItem>",group:"ListItem"});var Yu=gd("list_item",e=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Nt(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(Xu.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{const o=null!=t.label?`${t.label}.`:"•",r=null!=t.label?"ordered":"bullet",i=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:o,listType:r,spread:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Vd(Yu.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),Vd(Yu.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var Qu=ld("SinkListItem",e=>()=>{return t=Yu.type(e),function(e,n){let{$from:o,$to:r}=e.selection,i=o.blockRange(r,e=>e.childCount>0&&e.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let o=l.lastChild&&l.lastChild.type==a.type,r=Ht.from(o?t.create():null),s=new Kt(Ht.from(t.create(null,Ht.from(a.type.create(null,r)))),o?3:1,0),c=i.start,d=i.end;n(e.tr.step(new uo(c-(o?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0};var t});Vd(Qu,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var ep=ld("LiftListItem",e=>()=>Ad(Yu.type(e)));Vd(ep,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var tp=ld("SplitListItem",e=>()=>{return t=Yu.type(e),function(e,n){let{$from:o,$to:r,node:i}=e.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(r))return!1;let s=o.node(-1);if(s.type!=t)return!1;if(0==o.parent.content.size&&o.node(-1).childCount==o.indexAfter(-1)){if(3==o.depth||o.node(-3).type!=t||o.index(-2)!=o.node(-2).childCount-1)return!1;if(n){let r=Ht.empty,i=o.index(-1)?1:o.index(-2)?2:3;for(let e=o.depth-i;e>=o.depth-3;e--)r=Ht.from(o.node(e).copy(r));let s=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;r=r.append(Ht.from(t.createAndFill()));let a=o.before(o.depth-(i-1)),l=e.tr.replace(a,o.after(-s),new Kt(r,4-i,0)),c=-1;l.doc.nodesBetween(a,l.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)}),c>-1&&l.setSelection(jo.near(l.doc.resolve(c))),n(l.scrollIntoView())}return!0}let a=r.pos==o.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(o.pos,r.pos),c=a?[null,{type:a}]:void 0;return!!bo(l.doc,o.pos,2,c)&&(n&&n(l.split(o.pos,2,c).scrollIntoView()),!0)};var t});Vd(tp,{displayName:"Command<splitListItemCommand>",group:"ListItem"});var np=ld("LiftFirstListItem",e=>()=>function(e){return(t,n,o)=>{const{selection:r}=t;if(!(r instanceof Fo))return!1;const{empty:i,$from:s}=r;return!(!i||0!==s.parentOffset)&&s.node(-1).type===Yu.type(e)&&cr(t,n,o)}}(e));Vd(np,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var op=yd("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(bc);return()=>t.call(tp.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(bc);return()=>t.call(Qu.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(bc);return()=>t.call(ep.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(bc);return()=>t.call(np.key)}}});Vd(op.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),Vd(op.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var rp=ud("text",()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}}));Vd(rp,{displayName:"NodeSchema<text>",group:"Text"});var ip=wd("html");Vd(ip,{displayName:"Attr<html>",group:"Html"});var sp=gd("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{const n=document.createElement("span"),o={...e.get(ip.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",o,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>Boolean("html"===e),runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));Vd(sp.node,{displayName:"NodeSchema<html>",group:"Html"}),Vd(sp.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var ap=[ru,au,lu,pu,hu,fu,Au,Ru,wu,bu,Nu,Su,Vu,ju,_u,Tu,Hu,Fu,Uu,Ku,Xu,Yu,jd,$d,qd,Wd,Jd,Zd,eu,tu,ip,sp,rp].flat(),lp=[ku,zu,Gu,Ou,$u,mu].flat(),cp=[Hd,Fd,Yd,Kd],dp=ld("IsMarkSelected",()=>e=>t=>{if(!e)return!1;const{doc:n,selection:o}=t;return n.rangeHasMark(o.from,o.to,e)}),up=ld("IsNoteSelected",()=>e=>t=>!!e&&bi(t,e).hasNode),pp=ld("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr;const{$from:o,$to:r}=n.selection,{pos:i}=o,{pos:s}=r,a=i-o.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),hp=ld("SetBlockType",()=>e=>(t,n)=>{const{nodeType:o,attrs:r=null}=e??{};if(!o)return!1;const i=t.tr,{from:s,to:a}=i.selection;try{i.setBlockType(s,a,o,r)}catch{return!1}return n?.(i),!0}),fp=ld("WrapInBlockType",()=>e=>(t,n)=>{const{nodeType:o,attrs:r=null}=e??{};if(!o)return!1;let i=t.tr;try{const{$from:e,$to:t}=i.selection,n=e.blockRange(t),s=n&&go(n,o,r);if(!s)return!1;i=i.wrap(n,s)}catch{return!1}return n?.(i),!0}),mp=ld("AddBlockType",()=>e=>(t,n)=>{const{nodeType:o,attrs:r=null}=e??{};if(!o)return!1;const i=t.tr;try{const e=o instanceof pn?o:o.createAndFill(r);if(!e)return!1;i.replaceSelectionWith(e)}catch{return!1}return n?.(i),!0}),gp=ld("SelectTextNearPos",()=>e=>(t,n)=>{const{pos:o}=e??{};if(null==o)return!1;const r=t.tr;try{const e=t.doc.resolve((i=o,s=0,a=t.doc.content.size,Math.min(Math.max(i,s),a)));r.setSelection(Fo.near(e))}catch{return!1}var i,s,a;return n?.(r.scrollIntoView()),!0}),vp=[cu,Cu,gu,vu,Eu,Pu,Bu,Du,Iu,Ju,qu,Qu,tp,ep,np,Bd,Xd,Ud,nu,ou,dp,up,pp,hp,fp,mp,gp],yp=[xu,Mu,Lu,yu,op,Zu,Wu,du,zd,Qd,Gd].flat(),wp=kd("remarkAddOrderInList",()=>()=>e=>{ee(e,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});Vd(wp.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),Vd(wp.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var bp=kd("remarkLineBreak",()=>()=>e=>{const t=/[\t ]*(?:\r?\n|\r)/g;ee(e,"text",(e,n,o)=>{if(!e.value||"string"!=typeof e.value)return;const r=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&r.push({type:"text",value:e.value.slice(i,n)}),r.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return r.length>0&&o&&"number"==typeof n?(i<e.value.length&&r.push({type:"text",value:e.value.slice(i)}),o.children.splice(n,1,...r),n+r.length):void 0})});Vd(bp.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),Vd(bp.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var kp=kd("remarkInlineLink",()=>Pd);Vd(kp.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),Vd(kp.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var Cp=["root","blockquote","listItem"],xp=kd("remarkHTMLTransformer",()=>()=>e=>{var t;t=(e,t,n)=>(e=>"html"===e.type)(e)?(n&&Cp.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e],function e(n,o,r){if((e=>!!e.children)(n)){const t=[];for(let o=0,r=n.children.length;o<r;o++){const r=n.children[o];if(r){const i=e(r,o,n);if(i)for(let e=0,n=i.length;e<n;e++){const n=i[e];n&&t.push(n)}}}n.children=t}return t(n,o,r)}(e,0,null)[0]});Vd(xp.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),Vd(xp.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var Np=kd("remarkMarker",()=>()=>(e,t)=>{ee(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)})});Vd(Np.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),Vd(Np.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Sp=pd(()=>{let e=!1;const t=new or({key:new sr("MILKDOWN_INLINE_NODES_CURSOR"),state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,o=t.nodeAfter;return!(!(n&&o&&n.isInline&&!n.isText&&o.isInline)||o.isText)}},props:{handleDOMEvents:{compositionend:(n,o)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){const e=n.state.selection.from;o.preventDefault(),n.dispatch(n.state.tr.insertText(o.data||"",e))}}),!0),compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,o)=>{if(t.getState(n.state)&&o instanceof InputEvent&&o.data&&!e){const e=n.state.selection.from;return o.preventDefault(),n.dispatch(n.state.tr.insertText(o.data||"",e)),!0}return!1}},decorations(e){if(t.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),o=gl.widget(t,n,{side:-1}),r=document.createElement("span"),i=gl.widget(t,r);return setTimeout(()=>{n.contentEditable="true",r.contentEditable="true"}),wl.create(e.doc,[o,i])}return wl.empty}}});return t});Vd(Sp,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var Op=pd(e=>new or({key:new sr("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,o)=>{if(!t.length)return;const[r]=t;if(!r)return;const[i]=r.steps;if(r.getMeta("hardbreak")){if(!(i instanceof co))return;const{from:t}=i;return o.tr.setNodeMarkup(t,Ru.type(e),void 0,[])}if(i instanceof io){let t=o.tr;const{from:n,to:r}=i;return o.doc.nodesBetween(n,r,(n,o)=>{n.type===Ru.type(e)&&(t=t.setNodeMarkup(o,Ru.type(e),void 0,[]))}),t}}}));Vd(Op,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Ep=md(["table","code_block"],"hardbreakFilterNodes");Vd(Ep,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Mp=pd(e=>{const t=e.get(Ep.key);return new or({key:new sr("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const o=e.getMeta("hardbreak"),[r]=e.steps;if(o&&r){const{from:e}=r,o=n.doc.resolve(e);let i=o.depth,s=!0;for(;i>0;)t.includes(o.node(i).type.name)&&(s=!1),i--;return s}return!0}})});Vd(Mp,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var _p=pd(e=>{const t=new sr("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const o=e.get(pu.key),r=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants((n,a)=>{if(n.type===fu.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let l=o(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(i=!0,r.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),i&&n.dispatch(r)};return new or({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});Vd(_p,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Tp=pd(e=>new or({key:new sr("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,o)=>{if(!o.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;const r=Ku.type(e),i=Fu.type(e),s=Yu.type(e),a=(e,t,n=1)=>{let o=!1;const r=`${t+n}.`;return e.label!==r&&(e.label=r,o=!0),o};let l=o.tr,c=!1;return o.doc.descendants((e,t,n,o)=>{if(e.type===i){const n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,r,{spread:"true"}),e.descendants((e,t,n,o)=>{if(e.type===s){const n={...e.attrs};a(n,o)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===r){const r={...e.attrs};let i=!1;"ordered"!==r.listType&&(r.listType="ordered",i=!0),n?.maybeChild(0)&&(i=a(r,o,n?.attrs.order??1)),i&&(l=l.setNodeMarkup(t,void 0,r),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));Vd(Tp,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var Dp=[ap,lp,cp,vp,yp,[Op,Ep,Mp,Sp,wp,kp,bp,xp,Np,su,_p,Tp].flat()].flat(),Ip=200,Ap=function(){};Ap.prototype.append=function(e){return e.length?(e=Ap.from(e),!this.length&&e||e.length<Ip&&this.leafAppend(e)||this.length<Ip&&e.leafPrepend(this)||this.appendInner(e)):this},Ap.prototype.prepend=function(e){return e.length?Ap.from(e).append(this):this},Ap.prototype.appendInner=function(e){return new Pp(this,e)},Ap.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Ap.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Ap.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ap.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Ap.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var o=[];return this.forEach(function(t,n){return o.push(e(t,n))},t,n),o},Ap.from=function(e){return e instanceof Ap?e:e&&e.length?new Rp(e):Ap.empty};var Rp=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,o){for(var r=t;r<n;r++)if(!1===e(this.values[r],o+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,o){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],o+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Ip)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ip)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Ap);Ap.empty=new Rp([]);var Pp=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,o){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),o))&&(!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,o+r))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,o){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,o+r))&&(!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,o))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Ap);class Lp{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--){if(this.items.get(r-1).selection){--r;break}}t&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,a=e.tr,l=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(r,t+1),o=n.maps.length),o--,void c.push(e);if(n){c.push(new Vp(e.map));let t,r=e.step.map(n.slice(o));r&&a.maybeStep(r).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new Vp(t,void 0,void 0,l.length+c.length))),o--,t&&n.appendMap(t,o)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(o)):e.selection,s=new Lp(this.items.slice(0,r).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(e,t,n,o){let r=[],i=this.eventCount,s=this.items,a=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),d=new Vp(e.mapping.maps[n],c,t);(l=a&&a.merge(d))&&(d=l,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),t&&(i++,t=void 0),o||(a=d)}let l=i-n.depth;return l>$p&&(s=function(e,t){let n;return e.forEach((e,o)=>{if(e.selection&&0==t--)return n=o,!1}),e.slice(n)}(s,l),i-=l),new Lp(s.append(r),i)}remapping(e,t){let n=new eo;return this.items.forEach((t,o)=>{let r=null!=t.mirrorOffset&&o-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)},e,t),n}addMaps(e){return 0==this.eventCount?this:new Lp(this.items.append(e.map(e=>new Vp(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},o);let a=t;this.items.forEach(t=>{let o=r.getMirror(--a);if(null==o)return;i=Math.min(i,o);let l=r.maps[o];if(t.step){let i=e.steps[o].invert(e.docs[o]),c=t.selection&&t.selection.map(r.slice(a+1,o));c&&s++,n.push(new Vp(l,i,c))}else n.push(new Vp(l))},o);let l=[];for(let e=t;e<i;e++)l.push(new Vp(r.maps[e]));let c=this.items.slice(0,o).append(l).append(n),d=new Lp(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,o=[],r=0;return this.items.forEach((i,s)=>{if(s>=e)o.push(i),i.selection&&r++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&r++;let l,c=new Vp(s.invert(),e,a),d=o.length-1;(l=o.length&&o[d].merge(c))?o[d]=l:o.push(c)}}else i.map&&n--},this.items.length,0),new Lp(Ap.from(o.reverse()),r)}}Lp.empty=new Lp(Ap.empty,0);class Vp{constructor(e,t,n,o){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Vp(t.getMap().invert(),t,this.selection)}}}class jp{constructor(e,t,n,o,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const $p=20;function Bp(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,o,r)=>t.push(o,r));return t}function Hp(e,t){if(!e)return null;let n=[];for(let o=0;o<e.length;o+=2){let r=t.map(e[o],1),i=t.map(e[o+1],-1);r<=i&&n.push(r,i)}return n}let Fp=!1,zp=null;function qp(e){let t=e.plugins;if(zp!=t){Fp=!1,zp=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Fp=!0;break}}return Fp}const Wp=new sr("history"),Up=new sr("closeHistory");function Kp(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new or({key:Wp,state:{init:()=>new jp(Lp.empty,Lp.empty,null,0,-1),apply:(t,n,o)=>function(e,t,n,o){let r,i=n.getMeta(Wp);if(i)return i.historyState;n.getMeta(Up)&&(e=new jp(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Wp))return s.getMeta(Wp).redo?new jp(e.done.addTransform(n,void 0,o,qp(t)),e.undone,Bp(n.mapping.maps),e.prevTime,e.prevComposition):new jp(e.done,e.undone.addTransform(n,void 0,o,qp(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new jp(e.done.rebased(n,r),e.undone.rebased(n,r),Hp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new jp(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Hp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let r=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-o.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,o)=>{for(let r=0;r<t.length;r+=2)e<=t[r+1]&&o>=t[r]&&(n=!0)}),n}(n,e.prevRanges)),a=s?Hp(e.prevRanges,n.mapping):Bp(n.mapping.maps);return new jp(e.done.addTransform(n,i?t.selection.getBookmark():void 0,o,qp(t)),Lp.empty,a,n.time,null==r?e.prevComposition:r)}}(n,o,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,o="historyUndo"==n?Jp:"historyRedo"==n?Zp:null;return!(!o||!e.editable)&&(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Gp(e,t){return(n,o)=>{let r=Wp.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(o){let i=function(e,t,n){let o=qp(t),r=Wp.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),r,o),l=new jp(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(Wp,{redo:n,historyState:l})}(r,n,e);i&&o(t?i.scrollIntoView():i)}return!0}}const Jp=Gp(!1,!0),Zp=Gp(!0,!0);
2
2
  /**
3
3
  * @vue/shared v3.5.32
4
4
  * (c) 2018-present Yuxi (Evan) You and Vue contributors