@juki-team/base-ui 1.5.14 → 1.5.15

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 (257) hide show
  1. package/dist/esm/ArrowForwardIcon-Bd0B_Kwe.js +1 -0
  2. package/dist/esm/BarChart-B6teyAwl.js +1 -0
  3. package/dist/esm/{CartesianChart-DCv2SXML.js → CartesianChart-BZZYJ31q.js} +1 -1
  4. package/dist/esm/ChangePasswordModal-wjB2d2a0.js +1 -0
  5. package/dist/esm/CodeEditor--mRrq7Xc.js +1 -0
  6. package/dist/esm/CodeViewer-C2keyN4-.js +1 -0
  7. package/dist/esm/Collapse-C_rZY9aE.js +1 -0
  8. package/dist/esm/{DataGrid-1GBbtJPo.js → DataGrid-DbFP5mTw.js} +1 -1
  9. package/dist/esm/DataViewer-lFoDNwIZ.js +1 -0
  10. package/dist/esm/DrawerView-BLwtJxwY.js +1 -0
  11. package/dist/esm/ExcalidrawButton-CrNTOZTX.js +1 -0
  12. package/dist/esm/GraphvizViewer-beaBRsJd.js +1 -0
  13. package/dist/esm/ImageLoaderCropper-_ZIo2zEm.js +1 -0
  14. package/dist/esm/InputCellPhoneNumber-CusvoWas.js +1 -0
  15. package/dist/esm/{InputColor-UJ28fLOn.js → InputColor-ADhkNitB.js} +1 -1
  16. package/dist/esm/LineChart-DUg6yaTg.js +1 -0
  17. package/dist/esm/{LoaderLayer-CyitSTCe.js → LoaderLayer-Csc8unUJ.js} +1 -1
  18. package/dist/esm/MdMath-Dstso3EJ.js +1 -0
  19. package/dist/esm/{MdMathEditor-DWwwX_SO.js → MdMathEditor-BMYIOhto.js} +1 -1
  20. package/dist/esm/{Popover-CmhtPayh.js → Popover-DRm9Iqcj.js} +1 -1
  21. package/dist/esm/ReplyIcon-BAIEk00m.js +1 -0
  22. package/dist/esm/{SettingsIcon-CegP07CF.js → SettingsIcon-Cd0qgB0A.js} +1 -1
  23. package/dist/esm/SlideDeck-C0Py_6HO.js +1 -0
  24. package/dist/esm/{TableEyeIcon-C4nuk_xp.js → TableEyeIcon-CYXh-eSU.js} +1 -1
  25. package/dist/esm/{TableOfContents-B7API9_v.js → TableOfContents-GPaHLa0x.js} +1 -1
  26. package/dist/esm/Tooltip-DZbA_43G.js +1 -0
  27. package/dist/esm/UserCodeEditor-D_rQzIU2.js +61 -0
  28. package/dist/esm/VirtualizedRowsFixed-BgL_awYQ.js +1 -0
  29. package/dist/esm/WorksheetAsSlides-B8zp1Rak.js +1 -0
  30. package/dist/esm/{WorksheetBodies-dstnMykc.js → WorksheetBodies-Cr9jJtnr.js} +1 -1
  31. package/dist/esm/WorksheetContents-Y4b_IwYP.js +1 -0
  32. package/dist/esm/WorksheetEditor-BoecibGe.js +1 -0
  33. package/dist/esm/{WorksheetNode-BWrXWPtD.js → WorksheetNode-DTyHDssN.js} +1 -1
  34. package/dist/esm/WorksheetViewer-BkyLzOi4.js +1 -0
  35. package/dist/esm/abnfDiagram-WEYOIA3C-C_CVppQA.js +1 -0
  36. package/dist/esm/{arc-DomqdCJb.js → arc-vEmnBEcc.js} +1 -1
  37. package/dist/esm/architectureDiagram-ZHVYKT53-CCcP7rrg.js +1 -0
  38. package/dist/esm/blockDiagram-RJAE7QA3-DU8sn8Km.js +1 -0
  39. package/dist/esm/c4Diagram-XDPPPE54-DQFPX695.js +1 -0
  40. package/dist/esm/channel-5x2nMoMO.js +1 -0
  41. package/dist/esm/{chunk-2E7WHVMD-Beocb-Jh.js → chunk-2E7WHVMD-p2GM0eBD.js} +1 -1
  42. package/dist/esm/{chunk-2Q5K7J3B-BvYoUWYj.js → chunk-2Q5K7J3B-Cy8SGmP2.js} +1 -1
  43. package/dist/esm/{chunk-4EMNKR2T-CwTwaoZv.js → chunk-4EMNKR2T-CyLGLodZ.js} +1 -1
  44. package/dist/esm/{chunk-55XCU76K-Bm2vEyhO.js → chunk-55XCU76K-BN8xVJCh.js} +1 -1
  45. package/dist/esm/{chunk-5VM5RSS4-bDfGkvI-.js → chunk-5VM5RSS4-D3PGx3gp.js} +1 -1
  46. package/dist/esm/{chunk-JWPE2WC7-WoJ0Gwzc.js → chunk-JWPE2WC7-BJAR6xMq.js} +1 -1
  47. package/dist/esm/{chunk-NQOKRVIF-BsYoUZL4.js → chunk-NQOKRVIF-fUehRCXZ.js} +1 -1
  48. package/dist/esm/{chunk-VQ5W62QI-BTvKzH75.js → chunk-VQ5W62QI-mHHsR0s0.js} +1 -1
  49. package/dist/esm/{chunk-XXDRQBXY-ClHdtw3t.js → chunk-XXDRQBXY-DLLBlZjr.js} +1 -1
  50. package/dist/esm/{chunk-ZCHMQSOR-BuzD1sYe.js → chunk-ZCHMQSOR-t517tTkb.js} +1 -1
  51. package/dist/esm/classDiagram-v2-4MYWR3UA-CrNA_w1s.js +1 -0
  52. package/dist/esm/{commons-CmbPiYDE.js → commons-BLDufAOm.js} +1 -1
  53. package/dist/esm/constants.js +1 -1
  54. package/dist/esm/cose-bilkent-JH36ORCC-DTawllqu.js +1 -0
  55. package/dist/esm/cynefinDiagram-WF24UDRP-DWwhOkSi.js +1 -0
  56. package/dist/esm/dagre-NK4GIZVX-Jm0gIaFX.js +1 -0
  57. package/dist/esm/diagram-CBK3MWTC-CcOs3Ceh.js +1 -0
  58. package/dist/esm/diagram-I5XIIV2D-BBh0FWXm.js +1 -0
  59. package/dist/esm/diagram-ODIL2UCW-BlztNr6r.js +1 -0
  60. package/dist/esm/diagram-PFBEJUXE-DtRoe0ng.js +1 -0
  61. package/dist/esm/diagram-RJA3I4VV-LdjGFjBw.js +1 -0
  62. package/dist/esm/diagram-TYUNFSNR-D8WXXh7g.js +1 -0
  63. package/dist/esm/ebnfDiagram-V4P3TTPT-DESDKr7D.js +1 -0
  64. package/dist/esm/elk-QONTBCTQ-DDBz4veG.js +1 -0
  65. package/dist/esm/enums.js +1 -1
  66. package/dist/esm/erDiagram-KYQIGQAA-CBg-NMBs.js +1 -0
  67. package/dist/esm/flowDiagram-IUGLLWBU-BytjhPBX.js +1 -0
  68. package/dist/esm/ganttDiagram-R7GPNTJY-BKQtPa2l.js +1 -0
  69. package/dist/esm/gitGraphDiagram-PDYL7XHY-SgW1IIil.js +1 -0
  70. package/dist/esm/helpers.js +1 -1
  71. package/dist/esm/index-38k9tHSo.js +1 -0
  72. package/dist/esm/index-3QSNRp1k.js +1 -0
  73. package/dist/esm/{index-DBVTTZ07.js → index-CEgC-P3H.js} +1 -1
  74. package/dist/esm/{index-P2yxumel.js → index-D954khxt.js} +1 -1
  75. package/dist/esm/{index-D9j3iMPO.js → index-yFCV1i1-.js} +1 -1
  76. package/dist/esm/infoDiagram-MVDRKAX5-DfklDIw_.js +1 -0
  77. package/dist/esm/ishikawaDiagram-HPEHV2GE-BgFDqFFr.js +1 -0
  78. package/dist/esm/journeyDiagram-BOSHW7O7-DMgZlI3B.js +1 -0
  79. package/dist/esm/kanban-definition-FNSA4HC5-6nGtZdla.js +1 -0
  80. package/dist/esm/main.js +1 -1
  81. package/dist/esm/{mermaid.core-GJX79pQL.js → mermaid.core-VF3HuzPL.js} +2 -2
  82. package/dist/esm/mindmap-definition-6OY57UG3-CldUD6qU.js +1 -0
  83. package/dist/esm/pegDiagram-ECIUJNBX-CxOzmAR6.js +1 -0
  84. package/dist/esm/pieDiagram-GNMPY74T-CVzFNxbL.js +1 -0
  85. package/dist/esm/quadrantDiagram-D57K4MC3-zu8PK3sn.js +1 -0
  86. package/dist/esm/railroadDiagram-Y72NRBL7-32O5vSNO.js +1 -0
  87. package/dist/esm/requirementDiagram-EQYSW5RA-y8y1LAQQ.js +1 -0
  88. package/dist/esm/sankeyDiagram-SY24JHO5-B6RN54HY.js +1 -0
  89. package/dist/esm/sequenceDiagram-BLEHNHQU-x0406cvr.js +1 -0
  90. package/dist/esm/server.js +1 -1
  91. package/dist/esm/settings-6x4qNkNZ.js +1 -0
  92. package/dist/esm/settings.js +1 -1
  93. package/dist/esm/sizeCapture-INFHLROL--wG_Awhp.js +1 -0
  94. package/dist/esm/stateDiagram-v2-A6IESKWZ-BO6rHKAj.js +1 -0
  95. package/dist/esm/swimlanes-B3ENRKFQ-Bn5D5Wx7.js +1 -0
  96. package/dist/esm/swimlanesDiagram-AYQRV4AK-Ba9zNATm.js +1 -0
  97. package/dist/esm/timeline-definition-JXYKGLGB-BEJjWLZB.js +1 -0
  98. package/dist/esm/{types-DS5jBUtV.js → types-B-kh3Oeb.js} +1 -1
  99. package/dist/esm/usecaseDiagram-WPOLBNNX-RyH7DcwX.js +1 -0
  100. package/dist/esm/vennDiagram-Q3Y3IDCW-CxTrhG-i.js +1 -0
  101. package/dist/esm/wardleyDiagram-IVAIDKWA-pBsrgWov.js +1 -0
  102. package/dist/esm/websocket-D79arGLt.js +1 -0
  103. package/dist/esm/xychartDiagram-4URNHDU4-CA9STbh6.js +1 -0
  104. package/dist/module-types/src/components/helpers/problem.d.ts +1 -1
  105. package/dist/module-types/src/components/helpers/websocket.d.ts +3 -11
  106. package/dist/module-types/src/components/hooks/useInjectOrganizationStyles.d.ts +1 -0
  107. package/dist/module-types/src/components/hooks/useJudge.d.ts +2 -2
  108. package/dist/module-types/src/components/hooks/useJukiUser.d.ts +17 -17
  109. package/dist/module-types/src/components/hooks/{useCompanyPresence.d.ts → useOrganizationPresence.d.ts} +3 -3
  110. package/dist/module-types/src/components/hooks/useOwnPresence.d.ts +1 -1
  111. package/dist/module-types/src/components/hooks/useSubscribe.d.ts +2 -2
  112. package/dist/module-types/src/components/molecules/LinkLastPath/types.d.ts +1 -1
  113. package/dist/module-types/src/components/organisms/HorizontalMenu/MenuParts.d.ts +19 -0
  114. package/dist/module-types/src/components/organisms/LoginUser/LoginUser.d.ts +3 -1
  115. package/dist/module-types/src/components/organisms/ProblemSelector/ProblemSelector.d.ts +1 -1
  116. package/dist/module-types/src/components/organisms/ProblemSelector/types.d.ts +4 -4
  117. package/dist/module-types/src/components/organisms/SubmitView/commons/SubmissionListenerVerdict.d.ts +2 -2
  118. package/dist/module-types/src/components/organisms/SubmitView/commons/SubmissionVerdict.d.ts +3 -3
  119. package/dist/module-types/src/components/organisms/SubmitView/commons/SubmitViewContent.d.ts +2 -2
  120. package/dist/module-types/src/components/organisms/UserChip/types.d.ts +2 -2
  121. package/dist/module-types/src/components/organisms/UserNicknameLink/UserNicknameLink.d.ts +1 -1
  122. package/dist/module-types/src/components/organisms/UsersSelector/types.d.ts +3 -3
  123. package/dist/module-types/src/components/organisms/_layz_/DataViewer/JkContestTableTest/MockJkContestTable.d.ts +2 -2
  124. package/dist/module-types/src/components/organisms/_layz_/DataViewer/JkProblemTableTest/MockJkProblemTable.d.ts +2 -2
  125. package/dist/module-types/src/components/organisms/_layz_/DataViewer/JkSubmissionsTableTest/MockJkSubmissionTable.d.ts +2 -2
  126. package/dist/module-types/src/components/organisms/_layz_/WorksheetAsSlides/types.d.ts +2 -2
  127. package/dist/module-types/src/components/organisms/_layz_/WorksheetEditor/sheets/ResultHeader.d.ts +2 -2
  128. package/dist/module-types/src/components/organisms/_layz_/WorksheetViewer/types.d.ts +2 -2
  129. package/dist/module-types/src/components/organisms/modals/ImageUploaderModal/PublicImagesTab/PublicImages.d.ts +2 -2
  130. package/dist/module-types/src/components/organisms/modals/LoginModal/LoginModal.d.ts +1 -1
  131. package/dist/module-types/src/components/organisms/modals/LoginModal/LoginModalTemplate/types.d.ts +2 -2
  132. package/dist/module-types/src/components/organisms/modals/LoginModal/types.d.ts +1 -1
  133. package/dist/module-types/src/components/organisms/modals/UserPreviewModal/UserPreviewContentModal.d.ts +4 -4
  134. package/dist/module-types/src/components/providers/JukiAblyInitializer/JukiAblyInitializer.d.ts +1 -1
  135. package/dist/module-types/src/components/providers/JukiUIProvider/JukiUIProvider.d.ts +1 -1
  136. package/dist/module-types/src/components/providers/JukiUIProvider/types.d.ts +2 -2
  137. package/dist/module-types/src/components/providers/JukiUserProvider/types.d.ts +4 -4
  138. package/dist/module-types/src/components/templates/ContestNameLinkField/types.d.ts +3 -3
  139. package/dist/module-types/src/components/templates/EditProfileModal/ImageProfileModal.d.ts +1 -1
  140. package/dist/module-types/src/components/templates/EditProfileModal/types.d.ts +5 -5
  141. package/dist/module-types/src/components/templates/MainMenu/SettingsSection/index.d.ts +1 -1
  142. package/dist/module-types/src/components/templates/MainMenu/types.d.ts +1 -1
  143. package/dist/module-types/src/components/templates/ProblemView/commons/ProblemCodeEditor.d.ts +2 -2
  144. package/dist/module-types/src/components/templates/ProblemView/types.d.ts +3 -3
  145. package/dist/module-types/src/components/templates/ResetPasswordModal/ResetPasswordModal.d.ts +1 -1
  146. package/dist/module-types/src/components/templates/ResetPasswordModal/types.d.ts +1 -1
  147. package/dist/module-types/src/components/templates/UserProfile/types.d.ts +3 -3
  148. package/dist/module-types/src/components/templates/UserProfileSettings/types.d.ts +2 -2
  149. package/dist/module-types/src/components/templates/UserViewLayout/types.d.ts +2 -2
  150. package/dist/module-types/src/components/templates/columns/contest-columns/getContestContestantsHeader.d.ts +2 -2
  151. package/dist/module-types/src/components/templates/columns/contest-columns/getContestDateHeader.d.ts +2 -2
  152. package/dist/module-types/src/components/templates/columns/contest-columns/getContestNameHeader.d.ts +2 -2
  153. package/dist/module-types/src/components/templates/columns/contest-columns/getContestStatusHeader.d.ts +2 -2
  154. package/dist/module-types/src/components/templates/columns/contest-columns/getContestTagsHeader.d.ts +2 -2
  155. package/dist/module-types/src/components/templates/columns/problem-columns/getProblemAdminActionsHeader.d.ts +2 -2
  156. package/dist/module-types/src/components/templates/columns/problem-columns/getProblemKeyHeader.d.ts +2 -2
  157. package/dist/module-types/src/components/templates/columns/problem-columns/getProblemModeHeader.d.ts +2 -2
  158. package/dist/module-types/src/components/templates/columns/problem-columns/getProblemNameHeader.d.ts +2 -2
  159. package/dist/module-types/src/components/templates/columns/problem-columns/getProblemOwnerHeader.d.ts +2 -2
  160. package/dist/module-types/src/components/templates/columns/problem-columns/getProblemTagsHeader.d.ts +2 -2
  161. package/dist/module-types/src/components/templates/columns/problem-columns/getProblemTypeHeader.d.ts +2 -2
  162. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionContestHeader.d.ts +2 -2
  163. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionContestProblemHeader.d.ts +3 -3
  164. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionDateHeader.d.ts +2 -2
  165. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionLanguageHeader.d.ts +2 -2
  166. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionMemoryHeader.d.ts +2 -2
  167. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionNicknameHeader.d.ts +2 -2
  168. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionProblemHeader.d.ts +3 -3
  169. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionRejudgeHeader.d.ts +2 -2
  170. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionTimeHeader.d.ts +2 -2
  171. package/dist/module-types/src/components/templates/columns/submission-columns/getSubmissionVerdictHeader.d.ts +2 -2
  172. package/dist/module-types/src/components/templates/members/DocumentMembersModal/DocumentMembersModal.d.ts +2 -2
  173. package/dist/module-types/src/components/templates/members/types.d.ts +6 -6
  174. package/dist/module-types/src/components/templates/problem/ProblemCrawlerField.d.ts +1 -1
  175. package/dist/module-types/src/components/templates/problem/ProblemOwnerField.d.ts +1 -1
  176. package/dist/module-types/src/components/templates/problem/types.d.ts +10 -10
  177. package/dist/module-types/src/components/templates/submission/SubmissionNicknameField.d.ts +1 -1
  178. package/dist/module-types/src/components/templates/submission/types.d.ts +9 -9
  179. package/dist/module-types/src/components/types/index.d.ts +6 -6
  180. package/dist/module-types/src/constants/index.d.ts +2 -2
  181. package/dist/module-types/src/enums/index.d.ts +1 -1
  182. package/dist/module-types/src/hooks/index.d.ts +1 -1
  183. package/dist/module-types/src/settings/ApiManager.d.ts +77 -93
  184. package/dist/module-types/src/settings/AppRoutes.d.ts +2 -2
  185. package/dist/module-types/src/stores/websocket/topicChannels.d.ts +9 -10
  186. package/dist/module-types/src/stores/websocket/types.d.ts +4 -7
  187. package/package.json +2 -2
  188. package/dist/esm/ArrowForwardIcon-C9lEPgxF.js +0 -1
  189. package/dist/esm/BarChart-CmUpEfgx.js +0 -1
  190. package/dist/esm/ChangePasswordModal-CLhaqd0t.js +0 -1
  191. package/dist/esm/CodeEditor-BCPgv2Cb.js +0 -1
  192. package/dist/esm/CodeViewer-BRpMXuea.js +0 -1
  193. package/dist/esm/Collapse-afKIPlSN.js +0 -1
  194. package/dist/esm/DataViewer-sY3-mm2f.js +0 -1
  195. package/dist/esm/DrawerView-CDVcbXRh.js +0 -1
  196. package/dist/esm/ExcalidrawButton-DpC-H9ia.js +0 -1
  197. package/dist/esm/GraphvizViewer-BVrLuU49.js +0 -1
  198. package/dist/esm/ImageLoaderCropper-qgwMwAGw.js +0 -1
  199. package/dist/esm/InputCellPhoneNumber-EJdJwdOU.js +0 -1
  200. package/dist/esm/LineChart-CK_uehIw.js +0 -1
  201. package/dist/esm/MdMath-DdXwM7hb.js +0 -1
  202. package/dist/esm/ReplyIcon-CxQ2sdad.js +0 -1
  203. package/dist/esm/SlideDeck-BCpZmg4u.js +0 -1
  204. package/dist/esm/Tooltip-C_PscPTv.js +0 -1
  205. package/dist/esm/UserCodeEditor-DqHZdH0s.js +0 -61
  206. package/dist/esm/VirtualizedRowsFixed-ExvaHy3O.js +0 -1
  207. package/dist/esm/WorksheetAsSlides-Bf0TBaKQ.js +0 -1
  208. package/dist/esm/WorksheetContents-DSLbRrOR.js +0 -1
  209. package/dist/esm/WorksheetEditor-DHgjrze5.js +0 -1
  210. package/dist/esm/WorksheetViewer-BtWO3C0N.js +0 -1
  211. package/dist/esm/abnfDiagram-WEYOIA3C-Hw5eOSwT.js +0 -1
  212. package/dist/esm/architectureDiagram-ZHVYKT53-BU7Zo-Vd.js +0 -1
  213. package/dist/esm/blockDiagram-RJAE7QA3-DSHzRL6J.js +0 -1
  214. package/dist/esm/c4Diagram-XDPPPE54-CpLQ9pqY.js +0 -1
  215. package/dist/esm/channel-p0K5iSo0.js +0 -1
  216. package/dist/esm/classDiagram-v2-4MYWR3UA-BGFOFtLW.js +0 -1
  217. package/dist/esm/cose-bilkent-JH36ORCC-WrGk8F3q.js +0 -1
  218. package/dist/esm/cynefinDiagram-WF24UDRP-plMeajnN.js +0 -1
  219. package/dist/esm/dagre-NK4GIZVX-DFmweJ5L.js +0 -1
  220. package/dist/esm/diagram-CBK3MWTC-Do3xyOgp.js +0 -1
  221. package/dist/esm/diagram-I5XIIV2D-BjcBIOdi.js +0 -1
  222. package/dist/esm/diagram-ODIL2UCW-B9Avmrsd.js +0 -1
  223. package/dist/esm/diagram-PFBEJUXE-BspjnifG.js +0 -1
  224. package/dist/esm/diagram-RJA3I4VV-CDb0YVvV.js +0 -1
  225. package/dist/esm/diagram-TYUNFSNR-CowQmn1U.js +0 -1
  226. package/dist/esm/ebnfDiagram-V4P3TTPT-DoV9Lfm1.js +0 -1
  227. package/dist/esm/elk-QONTBCTQ-Di5ig-t7.js +0 -1
  228. package/dist/esm/erDiagram-KYQIGQAA-bd6-MJG2.js +0 -1
  229. package/dist/esm/flowDiagram-IUGLLWBU-B0MSMUTA.js +0 -1
  230. package/dist/esm/ganttDiagram-R7GPNTJY-lkIa_H6_.js +0 -1
  231. package/dist/esm/gitGraphDiagram-PDYL7XHY-Vj--WuIK.js +0 -1
  232. package/dist/esm/index-KB6gLBva.js +0 -1
  233. package/dist/esm/index-jAIWmSeN.js +0 -1
  234. package/dist/esm/infoDiagram-MVDRKAX5-DOeZ2-C8.js +0 -1
  235. package/dist/esm/ishikawaDiagram-HPEHV2GE-CENo4osB.js +0 -1
  236. package/dist/esm/journeyDiagram-BOSHW7O7-C2tDYh4z.js +0 -1
  237. package/dist/esm/kanban-definition-FNSA4HC5-CoyAxabP.js +0 -1
  238. package/dist/esm/mindmap-definition-6OY57UG3-Cz5x8Ddo.js +0 -1
  239. package/dist/esm/pegDiagram-ECIUJNBX-Cp7mSGqB.js +0 -1
  240. package/dist/esm/pieDiagram-GNMPY74T-DoaR6KZl.js +0 -1
  241. package/dist/esm/quadrantDiagram-D57K4MC3-vGvfladt.js +0 -1
  242. package/dist/esm/railroadDiagram-Y72NRBL7-CC8xjkre.js +0 -1
  243. package/dist/esm/requirementDiagram-EQYSW5RA-CvYZNdVi.js +0 -1
  244. package/dist/esm/sankeyDiagram-SY24JHO5-DTEzoJWs.js +0 -1
  245. package/dist/esm/sequenceDiagram-BLEHNHQU-B1ssXHBq.js +0 -1
  246. package/dist/esm/settings-oXVFKYs2.js +0 -1
  247. package/dist/esm/sizeCapture-INFHLROL-BpAWjro_.js +0 -1
  248. package/dist/esm/stateDiagram-v2-A6IESKWZ-BpWTAT11.js +0 -1
  249. package/dist/esm/swimlanes-B3ENRKFQ-CRPiPPkB.js +0 -1
  250. package/dist/esm/swimlanesDiagram-AYQRV4AK-CPu0_glt.js +0 -1
  251. package/dist/esm/timeline-definition-JXYKGLGB-D7lhGXLl.js +0 -1
  252. package/dist/esm/usecaseDiagram-WPOLBNNX-07MB5ZhJ.js +0 -1
  253. package/dist/esm/vennDiagram-Q3Y3IDCW-BF4CwCTB.js +0 -1
  254. package/dist/esm/wardleyDiagram-IVAIDKWA-CE_jsTBp.js +0 -1
  255. package/dist/esm/websocket-CXHGKJlm.js +0 -1
  256. package/dist/esm/xychartDiagram-4URNHDU4-DK5TR51V.js +0 -1
  257. package/dist/module-types/src/components/hooks/useInjectCompanyStyles.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{P as n,S as r,aj as o,G as i,T as s,C as a,v as l}from"./settings-oXVFKYs2.js";import{W as c,X as d,g as u,L as h,Y as p,Z as f,E as m,G as g,_ as v,z as y,$ as w,a0 as b,a1 as x,a2 as k,a3 as C,a4 as S,a5 as M,a6 as N,a7 as E,a8 as O,a9 as A,U as T,aa as D,ab as _,ac as I,ad as R,ae as L,af as B,ag as P,ah as z,ai as j,aj as V,ak as H,Q as $,K as q,M as F}from"./basic-setup-DtpgwOSH.js";import{h as W,i as U,j as G,l as K,p as J,z as Z,m as Y,u as X,r as Q,v as ee,S as te,g as ne,d as re,c as oe,C as ie,k as se}from"./types-DS5jBUtV.js";import ae,{useRef as le,useState as ce,useMemo as de,createContext as ue,useContext as he,useCallback as pe,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 xe,l as ke,T as Ce,ad as Se,a2 as Me,ae as Ne}from"./index-jAIWmSeN.js";import{c as Ee,d as Oe}from"./commons-CmbPiYDE.js";import"./enums.js";import"./constants.js";import{L as Ae,s as Te,m as De,f as _e}from"./LoaderLayer-CyitSTCe.js";import"motion/react";import"react-dom";import"swr";import{c as Ie}from"./clsx-BeLtu-UY.js";import{c as Re,f as Le,o as Be,s as Pe,a as ze}from"./floating-ui.dom-DGDCR4EF.js";import{t as je,d as Ve}from"./throttle-tEKq3i9o.js";import{i as He,g as $e,F as qe}from"./isSymbol-D2gNAbOe.js";import{b as Fe,c as We}from"./toNumber-B6ypue5Z.js";import{i as Ue}from"./viz-BmmZnl4P.js";import{bj as Ge}from"./mermaid.core-GJX79pQL.js";import{y as Ke}from"./websocket-CXHGKJlm.js";import"./index-KB6gLBva.js";import"@ably/spaces";import"@ably/spaces/react";import"ably";import"ably/liveobjects";import"ably/react";import"@ably/spaces/dist/mjs/react";import"./floating-ui.core-DzsaFWsC.js";import"./string-DPJhNSkw.js";const Je={}.hasOwnProperty;function Ze(e,t){let n,r=-1;if(t.extensions)for(;++r<t.extensions.length;)Ze(e,t.extensions[r]);for(n in t)if(Je.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":Ye(e[n],t[n]);break;case"handlers":Xe(e[n],t[n]);break;default:e.options[n]=t[n]}return e}function Ye(e,t){t&&e.push(...t)}function Xe(e,t){t&&Object.assign(e,t)}const Qe=[function(e,t,n,r){if("code"===t.type&&W(t,r)&&("list"===e.type||e.type===t.type&&W(e,r)))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,r)))return;return n.spread?1:0}}];const et=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],tt=[{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:et},{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:et},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:et},{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:et},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:et},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:et},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:et},{atBreak:!0,character:"~"}];function nt(e){return e.label||!e.identifier?e.label||"":G(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 ot(e,t,n,r){let o=r.join.length;for(;o--;){const i=r.join[o](e,t,n,r);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 it=/\r?\n|\r/g;function st(e,t){const n=[];let r,o=0,i=0;for(;r=it.exec(e);)s(e.slice(o,r.index)),n.push(r[0]),o=r.index+r[0].length,i++;return s(e.slice(o)),n.join("");function s(e){n.push(t(e,i,!e))}}function at(e,t){return e-t}function lt(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],o=[],i=e+t;let s,a=-1,l=0;for(;s=n.exec(i);)r.push(s.index);for(;++a<r.length;)l!==r[a]&&o.push(e.slice(l,r[a])),o.push("\\"),l=r[a];return o.push(e.slice(l)),o.join("")}function ct(e){const t=e||{},n=t.now||{};let r=t.lineShift||0,o=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 o+=n.length-1,i=1===n.length?i+s.length:1+s.length+r,t},current:function(){return{now:{line:o,column:i},lineShift:r}},shift:function(e){r+=e}}}function dt(e,t){const n={associationId:nt,containerPhrasing:ft,containerFlow:mt,createTracker:ct,compilePattern:rt,enter:function(e){return n.stack.push(e),function(){n.stack.pop()}},handlers:{...Y},handle:void 0,indentLines:st,indexStack:[],join:[...Qe],options:{},safe:gt,stack:[],unsafe:[...tt]};Ze(n,t||{}),n.options.tightDefinitions&&n.join.push(pt),n.handle=Z("type",{invalid:ut,unknown:ht,handlers:n.handlers});let r=n.handle(e,void 0,n,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return r&&10!==r.charCodeAt(r.length-1)&&13!==r.charCodeAt(r.length-1)&&(r+="\n"),r}function ut(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function ht(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function pt(e,t){if("definition"===e.type&&e.type===t.type)return 0}function ft(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=[];let s,a=-1,l=n.before;r.push(-1);let c=t.createTracker(n);for(;++a<o.length;){const d=o[a];let u;if(r[r.length-1]=a,a+1<o.length){let n=t.handle.handlers[o[a+1].type];n&&n.peek&&(n=n.peek),u=n?n(o[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 h=t.handle(d,e,t,{...c.current(),after:u,before:l});s&&s===h.slice(0,1)&&(h=K(s.charCodeAt(0))+h.slice(1));const p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,p&&(i.length>0&&p.before&&l===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+K(l.charCodeAt(0))),p.after&&(s=u)),c.move(h),i.push(h),l=h.slice(-1)}return r.pop(),i.join("")}(e,this,t)}function mt(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=t.createTracker(n),s=[];let a=-1;for(r.push(-1);++a<o.length;){const n=o[a];r[r.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<o.length-1&&s.push(i.move(ot(n,o[a+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function gt(e,t){return function(e,t,n){const r=(n.before||"")+(t||"")+(n.after||""),o=[],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(r);){const e="before"in t||Boolean(t.atBreak),n="after"in t,r=i.index+(e?i[1].length:0);o.includes(r)?(s[r].before&&!e&&(s[r].before=!1),s[r].after&&!n&&(s[r].after=!1)):(o.push(r),s[r]={before:e,after:n})}}o.sort(at);let l=n.before?n.before.length:0;const c=r.length-(n.after?n.after.length:0);for(a=-1;++a<o.length;){const e=o[a];e<l||e>=c||e+1<c&&o[a+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||o[a-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(l!==e&&i.push(lt(r.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(i.push(K(r.charCodeAt(e))),l++):i.push("\\"))}return i.push(lt(r.slice(l,c),n.after)),i.join("")}(this,e,t)}var vt=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.aiProviderError="aiProviderError",e.aiBuildContextError="aiBuildContextError",e}({}),yt=class extends Error{constructor(e,t,n){super(t,n),this.name="MilkdownError",this.code=e,void 0!==n?.cause&&(this.cause=n.cause)}},wt=(e,t)=>"function"==typeof t?"[Function]":t,bt=e=>JSON.stringify(e,wt);function xt(){return new yt(vt.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function kt(){return new yt(vt.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Ct(e){return new yt(vt.expectDomTypeError,`Expect to be a dom, but get: ${bt(e)}.`)}function St(){return new yt(vt.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 Mt(e){return new yt(vt.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function Nt(e){try{return bt(e)}catch{return"[Unserializable]"}}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 function(e){return new yt(vt.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}("string"==typeof e?e:e.name)}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)}},Ot=class{#e;#t;#n;constructor(e,t,n){this.#e=[],this.#n=()=>{this.#e.forEach(e=>e(this.#t))},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=[]}},At=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw xt()}}create(e,t=this._defaultValue){return new Ot(e,t,this)}},Tt=(e,t)=>new At(e,t),Dt=class{#r;#o;#i;#s;#a;#l;#c;constructor(e,t,n){this.#s=new Set,this.#a=new Set,this.#l=new Map,this.#c=new Map,this.read=()=>({metadata:this.#r,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.#d=e=>this.#o.get(e).get(),this.#u=e=>this.#i.get(e).status,this.#o=e,this.#i=t,this.#r=n}#d;#u},_t=class e{#o;#i;#r;#h;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#o,this.#i,{...t}):this,this.inject=(e,t)=>{const n=e.create(this.#o.sliceMap);return null!=t&&n.set(t),this.#h?.onInject(e),this},this.remove=e=>(this.#o.remove(e),this.#h?.onRemove(e),this),this.record=e=>(e.create(this.#i.store),this.#h?.onRecord(e),this),this.clearTimer=e=>(this.#i.remove(e),this.#h?.onClear(e),this),this.isInjected=e=>this.#o.has(e),this.isRecorded=e=>this.#i.has(e),this.use=e=>(this.#h?.onUse(e),this.#o.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.#h?.onDone(e)},this.wait=e=>{const t=this.timer(e).start();return this.#h?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#o=t,this.#i=n,this.#r=r,r&&(this.#h=new Dt(t,n,r))}get meta(){return this.#r}get inspector(){return this.#h}},It=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw n=e.name,new yt(vt.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{#p;#f;#m;#g;#v;constructor(e,t){this.#p=null,this.#f=null,this.#g="pending",this.#v=null,this.start=()=>(this.#p??=new Promise((e,t)=>{this.#f=t=>{t instanceof CustomEvent&&t.detail.id===this.#m&&(this.#g="resolved",this.#y(),t.stopImmediatePropagation(),e())},this.#w(()=>{"pending"===this.#g&&(this.#g="rejected"),this.#y(),t(new Error(`Timing ${this.type.name} timeout.`))}),this.#g="pending",addEventListener(this.type.name,this.#f)}),this.#p),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:this.#m}});dispatchEvent(e)},this.#y=()=>{null!==this.#v&&(clearTimeout(this.#v),this.#v=null),this.#f&&removeEventListener(this.type.name,this.#f)},this.#w=e=>{this.#v=setTimeout(()=>{this.#v=null,e()},this.type.timeout)},this.#m=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#g}#y;#w},Lt=class{constructor(e,t=3e3){this.create=e=>new Rt(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Bt=(e,t=3e3)=>new Lt(e,t);function Pt(e){const t=this;t.compiler=function(n){return dt(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function zt(e){this.content=e}function jt(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){let e=o.text,t=i.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&$t(e.charCodeAt(r-1))&&Ht(e.charCodeAt(r))&&n--,n}if(o.content.size||i.content.size){let e=jt(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function Vt(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let e=s.text,t=a.text,o=e.length,i=t.length;for(;o>0&&i>0&&e[o-1]==t[i-1];)o--,i--,n--,r--;return o&&i&&o<e.length&&$t(e.charCodeAt(o-1))&&Ht(e.charCodeAt(o))&&(n++,r++),{a:n,b:r}}if(s.content.size||a.content.size){let e=Vt(s.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}function Ht(e){return e>=56320&&e<57344}function $t(e){return e>=55296&&e<56320}zt.prototype={constructor:zt,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 r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new zt(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 zt(n)},addToStart:function(e,t){return new zt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new zt(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new zt(o)},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=zt.from(e)).size?new zt(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=zt.from(e)).size?new zt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=zt.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}},zt.from=function(e){if(e instanceof zt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new zt(t)};let qt=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,r=0,o){for(let i=0,s=0;s<t;i++){let a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),n,r+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",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?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=l},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)o.push(t.content[i]);return new e(o,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let r=[],o=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))),r.push(s),o+=s.nodeSize),i=a}return new e(r,o)}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 r=this.content[t];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new e(o,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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return jt(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Vt(this,e,t,n)}findIndex(e){if(0==e)return Wt(0,e);if(e==this.size)return Wt(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 r=n+this.child(t).nodeSize;if(r>=e)return r==e?Wt(t+1,r):Wt(t,n);n=r}}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 e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let o=t[e];r+=o.nodeSize,e&&o.isText&&t[e-1].sameMarkup(o)?(n||(n=t.slice(0,e)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,r)}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)":""))}};qt.empty=new qt([],0);const Ft={index:0,offset:0};function Wt(e,t){return Ft.index=e,Ft.offset=t,Ft}function Ut(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(!Ut(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Ut(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Gt{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}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&&Ut(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`);return n.create(t.attrs)}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 Gt.none;if(e instanceof Gt)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Gt.none=[];class Kt extends Error{}class Jt{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=Yt(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new Jt(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Jt(Zt(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 Jt.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Jt(qt.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Jt(e,n,r)}}function Zt(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:a}=e.findIndex(n);if(o==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(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Zt(i.content,t-o-1,n-o-1)))}function Yt(e,t,n,r,o,i){let{index:s,offset:a}=e.findIndex(t),l=e.maybeChild(s);if(a==t||l.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=Yt(l.content,t-a-1,n,0==s?r-1:0,s==e.childCount-1?o-1:0,l);return c&&e.replaceChild(s,l.copy(c))}function Xt(e,t,n){if(n.openStart>e.depth)throw new Kt("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Kt("Inconsistent open depths");return Qt(e,t,n,0)}function Qt(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=Qt(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(qt.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return on(i,sn(e,o,s,t,r))}{let r=e.parent,o=r.content;return on(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return on(i,an(e,t,r))}function en(e,t){if(!t.type.compatibleContent(e.type))throw new Kt("Cannot join "+t.type.name+" onto "+e.type.name)}function tn(e,t,n){let r=e.node(n);return en(r,t.node(n)),r}function nn(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 rn(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(nn(e.nodeAfter,r),i++));for(let e=i;e<s;e++)nn(o.child(e),r);t&&t.depth==n&&t.textOffset&&nn(t.nodeBefore,r)}function on(e,t){if(!e.type.validContent(t))throw new Kt("Invalid content for node "+e.type.name);return e.copy(t)}function sn(e,t,n,r,o){let i=e.depth>o&&tn(e,t,o+1),s=r.depth>o&&tn(n,r,o+1),a=[];return rn(null,e,o,a),i&&s&&t.index(o)==n.index(o)?(en(i,s),nn(on(i,sn(e,t,n,r,o+1)),a)):(i&&nn(on(i,an(e,t,o+1)),a),rn(t,n,o,a),s&&nn(on(s,an(n,r,o+1)),a)),rn(r,null,o,a),new qt(a)}function an(e,t,n){let r=[];if(rn(null,e,n,r),e.depth>n){nn(on(tn(e,t,n+1),an(e,t,n+1)),r)}return rn(t,null,n,r),new qt(r)}Jt.empty=new Jt(qt.empty,0,0);class ln{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],r=e.child(t);return n?e.child(t).cut(n):r}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],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Gt.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].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 hn(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=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new ln(t,n,o)}static resolveCached(e,t){let n=un.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else un.set(e,n=new cn);let r=n.elts[n.i]=ln.resolve(e,t);return n.i=(n.i+1)%dn,r}}class cn{constructor(){this.elts=[],this.i=0}}const dn=12,un=new WeakMap;class hn{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 pn=Object.create(null);class fn{constructor(e,t,n,r=Gt.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||qt.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,r=0){this.content.nodesBetween(e,t,n,r,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,r){return this.content.textBetween(e,t,n,r)}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&&Ut(this.attrs,t||e.defaultAttrs||pn)&&Gt.sameSet(this.marks,n||Gt.none)}copy(e=null){return e==this.content?this:new fn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new fn(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 Jt.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new Jt(a,r.depth-i,o.depth-i)}replace(e,t,n){return Xt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+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 r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ln.resolveCached(this,e)}resolveNoCache(e){return ln.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+")"),gn(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=qt.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.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),vn(this.type.attrs,this.attrs,"node",this.type.name);let e=Gt.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];vn(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!Gt.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 r=qt.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}fn.prototype.text=void 0;let mn=class e extends fn{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):gn(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(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,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 gn(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function vn(e,t,n,r){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}class yn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new wn(e,t);if(null==n.next)return yn.empty;let r=bn(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return n(Nn(e,0));function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);Nn(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new yn(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(Mn);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}}(function(e){let t=[[]];return o(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(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 r(t,s),o(i(e.expr,s),s),[r(s)]}if("plus"==e.type){let s=n();return o(i(e.expr,t),s),o(i(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();o(i(e.expr,s),t),s=t}if(-1==e.max)o(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();r(s,t),o(i(e.expr,s),t),s=t}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(e.exprs[r],t);if(r==e.exprs.length-1)return s;o(s,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}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 r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}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 r=[this];return function o(i,s){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return qt.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==r.indexOf(n)){r.push(n);let e=o(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 r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),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 r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}yn.empty=new yn(!0);class wn{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 bn(e){let t=[];do{t.push(xn(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function xn(e){let t=[];do{t.push(kn(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function kn(e){let t=function(e){if(e.eat("(")){let t=bn(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(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=Sn(e,t)}return t}function Cn(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Sn(e,t){let n=Cn(e),r=n;return e.eat(",")&&(r="}"!=e.next?Cn(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Mn(e,t){return t-e}function Nn(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Mn)}function En(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function On(e,t){let n=Object.create(null);for(let r in e){let o=e[r],i=t&&t[r];if(void 0===i){if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=o.default}else o.validate&&o.validate(i);n[r]=i}return n}function An(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Dn(e,r,t[r]);return n}let Tn=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=An(e,n.attrs),this.defaultAttrs=En(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==yn.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:On(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new fn(this,this.computeAttrs(e),qt.from(t),Gt.setFrom(n))}createChecked(e=null,t,n){return t=qt.from(t),this.checkContent(t),new fn(this,this.computeAttrs(e),t,Gt.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=qt.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(qt.empty,!0);return o?new fn(this,e,t.append(o),Gt.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){}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:Gt.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,o)=>r[t]=new e(t,n,o));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let e in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class Dn{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 r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class _n{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=An(e,r.attrs),this.excluded=null;let o=En(this.attrs);this.instance=o?new Gt(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Gt(this,On(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new _n(e,r++,t,o)),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]}excludes(e){return this.excluded.indexOf(e)>-1}}class In{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=zt.from(e.nodes),t.marks=zt.from(e.marks||{}),this.nodes=Tn.compile(this.spec.nodes,this),this.marks=_n.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],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=yn.parse(r,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="_"==o?null:o?Rn(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Rn(this,n.split(" "))}this.nodeFromJSON=e=>fn.fromJSON(this,e),this.markFromJSON=e=>Gt.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Tn))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,r)}text(e,t){let n=this.nodes.text;return new mn(n,n.defaultAttrs,e,Gt.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 Rn(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Ln{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 Hn(this,t,!1);return n.addAll(e,Gt.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Hn(this,t,!0);return n.addAll(e,Gt.none,t.from,t.to),Jt.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if($n(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,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=qn(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=qn(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ln(e,Ln.schemaRules(e)))}}const Bn={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},zn={ol:!0,ul:!0};function jn(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class Vn{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=Gt.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(qt.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=qt.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(qt.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&&!Bn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Hn{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=jn(null,t.preserveWhitespace,0)|(n?4:0);r=o?new Vn(o.type,o.attrs,Gt.none,!0,t.topMatch||o.type.contentMatch,i):new Vn(n?null:e.schema.topNodeType,null,Gt.none,!0,null,i),this.nodes=[r],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,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)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=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.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 r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();zn.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&&zn.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,r=this.needsBlock;if(Bn.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.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(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?i:void 0)}this.localPreserveWS=r}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 r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,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,r){let o,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&&(o=!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(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+i)&&(r=a,o=s,!a.length))break;if(s.solid){if(n)break;i+=2}}if(!r)return null;this.sync(o);for(let e=0;e<r.length;e++)t=this.enterInner(r[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 r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Gt.none;for(let o of r.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):Fn(o.type,e.type))&&(n=o.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=jn(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=Gt.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 Vn(e,t,a,r,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 r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].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,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?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>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).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 $n(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function qn(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 r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class Wn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Gn(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Gn(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Zn(Gn(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Zn(Gn(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:Zn(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Wn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Un(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Un(e.marks)}}function Un(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Gn(e){return e.document||window.document}const Kn=new WeakMap;function Jn(e){let t=Kn.get(e);return void 0===t&&Kn.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 Zn(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Jn(r))&&o.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 o=d;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}if("string"==typeof i)l.appendChild(e.createTextNode(i));else{let{dom:t,contentDOM:o}=Zn(e,i,n,r);if(l.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:l,contentDOM:s}}const Yn=Math.pow(2,16);function Xn(e,t){return e+t*Yn}function Qn(e){return 65535&e}class er{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 tr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&tr.empty)return tr.empty}recover(e){let t=0,n=Qn(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))/Yn}(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 r=0,o=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?r:0);if(a>e)break;let l=this.ranges[s+o],c=this.ranges[s+i],d=a+l;if(e<=d){let o=a+r+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?a:d)?null:Xn(s/3,e-a),u=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(u|=8),new er(o,u,i)}r+=c-l}return n?e+r:new er(e+r,0,null)}touches(e,t){let n=0,r=Qn(t),o=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+o];if(e<=s+a&&t==3*r)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 r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),o+=c-l}}invert(){return new tr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?tr.empty:new tr(e<0?[0,-e,0]:[0,0,e])}}tr.empty=new tr([]);class nr{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new nr(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 r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r: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 r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new nr;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 r=0;for(let n=this.from;n<this.to;n++){let o=this._maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new er(e,r,null)}}const rr=Object.create(null);class or{getMap(){return tr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=rr[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 rr)throw new RangeError("Duplicate use of step JSON ID "+e);return rr[e]=t,t.prototype.jsonID=e,t}}class ir{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ir(e,null)}static fail(e){return new ir(null,e)}static fromReplace(e,t,n,r){try{return ir.ok(e.replace(t,n,r))}catch(e){if(e instanceof Kt)return ir.fail(e.message);throw e}}}function sr(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(sr(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return qt.fromArray(r)}class ar extends or{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),r=n.node(n.sharedDepth(this.to)),o=new Jt(sr(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return ir.fromReplace(e,this.from,this.to,o)}invert(){return new lr(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 ar(t.pos,n.pos,this.mark)}merge(e){return e instanceof ar&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ar(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 ar(t.from,t.to,e.markFromJSON(t.mark))}}or.jsonID("addMark",ar);class lr extends or{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 Jt(sr(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return ir.fromReplace(e,this.from,this.to,n)}invert(){return new ar(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 lr(t.pos,n.pos,this.mark)}merge(e){return e instanceof lr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lr(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 lr(t.from,t.to,e.markFromJSON(t.mark))}}or.jsonID("removeMark",lr);class cr extends or{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ir.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ir.fromReplace(e,this.pos,this.pos+1,new Jt(qt.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 cr(this.pos,t.marks[n]);return new cr(this.pos,this.mark)}}return new dr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new cr(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 cr(t.pos,e.markFromJSON(t.mark))}}or.jsonID("addNodeMark",cr);class dr extends or{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ir.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ir.fromReplace(e,this.pos,this.pos+1,new Jt(qt.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new cr(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dr(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 dr(t.pos,e.markFromJSON(t.mark))}}or.jsonID("removeNodeMark",dr);class ur extends or{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&pr(e,this.from,this.to)?ir.fail("Structure replace would overwrite content"):ir.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new tr([this.from,this.to-this.from,this.slice.size])}invert(e){return new ur(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&&ur.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new ur(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ur)||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?Jt.empty:new Jt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ur(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Jt.empty:new Jt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ur(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 ur(t.from,t.to,Jt.fromJSON(e,t.slice),!!t.structure)}}ur.MAP_BIAS=1,or.jsonID("replace",ur);class hr extends or{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(pr(e,this.from,this.gapFrom)||pr(e,this.gapTo,this.to)))return ir.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ir.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ir.fromReplace(e,this.from,this.to,n):ir.fail("Content does not fit in gap")}getMap(){return new tr([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 hr(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),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new hr(t.pos,n.pos,r,o,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 hr(t.from,t.to,t.gapFrom,t.gapTo,Jt.fromJSON(e,t.slice),t.insert,!!t.structure)}}function pr(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function fr(e,t,n,r=n.contentMatch,o=!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=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new lr(a,c,l.marks[t]));if(o&&l.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(l.text);)t||(t=new Jt(qt.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new ur(a+e.index,a+e.index+e[0].length,t))}}else s.push(new ur(a,c,Jt.empty));a=c}if(!r.validEnd){let t=r.fillBefore(qt.empty,!0);e.replace(a,a,new Jt(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function mr(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gr(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,o=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(s,a,t))return n;if(0==n||i.type.spec.isolating||!mr(i,s,a))break;s&&(r=1),a<i.childCount&&(o=1)}return null}function vr(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<o;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return i?o.map(yr).concat({type:t,attrs:n}).concat(i.map(yr)):null}function yr(e){return{type:e,attrs:null}}function wr(e,t,n,r){t.forEach((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}})}function br(e,t,n,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}})}function xr(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function kr(e,t){let n=e.resolve(t),r=n.index();return o=n.nodeBefore,i=n.nodeAfter,!(!o||!i||o.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?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}(o,i))&&n.parent.canReplace(r,r+1);var o,i}function Cr(e,t,n=t,r=Jt.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Sr(o,i,r)?new ur(t,n,r):new Mr(o,i,r).fit()}function Sr(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}or.jsonID("replaceAround",hr);class Mr{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=qt.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=qt.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,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new Jt(o,i,s);return e>-1?new hr(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new ur(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Or(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(o?a.matchType(o.type)||(l=a.fillBefore(qt.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:l};if(2==t&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Or(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new Jt(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Or(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Jt(Nr(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Jt(Nr(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[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(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let h=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(Ar(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let p=l==s.childCount;p||(h=-1),this.placed=Er(this.placed,t,qt.from(c)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Jt.empty:new Jt(Nr(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Jt(Nr(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||!Tr(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,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Tr(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Tr(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?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=Er(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Er(this.placed,this.depth,qt.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(qt.empty,!0);e.childCount&&(this.placed=Er(this.placed,this.frontier.length,e))}}function Nr(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Nr(e.firstChild.content,t-1,n)))}function Er(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Er(e.lastChild.content,t-1,n)))}function Or(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ar(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ar(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(qt.empty,!0)))),e.copy(r)}function Tr(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function Dr(e){return e.spec.defining||e.spec.definingForContent}function _r(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(_r(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(qt.empty,!0))}return e}function Ir(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class Rr extends or{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 ir.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 r=t.type.create(n,null,t.marks);return ir.fromReplace(e,this.pos,this.pos+1,new Jt(qt.from(r),0,t.isLeaf?0:1))}getMap(){return tr.empty}invert(e){return new Rr(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 Rr(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 Rr(t.pos,t.attr,t.value)}}or.jsonID("attr",Rr);class Lr extends or{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 ir.ok(n)}getMap(){return tr.empty}invert(e){return new Lr(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 Lr(t.attr,t.value)}}or.jsonID("docAttr",Lr);let Br=class extends Error{};Br=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Br.prototype=Object.create(Error.prototype)).constructor=Br,Br.prototype.name="TransformError";class Pr{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Br(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 r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,o,i)=>{e=Math.min(e,o),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=Jt.empty){let r=Cr(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Jt(qt.from(n),0,0))}delete(e,t){return this.replace(e,t,Jt.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Sr(o,i,r))return e.step(new ur(t,n,r));let s=Ir(o,i);0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=Dr(t.type);if(n&&!t.sameMarkup(o.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.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 h=o.node(c-1),p=o.index(c-1);if(h.canReplaceWith(p,p,u.type,u.marks))return e.replace(o.before(c),d?i.after(c):n,new Jt(_r(r.content,0,r.openStart,a),a,r.openEnd))}}let u=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>u));a--){let e=s[a];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Jt(qt.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&0==r.parentOffset&&0==o.parentOffset){let i=r.sharedDepth(n),s=!1;for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=o.depth;e>0&&n==o.start(e);e--)n=o.before(e);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let i=Ir(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=qt.empty,u=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=qt.from(r.node(e).copy(d)),u++):l--;let h=qt.empty,p=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,h=qt.from(o.node(e).copy(h)),p++):c++;e.step(new hr(l,c,s,a,new Jt(d.append(h),u,p),d.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);br(e,r.node(),r.before(),a)}s.inlineContent&&fr(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new ur(c,l.map(t+n,-1),Jt.empty,!0)),!0===r){let t=e.doc.resolve(c);wr(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=qt.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=qt.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new hr(o,i,o,i,new Jt(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.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 o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&br(e,t,n,i),fr(e,e.mapping.slice(i).map(n,1),r,void 0,null===o);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new hr(l,c,l+1,c-1,new Jt(qt.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===o&&wr(e,t,n,i),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||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 hr(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Jt(qt.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Rr(e,t,n)),this}setDocAttribute(e,t){return this.step(new Lr(e,t)),this}addNodeMark(e,t){return this.step(new cr(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 Gt)t.isInSet(n.marks)&&this.step(new dr(e,t));else{let r,o=n.marks,i=[];for(;r=t.isInSet(o);)i.push(new dr(e,r)),o=r.removeFromSet(o);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,r){let o=e.doc.resolve(t),i=qt.empty,s=qt.empty;for(let e=o.depth,t=o.depth-n,a=n-1;e>t;e--,a--){i=qt.from(o.node(e).copy(i));let t=r&&r[a];s=qt.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new ur(t,t,new Jt(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),u=Math.min(l+e.nodeSize,n),h=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(d[e])?o.to=u:s.push(o=new lr(c,u,d[e])));i&&i.to==c?i.to=u:a.push(i=new ar(c,u,r))}}),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,r){let o=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let a=null;if(r instanceof _n){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&l.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:l,from:Math.max(s,t),to:r,step:i})}}}),o.forEach(t=>e.step(new lr(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return fr(this,e,t,n),this}}const zr=Object.create(null);class jr{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Vr(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=Jt.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=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(o);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Jt.empty:t),0==s&&Zr(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);o?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Zr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new qr(e):Jr(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?Jr(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Jr(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Gr(e.node(0))}static atStart(e){return Jr(e,e,0,0,1)||new Gr(e)}static atEnd(e){return Jr(e,e,e.content.size,e.childCount,-1)||new Gr(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=zr[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 zr)throw new RangeError("Duplicate use of selection JSON ID "+e);return zr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return qr.between(this.$anchor,this.$head).getBookmark()}}jr.prototype.visible=!0;class Vr{constructor(e,t){this.$from=e,this.$to=t}}let Hr=!1;function $r(e){Hr||e.parent.inlineContent||(Hr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class qr extends jr{constructor(e,t=e){$r(e),$r(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 jr.near(n);let r=e.resolve(t.map(this.anchor));return new qr(r.parent.inlineContent?r:n,n)}replace(e,t=Jt.empty){if(super.replace(e,t),t==Jt.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof qr&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Fr(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 qr(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=jr.findFrom(t,n,!0)||jr.findFrom(t,-n,!0);if(!e)return jr.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(jr.findFrom(e,-n,!0)||jr.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new qr(e,t)}}jr.jsonID("text",qr);class Fr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Fr(e.map(this.anchor),e.map(this.head))}resolve(e){return qr.between(e.resolve(this.anchor),e.resolve(this.head))}}class Wr extends jr{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:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?jr.near(o):new Wr(o)}content(){return new Jt(qt.from(this.node),0,0)}eq(e){return e instanceof Wr&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ur(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Wr(e.resolve(t.anchor))}static create(e,t){return new Wr(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Wr.prototype.visible=!1,jr.jsonID("node",Wr);class Ur{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Fr(n,n):new Ur(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Wr.isSelectable(n)?new Wr(t):jr.near(t)}}class Gr extends jr{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Jt.empty){if(t==Jt.empty){e.delete(0,e.doc.content.size);let t=jr.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Gr(e)}map(e){return new Gr(e)}eq(e){return e instanceof Gr}getBookmark(){return Kr}}jr.jsonID("all",Gr);const Kr={map(){return this},resolve:e=>new Gr(e)};function Jr(e,t,n,r,o,i=!1){if(t.inlineContent)return qr.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Wr.isSelectable(r))return Wr.create(e,n-(o<0?r.nodeSize:0))}else{let t=Jr(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Zr(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof ur||i instanceof hr)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==o&&(o=r)}),e.setSelection(jr.near(e.doc.resolve(o),n)))}class Yr extends Pr{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 Gt.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)||Gt.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(jr.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 Xr(e,t){return t&&e?e.bind(t):e}class Qr{constructor(e,t,n){this.name=e,this.init=Xr(t.init,n),this.apply=Xr(t.apply,n)}}const eo=[new Qr("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Qr("selection",{init:(e,t)=>e.selection||jr.atStart(t.doc),apply:e=>e.selection}),new Qr("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Qr("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class to{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=eo.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 Qr(e.key,e.spec.state,e))})}}class no{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),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[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),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new no(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Yr(this)}static create(e){let t=new to(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new no(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new to(this.schema,e.plugins),n=t.fields,r=new no(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}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 r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.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 r=new to(e.schema,e.plugins),o=new no(r);return r.fields.forEach(r=>{if("doc"==r.name)o.doc=fn.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=jr.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.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==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=a.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}}),o}}function ro(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=ro(o,t,{})),n[r]=o}return n}class oo{constructor(e){this.spec=e,this.props={},e.props&&ro(e.props,this,this.props),this.key=e.key?e.key.key:so("plugin")}getState(e){return e[this.key]}}const io=Object.create(null);function so(e){return e in io?e+"$"+ ++io[e]:(io[e]=0,e+"$")}class ao{constructor(e="key"){this.key=so(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const lo=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function co(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const uo=(e,t,n)=>{let r=co(e,n);if(!r)return!1;let o=mo(r);if(!o){let n=r.blockRange(),o=n&&gr(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(bo(e,o,t,-1))return!0;if(0==r.parent.content.size&&(po(i,"end")||Wr.isSelectable(i)))for(let n=r.depth;;n--){let s=Cr(e.doc,r.before(n),r.after(n),Jt.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(po(i,"end")?jr.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Wr.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0)},ho=(e,t,n)=>{let r=co(e,n);if(!r)return!1;let o=mo(r);return!!o&&function(e,t,n){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=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=Cr(e.doc,i,l,Jt.empty);if(!c||c.from!=i||c instanceof ur&&c.slice.size>=l-i)return!1;if(n){let t=e.tr.step(c);t.setSelection(qr.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,o,t)};function po(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const fo=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=mo(r)}let s=i&&i.nodeBefore;return!(!s||!Wr.isSelectable(s))&&(t&&t(e.tr.setSelection(Wr.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function mo(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 go(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 vo(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 yo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=vo(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(jr.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0};const wo=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Wr&&e.selection.node.isBlock)return!(!n.parentOffset||!xr(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let o,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=vo(n.node(e-1).contentMatchAt(n.indexAfter(e-1))),s.unshift(a&&i?{type:i}:null),o=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof qr||e.selection instanceof Gr)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=xr(c.doc,d,s.length,s);if(u||(s[0]=i?{type:i}:null,u=xr(c.doc,d,s.length,s)),!u)return!1;if(c.split(d,s.length,s),!a&&l&&n.node(o).type!=i){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);i&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(o)),i)}return t&&t(c.scrollIntoView()),!0};function bo(e,t,n,r){let o,i,s=t.nodeBefore,a=t.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!kr(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&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,i=qt.empty;for(let e=o.length-1;e>=0;e--)i=qt.from(o[e].create(null,i));i=qt.from(s.copy(i));let l=e.tr.step(new hr(t.pos-1,r,t.pos,r,new Jt(i,1,0),o.length,!0)),c=l.doc.resolve(r+2*o.length);c.nodeAfter&&c.nodeAfter.type==s.type&&kr(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:jr.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),h=u&&gr(u);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(u,h).scrollIntoView()),!0;if(c&&po(a,"start",!0)&&po(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=qt.empty;for(let e=o.length-1;e>=0;e--)r=qt.from(o[e].copy(r));n(e.tr.step(new hr(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new Jt(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function xo(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(qr.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const ko=xo(-1),Co=xo(1);function So(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&vr(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function Mo(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function No(e,t=null,n){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!function(e,t,n){for(let r=0;r<t.length;r++){let{$from:o,$to:i}=t[r],s=0==o.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(o.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(r)if(i)e.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{let o,i=n.tr;o=!s.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e));for(let n=0;n<s.length;n++){let{$from:r,$to:a}=s[n];if(o){let n=r.pos,o=a.pos,s=r.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<o&&(n+=c,o-=d),i.addMark(n,o,e.create(t))}else i.removeMark(r.pos,a.pos,e)}r(i.scrollIntoView())}return!0}}function Eo(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let Oo=Eo(lo,uo,fo),Ao=Eo(lo,(e,t,n)=>{let r=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(!r)return!1;let o=go(r);if(!o)return!1;let i=o.nodeAfter;if(bo(e,o,t,1))return!0;if(0==r.parent.content.size&&(po(i,"start")||Wr.isSelectable(i))){let n=Cr(e.doc,r.before(),r.after(),Jt.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(po(i,"start")?jr.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Wr.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=go(r)}let s=i&&i.nodeAfter;return!(!s||!Wr.isSelectable(s))&&(t&&t(e.tr.setSelection(Wr.create(e.doc,i.pos)).scrollIntoView()),!0)});const To={Enter:Eo((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Gr||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=vo(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(qr.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 r=n.before();if(xr(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&gr(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)},wo),"Mod-Enter":yo,Backspace:Oo,"Mod-Backspace":Oo,"Shift-Backspace":Oo,Delete:Ao,"Mod-Delete":Ao,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Gr(e.doc))),!0)},Do={"Ctrl-h":To.Backspace,"Alt-Backspace":To["Mod-Backspace"],"Ctrl-d":To.Delete,"Ctrl-Alt-Backspace":To["Mod-Delete"],"Alt-Delete":To["Mod-Delete"],"Alt-d":To["Mod-Delete"],"Ctrl-a":ko,"Ctrl-e":Co};for(let e in To)Do[e]=To[e];const _o=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?Do:To;class Io{constructor(e,t,n={}){var r;this.match=e,this.match=e,this.handler="string"==typeof t?(r=t,function(e,t,n,o){let i=r;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let r=(n+=e)-o;r>0&&(i=t[0].slice(e-r,e)+i,n=o)}return e.tr.insertText(i,n,o)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const Ro=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function Lo(e,t,n=null,r){return new Io(e,(e,o,i,s)=>{let a=n instanceof Function?n(o):n,l=e.tr.delete(i,s),c=l.doc.resolve(i).blockRange(),d=c&&vr(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(i-1).nodeBefore;return u&&u.type==t&&kr(l.doc,i-1)&&(!r||r(o,u))&&l.join(i-1),l})}function Bo(e,t,n=null){return new Io(e,(e,r,o,i)=>{let s=e.doc.resolve(o),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,a):null})}new Io(/--$/,"—",{inCodeMark:!1}),new Io(/\.\.\.$/,"…",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new Io(/"$/,"”",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new Io(/'$/,"’",{inCodeMark:!1});const Po="undefined"!=typeof navigator?navigator:null,zo="undefined"!=typeof document?document:null,jo=Po&&Po.userAgent||"",Vo=/Edge\/(\d+)/.exec(jo),Ho=/MSIE \d/.exec(jo),$o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(jo),qo=!!(Ho||$o||Vo),Fo=Ho?document.documentMode:$o?+$o[1]:Vo?+Vo[1]:0,Wo=!qo&&/gecko\/(\d+)/i.test(jo),Uo=Wo&&+(/Firefox\/(\d+)/.exec(jo)||[0,0])[1],Go=!qo&&/Chrome\/(\d+)/.exec(jo),Ko=!!Go,Jo=Go?+Go[1]:0,Zo=!qo&&!!Po&&/Apple Computer/.test(Po.vendor),Yo=Zo&&(/Mobile\/\w+/.test(jo)||!!Po&&Po.maxTouchPoints>2),Xo=Yo||!!Po&&/Mac/.test(Po.platform),Qo=/Android \d/.test(jo),ei=!!zo&&"webkitFontSmoothing"in zo.documentElement.style,ti=ei?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var ni=Object.freeze({__proto__:null,android:Qo,chrome:Ko,chrome_version:Jo,gecko:Wo,gecko_version:Uo,ie:qo,ie_version:Fo,ios:Yo,mac:Xo,safari:Zo,webkit:ei,webkit_version:ti});function ri(e,t,n,r,o,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,"")+r;for(let a of o){const o=a,c=o.match.exec(l),d=c&&c[0]&&o.handler(s,c,t-(c[0].length-r.length),n);if(d)return!1!==o.undoable&&d.setMeta(i,{transform:d,from:t,to:n,text:r}),e.dispatch(d),!0}return!1}const oi=new ao("MILKDOWN_CUSTOM_INPUTRULES");function ii({rules:e}){const t=new oo({key:oi,isInputRules:!0,state:{init:()=>null,apply(e,t){const n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>ri(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&ri(n,r.pos,r.pos,"",e,t)}),!1),keydown:(e,t)=>!(!Qo||!Ko||"Enter"!==t.key)&&(!e.composing&&(!!e.someProp("handleKeyDown",n=>n(e,t))&&(t.preventDefault(),!0)))},handleKeyDown(n,r){if("Enter"!==r.key)return!1;const{$cursor:o}=n.state.selection;return!!o&&ri(n,o.pos,o.pos,"\n",e,t)}}});return t}function si(e){return e.some(e=>e.type.spec.code)}function ai(e,t,n){if(t>=n)return!1;let r=!1;return e.doc.nodesBetween(t,n,e=>(e.isInline&&si(e.marks)&&(r=!0),!r)),r}function li(e,t,n={}){return new Io(e,(e,r,o,i)=>{var s,a,l,c;const{tr:d}=e;let u,h=r[r.length-1],p=r[0],f=[];const m={group:h,fullMatch:p,start:o,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:h,fullMatch:p,start:o,end:i}=m),null===p)return null;if(""===(null==h?void 0:h.trim()))return null;if(h){const s=p.search(/\S/),m=o+p.indexOf(h),g=m+h.length,v=ai(e,o+s,m),y=g<i&&ai(e,g,i);if(v||y||function(e,t){var n;return si(null!=(n=e.storedMarks)?n:e.doc.resolve(t).marks())}(e,i))return null;f=null!=(a=d.storedMarks)?a:[],g<i&&d.delete(g,i),m>o&&d.delete(o+s,m),u=o+s+h.length;const w=null==(l=n.getAttr)?void 0:l.call(n,r);d.addMark(o,u,t.create(w)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:o,end:i,tr:d})}return d})}var ci=Object.defineProperty,di=Object.defineProperties,ui=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,pi=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,mi=(e,t,n)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function gi(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function vi(e,t,n){const r=e.state.doc.content.size,o=gi(t,0,r),i=gi(n,0,r),s=e.coordsAtPos(o),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),h={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return p=((e,t)=>{for(var n in t||(t={}))pi.call(t,n)&&mi(e,n,t[n]);if(hi)for(var n of hi(t))fi.call(t,n)&&mi(e,n,t[n]);return e})({},h),di(p,ui({toJSON:()=>h}));var p}function yi(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function wi(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 bi(e){return t=>{for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r)){return{from:t.before(n),to:t.after(n),node:r}}}}}function xi(e,t){const n=t.nodes[e];if(!n)throw function(e,t){return new yt(vt.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}("node",e);return n}function ki(e){return t=>{for(let n=t.depth;n>0;n--){const r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function Ci(e,t){if(!(e instanceof Wr))return;const{node:n,$from:r}=e;return function(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}(t,n)?{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}:void 0}const Si=(e,t)=>{const{selection:n,doc:r}=e;if(n instanceof Wr)return{hasNode:n.node.type===t,pos:n.from,target:n.node};const{from:o,to:i}=n;let s=!1,a=-1,l=null;return r.nodesBetween(o,i,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}},Mi="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ni="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function Ei(e){let t,n,r,o,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))o=!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))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Mi?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Oi(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 Ai(e){return new oo({props:{handleKeyDown:Ti(e)}})}function Ti(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Ei(n)]=e[n];return t}(e);return function(e,n){let r,o=c(n),i=t[Oi(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=t[Oi(o,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ni&&n.ctrlKey&&n.altKey)&&(r=d[n.keyCode])&&r!=o){let o=t[Oi(r,n)];if(o&&o(e.state,e.dispatch,e))return!0}}return!1}}var Di=class{},_i=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 kt();return e}}},Ii=class e extends Di{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,r){return new e(t,n,r)}},Ri=class extends _i{#b;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.#b=Gt.none,this.#x=e=>e.isText,this.#k=(e,t)=>{if(this.#x(e)&&this.#x(t)&&Gt.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)},this.#C=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 yt(vt.parserMatchError,`Cannot match target parser for node: ${bt(e)}.`)}(e);return t},this.#S=e=>{const t=this.#C(e);t.spec.parseMarkdown.runner(this,e,t)},this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Ii.create(e,[],t)),this),this.#M=()=>{this.#b=Gt.none;const e=this.close();return this.#N(e.type,e.attrs,e.content)},this.closeNode=()=>{try{this.#M()}catch(e){console.error(e)}return this},this.#N=(e,t,n)=>{const r=e.createAndFill(t,n,this.#b);if(!r)throw function(e,t,n){const r=`Cannot create node for ${"name"in e?e.name:e}`,o=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(o).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]",r],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:o(e):"null")]].reduce((e,[t,n])=>{const r=`${t}: ${o(n)}.`;return e.concat(r)},[]);return new yt(vt.createNodeInParserFail,i.join("\n"))}(e,t,n);return this.push(r),r},this.addNode=(e,t,n)=>{try{this.#N(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>{const n=e.create(t);return this.#b=n.addToSet(this.#b),this},this.closeMark=e=>(this.#b=e.removeFromSet(this.#b),this),this.addText=e=>{try{const t=this.top();if(!t)throw kt();const n=t.pop(),r=this.schema.text(e,this.#b);if(!n)return t.push(r),this;const o=this.#k(n,r);return o?(t.push(o),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do{e=this.#M()}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#S(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}#x;#k;#C;#S;#M;#N},Li=class e extends Di{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,o={})=>new e(t,n,r,o)}},Bi=class extends _i{#E;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.#E=[],this.#C=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 yt(vt.serializerMatchError,`Cannot match target serializer for node: ${bt(e)}.`)}(e.type);return t},this.#O=e=>this.#C(e).spec.toMarkdown.runner(this,e),this.#A=(e,t)=>this.#C(e).spec.toMarkdown.runner(this,e,t),this.#T=e=>{const t=e=>e.type.spec.priority??50,n=[...e].sort((e,n)=>t(e)-t(n)),r=[];return this.#E.forEach(({mark:e})=>{const t=n.findIndex(t=>t.eq(e));t>=0&&r.push(...n.splice(t,1))}),r.concat(n)},this.#D=e=>{const t=e?.marks;let n=0;for(;n<this.#E.length;){const{mark:e,spanning:r}=this.#E[n];if(!r||!t?.some(t=>t.eq(e)))break;n++}for(let e=this.#E.length-1;e>=n;e--)this.#_(this.#E[e].mark)},this.#S=(e,t)=>{this.#T(e.marks).every(t=>!this.#A(t,e))&&this.#O(e),this.#D(t)},this.#I=e=>{const{children:t}=e;return t?(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];const r=e.at(-1);if(r&&r.isMark&&t.isMark){const{children:n,...o}=t,{children:i,...s}=r;if(t.type===r.type&&n&&i&&JSON.stringify(o)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(this.#I(t))}}return e.concat(t)},[]),e):e},this.#R=e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t},this.openNode=(e,t,n)=>(this.open(Li.create(e,void 0,t,n)),this),this.#L=(e,t)=>{let n="",r="";const o=e.children;if(o){const e=o[0],t=o.at(-1);if(t&&"text"===t.type&&t.value.endsWith(" ")){const e=t.value,n=e.trimEnd();r=e.slice(n.length),t.value=n}if(e&&"text"===e.type&&e.value.startsWith(" ")){const t=e.value,r=t.trimStart();n=t.slice(0,t.length-r.length),e.value=r}}n.length&&this.#N("text",void 0,n);const i=t();return r.length&&this.#N("text",void 0,r),i},this.#M=(e=!1)=>{const t=this.close(),n=()=>this.#N(t.type,t.children,t.value,t.props);return e?this.#L(t,n):n()},this.closeNode=()=>(this.#M(),this),this.#N=(e,t,n,r)=>{const o=Li.create(e,t,n,r),i=this.#I(this.#R(o));return this.push(i),i},this.addNode=(e,t,n,r)=>(this.#N(e,t,n,r),this),this.#B=(e,t,n,r)=>this.#E.some(t=>t.mark.eq(e))?this:(this.#E.push({mark:e,spanning:null==n}),this.openNode(t,n,{...r,isMark:!0})),this.#_=e=>{let t=-1;for(let n=this.#E.length-1;n>=0;n--)if(this.#E[n].mark.eq(e)){t=n;break}t<0||(this.#E.splice(t,1),this.#M(!0))},this.withMark=(e,t,n,r)=>(this.#B(e,t,n,r),this),this.closeMark=e=>(this.#_(e),this),this.build=()=>{let e=null;do{e=this.#M()}while(this.size());return e.children||(e.children=[]),e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach((t,n,r)=>{this.#S(t,e.maybeChild(r+1)??void 0)}),this):(this.#S(e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.#E=[],this.next(e),this),this.schema=e}#C;#O;#A;#T;#D;#S;#I;#R;#L;#M;#N;#B;#_};const Pi=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},zi=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let ji=null;const Vi=function(e,t,n){let r=ji||(ji=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Hi=function(e,t,n,r){return n&&(qi(e,t,n,r,-1)||qi(e,t,n,r,1))},$i=/^(img|br|input|textarea|hr)$/i;function qi(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Fi(e))){let n=e.parentNode;if(!n||!Wi(n)||Ki(e)||$i.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Pi(e)+(o<0?0:1),e=n}else{if(!Wi(e))return!1;{let n=e.childNodes[t+(o<0?-1:0)];if(Wi(n)&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=n,t=o<0?Fi(e):0}}}}function Fi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Wi(e){return 1==e.nodeType}function Ui(e){return 3==e.nodeType}function Gi(e,t){return!!t&&e.contains(Wi(t)?t:t.parentNode)}function Ki(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 Ji=function(e){return e.focusNode&&Hi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};const Zi="undefined"!=typeof navigator?navigator:null,Yi="undefined"!=typeof document?document:null,Xi=Zi&&Zi.userAgent||"",Qi=/Edge\/(\d+)/.exec(Xi),es=/MSIE \d/.exec(Xi),ts=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xi),ns=!!(es||ts||Qi),rs=es?document.documentMode:ts?+ts[1]:Qi?+Qi[1]:0,is=!ns&&/gecko\/(\d+)/i.test(Xi);is&&(/Firefox\/(\d+)/.exec(Xi)||[0,0])[1];const ss=!ns&&/Chrome\/(\d+)/.exec(Xi),as=!!ss,ls=ss?+ss[1]:0,cs=!ns&&!!Zi&&/Apple Computer/.test(Zi.vendor),ds=cs&&(/Mobile\/\w+/.test(Xi)||!!Zi&&Zi.maxTouchPoints>2),us=ds||!!Zi&&/Mac/.test(Zi.platform),hs=!!Zi&&/Win/.test(Zi.platform),ps=/Android \d/.test(Xi),fs=!!Yi&&"webkitFontSmoothing"in Yi.documentElement.style,ms=fs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gs(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 vs(e,t){return"number"==typeof e?e:e[t]}function ys(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function ws(e,t,n){if(!Es(t)&&0==t.left)return;let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(!Wi(s)){s=zi(s);continue}let e=s==i.body,n=e?gs(i):ys(s),a=0,l=0;if(t.top<n.top+vs(r,"top")?l=-(n.top-t.top+vs(o,"top")):t.bottom>n.bottom-vs(r,"bottom")&&(l=t.bottom-t.top>n.bottom-n.top?t.top+vs(o,"top")-n.top:t.bottom-n.bottom+vs(o,"bottom")),t.left<n.left+vs(r,"left")?a=-(n.left-t.left+vs(o,"left")):t.right>n.right-vs(r,"right")&&(a=t.right-n.right+vs(o,"right")),a||l)if(e)i.defaultView.scrollBy(a,l);else{let e=s.scrollLeft,n=s.scrollTop;l&&(s.scrollTop+=l),a&&(s.scrollLeft+=a);let r=s.scrollLeft-e,o=s.scrollTop-n;t={left:t.left-r,top:t.top-o,right:t.right-r,bottom:t.bottom-o}}let c=e?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(c))break;s="absolute"==c?s.offsetParent:zi(s)}}function bs(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=zi(r));return t}function xs(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ks=null;function Cs(e,t){let n,r,o,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(Wi(d))e=d.getClientRects();else{if(!Ui(d))continue;e=Vi(d).getClientRects()}for(let h=0;h<e.length;h++){let p=e[h];if(p.top<=l&&p.bottom>=c){l=Math.max(p.bottom,l),c=Math.min(p.top,c);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=d,s=e,r=e&&Ui(n)?{left:p.right<t.left?p.right:p.left,top:t.top}:t,Wi(d)&&e&&(a=u+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=d,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=u+1)}}return!n&&o&&(n=o,r=i,s=0),n&&Ui(n)?function(e,t){let n,r=e.nodeValue.length,o=document.createRange();for(let i=0;i<r;i++){o.setEnd(e,i+1),o.setStart(e,i);let r=Os(o,1);if(r.top!=r.bottom&&Ss(t,r)){n={node:e,offset:i+(t.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),n||{node:e,offset:0}}(n,r):!n||s?{node:e,offset:a}:Cs(n,r)}function Ss(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ms(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(Wi(n)){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(Ss(t,o))return Ms(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function Ns(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Fi(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Fi(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(a)){let n=e.dom.getBoundingClientRect();if(!Ss(t,n))return null;if(a=Ms(e.dom,t,n),!a)return null}if(cs)for(let e=a;n&&e;e=zi(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(is&&Wi(n)&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;fs&&o&&Wi(n)&&Wi(r=n.childNodes[o-1])&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&Wi(n.lastChild)&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&Wi(n)&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(Wi(s.dom)&&(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>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=Cs(t,n),i=-1;if(Wi(r)&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function Es(e){return e.top<e.bottom||e.left<e.right}function Os(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Es(e))return e}return Array.prototype.find.call(n,Es)||e.getBoundingClientRect()}const As=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ts(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=fs||is;if(Ui(r)){if(!s||!As.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,Ds(Os(Vi(r,e,t),i),i<0)}{let e=Os(Vi(r,o,o),n);if(is&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Os(Vi(r,o-1,o-1),-1);if(t.top==e.top){let n=Os(Vi(r,o,o+1),-1);if(n.top!=e.top)return Ds(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==Fi(r))){let e=r.childNodes[o-1];if(Wi(e))return _s(e.getBoundingClientRect(),!1)}if(null==i&&o<Fi(r)){let e=r.childNodes[o];if(Wi(e))return _s(e.getBoundingClientRect(),!0)}return _s(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==Fi(r))){let e=r.childNodes[o-1],t=Ui(e)?Vi(e,Fi(e)-(s?0:1)):!Wi(e)||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ds(Os(t,1),!1)}if(null==i&&o<Fi(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?Ui(e)?Vi(e,0,s?0:1):Wi(e)?e:null:null;if(t)return Ds(Os(t,-1),!0)}return Ds(Os(Ui(r)?Vi(r):r,-n),n>=0)}function Ds(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 _s(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 Is(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Rs=/[\u0590-\u08ac]/;let Ls=null,Bs=null,Ps=!1;function zs(e,t,n){return Ls==t&&Bs==n?Ps:(Ls=t,Bs=n,Ps="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Is(e,t,()=>{let{node:t}=e.docView.domFromPos(o.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 r=Ts(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(Wi(e))t=e.getClientRects();else{if(!Ui(e))continue;t=Vi(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.domSelection();return a?Rs.test(r.parent.textContent)&&a.modify?Is(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!Gi(c,d)||t==d&&o==u;try{a.collapse(i,s),t&&(t!=i||o!=s)&&a.extend&&a.extend(t,o)}catch(e){}return null!=l&&(a.caretBidiLevel=l),h}):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class js{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,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(e){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 r=this.children[t];if(r==e)return n;n+=r.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&&Gi(this.contentDOM,e)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Pi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=16&n?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(4&n)}else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(Wi(o)?Gi(o,e):o==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 r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=t+this.children[n].size;if(o>e){r=e-t;break}t=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof Us||e instanceof Vs&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Pi(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Pi(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 r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);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)){r=Pi(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-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)){o=Pi(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}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(!Wi(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=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(o>a&&i<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);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((is||cs)&&e==t){let{node:e,offset:t}=s;if(Ui(e)){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:Pi(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(is&&c.focusNode&&c.focusNode!=a.node&&Wi(c.focusNode)){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&cs)&&Hi(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Hi(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!d||!is)){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,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.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 Vs extends js{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!t.type.spec.raw){let e=Wi(i)?i:document.createElement("span");e!=i&&(e.appendChild(i),i=e),e.hasAttribute("contenteditable")||(e.contentEditable="false"),e.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=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 Hs extends js{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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 $s extends js{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=Wn.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new $s(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 r=$s.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=ia(o,t,i,n)),e>0&&(o=ia(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class qs extends js{constructor(e,t,n,r,o,i,s){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,a=o.nodeViews[t.type.name],l=a&&a(t,o,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(!Ui(c))throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Wn.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=ea(c,n,t),l?s=new Gs(e,t,n,r,c,d||null,u,l):t.isText?new Ws(e,t,n,r,c,u):new qs(e,t,n,r,c,d||null,u)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>Wi(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>qt.empty}}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ta(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,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new ra(this,i&&i.node,e),l=this.node.inlineContent,c=l&&this.node.isBlock;!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,h,p;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(oa);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)p=-1,h=l,l=null;else{if(!(c<e.childCount))break;p=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=h.cut(e-i),h=h.cut(0,e-i),f=e,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(h,h.isInline&&!h.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(i,h),p),i=f}}(this.node,this.innerDeco,(t,o,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,o):t.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?Gt.none:this.node.child(o).marks,n,e,o),a.placeWidget(t,e,r)},(t,i,d,u)=>{let h;a.syncToMarks(t.marks,n,e,u),c&&t.isAtom&&!t.isText&&a.addHackNode("IMG",a.top),a.findNodeMatch(t,i,d,u)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,i,d,h,e)||a.updateNextNode(t,i,d,e,u,r)||a.addNode(t,i,d,e,r),r+=t.nodeSize,l&&(c=t.isAtom&&!t.isText)}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Ks(this.contentDOM,this.children,e),ds&&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:r}=e.state.selection;if(!(e.state.selection instanceof qr)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Hs(this,o,t,r);e.input.compositionNodes.push(i),this.children=ia(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ta(e,this.outerDeco))return;let t=!Wi(this.nodeDOM),n=this.dom;this.dom=Xs(this.dom,this.nodeDOM,Ys(this.outerDeco,this.node,t),Ys(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){Wi(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){Wi(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Fs(e,t,n,r,o){ea(r,t,e);let i=new qs(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}class Ws extends qs{constructor(e,t,n,r,o,i){super(e,t,n,r,o,null,i)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){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,r.trackWrites==this.nodeDOM&&(r.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 r=this.node.cut(e,t),o=document.createTextNode(r.text);return new Ws(this.parent,r,this.outerDeco,this.innerDeco,o,o)}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 Us extends js{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 Gs extends qs{constructor(e,t,n,r,o,i,s,a){super(e,t,n,r,o,i,s),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}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 Ks(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=na(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(a,r);if(s instanceof $s){let t=r?r.previousSibling:e.lastChild;Ks(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=na(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const Js=function(e){e&&(this.nodeName=e)};Js.prototype=Object.create(null);const Zs=[new Js];function Ys(e,t,n){if(0==e.length)return Zs;let r=n?Zs[0]:new Js,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Js(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new Js(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Xs(e,t,n,r){if(n==Zs&&r==Zs)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=Zs[0]),o=t}Qs(o,s||Zs[0],i)}return o}function Qs(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ea(e,t,n){return Xs(e,e,Zs,Ys(t,n,!Wi(e)))}function ta(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 na(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ra{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,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof $s)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,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,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<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 o=-1,s=this.top.children.length;r<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)){o=t;break}}if(o<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof $s&&3!=t.dirty&&t.mark.type==e[i].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[i])&&(t.mark=e[i],o=this.index,this.changed=!0)}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let r=$s.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),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,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof qs){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)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&&ta(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(a,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ta(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=qs.create(this.top,t,n,r,o,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,r,o){let i=qs.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Vs(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof $s;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ws)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((cs||as)&&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 r=new Us(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||Wi(e)&&e.contains(this.lock.parentNode))}}function oa(e,t){return e.type.side-t.type.side}function ia(e,t,n,r,o){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,r)),o&&(i.push(o),o=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function sa(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(Ji(n)){for(a=s;o&&!o.node;)o=o.parent;if(!(o&&o.node.isAtom&&Wr.isSelectable(o.node)&&o.parent)||o.node.isInline&&function(e,t,n){for(let r=0==t,o=t==Fi(e);r||o;){if(e==n)return!0;let t=Pi(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Fi(e)}}(n.focusNode,n.focusOffset,o.dom)){if(is&&"key"==t&&s>e.state.selection.to&&Wi(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if("visible"!=getComputedStyle(e).overflow){l=jr.findFrom(r.resolve(o.posAtStart),1);break}if(e==o.dom||e.nextSibling||!e.parentNode||!Wi(e.parentNode))break}}else{let e=o.posBefore;l=new Wr(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[a,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!l){l=ma(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return l}function aa(e){return e.editable?e.hasFocus():va(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function la(e,t=!1){let n=e.state.selection;if(pa(e,n),!aa(e))return;let r=e.input.mouseDown;if(!t&&as&&r){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Hi(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)&&r.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Pi(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&ns&&rs<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!ca||n instanceof qr||(n.$from.parent.inlineContent||(r=da(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=da(e,n.to))),e.docView.setSelection(i,s,e,t),ca&&(r&&ha(r),o&&ha(o)),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(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{aa(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}const ca=cs||as&&ls<63;function da(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(cs&&o&&"false"==o.contentEditable)return ua(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return ua(o);if(i)return ua(i)}}function ua(e){return e.contentEditable="true",cs&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ha(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function pa(e,t){if(t instanceof Wr){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(fa(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else fa(e)}function fa(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function ma(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||qr.between(t,n,r)}function ga(e){return!(e.editable&&!e.hasFocus())&&va(e)}function va(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Gi(e.dom,t.anchorNode)&&(e.editable||Gi(e.dom,t.focusNode))}catch(e){return!1}}function ya(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&jr.findFrom(i,t)}function wa(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ba(e,t,n){let r=e.state.selection;if(!(r instanceof qr)){if(r instanceof Wr&&r.node.isInline)return wa(e,new qr(t>0?r.$to:r.$from));{let n=ya(e.state,t);return!!n&&wa(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return wa(e,new qr(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=ya(e.state,t);return!!(n&&n instanceof Wr)&&wa(e,n)}if(!us||n.indexOf("m")<0){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Wr.isSelectable(i)?wa(e,new Wr(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):wa(e,new qr(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function xa(e,t){let n=e.pmViewDesc;return n?0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName):Wi(e)&&"false"==e.contentEditable}function ka(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;is&&Wi(n)&&r<Fi(n)&&xa(n.childNodes[r],-1)&&(s=!0);for(;;)if(r>0){if(!Wi(n))break;let e=n.childNodes[r-1];if(xa(e,-1))o=n,i=--r;else{if(!Ui(e))break;n=e,r=n.nodeValue.length}}else{if(Ca(n))break;{let t=n.previousSibling;for(;t&&xa(t,-1);)o=n.parentNode,i=Pi(t),t=t.previousSibling;if(t)n=t,r=Fi(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Sa(e,n,r):o&&Sa(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=Fi(n);for(;;)if(r<s){if(!Wi(n))break;if(!xa(n.childNodes[r],1))break;o=n,i=++r}else{if(Ca(n))break;{let t=n.nextSibling;for(;t&&xa(t,1);)o=t.parentNode,i=Pi(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=Fi(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&Sa(e,o,i)}(e)}function Ca(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Sa(e,t,n){if(!Ui(t)){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Ki(e);)t=Pi(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(Ui(n))return n;if(Wi(n)&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Ki(e);)t=Pi(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(Ui(n))return n;if(Wi(n)&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection(),o=e.domSelectionRange();if(!r)return;Ji(o)?r.collapse(t,n):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(t,n)),e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&la(e)},50)}function Ma(e,t){let n=e.state.doc.resolve(t);if(!as&&!hs&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return"rtl"==getComputedStyle(r).direction?"rtl":"ltr"}function Na(e,t,n){let r=e.state.selection;if(r instanceof qr&&!r.empty||n.indexOf("s")>-1)return!1;if(us&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=ya(e.state,t);if(n&&n instanceof Wr)return wa(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Gr?jr.near(n,t):jr.findFrom(n,t);return!!s&&wa(e,s)}return!1}function Ea(e,t){if(!(e.state.selection instanceof qr))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)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 r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Oa(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Aa(e,t){let n=t.keyCode,r=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||us&&72==n&&"c"==r)return Ea(e,-1)||ka(e,-1);if(46==n&&!t.shiftKey||us&&68==n&&"c"==r)return Ea(e,1)||ka(e,1);if(13==n||27==n)return!0;if(37==n||us&&66==n&&"c"==r){let t=37==n?"ltr"==Ma(e,e.state.selection.from)?-1:1:-1;return ba(e,t,r)||ka(e,t)}if(39==n||us&&70==n&&"c"==r){let t=39==n?"ltr"==Ma(e,e.state.selection.from)?1:-1:1;return ba(e,t,r)||ka(e,t)}return 38==n||us&&80==n&&"c"==r?Na(e,-1,r)||ka(e,-1):40==n||us&&78==n&&"c"==r?function(e){if(!cs||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&Wi(t)&&0==n&&t.firstChild&&Wi(t.firstChild)&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Oa(e,n,"true"),setTimeout(()=>Oa(e,n,"false"),20)}return!1}(e)||Na(e,1,r)||ka(e,1):r==(us?"m":"c")&&(66==n||73==n||89==n||90==n)}function Ta(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||Wn.fromSchema(e.state.schema),a=ja(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,d=l.firstChild,u=0;for(;d&&Wi(d)&&(c=za[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&&Wi(d)&&d.setAttribute("data-pm-slice",`${o} ${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 Da(e,t,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return s=new Jt(qt.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,o,r,e));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=Wn.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.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,r=ja(),o=r.body,i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&za[i[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;if(!Va){if(Va=t.defaultPolicy)try{return Va.createHTML(e)}catch(e){}Va=t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})}return Va.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;for(let e=0;e<r.styleSheets.length;e++){let t=r.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=o.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return o}(n),fs&&function(e){let t=e.querySelectorAll(as?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(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&&!Wi(e);)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Ln.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||_a.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;try{o=qt.from(t.create(n[e+1],o))}catch(e){break}i++,s++}return new Jt(o,i,s)}(Pa(s,+d[1],+d[2]),d[4]);else if(s=Jt.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&Ra(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=La(i[i.length-1],r.length));let t=Ia(e,n);i.push(t),o=o.matchType(t.type),r=n}}),i)return qt.from(i)}return e}(s.content,o),!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=Pa(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const _a=/^(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 Ia(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,qt.from(e));return e}function Ra(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Ra(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(qt.from(Ia(n,e,o+1))))}}function La(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,La(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(qt.empty,!0);return e.copy(n.append(r))}function Ba(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),o<r-1&&(a=Ba(a,t,n,r,o+1,i)),o>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(qt.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function Pa(e,t,n){return t<e.openStart&&(e=new Jt(Ba(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Jt(Ba(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const za={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function ja(){return document.implementation.createHTMLDocument("title")}let Va=null;const Ha={},$a={},qa={touchstart:!0,touchmove:!0};class Fa{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,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 Wa(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Ua(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Ga(e,t))})}function Ga(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Ka(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 Ja(e,t){let{input:n}=e;return!n.lastKeyDispatched&&!e.composing&&(n.lastKeyDispatched=!0,"string"==typeof t&&(t=function(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}("Backspace"==t?8:13,t)),e.someProp("handleKeyDown",n=>n(e,t)))}function Za(e){return{left:e.clientX,top:e.clientY}}function Ya(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function Xa(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Qa(e,t,n,r,o){return Ya(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Wr&&(n=o.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(Wr.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Xa(e,Wr.create(e.state.doc,r)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Wr.isSelectable(r))&&(Xa(e,new Wr(n)),!0)}(e,n))}function el(e,t,n,r){return Ya(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function tl(e,t,n,r){return Ya(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=nl(e,t,!0),o=e.state.doc;if(!r)return!1;Xa(e,r),r instanceof qr&&o.eq(e.state.doc)&&(e.input.mouseDown=new al(e,r));return!0}(e,n,r)}function nl(e,t,n){let r=e.state.doc;if(-1==t)return r.inlineContent?qr.create(r,0,r.content.size):null;let o=r.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e),i=o.before(e);if(t.inlineContent)return qr.create(r,i+1,i+1+t.content.size);if(n&&Wr.isSelectable(t))return Wr.create(r,i)}return null}function rl(e){return pl(e)}$a.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!ll(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!ps||!as||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!ds||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)Ja(e,n)||Aa(e,n)?n.preventDefault():Wa(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(Ja(e,"Enter"),e.input.lastIOSEnter=0)},200)}},$a.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},$a.keypress=(e,t)=>{let n=t;if(ll(e)||!n.charCode||n.ctrlKey&&!n.altKey||us&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof qr&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,o))||e.dispatch(o()),n.preventDefault()}};const ol=us?"metaKey":"ctrlKey";Ha.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=rl(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[ol]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(Za(n));s&&("singleClick"==i?e.input.mouseDown=new sl(e,s,n,!!r):("doubleClick"==i?el:tl)(e,s.pos,s.inside,n)?n.preventDefault():Wa(e,"pointer"))};class il{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){0==e.buttons&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class sl extends il{constructor(e,t,n,r){let o,i;if(super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[ol],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&Wi(a.nodeDOM)?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof Wr&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!is||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()),Wa(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||la(this.view)})}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(Za(e))),this.updateAllowDefault(e),this.allowDefault||!t?Wa(this.view,"pointer"):Qa(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||cs&&this.mightDrag&&!this.mightDrag.node.isAtom||as&&!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)?(Xa(this.view,jr.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Wa(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wa(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return!!this.allowDefault&&(this.delayedSelectionSync=!0,!0)}}class al extends il{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(0==e.buttons||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc))return void this.done();e.preventDefault(),Wa(this.view,"pointer");let t=this.view.posAtCoords(Za(e)),n=t&&nl(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,o=this.startSelection,[i,s]=n.from<o.from?[o.to,n.from]:[o.from,n.to];Xa(this.view,qr.create(r,i,s))}}function ll(e,t){return!!e.composing||!!(cs&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Ha.touchstart=e=>{e.input.lastTouch=Date.now(),rl(e),Wa(e,"pointer")},Ha.touchmove=e=>{e.input.lastTouch=Date.now(),Wa(e,"pointer")},Ha.contextmenu=e=>rl(e);const cl=ps?5e3:-1;function dl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>pl(e),t))}function ul(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function hl(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(Ui(e)&&t)return e;if(Wi(e)&&t>0){if("false"==e.contentEditable)return null;t=Fi(e=e.childNodes[t-1])}else{if(!e.parentNode||Ki(e))return null;t=Pi(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(Ui(e)&&t<e.nodeValue.length)return e;if(Wi(e)&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Ki(e))return null;t=Pi(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function pl(e,t=!1){if(!(ps&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ul(e),t||e.docView&&e.docView.dirty){let n=sa(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}$a.compositionstart=$a.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof qr&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||as&&hs&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!Wi(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return Wi(r)&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),pl(e,!0),e.markCursor=null;else if(pl(e,!t.selection.empty),is&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&Wi(n)&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(Ui(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}dl(e,cl)},$a.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),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++,dl(e,20))};const fl=ns&&rs<15||ds&&ms<604;function ml(e,t,n,r,o){let i=Da(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,o,i||Jt.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,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gl(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," "):""}Ha.copy=$a.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=fl?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Ta(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 r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},$a.paste=(e,t)=>{let n=t;if(e.composing&&!ps)return;let r=fl?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ml(e,gl(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ml(e,r.value,null,o,t):ml(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class vl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const yl=us?"altKey":"ctrlKey";function wl(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[yl]}Ha.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Za(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Wr?i.to-1:i.to));else if(r&&r.mightDrag)o=Wr.create(e.state.doc,r.mightDrag.pos);else if(n.target&&Wi(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Wr.create(e.state.doc,t.posBefore))}let a=(o||e.state.selection).content(),{dom:l,text:c,slice:d}=Ta(e,a);(!n.dataTransfer.files.length||!as||ls>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(fl?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",fl||n.dataTransfer.setData("text/plain",c),e.dragging=new vl(d,wl(e,n),o)},Ha.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},$a.dragover=$a.dragenter=(e,t)=>t.preventDefault(),$a.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Za(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Da(e,gl(t.dataTransfer),fl?null:t.dataTransfer.getData("text/html"),!1,o);let s=!(!n||!wl(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||Jt.empty,s)))return void t.preventDefault();if(!i)return;t.preventDefault();let a=i?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,o.pos,i):o.pos;null==a&&(a=o.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 h=l.doc.resolve(c);if(d&&Wr.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new Wr(h));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),l.setSelection(ma(e,h,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Ha.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let t=e.domSelectionRange();t.focusNode==n&&t.focusOffset==r&&e.docView&&e.hasFocus()&&la(e)},20)}}},Ha.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)},Ha.beforeinput=(e,t)=>{if(ps&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length)return;if(e.dom.blur(),e.focus(),Ja(e,"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 $a)Ha[e]=$a[e];function bl(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 xl{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}}class kl{constructor(e,t){this.toDOM=e,this.spec=t||El,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Ml(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof kl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&bl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Cl{constructor(e,t){this.attrs=e,this.spec=t||El}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ml(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Cl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}static is(e){return e.type instanceof Cl}destroy(){}}class Sl{constructor(e,t){this.attrs=e,this.spec=t||El}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ml(o.pos-n,i.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(e){return this==e||e instanceof Sl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}destroy(){}}class Ml{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Ml(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 Ml(e,e,new kl(t,n))}static inline(e,t,n,r){return new Ml(e,t,new Cl(n,r))}static node(e,t,n,r){return new Ml(e,t,new Sl(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Cl}get widget(){return this.type instanceof kl}}const Nl=[],El={};class Ol{constructor(e,t){this.local=e.length?e:Nl,this.children=t.length?t:Nl}static create(e,t){return t.length?Rl(t,e,0,El):Al}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}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,r+s,o)}}map(e,t,n){return this==Al||0==e.maps.length?this:this.mapInner(e,t,0,0,n||El)}mapInner(e,t,n,r,o){let i;if(this.local.length){let s=new xl(t.content);for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,n,r);l&&l.type.valid(t,l,s)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}}return this.children.length?function(e,t,n,r,o,i,s){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<a.length;o+=3){let i=a[o+1];if(i<0||e>i+t-r)continue;let l=a[o]+t-r;n>=l?a[o+1]=e<=l?-2:-1:e>=t&&s&&(a[o]+=s,a[o+1]+=s)}r+=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-o;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=a[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=Al?(a[t]=d,a[t+1]=u,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,o,i,s){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(r,o,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,o,i,s),c=Rl(l,r,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 Ol(t.sort(Ll),a)}(this.children,i||[],e,t,n,r,o):i?new Ol(i.sort(Ll),Nl):Al}add(e,t){return t.length?this==Al?Ol.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,a=i+n;if(s=_l(t,e,a)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,a+1):r.splice(o,0,i,i+e.nodeSize,Rl(s,e,a+1,El)),o+=3}});let i=Dl(o?Il(t):t,-n);if(i.length){let t=new xl(e.content);for(let n=0;n<i.length;n++)i[n].type.valid(e,i[n],t)||i.splice(n--,1)}return new Ol(i.length?this.local.concat(i).sort(Ll):this.local,r||this.children)}remove(e){return 0==e.length||this==Al?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(o,i+1);a!=Al?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Ol(r,n):Al}forChild(e,t){if(this==Al)return this;if(t.isLeaf)return Ol.empty;let n,r;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 o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof Cl){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new Ol(r.sort(Ll),Nl);return n?new Tl([e,n]):e}return n||Al}eq(e){if(this==e)return!0;if(!(e instanceof Ol)||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 Bl(this.localsInner(e))}localsInner(e){if(this==Al)return Nl;if(e.inlineContent||!this.local.some(Cl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Cl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}Ol.empty=new Ol([],[]),Ol.removeOverlap=Bl;const Al=Ol.empty;class Tl{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,El));return Tl.from(n)}forChild(e,t){if(t.isLeaf)return Ol.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=Al&&(o instanceof Tl?n=n.concat(o.members):n.push(o))}return Tl.from(n)}eq(e){if(!(e instanceof Tl)||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 r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Bl(n?t:t.sort(Ll)):Nl}static from(e){switch(e.length){case 0:return Al;case 1:return e[0];default:return new Tl(e.every(e=>e instanceof Ol)?e:e.reduce((e,t)=>e.concat(t instanceof Ol?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Dl(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new Ml(o.from+t,o.to+t,o.type))}return n}function _l(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Il(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Rl(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let a=_l(e,t,s+n);if(a){i=!0;let e=Rl(a,t,n+s+1,r);e!=Al&&o.push(s,s+t.nodeSize,e)}});let s=Dl(i?Il(e):e,-n).sort(Ll);if(s.length){let e=new xl(t.content);for(let n=0;n<s.length;n++)s[n].type.valid(t,s[n],e)||(r.onRemove&&r.onRemove(s[n].spec),s.splice(n--,1))}return s.length||o.length?new Ol(s,o):Al}function Ll(e,t){return e.from-t.from||e.to-t.to}function Bl(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Pl(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Pl(t,o+1,i.copy(r.to,i.to)))}}return t}function Pl(e,t,n){for(;t<e.length&&Ll(n,e[t])>0;)t++;e.splice(t,0,n)}function zl(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Al&&t.push(r)}),e.cursorWrapper&&t.push(Ol.create(e.state.doc,[e.cursorWrapper.deco])),Tl.from(t)}const jl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Vl=ns&&rs<=11;class Hl{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 $l{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Hl,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]);ns&&rs<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():cs&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Vl&&(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,jl)),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(ga(this.view)){if(this.suppressingSelectionUpdates)return la(this.view);if(ns&&rs<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Hi(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=zi(t))n.add(t);for(let r=e.anchorNode;r;r=zi(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:Ui(t)?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,r=!1;!this.suppressingSelectionUpdates&&ga(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let o=-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&&(o=o<0?n.from:Math.min(n.from,o),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||as&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>"childList"==e.type&&e.removedNodes.length))){for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&Wi(t);){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(is&&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 r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&Ul(e,n)==t||r.remove()}}}let l=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ji(n)&&(l=sa(e))&&l.eq(jr.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,la(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(ql.has(e))return;if(ql.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=is,Fl)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."),Fl=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:o}=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||!Wi(e)||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}(e,a)),this.handleDOMChange(o,i,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&la(e),n&&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 r=e.addedNodes[n];t.push(r),Ui(r)&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(ns&&rs<=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)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?Pi(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?Pi(o):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 ql=new WeakMap,Fl=!1;function Wl(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Hi(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Ul(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}const Gl=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if("BR"==t.nodeName&&t.parentNode){if(cs&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(t.parentNode.lastChild==t||cs&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},Kl=/^(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 Jl(e,t,n,r,o){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=sa(e,t);if(n&&!e.state.selection.eq(n)){if(as&&ps&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&Ja(e,"Enter"))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}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,r){let o,{node:i,fromOffset:s,toOffset:a,from:l,to:c}=e.docView.parseRange(t,n),d=e.domSelectionRange(),u=d.anchorNode;if(u&&Gi(e.dom,u)&&(o=[{node:u,offset:d.anchorOffset}],Ji(d)||o.push({node:d.focusNode,offset:d.focusOffset})),as&&8===e.input.lastKeyCode)for(let e=a;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){a=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||Ln.fromSchema(e.state.schema),f=h.resolve(l),m=null,g=p.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:a,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Gl(r),context:f});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),m={anchor:e+l,head:t+l}}return{doc:g,sel:m,from:l,to:c}}(e,t,n,o),h=e.state.doc,p=h.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,r,o){let i=e.findDiffStart(t,n),s=n+e.size,a=n+t.size;if(null==i)return null;let{a:l,b:c}=e.findDiffEnd(t,s,a);if("end"==o){r-=l+Math.max(0,i-Math.min(l,c))-i}if(l<i&&s<a){i-=r<=i&&r>=l?i-r:0,c=i+(c-l),l=i}else if(c<i){i-=r<=i&&r>=c?i-r:0,l=i+(l-c),c=i}return{start:i,endA:l,endB:c}}(p.content,u.doc.content,u.from,l,c);if(f&&e.input.domChangeCount++,(ds&&e.input.lastIOSEnter>Date.now()-225||ps)&&o.some(e=>Wi(e)&&!Kl.test(e.nodeName))&&(!f||f.endA>=f.endB)&&Ja(e,"Enter"))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof qr&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=Zl(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 qr&&(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)),ns&&rs<=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=h.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA;if((ds&&e.input.lastIOSEnter>Date.now()-225&&(!y||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&function(e,t,n){let r=0,o=0;return e.nodesBetween(t,n,(e,i)=>{e.isTextblock&&i>=t&&i<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-i),Math.min(e.nodeSize,n-i))):e.isLeaf)&&o++}),0==o&&1==r}(u.doc,m.pos,g.pos))&&Ja(e,"Enter"))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&(y?f.endA>f.start&&f.endB==f.start:function(e,t,n,r,o){if(n-t<=o.pos-r.pos||Yl(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.inlineContent){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(Yl(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Yl(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(h,f.start,f.endA,m,g))&&Ja(e,"Backspace"))return void(ps&&as&&e.domObserver.suppressSelectionUpdates());as&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),ps&&!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(()=>Ja(e,"Enter"),20));let w,b=f.start,x=f.endA,k=t=>{let n=t||e.state.tr.replace(b,x,u.doc.slice(f.start-u.from,f.endB-u.from));if(u.sel){let t=Zl(e,n.doc,u.sel);t&&!(as&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(x)-1)||ns&&t.empty&&t.head==b)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(y)if(m.pos==g.pos){ns&&rs<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>la(e),20));let t=k(e.state.tr.delete(b,x)),n=h.resolve(f.start).marksAcross(h.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(w=function(e,t){let n,r,o,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)r=a[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if(qt.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start())))){let t=k(e.state.tr);"add"==w.type?t.addMark(b,x,w.mark):t.removeMark(b,x,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=()=>k(e.state.tr.insertText(t,b,x));e.someProp("handleTextInput",r=>r(e,b,x,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())}function Zl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:ma(e,t.resolve(n.anchor),t.resolve(n.head))}function Yl(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}class Xl{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 Fa,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(rc),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=tc(this),ec(this),this.nodeViews=nc(this),this.docView=Fs(this.state.doc,Ql(this),zl(this),this.dom,this),this.domObserver=new $l(this,(e,t,n,r)=>Jl(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in Ha){let n=Ha[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Ka(e,t)||Ga(e,t)||!e.editable&&t.type in $a||n(e,t)},qa[t]?{passive:!0}:void 0)}cs&&e.dom.addEventListener("input",()=>null),Ua(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&&Ua(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(rc),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 r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(ul(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=nc(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ua(this),this.editable=tc(this),ec(this);let a=zl(this),l=Ql(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(r.selection)||(i=!0);let u="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=o-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:bs(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(ns||as)&&!this.composing&&!r.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)}(r.selection,e.selection);if(d){let n=as?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hl(this)),!o&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=Fs(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let n=this.input.mouseDown;t||!(n&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Hi(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this)&&n.delaySelUpdate())?la(this,t):(pa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;xs(n,0==r?0:r-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Gi(this.dom,e))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof Wr){let t=this.docView.domAfterPos(this.state.selection.from);Wi(t)&&ws(this,t.getBoundingClientRect(),e)}else ws(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,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=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&&(r=e)}this.dragging=new vl(e.slice,e.move,r<0?void 0:Wr.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(ns){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(ks)return e.focus(ks);let t=bs(e);e.focus(null==ks?{get preventScroll(){return ks={preventScroll:!0},!0}}:void 0),ks||(ks=!1,xs(t,0))}(this.dom),la(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 Ns(this,e)}coordsAtPos(e,t=1){return Ts(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 r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return zs(this,t||this.state,e)}pasteHTML(e,t){return ml(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ml(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ta(this,e)}destroy(){this.docView&&(!function(e){e.input.mouseDown&&e.input.mouseDown.done(),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,[],zl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ji=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Ga(e,t)||!Ha[t.type]||!e.editable&&t.type in $a||Ha[t.type](e,t)}(this,e)}domSelectionRange(){let e=!1!==this.dom.isConnected&&this.domSelection();return e?cs&&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 Wl(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Wl(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ql(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"),[Ml.node(0,e.state.doc.content.size,t)]}function ec(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:Ml.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function tc(e){return!e.someProp("editable",t=>!1===t(e.state))}function nc(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 rc(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 oc(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}Xl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};var ic={text:(e,t,n,r)=>{const o=e.value;return/^[^*_\\]*\s+$/.test(o)?o:n.safe(o,{...r,encode:[]})},strong:(e,t,n,r)=>{const o=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(r);let a=s.move(o+o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o+o),i(),a},emphasis:(e,t,n,r)=>{const o=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(r);let a=s.move(o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o),i(),a}},sc=Tt({},"editorView"),ac=Tt({},"editorState"),lc=Tt([],"initTimer"),cc=Tt({},"editor"),dc=Tt([],"inputRules"),uc=Tt([],"prosePlugins"),hc=Tt([],"remarkPlugins"),pc=Tt([],"nodeView"),fc=Tt([],"markView"),mc=Tt(X().use(Q).use(Pt),"remark"),gc=Tt({handlers:ic,encode:[]},"remarkStringifyOptions"),vc=Bt("ConfigReady");var yc=Bt("InitReady");function wc(e){const t=t=>(t.inject(cc,e).inject(uc,[]).inject(hc,[]).inject(dc,[]).inject(pc,[]).inject(fc,[]).inject(gc,{handlers:ic,encode:[]}).inject(mc,X().use(Q).use(Pt)).inject(lc,[vc]).record(yc),async()=>{await t.waitTimers(lc);const e=t.get(gc);return t.set(mc,X().use(Q).use(Pt,e)),t.done(yc),()=>{t.remove(cc).remove(uc).remove(hc).remove(dc).remove(pc).remove(fc).remove(gc).remove(mc).remove(lc).clearTimer(yc)}});return oc(t,{displayName:"Init"}),t}var bc=Bt("SchemaReady"),xc=Tt([],"schemaTimer"),kc=Tt({},"schema"),Cc=Tt([],"nodes"),Sc=Tt([],"marks");function Mc(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var Nc=e=>(e.inject(kc,{}).inject(Cc,[]).inject(Sc,[]).inject(xc,[yc]).record(bc),async()=>{await e.waitTimers(xc);const t=e.get(mc),n=e.get(hc).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(mc,n);const r=Object.fromEntries(e.get(Cc).map(([e,t])=>[e,Mc(t)])),o=Object.fromEntries(e.get(Sc).map(([e,t])=>[e,Mc(t)])),i=new In({nodes:r,marks:o});return e.set(kc,i),e.done(bc),()=>{e.remove(kc).remove(Cc).remove(Sc).remove(xc).clearTimer(bc)}});oc(Nc,{displayName:"Schema"});var Ec=class{constructor(){this.#o=new Et,this.#P=null,this.setCtx=e=>{this.#P=e},this.chain=()=>{if(null==this.#P)throw St();const e=this.#P,t=[],n=this.get.bind(this),r={run:()=>{const n=Eo(...t),r=e.get(sc);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:function(e,o){const i=n(e);return t.push(i(o)),r}.bind(this)};return r}}#o;#P;get ctx(){return this.#P}create(e,t){const n=e.create(this.#o.sliceMap);return n.set(t),n}get(e){return this.#o.get(e).get()}remove(e){return this.#o.remove(e)}call(e,t){if(null==this.#P)throw St();const n=this.get(e)(t),r=this.#P.get(sc);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#P)throw St();const t=this.#P.get(sc);return e(t.state,t.dispatch,t)}};var Oc=Tt(new Ec,"commands"),Ac=Tt([bc],"commandsTimer"),Tc=Bt("CommandsReady"),Dc=e=>{const t=new Ec;return t.setCtx(e),e.inject(Oc,t).inject(Ac,[bc]).record(Tc),async()=>(await e.waitTimers(Ac),e.done(Tc),()=>{e.remove(Oc).remove(Ac).clearTimer(Tc)})};oc(Dc,{displayName:"Commands"});var _c=class{constructor(){this.#P=null,this.#z=[],this.setCtx=e=>{this.#P=e},this.add=e=>(this.#z.push(e),()=>{this.#z=this.#z.filter(t=>t!==e)}),this.addObjectKeymap=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){const r={key:e,onRun:()=>n};this.#z.push(r),t.push(()=>{this.#z=this.#z.filter(e=>e!==r)})}else this.#z.push(n),t.push(()=>{this.#z=this.#z.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{const e=function(e){return e.Backspace=Eo(Ro,lo,ho,fo),e}(_o);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#z.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,r)=>{const o=this.#P;if(null==o)throw xt();return Eo(...n.map(e=>e.onRun(o)))(e,t,r)}]}))}}#P;#z;get ctx(){return this.#P}},Ic=Tt(new _c,"keymap"),Rc=Tt([bc],"keymapTimer"),Lc=Bt("KeymapReady"),Bc=e=>{const t=new _c;return t.setCtx(e),e.inject(Ic,t).inject(Rc,[bc]).record(Lc),async()=>(await e.waitTimers(Rc),e.done(Lc),()=>{e.remove(Ic).remove(Rc).clearTimer(Lc)})},Pc=Bt("ParserReady"),zc=()=>{throw xt()},jc=Tt(zc,"parser"),Vc=Tt([],"parserTimer"),Hc=e=>(e.inject(jc,zc).inject(Vc,[bc]).record(Pc),async()=>{await e.waitTimers(Vc);const t=e.get(mc),n=e.get(kc);return e.set(jc,Ri.create(n,t)),e.done(Pc),()=>{e.remove(jc).remove(Vc).clearTimer(Pc)}});oc(Hc,{displayName:"Parser"});var $c=Bt("SerializerReady"),qc=Tt([],"serializerTimer"),Fc=()=>{throw xt()},Wc=Tt(Fc,"serializer"),Uc=e=>(e.inject(Wc,Fc).inject(qc,[bc]).record($c),async()=>{await e.waitTimers(qc);const t=e.get(mc),n=e.get(kc);return e.set(Wc,Bi.create(n,t)),e.done($c),()=>{e.remove(Wc).remove(qc).clearTimer($c)}});oc(Uc,{displayName:"Serializer"});var Gc=Tt("","defaultValue"),Kc=Tt(e=>e,"stateOptions"),Jc=Tt([],"editorStateTimer"),Zc=Bt("EditorStateReady");function Yc(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return Ln.fromSchema(n).parse(e.dom);if("json"===e.type)return fn.fromJSON(n,e.value);throw r=e,new yt(vt.docTypeError,`Doc type error, unsupported type: ${bt(r)}`);var r}var Xc=new ao("MILKDOWN_STATE_TRACKER"),Qc=e=>(e.inject(Gc,"").inject(ac,{}).inject(Kc,e=>e).inject(Jc,[Pc,$c,Tc,Lc]).record(Zc),async()=>{await e.waitTimers(Jc);const t=e.get(kc),n=e.get(jc),r=e.get(dc),o=e.get(Kc),i=e.get(uc),s=Yc(e.get(Gc),n,t),a=e.get(Ic),l=a.addBaseKeymap(),c=[...i,new oo({key:Xc,state:{init:()=>{},apply:(t,n,r,o)=>{e.set(ac,o)}}}),ii({rules:r}),Ai(a.build())];e.set(uc,c);const d=o({schema:t,doc:s,plugins:c}),u=no.create(d);return e.set(ac,u),e.done(Zc),()=>{l(),e.remove(Gc).remove(ac).remove(Kc).remove(Jc).clearTimer(Zc)}});oc(Qc,{displayName:"EditorState"});var ed=Tt([],"pasteRule"),td=Tt([bc],"pasteRuleTimer"),nd=Bt("PasteRuleReady"),rd=e=>(e.inject(ed,[]).inject(td,[bc]).record(nd),async()=>(await e.waitTimers(td),e.done(nd),()=>{e.remove(ed).remove(td).clearTimer(nd)}));oc(rd,{displayName:"PasteRule"});var od=Bt("EditorViewReady"),id=Tt([],"editorViewTimer"),sd=Tt({},"editorViewOptions"),ad=Tt(null,"root"),ld=Tt(null,"rootDOM"),cd=Tt({},"rootAttrs");var dd=new ao("MILKDOWN_VIEW_CLEAR"),ud=e=>(e.inject(ad,document.body).inject(sc,{}).inject(sd,{}).inject(ld,null).inject(cd,{}).inject(id,[Zc,nd]).record(od),async()=>{await e.wait(yc);const t=e.get(ad)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(uc,t=>[new oo({key:dd,view:t=>{const r=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(ld,n);const r=t.get(cd);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}(n,e):void 0;return(()=>{if(r&&n){const e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(id);const r=e.get(ac),o=e.get(sd),i=Object.fromEntries(e.get(pc)),s=Object.fromEntries(e.get(fc)),a=new Xl(n,{state:r,nodeViews:i,markViews:s,transformPasted:(t,n,r)=>(e.get(ed).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});var l;return(l=a.dom).classList.add("editor"),l.setAttribute("role","textbox"),e.set(sc,a),e.done(od),()=>{a?.destroy(),e.remove(ad).remove(sc).remove(sd).remove(ld).remove(cd).remove(id).clearTimer(od)}});oc(ud,{displayName:"EditorView"});var hd=function(e){return e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e}({}),pd=class e{constructor(){this.#j=!1,this.#g="Idle",this.#V=[],this.#H=()=>{},this.#o=new Et,this.#i=new It,this.#$=new Map,this.#q=new Map,this.#P=new _t(this.#o,this.#i),this.#F=()=>{const e=function(e){const t=t=>(t.record(vc),async()=>(await e(t),t.done(vc),()=>{t.clearTimer(vc)}));return oc(t,{displayName:"Config"}),t}(async e=>{await Promise.all(this.#V.map(t=>Promise.resolve(t(e))))}),t=[Nc,Hc,Uc,Dc,Bc,rd,Qc,ud,wc(this),e];this.#W(t,this.#q)},this.#W=(e,t)=>{e.forEach(e=>{const n=this.#P.produce(this.#j?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#U=(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})),this.#G=async()=>{await Promise.all([...this.#q.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#q.clear()},this.#K=e=>{this.#g=e,this.#H(e)},this.#J=e=>[...e.entries()].map(async([t,n])=>{const{ctx:r,handler:o}=n;if(!o)return;const i=await o();e.set(t,{ctx:r,handler:o,cleanup:i})}),this.enableInspector=(e=!0)=>(this.#j=e,this),this.onStatusChange=e=>(this.#H=e,this),this.config=e=>(this.#V.push(e),this),this.removeConfig=e=>(this.#V=this.#V.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})}),"Created"===this.#g&&this.#W(t,this.#$),this},this.remove=async e=>"OnCreate"===this.#g?(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.#U([e].flat(),!0),this),this.create=async()=>("OnCreate"===this.#g||("Created"===this.#g&&await this.destroy(),this.#K("OnCreate"),this.#F(),this.#W([...this.#$.keys()],this.#$),await Promise.all([this.#J(this.#q),this.#J(this.#$)].flat()),this.#K("Created")),this),this.destroy=async(e=!1)=>"Destroyed"===this.#g||"OnDestroy"===this.#g?this:"OnCreate"===this.#g?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#V=[]),this.#K("OnDestroy"),await this.#U([...this.#$.keys()],e),await this.#G(),this.#K("Destroyed"),this),this.action=e=>e(this.#P),this.inspect=()=>this.#j?[...this.#q.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}#j;#g;#V;#H;#o;#i;#$;#q;#P;#F;#W;#U;#G;#K;#J;get ctx(){return this.#P}get status(){return this.#g}};let fd=e=>crypto.getRandomValues(new Uint8Array(e)),md=(e,t=21)=>((e,t,n)=>{let r=256-256%e.length;if(256===r){let r=e.length-1;return(o=t)=>{if(!o)return"";let i="";for(;;){let t=n(o),s=o|=0;for(;s--;)if(i+=e[t[s]&r],i.length>=o)return i}}}return(o=t)=>{if(!o)return"";let i="",s=Math.ceil(409.6*o/r);for(;;){let t=n(s),a=s;for(;a--;)if(t[a]<r&&(i+=e[t[a]%e.length],i.length>=o))return i}}})(e,0|t,fd);function gd(e,t,n){const r=e.findIndex(([e])=>e===t);if(-1===r)return[...e,n];const o=e.slice();return o[r]=n,o}function vd(e,t){const n=function(e="cmdKey"){return Tt(()=>()=>!1,e)}(e),r=o=>async()=>{r.key=n,await o.wait(Tc);const i=t(o);return o.get(Oc).create(n,i),r.run=t=>o.get(Oc).call(e,t),()=>{o.get(Oc).remove(n)}};return r}function yd(e){const t=n=>async()=>{await n.wait(bc);const r=e(n);return n.update(dc,e=>[...e,r]),t.inputRule=r,()=>{n.update(dc,e=>e.filter(e=>e!==r))}};return t}function wd(e,t){const n=r=>async()=>{const o=t(r);return r.update(Sc,t=>gd(t,e,[e,o])),n.id=e,n.schema=o,()=>{r.update(Sc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(kc).marks[e];if(!n)throw r=e,new yt(vt.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${r}" in schema.`);var r;return n},n}function bd(e,t){const n=r=>async()=>{const o=t(r);return r.update(Cc,t=>gd(t,e,[e,o])),n.id=e,n.schema=o,()=>{r.update(Cc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(kc).nodes[e];if(!n)throw Mt(e);return n},n}function xd(e){let t;const n=n=>async()=>(await n.wait(bc),t=e(n),n.update(uc,e=>[...e,t]),()=>{n.update(uc,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function kd(e){const t=n=>async()=>{await n.wait(Lc);const r=n.get(Ic),o=e(n),i=r.addObjectKeymap(o);return t.keymap=o,()=>{i()}};return t}function Cd(e,t){const n=r=>async()=>{await r.wait(bc);const o=t(r);return e.type(r)instanceof Tn?r.update(pc,t=>[...t,[e.id,o]]):r.update(fc,t=>[...t,[e.id,o]]),n.view=o,n.type=e,()=>{e.type(r)instanceof Tn?r.update(pc,t=>t.filter(t=>t[0]!==e.id)):r.update(fc,t=>t.filter(t=>t[0]!==e.id))}};return n}function Sd(e,t){const n=Tt(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function Md(e,t){const n=Sd(t,e),r=bd(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.node=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>Md(e,n(t)),o}function Nd(e,t){const n=Sd(t,e),r=wd(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.mark=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>Nd(e,n(t)),o}function Ed(e,t){const n=Sd(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=kd(e=>{const r=e.get(n.key),o=Object.entries(t).flatMap(([e,{command:t}])=>{const n=r[e],o=[n.shortcuts].flat(),i=n.priority;return o.map(e=>[e,{key:e,onRun:t,priority:i}])});return Object.fromEntries(o)}),o=[n,r];return o.ctx=n,o.shortcuts=r,o.key=n.key,o.keymap=r.keymap,o}md("abcedfghicklmn",10);var Od=(e,t=()=>({}))=>Sd(t,`${e}Attr`),Ad=(e,t=()=>({}))=>Sd(t,`${e}Attr`);function Td(e,t,n){const r=Sd({},e),o=e=>async()=>{await e.wait(yc);const n={plugin:t(e),options:e.get(r.key)};return e.update(hc,e=>[...e,n]),()=>{e.update(hc,e=>e.filter(e=>e!==n))}},i=[r,o];return i.id=e,i.plugin=o,i.options=r,i}function Dd(e){return e=>{const t=e.get(sc);e.get(kc);return e.get(Wc)(t.state.doc)}}var _d=ue({});var Id=()=>{const e=function(){const{dom:e,editor:t,setLoading:n,editorFactory:r}=he(_d),o=le(null);return me(()=>{const i=o.current;if(!r)return;if(!i)return;e.current=i;const s=r(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,r,n]),o}();return ae.createElement("div",{"data-milkdown-root":!0,ref:e})},Rd=({children:e})=>{const t=le(void 0),[n,r]=ce(void 0),o=le(void 0),[i,s]=ce(!0),a=de(()=>({loading:i,dom:t,editor:o,setLoading:s,editorFactory:n,setEditorFactory:r}),[i,n]);return ae.createElement(_d.Provider,{value:a},e)};function Ld(){const e=he(_d),t=pe(()=>e.editor.current,[e.editor]);return[e.loading,t]}function Bd(e){return new h(p.define(e))}function Pd(e){return import("./index-CHgqN-d9.js").then(t=>t.sql({dialect:t[e]}))}const zd=[u.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-DDBuqExW.js").then(e=>e.cpp())}),u.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-DDBuqExW.js").then(e=>e.cpp())}),u.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Pd("Cassandra")}),u.of({name:"CSS",extensions:["css"],load:()=>import("./index-B9JSZpaA.js").then(e=>e.css())}),u.of({name:"Go",extensions:["go"],load:()=>import("./index-wJyG4Gm6.js").then(e=>e.go())}),u.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-CHVYA2P8.js").then(e=>e.html())}),u.of({name:"Java",extensions:["java"],load:()=>import("./index-D6A8P_xS.js").then(e=>e.java())}),u.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript())}),u.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-BS7YTgMe.js").then(e=>e.jinja())}),u.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-vxKx70Pe.js").then(e=>e.json())}),u.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript({jsx:!0}))}),u.of({name:"LESS",extensions:["less"],load:()=>import("./index-YYM2ZvZ6.js").then(e=>e.less())}),u.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index-CffiBbeH.js").then(e=>e.liquid())}),u.of({name:"MariaDB SQL",load:()=>Pd("MariaSQL")}),u.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-DBWowQHL.js").then(e=>e.markdown())}),u.of({name:"MS SQL",load:()=>Pd("MSSQL")}),u.of({name:"MySQL",load:()=>Pd("MySQL")}),u.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-mLZqgXD7.js").then(e=>e.php())}),u.of({name:"PLSQL",extensions:["pls"],load:()=>Pd("PLSQL")}),u.of({name:"PostgreSQL",load:()=>Pd("PostgreSQL")}),u.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-BNvG4PUn.js").then(e=>e.python())}),u.of({name:"Rust",extensions:["rs"],load:()=>import("./index-B46RgSF9.js").then(e=>e.rust())}),u.of({name:"Sass",extensions:["sass"],load:()=>import("./index-D9BPo-_o.js").then(e=>e.sass({indented:!0}))}),u.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-D9BPo-_o.js").then(e=>e.sass())}),u.of({name:"SQL",extensions:["sql"],load:()=>Pd("StandardSQL")}),u.of({name:"SQLite",load:()=>Pd("SQLite")}),u.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript({jsx:!0,typescript:!0}))}),u.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript({typescript:!0}))}),u.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-Bohl_WFx.js").then(e=>e.wast())}),u.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-D5AIo8KT.js").then(e=>e.xml())}),u.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-BDQ8194g.js").then(e=>e.yaml())}),u.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-CXdQSnD-.js").then(e=>Bd(e.apl))}),u.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-D5V0T9Cu.js").then(e=>Bd(e.asciiArmor))}),u.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-DWPaVWf6.js").then(e=>Bd(e.asn1({})))}),u.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-B46aRdXb.js").then(e=>Bd(e.asterisk))}),u.of({name:"Brainfuck",extensions:["b","bf"],load:()=>import("./brainfuck-CtZaYBKt.js").then(e=>Bd(e.brainfuck))}),u.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-stawOqaz.js").then(e=>Bd(e.cobol))}),u.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.csharp))}),u.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Bd(e.clojure))}),u.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Bd(e.clojure))}),u.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-C4GSMmGA.js").then(e=>Bd(e.gss))}),u.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-DXn5xaP-.js").then(e=>Bd(e.cmake))}),u.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-BTDxI-eT.js").then(e=>Bd(e.coffeeScript))}),u.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-vq6DHwts.js").then(e=>Bd(e.commonLisp))}),u.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-gJDei3ni.js").then(e=>Bd(e.cypher))}),u.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-On6Xi21R.js").then(e=>Bd(e.cython))}),u.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-CRzZ78HM.js").then(e=>Bd(e.crystal))}),u.of({name:"D",extensions:["d"],load:()=>import("./d-BShv7fp-.js").then(e=>Bd(e.d))}),u.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.dart))}),u.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-UJJ5BM9S.js").then(e=>Bd(e.diff))}),u.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-DVQ9Q8O9.js").then(e=>Bd(e.dockerFile))}),u.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-DI9Herc-.js").then(e=>Bd(e.dtd))}),u.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-DkEP81N9.js").then(e=>Bd(e.dylan))}),u.of({name:"EBNF",load:()=>import("./ebnf-B-Df8AvO.js").then(e=>Bd(e.ebnf))}),u.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-DPFc0Uaf.js").then(e=>Bd(e.ecl))}),u.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Bd(e.clojure))}),u.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-DR5c0IrL.js").then(e=>Bd(e.eiffel))}),u.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-DompmV0j.js").then(e=>Bd(e.elm))}),u.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-BuqgqA5h.js").then(e=>Bd(e.erlang))}),u.of({name:"Esper",load:()=>import("./sql-ByLYq2fX.js").then(e=>Bd(e.esper))}),u.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-Bk9_H-XT.js").then(e=>Bd(e.factor))}),u.of({name:"FCL",load:()=>import("./fcl-CVaBTCzQ.js").then(e=>Bd(e.fcl))}),u.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-POgR1ypr.js").then(e=>Bd(e.forth))}),u.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-DL7KluxX.js").then(e=>Bd(e.fortran))}),u.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Bd(e.fSharp))}),u.of({name:"Gas",extensions:["s"],load:()=>import("./gas-8mz5Q3qN.js").then(e=>Bd(e.gas))}),u.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-B6X1vGSW.js").then(e=>Bd(e.gherkin))}),u.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-DnIzCrpZ.js").then(e=>Bd(e.groovy))}),u.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-CLQs6EAM.js").then(e=>Bd(e.haskell))}),u.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Bd(e.haxe))}),u.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Bd(e.hxml))}),u.of({name:"HTTP",load:()=>import("./http-BKJkqRj4.js").then(e=>Bd(e.http))}),u.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-pcmmZuaN.js").then(e=>Bd(e.idl))}),u.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-BVaBnk3P.js").then(e=>Bd(e.jsonld))}),u.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-DjdwvFuI.js").then(e=>Bd(e.julia))}),u.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.kotlin))}),u.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-HO6ttBFx.js").then(e=>Bd(e.liveScript))}),u.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-BvgfYBhq.js").then(e=>Bd(e.lua))}),u.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-DkvFAiy5.js").then(e=>Bd(e.mirc))}),u.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-IIbmv7SK.js").then(e=>Bd(e.mathematica))}),u.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-DSrSSXCg.js").then(e=>Bd(e.modelica))}),u.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-zvxmGV4l.js").then(e=>Bd(e.mumps))}),u.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-z_N2Mo3d.js").then(e=>Bd(e.mbox))}),u.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-B4hAVlXN.js").then(e=>Bd(e.nginx))}),u.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-BFvJq6Vq.js").then(e=>Bd(e.nsis))}),u.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-BSwWqoLa.js").then(e=>Bd(e.ntriples))}),u.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.objectiveC))}),u.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.objectiveCpp))}),u.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Bd(e.oCaml))}),u.of({name:"Octave",extensions:["m"],load:()=>import("./octave-C4hdQ5Hf.js").then(e=>Bd(e.octave))}),u.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-qQq7irPq.js").then(e=>Bd(e.oz))}),u.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-CafrKXZF.js").then(e=>Bd(e.pascal))}),u.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-tdMlh9QA.js").then(e=>Bd(e.perl))}),u.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CwGJVRC4.js").then(e=>Bd(e.pig))}),u.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-D1ly3AHC.js").then(e=>Bd(e.powerShell))}),u.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-_nPj978X.js").then(e=>Bd(e.properties))}),u.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-B4y9do6W.js").then(e=>Bd(e.protobuf))}),u.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-Dlfivyh-.js").then(e=>Bd(e.pug))}),u.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-Bc-yJKzi.js").then(e=>Bd(e.puppet))}),u.of({name:"Q",extensions:["q"],load:()=>import("./q-mUfi2b_o.js").then(e=>Bd(e.q))}),u.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-BA4EbLKE.js").then(e=>Bd(e.r))}),u.of({name:"RPM Changes",load:()=>import("./rpm-DI_rRufH.js").then(e=>Bd(e.rpmChanges))}),u.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-DI_rRufH.js").then(e=>Bd(e.rpmSpec))}),u.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-D9chwFAN.js").then(e=>Bd(e.ruby))}),u.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-Bqaci40L.js").then(e=>Bd(e.sas))}),u.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.scala))}),u.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-qjP0V5Ag.js").then(e=>Bd(e.scheme))}),u.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-BLav31RL.js").then(e=>Bd(e.shell))}),u.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-r025o_jW.js").then(e=>Bd(e.sieve))}),u.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-C7J3IyEP.js").then(e=>Bd(e.smalltalk))}),u.of({name:"Solr",load:()=>import("./solr-78MBEUkU.js").then(e=>Bd(e.solr))}),u.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Bd(e.sml))}),u.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-BRLJFz69.js").then(e=>Bd(e.sparql))}),u.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-CGlWr0eM.js").then(e=>Bd(e.spreadsheet))}),u.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.squirrel))}),u.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-Bdo_Aemu.js").then(e=>Bd(e.stylus))}),u.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-B_XXVlXX.js").then(e=>Bd(e.swift))}),u.of({name:"sTeX",load:()=>Promise.resolve().then(function(){return Hd}).then(e=>Bd(e.stex))}),u.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>Promise.resolve().then(function(){return Hd}).then(e=>Bd(e.stex))}),u.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Bd(e.verilog))}),u.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-B2fODqDH.js").then(e=>Bd(e.tcl))}),u.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-BuVhTOzU.js").then(e=>Bd(e.textile))}),u.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-BgR6AEZu.js").then(e=>Bd(e.tiddlyWiki))}),u.of({name:"Tiki wiki",load:()=>import("./tiki-CI-ztowC.js").then(e=>Bd(e.tiki))}),u.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-BVJm5Fzd.js").then(e=>Bd(e.toml))}),u.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-Ce85hlLp.js").then(e=>Bd(e.troff))}),u.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-BxnYHtq8.js").then(e=>Bd(e.ttcn))}),u.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-CKJxb-l2.js").then(e=>Bd(e.ttcnCfg))}),u.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-BkSuIpt-.js").then(e=>Bd(e.turtle))}),u.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-CGwyPRYs.js").then(e=>Bd(e.webIDL))}),u.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-BHgjm0DN.js").then(e=>Bd(e.vb))}),u.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-VzWlGt02.js").then(e=>Bd(e.vbScript))}),u.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-BdD_26Jv.js").then(e=>Bd(e.velocity))}),u.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Bd(e.verilog))}),u.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-CWWH2SUo.js").then(e=>Bd(e.vhdl))}),u.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-CVDBqZPY.js").then(e=>Bd(e.xQuery))}),u.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-I8QjZlxf.js").then(e=>Bd(e.yacas))}),u.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-DMVFMNEx.js").then(e=>Bd(e.z80))}),u.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Bd(e.mscgen))}),u.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Bd(e.xu))}),u.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Bd(e.msgenny))}),u.of({name:"Vue",extensions:["vue"],load:()=>import("./index-CmWQEzQl.js").then(e=>e.vue())}),u.of({name:"Angular Template",load:()=>import("./index-nNMK7HvL.js").then(e=>e.angular())})];function jd(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 r(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 o={};function i(e,t){e.f=t}function s(e,r){var s;if(e.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var c=e.current().slice(1);return t(r,s=new(s=o.hasOwnProperty(c)?o[c]:o.DEFAULT)),i(r,l),s.style}if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/\\]/))return"tag";if(e.match("\\["))return i(r,function(e,t){return a(e,t,"\\]")}),"keyword";if(e.match("\\("))return i(r,function(e,t){return a(e,t,"\\)")}),"keyword";if(e.match("$$"))return i(r,function(e,t){return a(e,t,"$$")}),"keyword";if(e.match("$"))return i(r,function(e,t){return a(e,t,"$")}),"keyword";var d=e.next();return"%"==d?(e.skipToEnd(),"comment"):"}"==d||"]"==d?(s=n(r))?(s.closeBracket(d),i(r,l),"bracket"):"error":"{"==d||"["==d?(t(r,s=new(s=o.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 r=t[n];if("DEFAULT"!=r.name)return r}return{styleIdentifier:function(){return null}}}(r),"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 r=e.next();return"{"==r||"}"==r||"["==r||"]"==r||"("==r||")"==r?"bracket":"%"==r?(e.skipToEnd(),"comment"):"error"}function l(e,t){var r=e.peek();return"{"==r||"["==r?(n(t).openBracket(r),e.eat(r),i(t,s),"bracket"):/[ \t\r]/.test(r)?(e.eat(r),null):(i(t,s),function(e){var t=e.cmdState.pop();t&&t.closeBracket()}(t),s(e,t))}return o.importmodule=r("importmodule","tag",["string","builtin"]),o.documentclass=r("documentclass","tag",["","atom"]),o.usepackage=r("usepackage","tag",["atom"]),o.begin=r("begin","tag",["atom"]),o.end=r("end","tag",["atom"]),o.label=r("label","tag",["atom"]),o.ref=r("ref","tag",["atom"]),o.eqref=r("eqref","tag",["atom"]),o.cite=r("cite","tag",["atom"]),o.bibitem=r("bibitem","tag",["atom"]),o.Bibitem=r("Bibitem","tag",["atom"]),o.RBibitem=r("RBibitem","tag",["atom"]),o.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 Vd=jd(!1);jd(!0);var Hd=Object.freeze({__proto__:null,stex:Vd});function $d(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);return!!i&&(!n||(r.node(i.depth-1).type==e?function(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new hr(i-1,s,i,s,new Jt(qt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new hn(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const a=gr(r);if(null==a)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(i,-1)-1);kr(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos);return t(o.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?qt.empty:qt.from(o))))return!1;let u=i.pos,h=u+s.nodeSize;return r.step(new hr(u-(a?1:0),h+(l?1:0),u+1,h-1,new Jt((a?qt.empty:qt.from(o.copy(qt.empty))).append(l?qt.empty:qt.from(o.copy(qt.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,i)))}}function qd(e){return String(e||"").toUpperCase()}function Fd(){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=qd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){const n=qd(e);return t.get(n)}}(e);ee(e,function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[te,n];if("imageReference"===e.type||"linkReference"===e.type){const o=t(e.identifier);if(o&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:o.url,title:o.title,alt:e.alt}:{type:"link",url:o.url,title:o.title,children:e.children},[te,n]}})}}function Wd(e){const t={...e};return t.position&&(t.position={start:{...t.position.start},end:{...t.position.end}}),delete t.children,t}var Ud=/^<br\s*\/?\s*>$/i;function Gd(e,t){if(!(t.childCount>=1&&"hardbreak"===t.lastChild?.type.name))return void e.next(t.content);const n=[];t.content.forEach((e,r,o)=>{o!==t.childCount-1&&n.push(e)}),e.next(qt.fromArray(n))}function Kd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}var Jd=Ad("emphasis");Kd(Jd,{displayName:"Attr<emphasis>",group:"Emphasis"});var Zd=Nd("emphasis",e=>({attrs:{marker:{default:e.get(gc).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})}}}));Kd(Zd.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),Kd(Zd.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Yd=vd("ToggleEmphasis",e=>()=>No(Zd.type(e)));Kd(Yd,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var Xd=yd(e=>li(/(?:^|[^*])\*([^*]+)\*$/,Zd.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));Kd(Xd,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var Qd=yd(e=>li(/\b_(?![_\s])(.*?[^_\s])_$/,Zd.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));Kd(Qd,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var eu=Ed("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(Oc);return()=>t.call(Yd.key)}}});Kd(eu.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),Kd(eu.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var tu=Ad("strong");Kd(tu,{displayName:"Attr<strong>",group:"Strong"});var nu=Nd("strong",e=>({attrs:{marker:{default:e.get(gc).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(tu.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})}}}));Kd(nu.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),Kd(nu.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var ru=vd("ToggleStrong",e=>()=>No(nu.type(e)));Kd(ru,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var ou=yd(e=>li(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,nu.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));Kd(ou,{displayName:"InputRule<strong>",group:"Strong"});var iu=Ed("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(Oc);return()=>t.call(ru.key)}}});Kd(iu.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),Kd(iu.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var su=Ad("inlineCode");Kd(su,{displayName:"Attr<inlineCode>",group:"InlineCode"});var au=Nd("inlineCode",e=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(su.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)}}));Kd(au.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),Kd(au.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var lu=vd("ToggleInlineCode",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(r.empty)return!1;const{from:i,to:s}=r;return t.doc.rangeHasMark(i,s,au.type(e))?(n?.(o.removeMark(i,s,au.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==au.type.name).map(e=>t.schema.marks[e]).forEach(e=>{o.removeMark(i,s,e)}),n?.(o.addMark(i,s,au.type(e).create())),!0)});Kd(lu,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var cu=yd(e=>li(/(?:`)([^`]+)(?:`)$/,au.type(e)));Kd(cu,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var du=Ed("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(Oc);return()=>t.call(lu.key)}}});Kd(du.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),Kd(du.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var uu=new Set(["http:","https:","mailto:","tel:","ftp:"]);function hu(e){return e<=32||e>=127&&e<=160||e>=8203&&e<=8205||8232===e||8233===e||65279===e}function pu(e){if("string"!=typeof e)return"";const t=e.trim();if(!t)return"";const n=function(e){let t="";for(const n of e)hu(n.codePointAt(0)??0)||(t+=n);return t}(t),r=/^([a-z][a-z0-9+.-]*):/i.exec(n)?.[1];return r?uu.has(`${r.toLowerCase()}:`)?t:"":t}var fu=Ad("link");Kd(fu,{displayName:"Attr<link>",group:"Link"});var mu=Nd("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ct(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(fu.key)(t),...t.attrs,href:pu(t.attrs.href)}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const r=t.url,o=t.title;e.openMark(n,{href:r,title:o}),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})}}}));Kd(mu.mark,{displayName:"MarkSchema<link>",group:"Link"});var gu=vd("ToggleLink",e=>(t={})=>No(mu.type(e),t));Kd(gu,{displayName:"Command<toggleLinkCommand>",group:"Link"});var vu=vd("UpdateLink",e=>(t={})=>(n,r)=>{if(!r)return!1;let o,i=-1;const{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(mu.type(e).isInSet(t.marks))return o=t,i=n,!1}),!o)return!1;const c=o.marks.find(({type:t})=>t===mu.type(e));if(!c)return!1;const d=i,u=i+o.nodeSize,{tr:h}=n,p=mu.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(d,u,c).addMark(d,u,p).setSelection(new qr(h.selection.$anchor)).scrollIntoView()),!0)});Kd(vu,{displayName:"Command<updateLinkCommand>",group:"Link"});var yu=bd("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");const n=t.childCount>0?t.child(t.childCount-1):null,r="paragraph"===n?.type.name&&0===n.content.size?t.content.cut(0,t.content.size-n.nodeSize):t.content;e.next(r)}}}));Kd(yu,{displayName:"NodeSchema<doc>",group:"Doc"});var wu=Object.freeze(["root","blockquote","listItem","footnoteDefinition"]),bu=new Set(["paragraph","heading","tableCell","link","linkReference","emphasis","strong","delete","footnote"]),xu=Sd(wu,"blockContainerTypes");Kd(xu,{displayName:"Ctx<blockContainerTypes>",group:"Remark"});var ku=new Set;function Cu(e){const t=e.isInjected(xu.key)?e.get(xu.key):wu,n=new Set;for(const e of t)bu.has(e)?ku.has(e)||(ku.add(e),console.warn(`[milkdown/preset-commonmark] "${e}" holds phrasing content and cannot be a block container; it is ignored in blockContainerTypes.`)):n.add(e);return n}var Su=new Set(["paragraph","tableCell"]);function Mu(e,t){return ne(e,e=>{return"html"===e.type&&("string"==typeof(t=e.value)&&Ud.test(t.trim()));var t},(e,n)=>{const r=n[n.length-1];if(r)if(Su.has(r.type))1===r.children.length&&(r.children=[]);else if(t.has(r.type)){const t=e;return t.children=[],delete t.value,t.type="paragraph",te}})}var Nu=Td("remark-preserve-empty-line",e=>()=>t=>Mu(t,Cu(e)));Kd(Nu.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),Kd(Nu.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Eu=Od("paragraph");Kd(Eu,{displayName:"Attr<paragraph>",group:"Paragraph"});var Ou=Md("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(Eu.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)=>{t.openNode("paragraph"),n.content&&0!==n.content.size||!function(e){return e.isInjected(Nu.options.key)}(e)?Gd(t,n):t.addNode("html",void 0,"<br />"),t.closeNode()}}}));Kd(Ou.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),Kd(Ou.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Au=vd("TurnIntoText",e=>()=>Mo(Ou.type(e)));Kd(Au,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Tu=Ed("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(Oc);return()=>t.call(Au.key)}}});Kd(Tu.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),Kd(Tu.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var Du=Array(6).fill(0).map((e,t)=>t+1);var _u=Sd(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");Kd(_u,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Iu=Od("heading");Kd(Iu,{displayName:"Attr<heading>",group:"Heading"});var Ru=Md("heading",e=>{const t=e.get(_u.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:Du.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Ct(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(Iu.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const r=t.depth;e.openNode(n,{level:r}),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}),Gd(e,t),e.closeNode()}}}});Kd(Ru.node,{displayName:"NodeSchema<heading>",group:"Heading"}),Kd(Ru.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var Lu=yd(e=>Bo(/^(?<hashes>#+)\s$/,Ru.type(e),t=>{const n=t.groups?.hashes?.length||0,{$from:r}=e.get(sc).state.selection,o=r.node();if("heading"===o.type.name){let e=Number(o.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));Kd(Lu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var Bu=vd("WrapInHeading",e=>t=>(t??=1,t<1?Mo(Ou.type(e)):Mo(Ru.type(e),{level:t})));Kd(Bu,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Pu=vd("DowngradeHeading",e=>()=>(t,n,r)=>{const{$from:o}=t.selection,i=o.node();if(i.type!==Ru.type(e)||!t.selection.empty||0!==o.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):Mo(Ou.type(e))(t,n)});Kd(Pu,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var zu=Ed("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(Oc);return()=>t.call(Pu.key)}}});Kd(zu.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),Kd(zu.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var ju=Od("blockquote");Kd(ju,{displayName:"Attr<blockquote>",group:"Blockquote"});var Vu=Md("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(ju.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()}}}));Kd(Vu.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),Kd(Vu.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var Hu=yd(e=>Lo(/^\s*>\s$/,Vu.type(e)));Kd(Hu,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var $u=vd("WrapInBlockquote",e=>()=>So(Vu.type(e)));Kd($u,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var qu=Ed("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(Oc);return()=>t.call($u.key)}}});Kd(qu.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),Kd(qu.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Fu=Od("codeBlock",()=>({pre:{},code:{}}));Kd(Fu,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Wu=Md("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 Ct(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(Fu.key)(t),r=t.attrs.language,o=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...o},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const r=t.lang??"",o=t.value;e.openNode(n,{language:r}),o&&e.addText(o),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})}}}));Kd(Wu.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),Kd(Wu.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Uu=yd(e=>Bo(/^```(?<language>[a-z]*)?[\s\n]$/,Wu.type(e),e=>({language:e.groups?.language??""})));Kd(Uu,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Gu=vd("CreateCodeBlock",e=>(t="")=>Mo(Wu.type(e),{language:t}));Kd(Gu,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),Kd(vd("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Ku=Ed("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(Oc);return()=>t.call(Gu.key)}}});Kd(Ku.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),Kd(Ku.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Ju=Od("image");Kd(Ju,{displayName:"Attr<image>",group:"Image"});var Zu=Md("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 Ct(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(Ju.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const r=t.url,o=t.alt??"",i=t.title??"";e.addNode(n,{src:r,alt:o,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})}}}));Kd(Zu.node,{displayName:"NodeSchema<image>",group:"Image"}),Kd(Zu.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Yu=vd("InsertImage",e=>(t={})=>(n,r)=>{if(!r)return!0;const{src:o="",alt:i="",title:s=""}=t,a=Zu.type(e).create({src:o,alt:i,title:s});return!a||(r(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});Kd(Yu,{displayName:"Command<insertImageCommand>",group:"Image"});var Xu=vd("UpdateImage",e=>(t={})=>(n,r)=>{const o=Ci(n.selection,Zu.type(e));if(!o)return!1;const{node:i,pos:s}=o,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),r?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});Kd(Xu,{displayName:"Command<updateImageCommand>",group:"Image"}),Kd(yd(e=>new Io(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,o)=>{const[i,s,a="",l]=n;return i?t.tr.replaceWith(r,o,Zu.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Qu=Od("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));Kd(Qu,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var eh=Md("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(Qu.key)(t)," "]:["br",e.get(Qu.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")}}}));Kd(eh.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),Kd(eh.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var th=vd("InsertHardbreak",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(!(r instanceof qr))return!1;if(r.empty){const e=r.$from.node();if(e.childCount>0&&"hardbreak"===e.lastChild?.type.name)return n?.(o.replaceRangeWith(r.to-1,r.to,t.schema.node("paragraph")).setSelection(jr.near(o.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(o.setMeta("hardbreak",!0).replaceSelectionWith(eh.type(e).create(),!1).scrollIntoView()),!0});Kd(th,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var nh=Ed("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(Oc);return()=>t.call(th.key)}}});Kd(nh.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),Kd(nh.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var rh=Od("hr");Kd(rh,{displayName:"Attr<hr>",group:"Hr"});var oh=Md("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(rh.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")}}}));Kd(oh.node,{displayName:"NodeSchema<hr>",group:"Hr"}),Kd(oh.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var ih=yd(e=>new Io(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,o)=>{const{tr:i}=t;return n[0]&&i.replaceWith(r-1,o,oh.type(e).create()),i}));Kd(ih,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var sh=vd("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;const r=Ou.node.type(e).create(),{tr:o,selection:i}=t,{from:s}=i,a=oh.type(e).create();if(!a)return!0;const l=o.replaceSelectionWith(a).insert(s,r),c=jr.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});Kd(sh,{displayName:"Command<insertHrCommand>",group:"Hr"});var ah=Od("bulletList");Kd(ah,{displayName:"Attr<bulletList>",group:"BulletList"});var lh=Md("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ct(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(ah.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const r=t.spread??!1;e.openNode(n,{spread:r}).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()}}}));Kd(lh.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),Kd(lh.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var ch=yd(e=>Lo(/^\s*([-+*])\s$/,lh.type(e)));Kd(ch,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var dh=vd("WrapInBulletList",e=>()=>So(lh.type(e)));Kd(dh,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var uh=Ed("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(Oc);return()=>t.call(dh.key)}}});Kd(uh.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),Kd(uh.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var hh=Od("orderedList");Kd(hh,{displayName:"Attr<orderedList>",group:"OrderedList"});var ph=Md("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 Ct(e);return{spread:"true"===e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(hh.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 r=t.spread??!0;e.openNode(n,{spread:r,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:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Kd(ph.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),Kd(ph.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var fh=yd(e=>Lo(/^\s*(\d+)\.\s$/,ph.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));Kd(fh,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var mh=vd("WrapInOrderedList",e=>()=>So(ph.type(e)));Kd(mh,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var gh=Ed("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(Oc);return()=>t.call(mh.key)}}});Kd(gh.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),Kd(gh.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var vh=Od("listItem");Kd(vh,{displayName:"Attr<listItem>",group:"ListItem"});var yh=Md("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 Ct(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(vh.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 r=null!=t.label?`${t.label}.`:"•",o=null!=t.label?"ordered":"bullet",i=t.spread??!0;e.openNode(n,{label:r,listType:o,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()}}}));Kd(yh.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),Kd(yh.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var wh=vd("SinkListItem",e=>()=>{return t=yh.type(e),function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,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 r=l.lastChild&&l.lastChild.type==a.type,o=qt.from(r?t.create():null),s=new Jt(qt.from(t.create(null,qt.from(a.type.create(null,o)))),r?3:1,0),c=i.start,d=i.end;n(e.tr.step(new hr(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0};var t});Kd(wh,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var bh=vd("LiftListItem",e=>()=>$d(yh.type(e)));Kd(bh,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var xh=vd("SplitListItem",e=>()=>(t,n,r)=>{return(o=yh.type(e),function(e,t){let{$from:n,$to:r,node:i}=e.selection;if(i&&i.isBlock||n.depth<2||!n.sameParent(r))return!1;let s=n.node(-1);if(s.type!=o)return!1;if(0==n.parent.content.size&&n.node(-1).childCount==n.indexAfter(-1)){if(3==n.depth||n.node(-3).type!=o||n.index(-2)!=n.node(-2).childCount-1)return!1;if(t){let r=qt.empty,i=n.index(-1)?1:n.index(-2)?2:3;for(let e=n.depth-i;e>=n.depth-3;e--)r=qt.from(n.node(e).copy(r));let s=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;r=r.append(qt.from(o.createAndFill()));let a=n.before(n.depth-(i-1)),l=e.tr.replace(a,n.after(-s),new Jt(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(jr.near(l.doc.resolve(c))),t(l.scrollIntoView())}return!0}let a=r.pos==n.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(n.pos,r.pos),c=a?[null,{type:a}]:void 0;return!!xr(l.doc,n.pos,2,c)&&(t&&t(l.split(n.pos,2,c).scrollIntoView()),!0)})(t,n&&(e=>{const{$from:r}=t.selection;if(0===r.parent.content.size&&r.node(-1).childCount===r.indexAfter(-1)){const{$from:t}=e.selection;e.setNodeMarkup(t.before(-1),void 0,r.node(-3).attrs)}n(e)}));var o});Kd(xh,{displayName:"Command<splitListItemCommand>",group:"ListItem"});var kh=vd("LiftFirstListItem",e=>()=>function(e){return(t,n,r)=>{const{selection:o}=t;if(!(o instanceof qr))return!1;const{empty:i,$from:s}=o;return!(!i||0!==s.parentOffset)&&s.node(-1).type===yh.type(e)&&uo(t,n,r)}}(e));Kd(kh,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Ch=Ed("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(Oc);return()=>t.call(xh.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(Oc);return()=>t.call(wh.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(Oc);return()=>t.call(bh.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(Oc);return()=>t.call(kh.key)}}});Kd(Ch.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),Kd(Ch.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var Sh=bd("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)}}}));Kd(Sh,{displayName:"NodeSchema<text>",group:"Text"});var Mh=Od("html");Kd(Mh,{displayName:"Attr<html>",group:"Html"});var Nh=Md("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{const n=document.createElement("span"),r={...e.get(Mh.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,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)}}}));Kd(Nh.node,{displayName:"NodeSchema<html>",group:"Html"}),Kd(Nh.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var Eh=[yu,Eu,Ou,_u,Iu,Ru,Qu,eh,ju,Vu,Fu,Wu,rh,oh,Ju,Zu,ah,lh,hh,ph,vh,yh,Jd,Zd,tu,nu,su,au,fu,mu,Mh,Nh,Sh].flat(),Oh=[Hu,ch,fh,Uu,ih,Lu].flat(),Ah=[Xd,Qd,cu,ou],Th=vd("IsMarkSelected",()=>e=>t=>{if(!e)return!1;const{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),Dh=vd("IsNoteSelected",()=>e=>t=>!!e&&Si(t,e).hasNode),_h=vd("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr;const{$from:r,$to:o}=n.selection,{pos:i}=r,{pos:s}=o,a=i-r.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),Ih=vd("SetBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr,{from:s,to:a}=i.selection;try{i.setBlockType(s,a,r,o)}catch{return!1}return n?.(i),!0}),Rh=vd("WrapInBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;let i=t.tr;try{const{$from:e,$to:t}=i.selection,n=e.blockRange(t),s=n&&vr(n,r,o);if(!s)return!1;i=i.wrap(n,s)}catch{return!1}return n?.(i),!0}),Lh=vd("AddBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr;try{const e=r instanceof fn?r:r.createAndFill(o);if(!e)return!1;i.replaceSelectionWith(e)}catch{return!1}return n?.(i),!0}),Bh=vd("SelectTextNearPos",()=>e=>(t,n)=>{const{pos:r}=e??{};if(null==r)return!1;const o=t.tr;try{const e=t.doc.resolve((i=r,s=0,a=t.doc.content.size,Math.min(Math.max(i,s),a)));o.setSelection(qr.near(e))}catch{return!1}var i,s,a;return n?.(o.scrollIntoView()),!0}),Ph=[Au,$u,Bu,Pu,Gu,th,sh,Yu,Xu,mh,dh,wh,xh,bh,kh,Yd,lu,ru,gu,vu,Th,Dh,_h,Ih,Rh,Lh,Bh],zh=[qu,Ku,nh,zu,Ch,gh,uh,Tu,eu,du,iu].flat(),jh=Td("remarkAddOrderInList",()=>()=>e=>{ee(e,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});Kd(jh.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),Kd(jh.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var Vh=Td("remarkLineBreak",()=>()=>e=>{const t=/(?<![\t ])[\t ]*(?:\r?\n|\r)/g;ee(e,"text",(e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;const o=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&o.push({type:"text",value:e.value.slice(i,n)}),o.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return o.length>0&&r&&"number"==typeof n?(i<e.value.length&&o.push({type:"text",value:e.value.slice(i)}),r.children.splice(n,1,...o),n+o.length):void 0})});Kd(Vh.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),Kd(Vh.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var Hh=Td("remarkInlineLink",()=>Fd);Kd(Hh.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),Kd(Hh.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var $h=Td("remarkHTMLTransformer",e=>()=>t=>{const n=Cu(e);var r;r=(e,t,r)=>(e=>"html"===e.type)(e)?(r&&n.has(r.type)&&(e.children=[Wd(e)],delete e.value,e.type="paragraph"),[e]):[e],function e(t,n,o){if((e=>!!e.children)(t)){const n=[];for(let r=0,o=t.children.length;r<o;r++){const o=t.children[r];if(o){const i=e(o,r,t);if(i)for(let e=0,t=i.length;e<t;e++){const t=i[e];t&&n.push(t)}}}t.children=n}return r(t,n,o)}(t,0,null)[0]});Kd($h.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),Kd($h.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var qh=Td("remarkMarker",()=>()=>(e,t)=>{ee(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)})});Kd(qh.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),Kd(qh.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Fh=xd(()=>{let e=!1;const t=new ao("MILKDOWN_INLINE_NODES_CURSOR"),n=new oo({key:t,state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!(!(n&&r&&n.isInline&&!n.isText&&r.isInline)||r.isText)}},props:{handleDOMEvents:{compositionend:(t,r)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(n.getState(t.state)){const e=t.state.selection.from;r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e))}}),!0),compositionstart:t=>(n.getState(t.state)&&(e=!0),!1),beforeinput:(t,r)=>{if(n.getState(t.state)&&r instanceof InputEvent&&r.data&&!e){const e=t.state.selection.from;return r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(n.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),r=Ml.widget(t,n,{side:-1}),o=document.createElement("span"),i=Ml.widget(t,o);return setTimeout(()=>{n.contentEditable="true",o.contentEditable="true"}),Ol.create(e.doc,[r,i])}return Ol.empty}}});return n});Kd(Fh,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var Wh=xd(e=>new oo({key:new ao("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;const o=eh.type(e);let i;return t.forEach((e,n)=>{e.steps.forEach((e,s)=>{if(!(e instanceof ar))return;const a=(e,r)=>t.slice(n).reduce((e,t,n)=>(0===n?t.mapping.slice(s+1):t.mapping).map(e,r),e),l=a(e.from,-1),c=a(e.to,1);r.doc.nodesBetween(l,c,(e,t)=>{e.type!==o||e.attrs.isInline||e.marks.length&&(i??=r.tr,i.setNodeMarkup(t,o,e.attrs,[]))})})}),i}}));Kd(Wh,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Uh=Sd(["table","code_block"],"hardbreakFilterNodes");Kd(Uh,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Gh=xd(e=>{const t=e.get(Uh.key);return new oo({key:new ao("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const r=e.getMeta("hardbreak"),[o]=e.steps;if(r&&o instanceof ur){const e=n.doc.resolve(o.from);let r=e.depth,i=!0;for(;r>0;)t.includes(e.node(r).type.name)&&(i=!1),r--;return i}return!0}})});Kd(Gh,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var Kh=xd(e=>{const t=new ao("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const r=e.get(_u.key),o=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants((n,a)=>{if(n.type===Ru.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let l=r(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(i=!0,o.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),i&&n.dispatch(o)};return new oo({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});Kd(Kh,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Jh=xd(e=>new oo({key:new ao("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;const o=ph.type(e),i=lh.type(e),s=yh.type(e),a=(e,t,n=1)=>{let r=!1;const o=`${t+n}.`;return e.label!==o&&(e.label=o,r=!0),r};let l=r.tr,c=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===i){const n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,o,{spread:!0}),e.descendants((e,t,n,r)=>{if(e.type===s){const n={...e.attrs};a(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===o){const o={...e.attrs};let i=!1;"ordered"!==o.listType&&(o.listType="ordered",i=!0),n?.maybeChild(0)&&(i=a(o,r,n?.attrs.order??1)),i&&(l=l.setNodeMarkup(t,void 0,o),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));Kd(Jh,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var Zh=[Eh,Oh,Ah,Ph,zh,[Wh,Uh,Gh,Fh,xu,jh,Hh,Vh,$h,qh,Nu,Kh,Jh].flat()].flat(),Yh=200,Xh=function(){};Xh.prototype.append=function(e){return e.length?(e=Xh.from(e),!this.length&&e||e.length<Yh&&this.leafAppend(e)||this.length<Yh&&e.leafPrepend(this)||this.appendInner(e)):this},Xh.prototype.prepend=function(e){return e.length?Xh.from(e).append(this):this},Xh.prototype.appendInner=function(e){return new ep(this,e)},Xh.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Xh.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Xh.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Xh.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)},Xh.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Xh.from=function(e){return e instanceof Xh?e:e&&e.length?new Qh(e):Xh.empty};var Qh=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,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Yh)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Yh)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}(Xh);Xh.empty=new Qh([]);var ep=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,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&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}(Xh);class tp{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=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(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new np(e.map));let t,o=e.step.map(n.slice(r));o&&a.maybeStep(o).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new np(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new tp(this.items.slice(0,o).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,r){let o=[],i=this.eventCount,s=this.items,a=!r&&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 np(e.mapping.maps[n],c,t);(l=a&&a.merge(d))&&(d=l,n?o.pop():s=s.slice(0,s.length-1)),o.push(d),t&&(i++,t=void 0),r||(a=d)}let l=i-n.depth;return l>op&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,l),i-=l),new tp(s.append(o),i)}remapping(e,t){let n=new nr;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new tp(this.items.append(e.map(e=>new np(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let a=t;this.items.forEach(t=>{let r=o.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(a+1,r));c&&s++,n.push(new np(l,i,c))}else n.push(new np(l))},r);let l=[];for(let e=t;e<i;e++)l.push(new np(o.maps[e]));let c=this.items.slice(0,r).append(l).append(n),d=new tp(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,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;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&&o++;let l,c=new np(s.invert(),e,a),d=r.length-1;(l=r.length&&r[d].merge(c))?r[d]=l:r.push(c)}}else i.map&&n--},this.items.length,0),new tp(Xh.from(r.reverse()),o)}}tp.empty=new tp(Xh.empty,0);class np{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new np(t.getMap().invert(),t,this.selection)}}}class rp{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const op=20;function ip(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,o)=>t.push(r,o));return t}function sp(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let ap=!1,lp=null;function cp(e){let t=e.plugins;if(lp!=t){ap=!1,lp=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){ap=!0;break}}return ap}const dp=new ao("history"),up=new ao("closeHistory");function hp(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new oo({key:dp,state:{init:()=>new rp(tp.empty,tp.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(dp);if(i)return i.historyState;n.getMeta(up)&&(e=new rp(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(dp))return s.getMeta(dp).redo?new rp(e.done.addTransform(n,void 0,r,cp(t)),e.undone,ip(n.mapping.maps),e.prevTime,e.prevComposition):new rp(e.done,e.undone.addTransform(n,void 0,r,cp(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new rp(e.done.rebased(n,o),e.undone.rebased(n,o),sp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new rp(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),sp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),a=s?sp(e.prevRanges,n.mapping):ip(n.mapping.maps);return new rp(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,cp(t)),tp.empty,a,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?fp:"historyRedo"==n?mp:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function pp(e,t){return(n,r)=>{let o=dp.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=cp(t),o=dp.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),l=new rp(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(dp,{redo:n,historyState:l})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const fp=pp(!1,!0),mp=pp(!0,!0);
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{P as n,S as r,aN as o,I as i,T as s,C as a,v as l}from"./settings-6x4qNkNZ.js";import{W as c,X as d,g as u,L as h,Y as p,Z as f,E as m,G as g,_ as v,z as y,$ as w,a0 as b,a1 as x,a2 as k,a3 as C,a4 as S,a5 as M,a6 as N,a7 as E,a8 as O,a9 as A,U as T,aa as D,ab as _,ac as I,ad as R,ae as L,af as B,ag as P,ah as z,ai as j,aj as V,ak as H,Q as $,K as q,M as F}from"./basic-setup-DtpgwOSH.js";import{h as W,i as U,j as G,l as K,p as J,z as Z,m as Y,u as X,r as Q,v as ee,S as te,g as ne,d as re,c as oe,C as ie,k as se}from"./types-B-kh3Oeb.js";import ae,{useRef as le,useState as ce,useMemo as de,createContext as ue,useContext as he,useCallback as pe,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 xe,l as ke,T as Ce,ad as Se,a2 as Me,ae as Ne}from"./index-38k9tHSo.js";import{c as Ee,d as Oe}from"./commons-BLDufAOm.js";import"./enums.js";import"./constants.js";import{L as Ae,s as Te,m as De,f as _e}from"./LoaderLayer-Csc8unUJ.js";import"motion/react";import"react-dom";import"swr";import{c as Ie}from"./clsx-BeLtu-UY.js";import{c as Re,f as Le,o as Be,s as Pe,a as ze}from"./floating-ui.dom-DGDCR4EF.js";import{t as je,d as Ve}from"./throttle-tEKq3i9o.js";import{i as He,g as $e,F as qe}from"./isSymbol-D2gNAbOe.js";import{b as Fe,c as We}from"./toNumber-B6ypue5Z.js";import{i as Ue}from"./viz-BmmZnl4P.js";import{bj as Ge}from"./mermaid.core-VF3HuzPL.js";import{y as Ke}from"./websocket-D79arGLt.js";import"./index-3QSNRp1k.js";import"@ably/spaces";import"@ably/spaces/react";import"ably";import"ably/liveobjects";import"@ably/spaces/dist/mjs/react";import"./floating-ui.core-DzsaFWsC.js";import"./string-DPJhNSkw.js";const Je={}.hasOwnProperty;function Ze(e,t){let n,r=-1;if(t.extensions)for(;++r<t.extensions.length;)Ze(e,t.extensions[r]);for(n in t)if(Je.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":Ye(e[n],t[n]);break;case"handlers":Xe(e[n],t[n]);break;default:e.options[n]=t[n]}return e}function Ye(e,t){t&&e.push(...t)}function Xe(e,t){t&&Object.assign(e,t)}const Qe=[function(e,t,n,r){if("code"===t.type&&W(t,r)&&("list"===e.type||e.type===t.type&&W(e,r)))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,r)))return;return n.spread?1:0}}];const et=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],tt=[{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:et},{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:et},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:et},{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:et},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:et},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:et},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:et},{atBreak:!0,character:"~"}];function nt(e){return e.label||!e.identifier?e.label||"":G(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 ot(e,t,n,r){let o=r.join.length;for(;o--;){const i=r.join[o](e,t,n,r);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 it=/\r?\n|\r/g;function st(e,t){const n=[];let r,o=0,i=0;for(;r=it.exec(e);)s(e.slice(o,r.index)),n.push(r[0]),o=r.index+r[0].length,i++;return s(e.slice(o)),n.join("");function s(e){n.push(t(e,i,!e))}}function at(e,t){return e-t}function lt(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],o=[],i=e+t;let s,a=-1,l=0;for(;s=n.exec(i);)r.push(s.index);for(;++a<r.length;)l!==r[a]&&o.push(e.slice(l,r[a])),o.push("\\"),l=r[a];return o.push(e.slice(l)),o.join("")}function ct(e){const t=e||{},n=t.now||{};let r=t.lineShift||0,o=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 o+=n.length-1,i=1===n.length?i+s.length:1+s.length+r,t},current:function(){return{now:{line:o,column:i},lineShift:r}},shift:function(e){r+=e}}}function dt(e,t){const n={associationId:nt,containerPhrasing:ft,containerFlow:mt,createTracker:ct,compilePattern:rt,enter:function(e){return n.stack.push(e),function(){n.stack.pop()}},handlers:{...Y},handle:void 0,indentLines:st,indexStack:[],join:[...Qe],options:{},safe:gt,stack:[],unsafe:[...tt]};Ze(n,t||{}),n.options.tightDefinitions&&n.join.push(pt),n.handle=Z("type",{invalid:ut,unknown:ht,handlers:n.handlers});let r=n.handle(e,void 0,n,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return r&&10!==r.charCodeAt(r.length-1)&&13!==r.charCodeAt(r.length-1)&&(r+="\n"),r}function ut(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function ht(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function pt(e,t){if("definition"===e.type&&e.type===t.type)return 0}function ft(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=[];let s,a=-1,l=n.before;r.push(-1);let c=t.createTracker(n);for(;++a<o.length;){const d=o[a];let u;if(r[r.length-1]=a,a+1<o.length){let n=t.handle.handlers[o[a+1].type];n&&n.peek&&(n=n.peek),u=n?n(o[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 h=t.handle(d,e,t,{...c.current(),after:u,before:l});s&&s===h.slice(0,1)&&(h=K(s.charCodeAt(0))+h.slice(1));const p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,p&&(i.length>0&&p.before&&l===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+K(l.charCodeAt(0))),p.after&&(s=u)),c.move(h),i.push(h),l=h.slice(-1)}return r.pop(),i.join("")}(e,this,t)}function mt(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=t.createTracker(n),s=[];let a=-1;for(r.push(-1);++a<o.length;){const n=o[a];r[r.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<o.length-1&&s.push(i.move(ot(n,o[a+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function gt(e,t){return function(e,t,n){const r=(n.before||"")+(t||"")+(n.after||""),o=[],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(r);){const e="before"in t||Boolean(t.atBreak),n="after"in t,r=i.index+(e?i[1].length:0);o.includes(r)?(s[r].before&&!e&&(s[r].before=!1),s[r].after&&!n&&(s[r].after=!1)):(o.push(r),s[r]={before:e,after:n})}}o.sort(at);let l=n.before?n.before.length:0;const c=r.length-(n.after?n.after.length:0);for(a=-1;++a<o.length;){const e=o[a];e<l||e>=c||e+1<c&&o[a+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||o[a-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(l!==e&&i.push(lt(r.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(i.push(K(r.charCodeAt(e))),l++):i.push("\\"))}return i.push(lt(r.slice(l,c),n.after)),i.join("")}(this,e,t)}var vt=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.aiProviderError="aiProviderError",e.aiBuildContextError="aiBuildContextError",e}({}),yt=class extends Error{constructor(e,t,n){super(t,n),this.name="MilkdownError",this.code=e,void 0!==n?.cause&&(this.cause=n.cause)}},wt=(e,t)=>"function"==typeof t?"[Function]":t,bt=e=>JSON.stringify(e,wt);function xt(){return new yt(vt.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function kt(){return new yt(vt.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Ct(e){return new yt(vt.expectDomTypeError,`Expect to be a dom, but get: ${bt(e)}.`)}function St(){return new yt(vt.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 Mt(e){return new yt(vt.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function Nt(e){try{return bt(e)}catch{return"[Unserializable]"}}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 function(e){return new yt(vt.contextNotFound,`Context "${e}" not found, do you forget to inject it?`)}("string"==typeof e?e:e.name)}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)}},Ot=class{#e;#t;#n;constructor(e,t,n){this.#e=[],this.#n=()=>{this.#e.forEach(e=>e(this.#t))},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=[]}},At=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw xt()}}create(e,t=this._defaultValue){return new Ot(e,t,this)}},Tt=(e,t)=>new At(e,t),Dt=class{#r;#o;#i;#s;#a;#l;#c;constructor(e,t,n){this.#s=new Set,this.#a=new Set,this.#l=new Map,this.#c=new Map,this.read=()=>({metadata:this.#r,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.#d=e=>this.#o.get(e).get(),this.#u=e=>this.#i.get(e).status,this.#o=e,this.#i=t,this.#r=n}#d;#u},_t=class e{#o;#i;#r;#h;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#o,this.#i,{...t}):this,this.inject=(e,t)=>{const n=e.create(this.#o.sliceMap);return null!=t&&n.set(t),this.#h?.onInject(e),this},this.remove=e=>(this.#o.remove(e),this.#h?.onRemove(e),this),this.record=e=>(e.create(this.#i.store),this.#h?.onRecord(e),this),this.clearTimer=e=>(this.#i.remove(e),this.#h?.onClear(e),this),this.isInjected=e=>this.#o.has(e),this.isRecorded=e=>this.#i.has(e),this.use=e=>(this.#h?.onUse(e),this.#o.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.#h?.onDone(e)},this.wait=e=>{const t=this.timer(e).start();return this.#h?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#o=t,this.#i=n,this.#r=r,r&&(this.#h=new Dt(t,n,r))}get meta(){return this.#r}get inspector(){return this.#h}},It=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw n=e.name,new yt(vt.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{#p;#f;#m;#g;#v;constructor(e,t){this.#p=null,this.#f=null,this.#g="pending",this.#v=null,this.start=()=>(this.#p??=new Promise((e,t)=>{this.#f=t=>{t instanceof CustomEvent&&t.detail.id===this.#m&&(this.#g="resolved",this.#y(),t.stopImmediatePropagation(),e())},this.#w(()=>{"pending"===this.#g&&(this.#g="rejected"),this.#y(),t(new Error(`Timing ${this.type.name} timeout.`))}),this.#g="pending",addEventListener(this.type.name,this.#f)}),this.#p),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:this.#m}});dispatchEvent(e)},this.#y=()=>{null!==this.#v&&(clearTimeout(this.#v),this.#v=null),this.#f&&removeEventListener(this.type.name,this.#f)},this.#w=e=>{this.#v=setTimeout(()=>{this.#v=null,e()},this.type.timeout)},this.#m=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#g}#y;#w},Lt=class{constructor(e,t=3e3){this.create=e=>new Rt(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Bt=(e,t=3e3)=>new Lt(e,t);function Pt(e){const t=this;t.compiler=function(n){return dt(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function zt(e){this.content=e}function jt(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){let e=o.text,t=i.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&$t(e.charCodeAt(r-1))&&Ht(e.charCodeAt(r))&&n--,n}if(o.content.size||i.content.size){let e=jt(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function Vt(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let e=s.text,t=a.text,o=e.length,i=t.length;for(;o>0&&i>0&&e[o-1]==t[i-1];)o--,i--,n--,r--;return o&&i&&o<e.length&&$t(e.charCodeAt(o-1))&&Ht(e.charCodeAt(o))&&(n++,r++),{a:n,b:r}}if(s.content.size||a.content.size){let e=Vt(s.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}function Ht(e){return e>=56320&&e<57344}function $t(e){return e>=55296&&e<56320}zt.prototype={constructor:zt,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 r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new zt(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 zt(n)},addToStart:function(e,t){return new zt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new zt(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new zt(o)},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=zt.from(e)).size?new zt(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=zt.from(e)).size?new zt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=zt.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}},zt.from=function(e){if(e instanceof zt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new zt(t)};let qt=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,r=0,o){for(let i=0,s=0;s<t;i++){let a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),n,r+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",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?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=l},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<t.content.length;i++)o.push(t.content[i]);return new e(o,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let r=[],o=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))),r.push(s),o+=s.nodeSize),i=a}return new e(r,o)}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 r=this.content[t];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new e(o,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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return jt(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Vt(this,e,t,n)}findIndex(e){if(0==e)return Wt(0,e);if(e==this.size)return Wt(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 r=n+this.child(t).nodeSize;if(r>=e)return r==e?Wt(t+1,r):Wt(t,n);n=r}}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 e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let o=t[e];r+=o.nodeSize,e&&o.isText&&t[e-1].sameMarkup(o)?(n||(n=t.slice(0,e)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,r)}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)":""))}};qt.empty=new qt([],0);const Ft={index:0,offset:0};function Wt(e,t){return Ft.index=e,Ft.offset=t,Ft}function Ut(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(!Ut(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Ut(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Gt{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}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&&Ut(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`);return n.create(t.attrs)}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 Gt.none;if(e instanceof Gt)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Gt.none=[];class Kt extends Error{}class Jt{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=Yt(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new Jt(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Jt(Zt(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 Jt.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Jt(qt.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Jt(e,n,r)}}function Zt(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:a}=e.findIndex(n);if(o==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(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Zt(i.content,t-o-1,n-o-1)))}function Yt(e,t,n,r,o,i){let{index:s,offset:a}=e.findIndex(t),l=e.maybeChild(s);if(a==t||l.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=Yt(l.content,t-a-1,n,0==s?r-1:0,s==e.childCount-1?o-1:0,l);return c&&e.replaceChild(s,l.copy(c))}function Xt(e,t,n){if(n.openStart>e.depth)throw new Kt("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Kt("Inconsistent open depths");return Qt(e,t,n,0)}function Qt(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=Qt(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(qt.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return on(i,sn(e,o,s,t,r))}{let r=e.parent,o=r.content;return on(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return on(i,an(e,t,r))}function en(e,t){if(!t.type.compatibleContent(e.type))throw new Kt("Cannot join "+t.type.name+" onto "+e.type.name)}function tn(e,t,n){let r=e.node(n);return en(r,t.node(n)),r}function nn(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 rn(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(nn(e.nodeAfter,r),i++));for(let e=i;e<s;e++)nn(o.child(e),r);t&&t.depth==n&&t.textOffset&&nn(t.nodeBefore,r)}function on(e,t){if(!e.type.validContent(t))throw new Kt("Invalid content for node "+e.type.name);return e.copy(t)}function sn(e,t,n,r,o){let i=e.depth>o&&tn(e,t,o+1),s=r.depth>o&&tn(n,r,o+1),a=[];return rn(null,e,o,a),i&&s&&t.index(o)==n.index(o)?(en(i,s),nn(on(i,sn(e,t,n,r,o+1)),a)):(i&&nn(on(i,an(e,t,o+1)),a),rn(t,n,o,a),s&&nn(on(s,an(n,r,o+1)),a)),rn(r,null,o,a),new qt(a)}function an(e,t,n){let r=[];if(rn(null,e,n,r),e.depth>n){nn(on(tn(e,t,n+1),an(e,t,n+1)),r)}return rn(t,null,n,r),new qt(r)}Jt.empty=new Jt(qt.empty,0,0);class ln{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],r=e.child(t);return n?e.child(t).cut(n):r}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],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Gt.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].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 hn(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=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new ln(t,n,o)}static resolveCached(e,t){let n=un.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else un.set(e,n=new cn);let r=n.elts[n.i]=ln.resolve(e,t);return n.i=(n.i+1)%dn,r}}class cn{constructor(){this.elts=[],this.i=0}}const dn=12,un=new WeakMap;class hn{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 pn=Object.create(null);class fn{constructor(e,t,n,r=Gt.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||qt.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,r=0){this.content.nodesBetween(e,t,n,r,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,r){return this.content.textBetween(e,t,n,r)}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&&Ut(this.attrs,t||e.defaultAttrs||pn)&&Gt.sameSet(this.marks,n||Gt.none)}copy(e=null){return e==this.content?this:new fn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new fn(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 Jt.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new Jt(a,r.depth-i,o.depth-i)}replace(e,t,n){return Xt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+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 r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return ln.resolveCached(this,e)}resolveNoCache(e){return ln.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+")"),gn(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=qt.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.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),vn(this.type.attrs,this.attrs,"node",this.type.name);let e=Gt.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];vn(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!Gt.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 r=qt.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}fn.prototype.text=void 0;let mn=class e extends fn{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):gn(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(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,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 gn(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function vn(e,t,n,r){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}class yn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new wn(e,t);if(null==n.next)return yn.empty;let r=bn(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return n(Nn(e,0));function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);Nn(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new yn(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(Mn);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}}(function(e){let t=[[]];return o(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(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 r(t,s),o(i(e.expr,s),s),[r(s)]}if("plus"==e.type){let s=n();return o(i(e.expr,t),s),o(i(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();o(i(e.expr,s),t),s=t}if(-1==e.max)o(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();r(s,t),o(i(e.expr,s),t),s=t}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(e.exprs[r],t);if(r==e.exprs.length-1)return s;o(s,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}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 r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}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 r=[this];return function o(i,s){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return qt.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==r.indexOf(n)){r.push(n);let e=o(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 r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),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 r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}yn.empty=new yn(!0);class wn{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 bn(e){let t=[];do{t.push(xn(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function xn(e){let t=[];do{t.push(kn(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function kn(e){let t=function(e){if(e.eat("(")){let t=bn(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(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=Sn(e,t)}return t}function Cn(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function Sn(e,t){let n=Cn(e),r=n;return e.eat(",")&&(r="}"!=e.next?Cn(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Mn(e,t){return t-e}function Nn(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Mn)}function En(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function On(e,t){let n=Object.create(null);for(let r in e){let o=e[r],i=t&&t[r];if(void 0===i){if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=o.default}else o.validate&&o.validate(i);n[r]=i}return n}function An(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Dn(e,r,t[r]);return n}let Tn=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=An(e,n.attrs),this.defaultAttrs=En(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==yn.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:On(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new fn(this,this.computeAttrs(e),qt.from(t),Gt.setFrom(n))}createChecked(e=null,t,n){return t=qt.from(t),this.checkContent(t),new fn(this,this.computeAttrs(e),t,Gt.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=qt.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(qt.empty,!0);return o?new fn(this,e,t.append(o),Gt.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){}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:Gt.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,o)=>r[t]=new e(t,n,o));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let e in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class Dn{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 r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class _n{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=An(e,r.attrs),this.excluded=null;let o=En(this.attrs);this.instance=o?new Gt(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Gt(this,On(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new _n(e,r++,t,o)),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]}excludes(e){return this.excluded.indexOf(e)>-1}}class In{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=zt.from(e.nodes),t.marks=zt.from(e.marks||{}),this.nodes=Tn.compile(this.spec.nodes,this),this.marks=_n.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],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=yn.parse(r,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="_"==o?null:o?Rn(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Rn(this,n.split(" "))}this.nodeFromJSON=e=>fn.fromJSON(this,e),this.markFromJSON=e=>Gt.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Tn))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,r)}text(e,t){let n=this.nodes.text;return new mn(n,n.defaultAttrs,e,Gt.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 Rn(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Ln{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 Hn(this,t,!1);return n.addAll(e,Gt.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Hn(this,t,!0);return n.addAll(e,Gt.none,t.from,t.to),Jt.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if($n(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,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=qn(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=qn(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ln(e,Ln.schemaRules(e)))}}const Bn={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},zn={ol:!0,ul:!0};function jn(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class Vn{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=Gt.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(qt.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=qt.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(qt.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&&!Bn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Hn{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=jn(null,t.preserveWhitespace,0)|(n?4:0);r=o?new Vn(o.type,o.attrs,Gt.none,!0,t.topMatch||o.type.contentMatch,i):new Vn(n?null:e.schema.topNodeType,null,Gt.none,!0,null,i),this.nodes=[r],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,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)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=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.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 r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();zn.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&&zn.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,r=this.needsBlock;if(Bn.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.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(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?i:void 0)}this.localPreserveWS=r}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 r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,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,r){let o,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&&(o=!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(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+i)&&(r=a,o=s,!a.length))break;if(s.solid){if(n)break;i+=2}}if(!r)return null;this.sync(o);for(let e=0;e<r.length;e++)t=this.enterInner(r[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 r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Gt.none;for(let o of r.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):Fn(o.type,e.type))&&(n=o.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=jn(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=Gt.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 Vn(e,t,a,r,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 r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].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,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?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>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).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 $n(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function qn(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 r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class Wn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Gn(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Gn(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Zn(Gn(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Zn(Gn(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:Zn(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Wn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Un(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Un(e.marks)}}function Un(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Gn(e){return e.document||window.document}const Kn=new WeakMap;function Jn(e){let t=Kn.get(e);return void 0===t&&Kn.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 Zn(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Jn(r))&&o.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 o=d;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}if("string"==typeof i)l.appendChild(e.createTextNode(i));else{let{dom:t,contentDOM:o}=Zn(e,i,n,r);if(l.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:l,contentDOM:s}}const Yn=Math.pow(2,16);function Xn(e,t){return e+t*Yn}function Qn(e){return 65535&e}class er{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 tr{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&tr.empty)return tr.empty}recover(e){let t=0,n=Qn(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))/Yn}(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 r=0,o=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?r:0);if(a>e)break;let l=this.ranges[s+o],c=this.ranges[s+i],d=a+l;if(e<=d){let o=a+r+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?a:d)?null:Xn(s/3,e-a),u=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(u|=8),new er(o,u,i)}r+=c-l}return n?e+r:new er(e+r,0,null)}touches(e,t){let n=0,r=Qn(t),o=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+o];if(e<=s+a&&t==3*r)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 r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),o+=c-l}}invert(){return new tr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?tr.empty:new tr(e<0?[0,-e,0]:[0,0,e])}}tr.empty=new tr([]);class nr{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new nr(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 r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r: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 r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new nr;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 r=0;for(let n=this.from;n<this.to;n++){let o=this._maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new er(e,r,null)}}const rr=Object.create(null);class or{getMap(){return tr.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=rr[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 rr)throw new RangeError("Duplicate use of step JSON ID "+e);return rr[e]=t,t.prototype.jsonID=e,t}}class ir{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ir(e,null)}static fail(e){return new ir(null,e)}static fromReplace(e,t,n,r){try{return ir.ok(e.replace(t,n,r))}catch(e){if(e instanceof Kt)return ir.fail(e.message);throw e}}}function sr(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(sr(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return qt.fromArray(r)}class ar extends or{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),r=n.node(n.sharedDepth(this.to)),o=new Jt(sr(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return ir.fromReplace(e,this.from,this.to,o)}invert(){return new lr(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 ar(t.pos,n.pos,this.mark)}merge(e){return e instanceof ar&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ar(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 ar(t.from,t.to,e.markFromJSON(t.mark))}}or.jsonID("addMark",ar);class lr extends or{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 Jt(sr(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return ir.fromReplace(e,this.from,this.to,n)}invert(){return new ar(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 lr(t.pos,n.pos,this.mark)}merge(e){return e instanceof lr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new lr(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 lr(t.from,t.to,e.markFromJSON(t.mark))}}or.jsonID("removeMark",lr);class cr extends or{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ir.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ir.fromReplace(e,this.pos,this.pos+1,new Jt(qt.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 cr(this.pos,t.marks[n]);return new cr(this.pos,this.mark)}}return new dr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new cr(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 cr(t.pos,e.markFromJSON(t.mark))}}or.jsonID("addNodeMark",cr);class dr extends or{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ir.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ir.fromReplace(e,this.pos,this.pos+1,new Jt(qt.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new cr(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new dr(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 dr(t.pos,e.markFromJSON(t.mark))}}or.jsonID("removeNodeMark",dr);class ur extends or{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&pr(e,this.from,this.to)?ir.fail("Structure replace would overwrite content"):ir.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new tr([this.from,this.to-this.from,this.slice.size])}invert(e){return new ur(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&&ur.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new ur(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ur)||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?Jt.empty:new Jt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ur(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Jt.empty:new Jt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ur(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 ur(t.from,t.to,Jt.fromJSON(e,t.slice),!!t.structure)}}ur.MAP_BIAS=1,or.jsonID("replace",ur);class hr extends or{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(pr(e,this.from,this.gapFrom)||pr(e,this.gapTo,this.to)))return ir.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ir.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ir.fromReplace(e,this.from,this.to,n):ir.fail("Content does not fit in gap")}getMap(){return new tr([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 hr(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),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new hr(t.pos,n.pos,r,o,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 hr(t.from,t.to,t.gapFrom,t.gapTo,Jt.fromJSON(e,t.slice),t.insert,!!t.structure)}}function pr(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function fr(e,t,n,r=n.contentMatch,o=!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=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new lr(a,c,l.marks[t]));if(o&&l.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(l.text);)t||(t=new Jt(qt.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new ur(a+e.index,a+e.index+e[0].length,t))}}else s.push(new ur(a,c,Jt.empty));a=c}if(!r.validEnd){let t=r.fillBefore(qt.empty,!0);e.replace(a,a,new Jt(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function mr(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gr(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,o=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(s,a,t))return n;if(0==n||i.type.spec.isolating||!mr(i,s,a))break;s&&(r=1),a<i.childCount&&(o=1)}return null}function vr(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<o;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return i?o.map(yr).concat({type:t,attrs:n}).concat(i.map(yr)):null}function yr(e){return{type:e,attrs:null}}function wr(e,t,n,r){t.forEach((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}})}function br(e,t,n,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}})}function xr(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function kr(e,t){let n=e.resolve(t),r=n.index();return o=n.nodeBefore,i=n.nodeAfter,!(!o||!i||o.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?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}(o,i))&&n.parent.canReplace(r,r+1);var o,i}function Cr(e,t,n=t,r=Jt.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Sr(o,i,r)?new ur(t,n,r):new Mr(o,i,r).fit()}function Sr(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}or.jsonID("replaceAround",hr);class Mr{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=qt.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=qt.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,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new Jt(o,i,s);return e>-1?new hr(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new ur(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Or(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(o?a.matchType(o.type)||(l=a.fillBefore(qt.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:l};if(2==t&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Or(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new Jt(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Or(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Jt(Nr(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Jt(Nr(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[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(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let h=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(Ar(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let p=l==s.childCount;p||(h=-1),this.placed=Er(this.placed,t,qt.from(c)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Jt.empty:new Jt(Nr(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Jt(Nr(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||!Tr(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,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Tr(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Tr(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?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=Er(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Er(this.placed,this.depth,qt.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(qt.empty,!0);e.childCount&&(this.placed=Er(this.placed,this.frontier.length,e))}}function Nr(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Nr(e.firstChild.content,t-1,n)))}function Er(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Er(e.lastChild.content,t-1,n)))}function Or(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ar(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ar(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(qt.empty,!0)))),e.copy(r)}function Tr(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function Dr(e){return e.spec.defining||e.spec.definingForContent}function _r(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(_r(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(qt.empty,!0))}return e}function Ir(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class Rr extends or{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 ir.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 r=t.type.create(n,null,t.marks);return ir.fromReplace(e,this.pos,this.pos+1,new Jt(qt.from(r),0,t.isLeaf?0:1))}getMap(){return tr.empty}invert(e){return new Rr(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 Rr(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 Rr(t.pos,t.attr,t.value)}}or.jsonID("attr",Rr);class Lr extends or{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 ir.ok(n)}getMap(){return tr.empty}invert(e){return new Lr(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 Lr(t.attr,t.value)}}or.jsonID("docAttr",Lr);let Br=class extends Error{};Br=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Br.prototype=Object.create(Error.prototype)).constructor=Br,Br.prototype.name="TransformError";class Pr{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Br(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 r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,o,i)=>{e=Math.min(e,o),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=Jt.empty){let r=Cr(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Jt(qt.from(n),0,0))}delete(e,t){return this.replace(e,t,Jt.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Sr(o,i,r))return e.step(new ur(t,n,r));let s=Ir(o,i);0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=Dr(t.type);if(n&&!t.sameMarkup(o.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.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 h=o.node(c-1),p=o.index(c-1);if(h.canReplaceWith(p,p,u.type,u.marks))return e.replace(o.before(c),d?i.after(c):n,new Jt(_r(r.content,0,r.openStart,a),a,r.openEnd))}}let u=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>u));a--){let e=s[a];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Jt(qt.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&0==r.parentOffset&&0==o.parentOffset){let i=r.sharedDepth(n),s=!1;for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=o.depth;e>0&&n==o.start(e);e--)n=o.before(e);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let i=Ir(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=qt.empty,u=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=qt.from(r.node(e).copy(d)),u++):l--;let h=qt.empty,p=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,h=qt.from(o.node(e).copy(h)),p++):c++;e.step(new hr(l,c,s,a,new Jt(d.append(h),u,p),d.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);br(e,r.node(),r.before(),a)}s.inlineContent&&fr(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new ur(c,l.map(t+n,-1),Jt.empty,!0)),!0===r){let t=e.doc.resolve(c);wr(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=qt.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=qt.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new hr(o,i,o,i,new Jt(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.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 o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&br(e,t,n,i),fr(e,e.mapping.slice(i).map(n,1),r,void 0,null===o);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new hr(l,c,l+1,c-1,new Jt(qt.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===o&&wr(e,t,n,i),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||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 hr(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Jt(qt.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Rr(e,t,n)),this}setDocAttribute(e,t){return this.step(new Lr(e,t)),this}addNodeMark(e,t){return this.step(new cr(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 Gt)t.isInSet(n.marks)&&this.step(new dr(e,t));else{let r,o=n.marks,i=[];for(;r=t.isInSet(o);)i.push(new dr(e,r)),o=r.removeFromSet(o);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,r){let o=e.doc.resolve(t),i=qt.empty,s=qt.empty;for(let e=o.depth,t=o.depth-n,a=n-1;e>t;e--,a--){i=qt.from(o.node(e).copy(i));let t=r&&r[a];s=qt.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new ur(t,t,new Jt(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),u=Math.min(l+e.nodeSize,n),h=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(d[e])?o.to=u:s.push(o=new lr(c,u,d[e])));i&&i.to==c?i.to=u:a.push(i=new ar(c,u,r))}}),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,r){let o=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let a=null;if(r instanceof _n){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&l.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:l,from:Math.max(s,t),to:r,step:i})}}}),o.forEach(t=>e.step(new lr(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return fr(this,e,t,n),this}}const zr=Object.create(null);class jr{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Vr(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=Jt.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=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(o);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Jt.empty:t),0==s&&Zr(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);o?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Zr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new qr(e):Jr(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?Jr(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Jr(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Gr(e.node(0))}static atStart(e){return Jr(e,e,0,0,1)||new Gr(e)}static atEnd(e){return Jr(e,e,e.content.size,e.childCount,-1)||new Gr(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=zr[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 zr)throw new RangeError("Duplicate use of selection JSON ID "+e);return zr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return qr.between(this.$anchor,this.$head).getBookmark()}}jr.prototype.visible=!0;class Vr{constructor(e,t){this.$from=e,this.$to=t}}let Hr=!1;function $r(e){Hr||e.parent.inlineContent||(Hr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class qr extends jr{constructor(e,t=e){$r(e),$r(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 jr.near(n);let r=e.resolve(t.map(this.anchor));return new qr(r.parent.inlineContent?r:n,n)}replace(e,t=Jt.empty){if(super.replace(e,t),t==Jt.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof qr&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Fr(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 qr(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=jr.findFrom(t,n,!0)||jr.findFrom(t,-n,!0);if(!e)return jr.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(jr.findFrom(e,-n,!0)||jr.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new qr(e,t)}}jr.jsonID("text",qr);class Fr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Fr(e.map(this.anchor),e.map(this.head))}resolve(e){return qr.between(e.resolve(this.anchor),e.resolve(this.head))}}class Wr extends jr{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:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?jr.near(o):new Wr(o)}content(){return new Jt(qt.from(this.node),0,0)}eq(e){return e instanceof Wr&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ur(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Wr(e.resolve(t.anchor))}static create(e,t){return new Wr(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Wr.prototype.visible=!1,jr.jsonID("node",Wr);class Ur{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Fr(n,n):new Ur(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Wr.isSelectable(n)?new Wr(t):jr.near(t)}}class Gr extends jr{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Jt.empty){if(t==Jt.empty){e.delete(0,e.doc.content.size);let t=jr.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Gr(e)}map(e){return new Gr(e)}eq(e){return e instanceof Gr}getBookmark(){return Kr}}jr.jsonID("all",Gr);const Kr={map(){return this},resolve:e=>new Gr(e)};function Jr(e,t,n,r,o,i=!1){if(t.inlineContent)return qr.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Wr.isSelectable(r))return Wr.create(e,n-(o<0?r.nodeSize:0))}else{let t=Jr(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Zr(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof ur||i instanceof hr)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==o&&(o=r)}),e.setSelection(jr.near(e.doc.resolve(o),n)))}class Yr extends Pr{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 Gt.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)||Gt.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(jr.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 Xr(e,t){return t&&e?e.bind(t):e}class Qr{constructor(e,t,n){this.name=e,this.init=Xr(t.init,n),this.apply=Xr(t.apply,n)}}const eo=[new Qr("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Qr("selection",{init:(e,t)=>e.selection||jr.atStart(t.doc),apply:e=>e.selection}),new Qr("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Qr("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class to{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=eo.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 Qr(e.key,e.spec.state,e))})}}class no{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),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[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),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new no(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Yr(this)}static create(e){let t=new to(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new no(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new to(this.schema,e.plugins),n=t.fields,r=new no(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}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 r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.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 r=new to(e.schema,e.plugins),o=new no(r);return r.fields.forEach(r=>{if("doc"==r.name)o.doc=fn.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=jr.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.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==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=a.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}}),o}}function ro(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=ro(o,t,{})),n[r]=o}return n}class oo{constructor(e){this.spec=e,this.props={},e.props&&ro(e.props,this,this.props),this.key=e.key?e.key.key:so("plugin")}getState(e){return e[this.key]}}const io=Object.create(null);function so(e){return e in io?e+"$"+ ++io[e]:(io[e]=0,e+"$")}class ao{constructor(e="key"){this.key=so(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const lo=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function co(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const uo=(e,t,n)=>{let r=co(e,n);if(!r)return!1;let o=mo(r);if(!o){let n=r.blockRange(),o=n&&gr(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(bo(e,o,t,-1))return!0;if(0==r.parent.content.size&&(po(i,"end")||Wr.isSelectable(i)))for(let n=r.depth;;n--){let s=Cr(e.doc,r.before(n),r.after(n),Jt.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(po(i,"end")?jr.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Wr.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0)},ho=(e,t,n)=>{let r=co(e,n);if(!r)return!1;let o=mo(r);return!!o&&function(e,t,n){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=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=Cr(e.doc,i,l,Jt.empty);if(!c||c.from!=i||c instanceof ur&&c.slice.size>=l-i)return!1;if(n){let t=e.tr.step(c);t.setSelection(qr.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,o,t)};function po(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const fo=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=mo(r)}let s=i&&i.nodeBefore;return!(!s||!Wr.isSelectable(s))&&(t&&t(e.tr.setSelection(Wr.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function mo(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 go(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 vo(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 yo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=vo(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(jr.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0};const wo=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Wr&&e.selection.node.isBlock)return!(!n.parentOffset||!xr(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let o,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=vo(n.node(e-1).contentMatchAt(n.indexAfter(e-1))),s.unshift(a&&i?{type:i}:null),o=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof qr||e.selection instanceof Gr)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=xr(c.doc,d,s.length,s);if(u||(s[0]=i?{type:i}:null,u=xr(c.doc,d,s.length,s)),!u)return!1;if(c.split(d,s.length,s),!a&&l&&n.node(o).type!=i){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);i&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(o)),i)}return t&&t(c.scrollIntoView()),!0};function bo(e,t,n,r){let o,i,s=t.nodeBefore,a=t.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!kr(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&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,i=qt.empty;for(let e=o.length-1;e>=0;e--)i=qt.from(o[e].create(null,i));i=qt.from(s.copy(i));let l=e.tr.step(new hr(t.pos-1,r,t.pos,r,new Jt(i,1,0),o.length,!0)),c=l.doc.resolve(r+2*o.length);c.nodeAfter&&c.nodeAfter.type==s.type&&kr(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:jr.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),h=u&&gr(u);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(u,h).scrollIntoView()),!0;if(c&&po(a,"start",!0)&&po(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=qt.empty;for(let e=o.length-1;e>=0;e--)r=qt.from(o[e].copy(r));n(e.tr.step(new hr(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new Jt(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function xo(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(qr.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const ko=xo(-1),Co=xo(1);function So(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&vr(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function Mo(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function No(e,t=null,n){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!function(e,t,n){for(let r=0;r<t.length;r++){let{$from:o,$to:i}=t[r],s=0==o.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(o.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(r)if(i)e.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{let o,i=n.tr;o=!s.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e));for(let n=0;n<s.length;n++){let{$from:r,$to:a}=s[n];if(o){let n=r.pos,o=a.pos,s=r.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<o&&(n+=c,o-=d),i.addMark(n,o,e.create(t))}else i.removeMark(r.pos,a.pos,e)}r(i.scrollIntoView())}return!0}}function Eo(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let Oo=Eo(lo,uo,fo),Ao=Eo(lo,(e,t,n)=>{let r=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(!r)return!1;let o=go(r);if(!o)return!1;let i=o.nodeAfter;if(bo(e,o,t,1))return!0;if(0==r.parent.content.size&&(po(i,"start")||Wr.isSelectable(i))){let n=Cr(e.doc,r.before(),r.after(),Jt.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(po(i,"start")?jr.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Wr.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=go(r)}let s=i&&i.nodeAfter;return!(!s||!Wr.isSelectable(s))&&(t&&t(e.tr.setSelection(Wr.create(e.doc,i.pos)).scrollIntoView()),!0)});const To={Enter:Eo((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Gr||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=vo(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(qr.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 r=n.before();if(xr(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&gr(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)},wo),"Mod-Enter":yo,Backspace:Oo,"Mod-Backspace":Oo,"Shift-Backspace":Oo,Delete:Ao,"Mod-Delete":Ao,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Gr(e.doc))),!0)},Do={"Ctrl-h":To.Backspace,"Alt-Backspace":To["Mod-Backspace"],"Ctrl-d":To.Delete,"Ctrl-Alt-Backspace":To["Mod-Delete"],"Alt-Delete":To["Mod-Delete"],"Alt-d":To["Mod-Delete"],"Ctrl-a":ko,"Ctrl-e":Co};for(let e in To)Do[e]=To[e];const _o=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?Do:To;class Io{constructor(e,t,n={}){var r;this.match=e,this.match=e,this.handler="string"==typeof t?(r=t,function(e,t,n,o){let i=r;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let r=(n+=e)-o;r>0&&(i=t[0].slice(e-r,e)+i,n=o)}return e.tr.insertText(i,n,o)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const Ro=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function Lo(e,t,n=null,r){return new Io(e,(e,o,i,s)=>{let a=n instanceof Function?n(o):n,l=e.tr.delete(i,s),c=l.doc.resolve(i).blockRange(),d=c&&vr(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(i-1).nodeBefore;return u&&u.type==t&&kr(l.doc,i-1)&&(!r||r(o,u))&&l.join(i-1),l})}function Bo(e,t,n=null){return new Io(e,(e,r,o,i)=>{let s=e.doc.resolve(o),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,a):null})}new Io(/--$/,"—",{inCodeMark:!1}),new Io(/\.\.\.$/,"…",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new Io(/"$/,"”",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new Io(/'$/,"’",{inCodeMark:!1});const Po="undefined"!=typeof navigator?navigator:null,zo="undefined"!=typeof document?document:null,jo=Po&&Po.userAgent||"",Vo=/Edge\/(\d+)/.exec(jo),Ho=/MSIE \d/.exec(jo),$o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(jo),qo=!!(Ho||$o||Vo),Fo=Ho?document.documentMode:$o?+$o[1]:Vo?+Vo[1]:0,Wo=!qo&&/gecko\/(\d+)/i.test(jo),Uo=Wo&&+(/Firefox\/(\d+)/.exec(jo)||[0,0])[1],Go=!qo&&/Chrome\/(\d+)/.exec(jo),Ko=!!Go,Jo=Go?+Go[1]:0,Zo=!qo&&!!Po&&/Apple Computer/.test(Po.vendor),Yo=Zo&&(/Mobile\/\w+/.test(jo)||!!Po&&Po.maxTouchPoints>2),Xo=Yo||!!Po&&/Mac/.test(Po.platform),Qo=/Android \d/.test(jo),ei=!!zo&&"webkitFontSmoothing"in zo.documentElement.style,ti=ei?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var ni=Object.freeze({__proto__:null,android:Qo,chrome:Ko,chrome_version:Jo,gecko:Wo,gecko_version:Uo,ie:qo,ie_version:Fo,ios:Yo,mac:Xo,safari:Zo,webkit:ei,webkit_version:ti});function ri(e,t,n,r,o,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,"")+r;for(let a of o){const o=a,c=o.match.exec(l),d=c&&c[0]&&o.handler(s,c,t-(c[0].length-r.length),n);if(d)return!1!==o.undoable&&d.setMeta(i,{transform:d,from:t,to:n,text:r}),e.dispatch(d),!0}return!1}const oi=new ao("MILKDOWN_CUSTOM_INPUTRULES");function ii({rules:e}){const t=new oo({key:oi,isInputRules:!0,state:{init:()=>null,apply(e,t){const n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>ri(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&ri(n,r.pos,r.pos,"",e,t)}),!1),keydown:(e,t)=>!(!Qo||!Ko||"Enter"!==t.key)&&(!e.composing&&(!!e.someProp("handleKeyDown",n=>n(e,t))&&(t.preventDefault(),!0)))},handleKeyDown(n,r){if("Enter"!==r.key)return!1;const{$cursor:o}=n.state.selection;return!!o&&ri(n,o.pos,o.pos,"\n",e,t)}}});return t}function si(e){return e.some(e=>e.type.spec.code)}function ai(e,t,n){if(t>=n)return!1;let r=!1;return e.doc.nodesBetween(t,n,e=>(e.isInline&&si(e.marks)&&(r=!0),!r)),r}function li(e,t,n={}){return new Io(e,(e,r,o,i)=>{var s,a,l,c;const{tr:d}=e;let u,h=r[r.length-1],p=r[0],f=[];const m={group:h,fullMatch:p,start:o,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:h,fullMatch:p,start:o,end:i}=m),null===p)return null;if(""===(null==h?void 0:h.trim()))return null;if(h){const s=p.search(/\S/),m=o+p.indexOf(h),g=m+h.length,v=ai(e,o+s,m),y=g<i&&ai(e,g,i);if(v||y||function(e,t){var n;return si(null!=(n=e.storedMarks)?n:e.doc.resolve(t).marks())}(e,i))return null;f=null!=(a=d.storedMarks)?a:[],g<i&&d.delete(g,i),m>o&&d.delete(o+s,m),u=o+s+h.length;const w=null==(l=n.getAttr)?void 0:l.call(n,r);d.addMark(o,u,t.create(w)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:o,end:i,tr:d})}return d})}var ci=Object.defineProperty,di=Object.defineProperties,ui=Object.getOwnPropertyDescriptors,hi=Object.getOwnPropertySymbols,pi=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,mi=(e,t,n)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function gi(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function vi(e,t,n){const r=e.state.doc.content.size,o=gi(t,0,r),i=gi(n,0,r),s=e.coordsAtPos(o),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),h={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return p=((e,t)=>{for(var n in t||(t={}))pi.call(t,n)&&mi(e,n,t[n]);if(hi)for(var n of hi(t))fi.call(t,n)&&mi(e,n,t[n]);return e})({},h),di(p,ui({toJSON:()=>h}));var p}function yi(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function wi(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 bi(e){return t=>{for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r)){return{from:t.before(n),to:t.after(n),node:r}}}}}function xi(e,t){const n=t.nodes[e];if(!n)throw function(e,t){return new yt(vt.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}("node",e);return n}function ki(e){return t=>{for(let n=t.depth;n>0;n--){const r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function Ci(e,t){if(!(e instanceof Wr))return;const{node:n,$from:r}=e;return function(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}(t,n)?{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}:void 0}const Si=(e,t)=>{const{selection:n,doc:r}=e;if(n instanceof Wr)return{hasNode:n.node.type===t,pos:n.from,target:n.node};const{from:o,to:i}=n;let s=!1,a=-1,l=null;return r.nodesBetween(o,i,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}},Mi="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ni="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function Ei(e){let t,n,r,o,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))o=!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))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);Mi?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Oi(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 Ai(e){return new oo({props:{handleKeyDown:Ti(e)}})}function Ti(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Ei(n)]=e[n];return t}(e);return function(e,n){let r,o=c(n),i=t[Oi(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=t[Oi(o,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ni&&n.ctrlKey&&n.altKey)&&(r=d[n.keyCode])&&r!=o){let o=t[Oi(r,n)];if(o&&o(e.state,e.dispatch,e))return!0}}return!1}}var Di=class{},_i=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 kt();return e}}},Ii=class e extends Di{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,r){return new e(t,n,r)}},Ri=class extends _i{#b;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.#b=Gt.none,this.#x=e=>e.isText,this.#k=(e,t)=>{if(this.#x(e)&&this.#x(t)&&Gt.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)},this.#C=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 yt(vt.parserMatchError,`Cannot match target parser for node: ${bt(e)}.`)}(e);return t},this.#S=e=>{const t=this.#C(e);t.spec.parseMarkdown.runner(this,e,t)},this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Ii.create(e,[],t)),this),this.#M=()=>{this.#b=Gt.none;const e=this.close();return this.#N(e.type,e.attrs,e.content)},this.closeNode=()=>{try{this.#M()}catch(e){console.error(e)}return this},this.#N=(e,t,n)=>{const r=e.createAndFill(t,n,this.#b);if(!r)throw function(e,t,n){const r=`Cannot create node for ${"name"in e?e.name:e}`,o=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(o).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]",r],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:o(e):"null")]].reduce((e,[t,n])=>{const r=`${t}: ${o(n)}.`;return e.concat(r)},[]);return new yt(vt.createNodeInParserFail,i.join("\n"))}(e,t,n);return this.push(r),r},this.addNode=(e,t,n)=>{try{this.#N(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>{const n=e.create(t);return this.#b=n.addToSet(this.#b),this},this.closeMark=e=>(this.#b=e.removeFromSet(this.#b),this),this.addText=e=>{try{const t=this.top();if(!t)throw kt();const n=t.pop(),r=this.schema.text(e,this.#b);if(!n)return t.push(r),this;const o=this.#k(n,r);return o?(t.push(o),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do{e=this.#M()}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#S(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}#x;#k;#C;#S;#M;#N},Li=class e extends Di{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,o={})=>new e(t,n,r,o)}},Bi=class extends _i{#E;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.#E=[],this.#C=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 yt(vt.serializerMatchError,`Cannot match target serializer for node: ${bt(e)}.`)}(e.type);return t},this.#O=e=>this.#C(e).spec.toMarkdown.runner(this,e),this.#A=(e,t)=>this.#C(e).spec.toMarkdown.runner(this,e,t),this.#T=e=>{const t=e=>e.type.spec.priority??50,n=[...e].sort((e,n)=>t(e)-t(n)),r=[];return this.#E.forEach(({mark:e})=>{const t=n.findIndex(t=>t.eq(e));t>=0&&r.push(...n.splice(t,1))}),r.concat(n)},this.#D=e=>{const t=e?.marks;let n=0;for(;n<this.#E.length;){const{mark:e,spanning:r}=this.#E[n];if(!r||!t?.some(t=>t.eq(e)))break;n++}for(let e=this.#E.length-1;e>=n;e--)this.#_(this.#E[e].mark)},this.#S=(e,t)=>{this.#T(e.marks).every(t=>!this.#A(t,e))&&this.#O(e),this.#D(t)},this.#I=e=>{const{children:t}=e;return t?(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];const r=e.at(-1);if(r&&r.isMark&&t.isMark){const{children:n,...o}=t,{children:i,...s}=r;if(t.type===r.type&&n&&i&&JSON.stringify(o)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(this.#I(t))}}return e.concat(t)},[]),e):e},this.#R=e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t},this.openNode=(e,t,n)=>(this.open(Li.create(e,void 0,t,n)),this),this.#L=(e,t)=>{let n="",r="";const o=e.children;if(o){const e=o[0],t=o.at(-1);if(t&&"text"===t.type&&t.value.endsWith(" ")){const e=t.value,n=e.trimEnd();r=e.slice(n.length),t.value=n}if(e&&"text"===e.type&&e.value.startsWith(" ")){const t=e.value,r=t.trimStart();n=t.slice(0,t.length-r.length),e.value=r}}n.length&&this.#N("text",void 0,n);const i=t();return r.length&&this.#N("text",void 0,r),i},this.#M=(e=!1)=>{const t=this.close(),n=()=>this.#N(t.type,t.children,t.value,t.props);return e?this.#L(t,n):n()},this.closeNode=()=>(this.#M(),this),this.#N=(e,t,n,r)=>{const o=Li.create(e,t,n,r),i=this.#I(this.#R(o));return this.push(i),i},this.addNode=(e,t,n,r)=>(this.#N(e,t,n,r),this),this.#B=(e,t,n,r)=>this.#E.some(t=>t.mark.eq(e))?this:(this.#E.push({mark:e,spanning:null==n}),this.openNode(t,n,{...r,isMark:!0})),this.#_=e=>{let t=-1;for(let n=this.#E.length-1;n>=0;n--)if(this.#E[n].mark.eq(e)){t=n;break}t<0||(this.#E.splice(t,1),this.#M(!0))},this.withMark=(e,t,n,r)=>(this.#B(e,t,n,r),this),this.closeMark=e=>(this.#_(e),this),this.build=()=>{let e=null;do{e=this.#M()}while(this.size());return e.children||(e.children=[]),e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach((t,n,r)=>{this.#S(t,e.maybeChild(r+1)??void 0)}),this):(this.#S(e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.#E=[],this.next(e),this),this.schema=e}#C;#O;#A;#T;#D;#S;#I;#R;#L;#M;#N;#B;#_};const Pi=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},zi=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let ji=null;const Vi=function(e,t,n){let r=ji||(ji=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},Hi=function(e,t,n,r){return n&&(qi(e,t,n,r,-1)||qi(e,t,n,r,1))},$i=/^(img|br|input|textarea|hr)$/i;function qi(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Fi(e))){let n=e.parentNode;if(!n||!Wi(n)||Ki(e)||$i.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Pi(e)+(o<0?0:1),e=n}else{if(!Wi(e))return!1;{let n=e.childNodes[t+(o<0?-1:0)];if(Wi(n)&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=n,t=o<0?Fi(e):0}}}}function Fi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Wi(e){return 1==e.nodeType}function Ui(e){return 3==e.nodeType}function Gi(e,t){return!!t&&e.contains(Wi(t)?t:t.parentNode)}function Ki(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 Ji=function(e){return e.focusNode&&Hi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};const Zi="undefined"!=typeof navigator?navigator:null,Yi="undefined"!=typeof document?document:null,Xi=Zi&&Zi.userAgent||"",Qi=/Edge\/(\d+)/.exec(Xi),es=/MSIE \d/.exec(Xi),ts=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xi),ns=!!(es||ts||Qi),rs=es?document.documentMode:ts?+ts[1]:Qi?+Qi[1]:0,is=!ns&&/gecko\/(\d+)/i.test(Xi);is&&(/Firefox\/(\d+)/.exec(Xi)||[0,0])[1];const ss=!ns&&/Chrome\/(\d+)/.exec(Xi),as=!!ss,ls=ss?+ss[1]:0,cs=!ns&&!!Zi&&/Apple Computer/.test(Zi.vendor),ds=cs&&(/Mobile\/\w+/.test(Xi)||!!Zi&&Zi.maxTouchPoints>2),us=ds||!!Zi&&/Mac/.test(Zi.platform),hs=!!Zi&&/Win/.test(Zi.platform),ps=/Android \d/.test(Xi),fs=!!Yi&&"webkitFontSmoothing"in Yi.documentElement.style,ms=fs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function gs(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 vs(e,t){return"number"==typeof e?e:e[t]}function ys(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function ws(e,t,n){if(!Es(t)&&0==t.left)return;let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(!Wi(s)){s=zi(s);continue}let e=s==i.body,n=e?gs(i):ys(s),a=0,l=0;if(t.top<n.top+vs(r,"top")?l=-(n.top-t.top+vs(o,"top")):t.bottom>n.bottom-vs(r,"bottom")&&(l=t.bottom-t.top>n.bottom-n.top?t.top+vs(o,"top")-n.top:t.bottom-n.bottom+vs(o,"bottom")),t.left<n.left+vs(r,"left")?a=-(n.left-t.left+vs(o,"left")):t.right>n.right-vs(r,"right")&&(a=t.right-n.right+vs(o,"right")),a||l)if(e)i.defaultView.scrollBy(a,l);else{let e=s.scrollLeft,n=s.scrollTop;l&&(s.scrollTop+=l),a&&(s.scrollLeft+=a);let r=s.scrollLeft-e,o=s.scrollTop-n;t={left:t.left-r,top:t.top-o,right:t.right-r,bottom:t.bottom-o}}let c=e?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(c))break;s="absolute"==c?s.offsetParent:zi(s)}}function bs(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=zi(r));return t}function xs(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ks=null;function Cs(e,t){let n,r,o,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(Wi(d))e=d.getClientRects();else{if(!Ui(d))continue;e=Vi(d).getClientRects()}for(let h=0;h<e.length;h++){let p=e[h];if(p.top<=l&&p.bottom>=c){l=Math.max(p.bottom,l),c=Math.min(p.top,c);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=d,s=e,r=e&&Ui(n)?{left:p.right<t.left?p.right:p.left,top:t.top}:t,Wi(d)&&e&&(a=u+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=d,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=u+1)}}return!n&&o&&(n=o,r=i,s=0),n&&Ui(n)?function(e,t){let n,r=e.nodeValue.length,o=document.createRange();for(let i=0;i<r;i++){o.setEnd(e,i+1),o.setStart(e,i);let r=Os(o,1);if(r.top!=r.bottom&&Ss(t,r)){n={node:e,offset:i+(t.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),n||{node:e,offset:0}}(n,r):!n||s?{node:e,offset:a}:Cs(n,r)}function Ss(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ms(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(Wi(n)){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(Ss(t,o))return Ms(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function Ns(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Fi(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Fi(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(a)){let n=e.dom.getBoundingClientRect();if(!Ss(t,n))return null;if(a=Ms(e.dom,t,n),!a)return null}if(cs)for(let e=a;n&&e;e=zi(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(is&&Wi(n)&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;fs&&o&&Wi(n)&&Wi(r=n.childNodes[o-1])&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&Wi(n.lastChild)&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&Wi(n)&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(Wi(s.dom)&&(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>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=Cs(t,n),i=-1;if(Wi(r)&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function Es(e){return e.top<e.bottom||e.left<e.right}function Os(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Es(e))return e}return Array.prototype.find.call(n,Es)||e.getBoundingClientRect()}const As=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ts(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=fs||is;if(Ui(r)){if(!s||!As.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,Ds(Os(Vi(r,e,t),i),i<0)}{let e=Os(Vi(r,o,o),n);if(is&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Os(Vi(r,o-1,o-1),-1);if(t.top==e.top){let n=Os(Vi(r,o,o+1),-1);if(n.top!=e.top)return Ds(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==Fi(r))){let e=r.childNodes[o-1];if(Wi(e))return _s(e.getBoundingClientRect(),!1)}if(null==i&&o<Fi(r)){let e=r.childNodes[o];if(Wi(e))return _s(e.getBoundingClientRect(),!0)}return _s(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==Fi(r))){let e=r.childNodes[o-1],t=Ui(e)?Vi(e,Fi(e)-(s?0:1)):!Wi(e)||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ds(Os(t,1),!1)}if(null==i&&o<Fi(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?Ui(e)?Vi(e,0,s?0:1):Wi(e)?e:null:null;if(t)return Ds(Os(t,-1),!0)}return Ds(Os(Ui(r)?Vi(r):r,-n),n>=0)}function Ds(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 _s(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 Is(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Rs=/[\u0590-\u08ac]/;let Ls=null,Bs=null,Ps=!1;function zs(e,t,n){return Ls==t&&Bs==n?Ps:(Ls=t,Bs=n,Ps="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Is(e,t,()=>{let{node:t}=e.docView.domFromPos(o.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 r=Ts(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(Wi(e))t=e.getClientRects();else{if(!Ui(e))continue;t=Vi(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.domSelection();return a?Rs.test(r.parent.textContent)&&a.modify?Is(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!Gi(c,d)||t==d&&o==u;try{a.collapse(i,s),t&&(t!=i||o!=s)&&a.extend&&a.extend(t,o)}catch(e){}return null!=l&&(a.caretBidiLevel=l),h}):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class js{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,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(e){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 r=this.children[t];if(r==e)return n;n+=r.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&&Gi(this.contentDOM,e)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Pi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=16&n?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(4&n)}else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(Wi(o)?Gi(o,e):o==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 r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=t+this.children[n].size;if(o>e){r=e-t;break}t=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof Us||e instanceof Vs&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Pi(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Pi(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 r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);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)){r=Pi(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-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)){o=Pi(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}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(!Wi(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=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(o>a&&i<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);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((is||cs)&&e==t){let{node:e,offset:t}=s;if(Ui(e)){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:Pi(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(is&&c.focusNode&&c.focusNode!=a.node&&Wi(c.focusNode)){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&cs)&&Hi(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Hi(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!d||!is)){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,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.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 Vs extends js{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!t.type.spec.raw){let e=Wi(i)?i:document.createElement("span");e!=i&&(e.appendChild(i),i=e),e.hasAttribute("contenteditable")||(e.contentEditable="false"),e.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=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 Hs extends js{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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 $s extends js{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=Wn.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new $s(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 r=$s.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=ia(o,t,i,n)),e>0&&(o=ia(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class qs extends js{constructor(e,t,n,r,o,i,s){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,a=o.nodeViews[t.type.name],l=a&&a(t,o,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(!Ui(c))throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Wn.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=ea(c,n,t),l?s=new Gs(e,t,n,r,c,d||null,u,l):t.isText?new Ws(e,t,n,r,c,u):new qs(e,t,n,r,c,d||null,u)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>Wi(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>qt.empty}}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ta(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,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new ra(this,i&&i.node,e),l=this.node.inlineContent,c=l&&this.node.isBlock;!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,h,p;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(oa);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)p=-1,h=l,l=null;else{if(!(c<e.childCount))break;p=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=h.cut(e-i),h=h.cut(0,e-i),f=e,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(h,h.isInline&&!h.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(i,h),p),i=f}}(this.node,this.innerDeco,(t,o,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,o):t.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?Gt.none:this.node.child(o).marks,n,e,o),a.placeWidget(t,e,r)},(t,i,d,u)=>{let h;a.syncToMarks(t.marks,n,e,u),c&&t.isAtom&&!t.isText&&a.addHackNode("IMG",a.top),a.findNodeMatch(t,i,d,u)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,i,d,h,e)||a.updateNextNode(t,i,d,e,u,r)||a.addNode(t,i,d,e,r),r+=t.nodeSize,l&&(c=t.isAtom&&!t.isText)}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Ks(this.contentDOM,this.children,e),ds&&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:r}=e.state.selection;if(!(e.state.selection instanceof qr)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Hs(this,o,t,r);e.input.compositionNodes.push(i),this.children=ia(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ta(e,this.outerDeco))return;let t=!Wi(this.nodeDOM),n=this.dom;this.dom=Xs(this.dom,this.nodeDOM,Ys(this.outerDeco,this.node,t),Ys(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){Wi(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){Wi(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Fs(e,t,n,r,o){ea(r,t,e);let i=new qs(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}class Ws extends qs{constructor(e,t,n,r,o,i){super(e,t,n,r,o,null,i)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){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,r.trackWrites==this.nodeDOM&&(r.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 r=this.node.cut(e,t),o=document.createTextNode(r.text);return new Ws(this.parent,r,this.outerDeco,this.innerDeco,o,o)}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 Us extends js{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 Gs extends qs{constructor(e,t,n,r,o,i,s,a){super(e,t,n,r,o,i,s),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}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 Ks(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=na(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(a,r);if(s instanceof $s){let t=r?r.previousSibling:e.lastChild;Ks(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=na(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const Js=function(e){e&&(this.nodeName=e)};Js.prototype=Object.create(null);const Zs=[new Js];function Ys(e,t,n){if(0==e.length)return Zs;let r=n?Zs[0]:new Js,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Js(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new Js(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Xs(e,t,n,r){if(n==Zs&&r==Zs)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=Zs[0]),o=t}Qs(o,s||Zs[0],i)}return o}function Qs(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ea(e,t,n){return Xs(e,e,Zs,Ys(t,n,!Wi(e)))}function ta(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 na(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class ra{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,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof $s)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,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,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<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 o=-1,s=this.top.children.length;r<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)){o=t;break}}if(o<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof $s&&3!=t.dirty&&t.mark.type==e[i].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[i])&&(t.mark=e[i],o=this.index,this.changed=!0)}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let r=$s.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),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,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof qs){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)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&&ta(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(a,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ta(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=qs.create(this.top,t,n,r,o,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,r,o){let i=qs.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Vs(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof $s;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ws)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((cs||as)&&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 r=new Us(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||Wi(e)&&e.contains(this.lock.parentNode))}}function oa(e,t){return e.type.side-t.type.side}function ia(e,t,n,r,o){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,r)),o&&(i.push(o),o=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function sa(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(Ji(n)){for(a=s;o&&!o.node;)o=o.parent;if(!(o&&o.node.isAtom&&Wr.isSelectable(o.node)&&o.parent)||o.node.isInline&&function(e,t,n){for(let r=0==t,o=t==Fi(e);r||o;){if(e==n)return!0;let t=Pi(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Fi(e)}}(n.focusNode,n.focusOffset,o.dom)){if(is&&"key"==t&&s>e.state.selection.to&&Wi(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&o&&o.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if("visible"!=getComputedStyle(e).overflow){l=jr.findFrom(r.resolve(o.posAtStart),1);break}if(e==o.dom||e.nextSibling||!e.parentNode||!Wi(e.parentNode))break}}else{let e=o.posBefore;l=new Wr(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[a,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!l){l=ma(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return l}function aa(e){return e.editable?e.hasFocus():va(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function la(e,t=!1){let n=e.state.selection;if(pa(e,n),!aa(e))return;let r=e.input.mouseDown;if(!t&&as&&r){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Hi(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)&&r.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Pi(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&ns&&rs<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!ca||n instanceof qr||(n.$from.parent.inlineContent||(r=da(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=da(e,n.to))),e.docView.setSelection(i,s,e,t),ca&&(r&&ha(r),o&&ha(o)),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(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{aa(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}const ca=cs||as&&ls<63;function da(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(cs&&o&&"false"==o.contentEditable)return ua(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return ua(o);if(i)return ua(i)}}function ua(e){return e.contentEditable="true",cs&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ha(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function pa(e,t){if(t instanceof Wr){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(fa(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else fa(e)}function fa(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function ma(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||qr.between(t,n,r)}function ga(e){return!(e.editable&&!e.hasFocus())&&va(e)}function va(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Gi(e.dom,t.anchorNode)&&(e.editable||Gi(e.dom,t.focusNode))}catch(e){return!1}}function ya(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&jr.findFrom(i,t)}function wa(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ba(e,t,n){let r=e.state.selection;if(!(r instanceof qr)){if(r instanceof Wr&&r.node.isInline)return wa(e,new qr(t>0?r.$to:r.$from));{let n=ya(e.state,t);return!!n&&wa(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return wa(e,new qr(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=ya(e.state,t);return!!(n&&n instanceof Wr)&&wa(e,n)}if(!us||n.indexOf("m")<0){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Wr.isSelectable(i)?wa(e,new Wr(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):wa(e,new qr(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function xa(e,t){let n=e.pmViewDesc;return n?0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName):Wi(e)&&"false"==e.contentEditable}function ka(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;is&&Wi(n)&&r<Fi(n)&&xa(n.childNodes[r],-1)&&(s=!0);for(;;)if(r>0){if(!Wi(n))break;let e=n.childNodes[r-1];if(xa(e,-1))o=n,i=--r;else{if(!Ui(e))break;n=e,r=n.nodeValue.length}}else{if(Ca(n))break;{let t=n.previousSibling;for(;t&&xa(t,-1);)o=n.parentNode,i=Pi(t),t=t.previousSibling;if(t)n=t,r=Fi(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?Sa(e,n,r):o&&Sa(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=Fi(n);for(;;)if(r<s){if(!Wi(n))break;if(!xa(n.childNodes[r],1))break;o=n,i=++r}else{if(Ca(n))break;{let t=n.nextSibling;for(;t&&xa(t,1);)o=t.parentNode,i=Pi(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=Fi(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&Sa(e,o,i)}(e)}function Ca(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Sa(e,t,n){if(!Ui(t)){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Ki(e);)t=Pi(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(Ui(n))return n;if(Wi(n)&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Ki(e);)t=Pi(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(Ui(n))return n;if(Wi(n)&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection(),o=e.domSelectionRange();if(!r)return;Ji(o)?r.collapse(t,n):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(t,n)),e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&la(e)},50)}function Ma(e,t){let n=e.state.doc.resolve(t);if(!as&&!hs&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return"rtl"==getComputedStyle(r).direction?"rtl":"ltr"}function Na(e,t,n){let r=e.state.selection;if(r instanceof qr&&!r.empty||n.indexOf("s")>-1)return!1;if(us&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=ya(e.state,t);if(n&&n instanceof Wr)return wa(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Gr?jr.near(n,t):jr.findFrom(n,t);return!!s&&wa(e,s)}return!1}function Ea(e,t){if(!(e.state.selection instanceof qr))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)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 r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Oa(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Aa(e,t){let n=t.keyCode,r=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||us&&72==n&&"c"==r)return Ea(e,-1)||ka(e,-1);if(46==n&&!t.shiftKey||us&&68==n&&"c"==r)return Ea(e,1)||ka(e,1);if(13==n||27==n)return!0;if(37==n||us&&66==n&&"c"==r){let t=37==n?"ltr"==Ma(e,e.state.selection.from)?-1:1:-1;return ba(e,t,r)||ka(e,t)}if(39==n||us&&70==n&&"c"==r){let t=39==n?"ltr"==Ma(e,e.state.selection.from)?1:-1:1;return ba(e,t,r)||ka(e,t)}return 38==n||us&&80==n&&"c"==r?Na(e,-1,r)||ka(e,-1):40==n||us&&78==n&&"c"==r?function(e){if(!cs||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&Wi(t)&&0==n&&t.firstChild&&Wi(t.firstChild)&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Oa(e,n,"true"),setTimeout(()=>Oa(e,n,"false"),20)}return!1}(e)||Na(e,1,r)||ka(e,1):r==(us?"m":"c")&&(66==n||73==n||89==n||90==n)}function Ta(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||Wn.fromSchema(e.state.schema),a=ja(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,d=l.firstChild,u=0;for(;d&&Wi(d)&&(c=za[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&&Wi(d)&&d.setAttribute("data-pm-slice",`${o} ${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 Da(e,t,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return s=new Jt(qt.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,o,r,e));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=Wn.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.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,r=ja(),o=r.body,i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&za[i[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;if(!Va){if(Va=t.defaultPolicy)try{return Va.createHTML(e)}catch(e){}Va=t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})}return Va.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;for(let e=0;e<r.styleSheets.length;e++){let t=r.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=o.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return o}(n),fs&&function(e){let t=e.querySelectorAll(as?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(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&&!Wi(e);)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Ln.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||_a.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;try{o=qt.from(t.create(n[e+1],o))}catch(e){break}i++,s++}return new Jt(o,i,s)}(Pa(s,+d[1],+d[2]),d[4]);else if(s=Jt.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&Ra(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=La(i[i.length-1],r.length));let t=Ia(e,n);i.push(t),o=o.matchType(t.type),r=n}}),i)return qt.from(i)}return e}(s.content,o),!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=Pa(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const _a=/^(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 Ia(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,qt.from(e));return e}function Ra(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Ra(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(qt.from(Ia(n,e,o+1))))}}function La(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,La(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(qt.empty,!0);return e.copy(n.append(r))}function Ba(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),o<r-1&&(a=Ba(a,t,n,r,o+1,i)),o>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(qt.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function Pa(e,t,n){return t<e.openStart&&(e=new Jt(Ba(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Jt(Ba(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const za={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function ja(){return document.implementation.createHTMLDocument("title")}let Va=null;const Ha={},$a={},qa={touchstart:!0,touchmove:!0};class Fa{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,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 Wa(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Ua(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Ga(e,t))})}function Ga(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Ka(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 Ja(e,t){let{input:n}=e;return!n.lastKeyDispatched&&!e.composing&&(n.lastKeyDispatched=!0,"string"==typeof t&&(t=function(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}("Backspace"==t?8:13,t)),e.someProp("handleKeyDown",n=>n(e,t)))}function Za(e){return{left:e.clientX,top:e.clientY}}function Ya(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function Xa(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Qa(e,t,n,r,o){return Ya(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Wr&&(n=o.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(Wr.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Xa(e,Wr.create(e.state.doc,r)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Wr.isSelectable(r))&&(Xa(e,new Wr(n)),!0)}(e,n))}function el(e,t,n,r){return Ya(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function tl(e,t,n,r){return Ya(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=nl(e,t,!0),o=e.state.doc;if(!r)return!1;Xa(e,r),r instanceof qr&&o.eq(e.state.doc)&&(e.input.mouseDown=new al(e,r));return!0}(e,n,r)}function nl(e,t,n){let r=e.state.doc;if(-1==t)return r.inlineContent?qr.create(r,0,r.content.size):null;let o=r.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e),i=o.before(e);if(t.inlineContent)return qr.create(r,i+1,i+1+t.content.size);if(n&&Wr.isSelectable(t))return Wr.create(r,i)}return null}function rl(e){return pl(e)}$a.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!ll(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!ps||!as||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!ds||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)Ja(e,n)||Aa(e,n)?n.preventDefault():Wa(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(Ja(e,"Enter"),e.input.lastIOSEnter=0)},200)}},$a.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},$a.keypress=(e,t)=>{let n=t;if(ll(e)||!n.charCode||n.ctrlKey&&!n.altKey||us&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof qr&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,o))||e.dispatch(o()),n.preventDefault()}};const ol=us?"metaKey":"ctrlKey";Ha.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=rl(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[ol]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(Za(n));s&&("singleClick"==i?e.input.mouseDown=new sl(e,s,n,!!r):("doubleClick"==i?el:tl)(e,s.pos,s.inside,n)?n.preventDefault():Wa(e,"pointer"))};class il{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){0==e.buttons&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class sl extends il{constructor(e,t,n,r){let o,i;if(super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[ol],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&Wi(a.nodeDOM)?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof Wr&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!is||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()),Wa(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||la(this.view)})}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(Za(e))),this.updateAllowDefault(e),this.allowDefault||!t?Wa(this.view,"pointer"):Qa(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||cs&&this.mightDrag&&!this.mightDrag.node.isAtom||as&&!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)?(Xa(this.view,jr.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Wa(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wa(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return!!this.allowDefault&&(this.delayedSelectionSync=!0,!0)}}class al extends il{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(0==e.buttons||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc))return void this.done();e.preventDefault(),Wa(this.view,"pointer");let t=this.view.posAtCoords(Za(e)),n=t&&nl(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,o=this.startSelection,[i,s]=n.from<o.from?[o.to,n.from]:[o.from,n.to];Xa(this.view,qr.create(r,i,s))}}function ll(e,t){return!!e.composing||!!(cs&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Ha.touchstart=e=>{e.input.lastTouch=Date.now(),rl(e),Wa(e,"pointer")},Ha.touchmove=e=>{e.input.lastTouch=Date.now(),Wa(e,"pointer")},Ha.contextmenu=e=>rl(e);const cl=ps?5e3:-1;function dl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>pl(e),t))}function ul(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function hl(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(Ui(e)&&t)return e;if(Wi(e)&&t>0){if("false"==e.contentEditable)return null;t=Fi(e=e.childNodes[t-1])}else{if(!e.parentNode||Ki(e))return null;t=Pi(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(Ui(e)&&t<e.nodeValue.length)return e;if(Wi(e)&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Ki(e))return null;t=Pi(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function pl(e,t=!1){if(!(ps&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ul(e),t||e.docView&&e.docView.dirty){let n=sa(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}$a.compositionstart=$a.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof qr&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||as&&hs&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!Wi(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return Wi(r)&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),pl(e,!0),e.markCursor=null;else if(pl(e,!t.selection.empty),is&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&Wi(n)&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(Ui(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}dl(e,cl)},$a.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),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++,dl(e,20))};const fl=ns&&rs<15||ds&&ms<604;function ml(e,t,n,r,o){let i=Da(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,o,i||Jt.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,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gl(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," "):""}Ha.copy=$a.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=fl?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Ta(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 r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},$a.paste=(e,t)=>{let n=t;if(e.composing&&!ps)return;let r=fl?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ml(e,gl(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ml(e,r.value,null,o,t):ml(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class vl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const yl=us?"altKey":"ctrlKey";function wl(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[yl]}Ha.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Za(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Wr?i.to-1:i.to));else if(r&&r.mightDrag)o=Wr.create(e.state.doc,r.mightDrag.pos);else if(n.target&&Wi(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Wr.create(e.state.doc,t.posBefore))}let a=(o||e.state.selection).content(),{dom:l,text:c,slice:d}=Ta(e,a);(!n.dataTransfer.files.length||!as||ls>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(fl?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",fl||n.dataTransfer.setData("text/plain",c),e.dragging=new vl(d,wl(e,n),o)},Ha.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},$a.dragover=$a.dragenter=(e,t)=>t.preventDefault(),$a.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Za(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Da(e,gl(t.dataTransfer),fl?null:t.dataTransfer.getData("text/html"),!1,o);let s=!(!n||!wl(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||Jt.empty,s)))return void t.preventDefault();if(!i)return;t.preventDefault();let a=i?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,o.pos,i):o.pos;null==a&&(a=o.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 h=l.doc.resolve(c);if(d&&Wr.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new Wr(h));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),l.setSelection(ma(e,h,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Ha.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let t=e.domSelectionRange();t.focusNode==n&&t.focusOffset==r&&e.docView&&e.hasFocus()&&la(e)},20)}}},Ha.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)},Ha.beforeinput=(e,t)=>{if(ps&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length)return;if(e.dom.blur(),e.focus(),Ja(e,"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 $a)Ha[e]=$a[e];function bl(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 xl{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}}class kl{constructor(e,t){this.toDOM=e,this.spec=t||El,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new Ml(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof kl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&bl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Cl{constructor(e,t){this.attrs=e,this.spec=t||El}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ml(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Cl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}static is(e){return e.type instanceof Cl}destroy(){}}class Sl{constructor(e,t){this.attrs=e,this.spec=t||El}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ml(o.pos-n,i.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(e){return this==e||e instanceof Sl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}destroy(){}}class Ml{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Ml(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 Ml(e,e,new kl(t,n))}static inline(e,t,n,r){return new Ml(e,t,new Cl(n,r))}static node(e,t,n,r){return new Ml(e,t,new Sl(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Cl}get widget(){return this.type instanceof kl}}const Nl=[],El={};class Ol{constructor(e,t){this.local=e.length?e:Nl,this.children=t.length?t:Nl}static create(e,t){return t.length?Rl(t,e,0,El):Al}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}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,r+s,o)}}map(e,t,n){return this==Al||0==e.maps.length?this:this.mapInner(e,t,0,0,n||El)}mapInner(e,t,n,r,o){let i;if(this.local.length){let s=new xl(t.content);for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,n,r);l&&l.type.valid(t,l,s)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[a].spec)}}return this.children.length?function(e,t,n,r,o,i,s){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<a.length;o+=3){let i=a[o+1];if(i<0||e>i+t-r)continue;let l=a[o]+t-r;n>=l?a[o+1]=e<=l?-2:-1:e>=t&&s&&(a[o]+=s,a[o+1]+=s)}r+=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-o;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=a[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=Al?(a[t]=d,a[t+1]=u,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,o,i,s){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(r,o,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,o,i,s),c=Rl(l,r,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 Ol(t.sort(Ll),a)}(this.children,i||[],e,t,n,r,o):i?new Ol(i.sort(Ll),Nl):Al}add(e,t){return t.length?this==Al?Ol.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,a=i+n;if(s=_l(t,e,a)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,a+1):r.splice(o,0,i,i+e.nodeSize,Rl(s,e,a+1,El)),o+=3}});let i=Dl(o?Il(t):t,-n);if(i.length){let t=new xl(e.content);for(let n=0;n<i.length;n++)i[n].type.valid(e,i[n],t)||i.splice(n--,1)}return new Ol(i.length?this.local.concat(i).sort(Ll):this.local,r||this.children)}remove(e){return 0==e.length||this==Al?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(o,i+1);a!=Al?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Ol(r,n):Al}forChild(e,t){if(this==Al)return this;if(t.isLeaf)return Ol.empty;let n,r;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 o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof Cl){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new Ol(r.sort(Ll),Nl);return n?new Tl([e,n]):e}return n||Al}eq(e){if(this==e)return!0;if(!(e instanceof Ol)||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 Bl(this.localsInner(e))}localsInner(e){if(this==Al)return Nl;if(e.inlineContent||!this.local.some(Cl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Cl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}Ol.empty=new Ol([],[]),Ol.removeOverlap=Bl;const Al=Ol.empty;class Tl{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,El));return Tl.from(n)}forChild(e,t){if(t.isLeaf)return Ol.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=Al&&(o instanceof Tl?n=n.concat(o.members):n.push(o))}return Tl.from(n)}eq(e){if(!(e instanceof Tl)||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 r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Bl(n?t:t.sort(Ll)):Nl}static from(e){switch(e.length){case 0:return Al;case 1:return e[0];default:return new Tl(e.every(e=>e instanceof Ol)?e:e.reduce((e,t)=>e.concat(t instanceof Ol?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Dl(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new Ml(o.from+t,o.to+t,o.type))}return n}function _l(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Il(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Rl(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let a=_l(e,t,s+n);if(a){i=!0;let e=Rl(a,t,n+s+1,r);e!=Al&&o.push(s,s+t.nodeSize,e)}});let s=Dl(i?Il(e):e,-n).sort(Ll);if(s.length){let e=new xl(t.content);for(let n=0;n<s.length;n++)s[n].type.valid(t,s[n],e)||(r.onRemove&&r.onRemove(s[n].spec),s.splice(n--,1))}return s.length||o.length?new Ol(s,o):Al}function Ll(e,t){return e.from-t.from||e.to-t.to}function Bl(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Pl(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Pl(t,o+1,i.copy(r.to,i.to)))}}return t}function Pl(e,t,n){for(;t<e.length&&Ll(n,e[t])>0;)t++;e.splice(t,0,n)}function zl(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Al&&t.push(r)}),e.cursorWrapper&&t.push(Ol.create(e.state.doc,[e.cursorWrapper.deco])),Tl.from(t)}const jl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Vl=ns&&rs<=11;class Hl{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 $l{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Hl,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]);ns&&rs<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():cs&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Vl&&(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,jl)),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(ga(this.view)){if(this.suppressingSelectionUpdates)return la(this.view);if(ns&&rs<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Hi(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=zi(t))n.add(t);for(let r=e.anchorNode;r;r=zi(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:Ui(t)?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,r=!1;!this.suppressingSelectionUpdates&&ga(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let o=-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&&(o=o<0?n.from:Math.min(n.from,o),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||as&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>"childList"==e.type&&e.removedNodes.length))){for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&Wi(t);){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(is&&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 r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&Ul(e,n)==t||r.remove()}}}let l=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ji(n)&&(l=sa(e))&&l.eq(jr.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,la(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(ql.has(e))return;if(ql.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=is,Fl)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."),Fl=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:o}=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||!Wi(e)||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}(e,a)),this.handleDOMChange(o,i,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&la(e),n&&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 r=e.addedNodes[n];t.push(r),Ui(r)&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(ns&&rs<=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)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?Pi(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?Pi(o):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 ql=new WeakMap,Fl=!1;function Wl(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Hi(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Ul(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}const Gl=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if("BR"==t.nodeName&&t.parentNode){if(cs&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(t.parentNode.lastChild==t||cs&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},Kl=/^(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 Jl(e,t,n,r,o){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=sa(e,t);if(n&&!e.state.selection.eq(n)){if(as&&ps&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&Ja(e,"Enter"))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}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,r){let o,{node:i,fromOffset:s,toOffset:a,from:l,to:c}=e.docView.parseRange(t,n),d=e.domSelectionRange(),u=d.anchorNode;if(u&&Gi(e.dom,u)&&(o=[{node:u,offset:d.anchorOffset}],Ji(d)||o.push({node:d.focusNode,offset:d.focusOffset})),as&&8===e.input.lastKeyCode)for(let e=a;e>s;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){a=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||Ln.fromSchema(e.state.schema),f=h.resolve(l),m=null,g=p.parse(i,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:a,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Gl(r),context:f});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),m={anchor:e+l,head:t+l}}return{doc:g,sel:m,from:l,to:c}}(e,t,n,o),h=e.state.doc,p=h.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,r,o){let i=e.findDiffStart(t,n),s=n+e.size,a=n+t.size;if(null==i)return null;let{a:l,b:c}=e.findDiffEnd(t,s,a);if("end"==o){r-=l+Math.max(0,i-Math.min(l,c))-i}if(l<i&&s<a){i-=r<=i&&r>=l?i-r:0,c=i+(c-l),l=i}else if(c<i){i-=r<=i&&r>=c?i-r:0,l=i+(l-c),c=i}return{start:i,endA:l,endB:c}}(p.content,u.doc.content,u.from,l,c);if(f&&e.input.domChangeCount++,(ds&&e.input.lastIOSEnter>Date.now()-225||ps)&&o.some(e=>Wi(e)&&!Kl.test(e.nodeName))&&(!f||f.endA>=f.endB)&&Ja(e,"Enter"))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof qr&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=Zl(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 qr&&(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)),ns&&rs<=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=h.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA;if((ds&&e.input.lastIOSEnter>Date.now()-225&&(!y||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&function(e,t,n){let r=0,o=0;return e.nodesBetween(t,n,(e,i)=>{e.isTextblock&&i>=t&&i<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-i),Math.min(e.nodeSize,n-i))):e.isLeaf)&&o++}),0==o&&1==r}(u.doc,m.pos,g.pos))&&Ja(e,"Enter"))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&(y?f.endA>f.start&&f.endB==f.start:function(e,t,n,r,o){if(n-t<=o.pos-r.pos||Yl(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.inlineContent){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(Yl(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Yl(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(h,f.start,f.endA,m,g))&&Ja(e,"Backspace"))return void(ps&&as&&e.domObserver.suppressSelectionUpdates());as&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),ps&&!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(()=>Ja(e,"Enter"),20));let w,b=f.start,x=f.endA,k=t=>{let n=t||e.state.tr.replace(b,x,u.doc.slice(f.start-u.from,f.endB-u.from));if(u.sel){let t=Zl(e,n.doc,u.sel);t&&!(as&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(x)-1)||ns&&t.empty&&t.head==b)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(y)if(m.pos==g.pos){ns&&rs<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>la(e),20));let t=k(e.state.tr.delete(b,x)),n=h.resolve(f.start).marksAcross(h.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(w=function(e,t){let n,r,o,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)r=a[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if(qt.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start())))){let t=k(e.state.tr);"add"==w.type?t.addMark(b,x,w.mark):t.removeMark(b,x,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=()=>k(e.state.tr.insertText(t,b,x));e.someProp("handleTextInput",r=>r(e,b,x,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())}function Zl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:ma(e,t.resolve(n.anchor),t.resolve(n.head))}function Yl(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}class Xl{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 Fa,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(rc),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=tc(this),ec(this),this.nodeViews=nc(this),this.docView=Fs(this.state.doc,Ql(this),zl(this),this.dom,this),this.domObserver=new $l(this,(e,t,n,r)=>Jl(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in Ha){let n=Ha[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Ka(e,t)||Ga(e,t)||!e.editable&&t.type in $a||n(e,t)},qa[t]?{passive:!0}:void 0)}cs&&e.dom.addEventListener("input",()=>null),Ua(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&&Ua(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(rc),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 r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(ul(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=nc(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ua(this),this.editable=tc(this),ec(this);let a=zl(this),l=Ql(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(r.selection)||(i=!0);let u="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=o-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:bs(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(ns||as)&&!this.composing&&!r.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)}(r.selection,e.selection);if(d){let n=as?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=hl(this)),!o&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=Fs(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let n=this.input.mouseDown;t||!(n&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Hi(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this)&&n.delaySelUpdate())?la(this,t):(pa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;xs(n,0==r?0:r-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Gi(this.dom,e))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof Wr){let t=this.docView.domAfterPos(this.state.selection.from);Wi(t)&&ws(this,t.getBoundingClientRect(),e)}else ws(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,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=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&&(r=e)}this.dragging=new vl(e.slice,e.move,r<0?void 0:Wr.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(ns){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(ks)return e.focus(ks);let t=bs(e);e.focus(null==ks?{get preventScroll(){return ks={preventScroll:!0},!0}}:void 0),ks||(ks=!1,xs(t,0))}(this.dom),la(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 Ns(this,e)}coordsAtPos(e,t=1){return Ts(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 r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return zs(this,t||this.state,e)}pasteHTML(e,t){return ml(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ml(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ta(this,e)}destroy(){this.docView&&(!function(e){e.input.mouseDown&&e.input.mouseDown.done(),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,[],zl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ji=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Ga(e,t)||!Ha[t.type]||!e.editable&&t.type in $a||Ha[t.type](e,t)}(this,e)}domSelectionRange(){let e=!1!==this.dom.isConnected&&this.domSelection();return e?cs&&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 Wl(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Wl(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ql(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"),[Ml.node(0,e.state.doc.content.size,t)]}function ec(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:Ml.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function tc(e){return!e.someProp("editable",t=>!1===t(e.state))}function nc(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 rc(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 oc(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}Xl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};var ic={text:(e,t,n,r)=>{const o=e.value;return/^[^*_\\]*\s+$/.test(o)?o:n.safe(o,{...r,encode:[]})},strong:(e,t,n,r)=>{const o=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(r);let a=s.move(o+o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o+o),i(),a},emphasis:(e,t,n,r)=>{const o=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(r);let a=s.move(o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o),i(),a}},sc=Tt({},"editorView"),ac=Tt({},"editorState"),lc=Tt([],"initTimer"),cc=Tt({},"editor"),dc=Tt([],"inputRules"),uc=Tt([],"prosePlugins"),hc=Tt([],"remarkPlugins"),pc=Tt([],"nodeView"),fc=Tt([],"markView"),mc=Tt(X().use(Q).use(Pt),"remark"),gc=Tt({handlers:ic,encode:[]},"remarkStringifyOptions"),vc=Bt("ConfigReady");var yc=Bt("InitReady");function wc(e){const t=t=>(t.inject(cc,e).inject(uc,[]).inject(hc,[]).inject(dc,[]).inject(pc,[]).inject(fc,[]).inject(gc,{handlers:ic,encode:[]}).inject(mc,X().use(Q).use(Pt)).inject(lc,[vc]).record(yc),async()=>{await t.waitTimers(lc);const e=t.get(gc);return t.set(mc,X().use(Q).use(Pt,e)),t.done(yc),()=>{t.remove(cc).remove(uc).remove(hc).remove(dc).remove(pc).remove(fc).remove(gc).remove(mc).remove(lc).clearTimer(yc)}});return oc(t,{displayName:"Init"}),t}var bc=Bt("SchemaReady"),xc=Tt([],"schemaTimer"),kc=Tt({},"schema"),Cc=Tt([],"nodes"),Sc=Tt([],"marks");function Mc(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var Nc=e=>(e.inject(kc,{}).inject(Cc,[]).inject(Sc,[]).inject(xc,[yc]).record(bc),async()=>{await e.waitTimers(xc);const t=e.get(mc),n=e.get(hc).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(mc,n);const r=Object.fromEntries(e.get(Cc).map(([e,t])=>[e,Mc(t)])),o=Object.fromEntries(e.get(Sc).map(([e,t])=>[e,Mc(t)])),i=new In({nodes:r,marks:o});return e.set(kc,i),e.done(bc),()=>{e.remove(kc).remove(Cc).remove(Sc).remove(xc).clearTimer(bc)}});oc(Nc,{displayName:"Schema"});var Ec=class{constructor(){this.#o=new Et,this.#P=null,this.setCtx=e=>{this.#P=e},this.chain=()=>{if(null==this.#P)throw St();const e=this.#P,t=[],n=this.get.bind(this),r={run:()=>{const n=Eo(...t),r=e.get(sc);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:function(e,o){const i=n(e);return t.push(i(o)),r}.bind(this)};return r}}#o;#P;get ctx(){return this.#P}create(e,t){const n=e.create(this.#o.sliceMap);return n.set(t),n}get(e){return this.#o.get(e).get()}remove(e){return this.#o.remove(e)}call(e,t){if(null==this.#P)throw St();const n=this.get(e)(t),r=this.#P.get(sc);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#P)throw St();const t=this.#P.get(sc);return e(t.state,t.dispatch,t)}};var Oc=Tt(new Ec,"commands"),Ac=Tt([bc],"commandsTimer"),Tc=Bt("CommandsReady"),Dc=e=>{const t=new Ec;return t.setCtx(e),e.inject(Oc,t).inject(Ac,[bc]).record(Tc),async()=>(await e.waitTimers(Ac),e.done(Tc),()=>{e.remove(Oc).remove(Ac).clearTimer(Tc)})};oc(Dc,{displayName:"Commands"});var _c=class{constructor(){this.#P=null,this.#z=[],this.setCtx=e=>{this.#P=e},this.add=e=>(this.#z.push(e),()=>{this.#z=this.#z.filter(t=>t!==e)}),this.addObjectKeymap=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){const r={key:e,onRun:()=>n};this.#z.push(r),t.push(()=>{this.#z=this.#z.filter(e=>e!==r)})}else this.#z.push(n),t.push(()=>{this.#z=this.#z.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{const e=function(e){return e.Backspace=Eo(Ro,lo,ho,fo),e}(_o);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#z.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,r)=>{const o=this.#P;if(null==o)throw xt();return Eo(...n.map(e=>e.onRun(o)))(e,t,r)}]}))}}#P;#z;get ctx(){return this.#P}},Ic=Tt(new _c,"keymap"),Rc=Tt([bc],"keymapTimer"),Lc=Bt("KeymapReady"),Bc=e=>{const t=new _c;return t.setCtx(e),e.inject(Ic,t).inject(Rc,[bc]).record(Lc),async()=>(await e.waitTimers(Rc),e.done(Lc),()=>{e.remove(Ic).remove(Rc).clearTimer(Lc)})},Pc=Bt("ParserReady"),zc=()=>{throw xt()},jc=Tt(zc,"parser"),Vc=Tt([],"parserTimer"),Hc=e=>(e.inject(jc,zc).inject(Vc,[bc]).record(Pc),async()=>{await e.waitTimers(Vc);const t=e.get(mc),n=e.get(kc);return e.set(jc,Ri.create(n,t)),e.done(Pc),()=>{e.remove(jc).remove(Vc).clearTimer(Pc)}});oc(Hc,{displayName:"Parser"});var $c=Bt("SerializerReady"),qc=Tt([],"serializerTimer"),Fc=()=>{throw xt()},Wc=Tt(Fc,"serializer"),Uc=e=>(e.inject(Wc,Fc).inject(qc,[bc]).record($c),async()=>{await e.waitTimers(qc);const t=e.get(mc),n=e.get(kc);return e.set(Wc,Bi.create(n,t)),e.done($c),()=>{e.remove(Wc).remove(qc).clearTimer($c)}});oc(Uc,{displayName:"Serializer"});var Gc=Tt("","defaultValue"),Kc=Tt(e=>e,"stateOptions"),Jc=Tt([],"editorStateTimer"),Zc=Bt("EditorStateReady");function Yc(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return Ln.fromSchema(n).parse(e.dom);if("json"===e.type)return fn.fromJSON(n,e.value);throw r=e,new yt(vt.docTypeError,`Doc type error, unsupported type: ${bt(r)}`);var r}var Xc=new ao("MILKDOWN_STATE_TRACKER"),Qc=e=>(e.inject(Gc,"").inject(ac,{}).inject(Kc,e=>e).inject(Jc,[Pc,$c,Tc,Lc]).record(Zc),async()=>{await e.waitTimers(Jc);const t=e.get(kc),n=e.get(jc),r=e.get(dc),o=e.get(Kc),i=e.get(uc),s=Yc(e.get(Gc),n,t),a=e.get(Ic),l=a.addBaseKeymap(),c=[...i,new oo({key:Xc,state:{init:()=>{},apply:(t,n,r,o)=>{e.set(ac,o)}}}),ii({rules:r}),Ai(a.build())];e.set(uc,c);const d=o({schema:t,doc:s,plugins:c}),u=no.create(d);return e.set(ac,u),e.done(Zc),()=>{l(),e.remove(Gc).remove(ac).remove(Kc).remove(Jc).clearTimer(Zc)}});oc(Qc,{displayName:"EditorState"});var ed=Tt([],"pasteRule"),td=Tt([bc],"pasteRuleTimer"),nd=Bt("PasteRuleReady"),rd=e=>(e.inject(ed,[]).inject(td,[bc]).record(nd),async()=>(await e.waitTimers(td),e.done(nd),()=>{e.remove(ed).remove(td).clearTimer(nd)}));oc(rd,{displayName:"PasteRule"});var od=Bt("EditorViewReady"),id=Tt([],"editorViewTimer"),sd=Tt({},"editorViewOptions"),ad=Tt(null,"root"),ld=Tt(null,"rootDOM"),cd=Tt({},"rootAttrs");var dd=new ao("MILKDOWN_VIEW_CLEAR"),ud=e=>(e.inject(ad,document.body).inject(sc,{}).inject(sd,{}).inject(ld,null).inject(cd,{}).inject(id,[Zc,nd]).record(od),async()=>{await e.wait(yc);const t=e.get(ad)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(uc,t=>[new oo({key:dd,view:t=>{const r=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(ld,n);const r=t.get(cd);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}(n,e):void 0;return(()=>{if(r&&n){const e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(id);const r=e.get(ac),o=e.get(sd),i=Object.fromEntries(e.get(pc)),s=Object.fromEntries(e.get(fc)),a=new Xl(n,{state:r,nodeViews:i,markViews:s,transformPasted:(t,n,r)=>(e.get(ed).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});var l;return(l=a.dom).classList.add("editor"),l.setAttribute("role","textbox"),e.set(sc,a),e.done(od),()=>{a?.destroy(),e.remove(ad).remove(sc).remove(sd).remove(ld).remove(cd).remove(id).clearTimer(od)}});oc(ud,{displayName:"EditorView"});var hd=function(e){return e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e}({}),pd=class e{constructor(){this.#j=!1,this.#g="Idle",this.#V=[],this.#H=()=>{},this.#o=new Et,this.#i=new It,this.#$=new Map,this.#q=new Map,this.#P=new _t(this.#o,this.#i),this.#F=()=>{const e=function(e){const t=t=>(t.record(vc),async()=>(await e(t),t.done(vc),()=>{t.clearTimer(vc)}));return oc(t,{displayName:"Config"}),t}(async e=>{await Promise.all(this.#V.map(t=>Promise.resolve(t(e))))}),t=[Nc,Hc,Uc,Dc,Bc,rd,Qc,ud,wc(this),e];this.#W(t,this.#q)},this.#W=(e,t)=>{e.forEach(e=>{const n=this.#P.produce(this.#j?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#U=(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})),this.#G=async()=>{await Promise.all([...this.#q.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#q.clear()},this.#K=e=>{this.#g=e,this.#H(e)},this.#J=e=>[...e.entries()].map(async([t,n])=>{const{ctx:r,handler:o}=n;if(!o)return;const i=await o();e.set(t,{ctx:r,handler:o,cleanup:i})}),this.enableInspector=(e=!0)=>(this.#j=e,this),this.onStatusChange=e=>(this.#H=e,this),this.config=e=>(this.#V.push(e),this),this.removeConfig=e=>(this.#V=this.#V.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})}),"Created"===this.#g&&this.#W(t,this.#$),this},this.remove=async e=>"OnCreate"===this.#g?(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.#U([e].flat(),!0),this),this.create=async()=>("OnCreate"===this.#g||("Created"===this.#g&&await this.destroy(),this.#K("OnCreate"),this.#F(),this.#W([...this.#$.keys()],this.#$),await Promise.all([this.#J(this.#q),this.#J(this.#$)].flat()),this.#K("Created")),this),this.destroy=async(e=!1)=>"Destroyed"===this.#g||"OnDestroy"===this.#g?this:"OnCreate"===this.#g?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#V=[]),this.#K("OnDestroy"),await this.#U([...this.#$.keys()],e),await this.#G(),this.#K("Destroyed"),this),this.action=e=>e(this.#P),this.inspect=()=>this.#j?[...this.#q.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}#j;#g;#V;#H;#o;#i;#$;#q;#P;#F;#W;#U;#G;#K;#J;get ctx(){return this.#P}get status(){return this.#g}};let fd=e=>crypto.getRandomValues(new Uint8Array(e)),md=(e,t=21)=>((e,t,n)=>{let r=256-256%e.length;if(256===r){let r=e.length-1;return(o=t)=>{if(!o)return"";let i="";for(;;){let t=n(o),s=o|=0;for(;s--;)if(i+=e[t[s]&r],i.length>=o)return i}}}return(o=t)=>{if(!o)return"";let i="",s=Math.ceil(409.6*o/r);for(;;){let t=n(s),a=s;for(;a--;)if(t[a]<r&&(i+=e[t[a]%e.length],i.length>=o))return i}}})(e,0|t,fd);function gd(e,t,n){const r=e.findIndex(([e])=>e===t);if(-1===r)return[...e,n];const o=e.slice();return o[r]=n,o}function vd(e,t){const n=function(e="cmdKey"){return Tt(()=>()=>!1,e)}(e),r=o=>async()=>{r.key=n,await o.wait(Tc);const i=t(o);return o.get(Oc).create(n,i),r.run=t=>o.get(Oc).call(e,t),()=>{o.get(Oc).remove(n)}};return r}function yd(e){const t=n=>async()=>{await n.wait(bc);const r=e(n);return n.update(dc,e=>[...e,r]),t.inputRule=r,()=>{n.update(dc,e=>e.filter(e=>e!==r))}};return t}function wd(e,t){const n=r=>async()=>{const o=t(r);return r.update(Sc,t=>gd(t,e,[e,o])),n.id=e,n.schema=o,()=>{r.update(Sc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(kc).marks[e];if(!n)throw r=e,new yt(vt.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${r}" in schema.`);var r;return n},n}function bd(e,t){const n=r=>async()=>{const o=t(r);return r.update(Cc,t=>gd(t,e,[e,o])),n.id=e,n.schema=o,()=>{r.update(Cc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(kc).nodes[e];if(!n)throw Mt(e);return n},n}function xd(e){let t;const n=n=>async()=>(await n.wait(bc),t=e(n),n.update(uc,e=>[...e,t]),()=>{n.update(uc,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function kd(e){const t=n=>async()=>{await n.wait(Lc);const r=n.get(Ic),o=e(n),i=r.addObjectKeymap(o);return t.keymap=o,()=>{i()}};return t}function Cd(e,t){const n=r=>async()=>{await r.wait(bc);const o=t(r);return e.type(r)instanceof Tn?r.update(pc,t=>[...t,[e.id,o]]):r.update(fc,t=>[...t,[e.id,o]]),n.view=o,n.type=e,()=>{e.type(r)instanceof Tn?r.update(pc,t=>t.filter(t=>t[0]!==e.id)):r.update(fc,t=>t.filter(t=>t[0]!==e.id))}};return n}function Sd(e,t){const n=Tt(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function Md(e,t){const n=Sd(t,e),r=bd(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.node=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>Md(e,n(t)),o}function Nd(e,t){const n=Sd(t,e),r=wd(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.mark=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>Nd(e,n(t)),o}function Ed(e,t){const n=Sd(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=kd(e=>{const r=e.get(n.key),o=Object.entries(t).flatMap(([e,{command:t}])=>{const n=r[e],o=[n.shortcuts].flat(),i=n.priority;return o.map(e=>[e,{key:e,onRun:t,priority:i}])});return Object.fromEntries(o)}),o=[n,r];return o.ctx=n,o.shortcuts=r,o.key=n.key,o.keymap=r.keymap,o}md("abcedfghicklmn",10);var Od=(e,t=()=>({}))=>Sd(t,`${e}Attr`),Ad=(e,t=()=>({}))=>Sd(t,`${e}Attr`);function Td(e,t,n){const r=Sd({},e),o=e=>async()=>{await e.wait(yc);const n={plugin:t(e),options:e.get(r.key)};return e.update(hc,e=>[...e,n]),()=>{e.update(hc,e=>e.filter(e=>e!==n))}},i=[r,o];return i.id=e,i.plugin=o,i.options=r,i}function Dd(e){return e=>{const t=e.get(sc);e.get(kc);return e.get(Wc)(t.state.doc)}}var _d=ue({});var Id=()=>{const e=function(){const{dom:e,editor:t,setLoading:n,editorFactory:r}=he(_d),o=le(null);return me(()=>{const i=o.current;if(!r)return;if(!i)return;e.current=i;const s=r(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,r,n]),o}();return ae.createElement("div",{"data-milkdown-root":!0,ref:e})},Rd=({children:e})=>{const t=le(void 0),[n,r]=ce(void 0),o=le(void 0),[i,s]=ce(!0),a=de(()=>({loading:i,dom:t,editor:o,setLoading:s,editorFactory:n,setEditorFactory:r}),[i,n]);return ae.createElement(_d.Provider,{value:a},e)};function Ld(){const e=he(_d),t=pe(()=>e.editor.current,[e.editor]);return[e.loading,t]}function Bd(e){return new h(p.define(e))}function Pd(e){return import("./index-CHgqN-d9.js").then(t=>t.sql({dialect:t[e]}))}const zd=[u.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-DDBuqExW.js").then(e=>e.cpp())}),u.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-DDBuqExW.js").then(e=>e.cpp())}),u.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Pd("Cassandra")}),u.of({name:"CSS",extensions:["css"],load:()=>import("./index-B9JSZpaA.js").then(e=>e.css())}),u.of({name:"Go",extensions:["go"],load:()=>import("./index-wJyG4Gm6.js").then(e=>e.go())}),u.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-CHVYA2P8.js").then(e=>e.html())}),u.of({name:"Java",extensions:["java"],load:()=>import("./index-D6A8P_xS.js").then(e=>e.java())}),u.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript())}),u.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-BS7YTgMe.js").then(e=>e.jinja())}),u.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-vxKx70Pe.js").then(e=>e.json())}),u.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript({jsx:!0}))}),u.of({name:"LESS",extensions:["less"],load:()=>import("./index-YYM2ZvZ6.js").then(e=>e.less())}),u.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index-CffiBbeH.js").then(e=>e.liquid())}),u.of({name:"MariaDB SQL",load:()=>Pd("MariaSQL")}),u.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-DBWowQHL.js").then(e=>e.markdown())}),u.of({name:"MS SQL",load:()=>Pd("MSSQL")}),u.of({name:"MySQL",load:()=>Pd("MySQL")}),u.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-mLZqgXD7.js").then(e=>e.php())}),u.of({name:"PLSQL",extensions:["pls"],load:()=>Pd("PLSQL")}),u.of({name:"PostgreSQL",load:()=>Pd("PostgreSQL")}),u.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-BNvG4PUn.js").then(e=>e.python())}),u.of({name:"Rust",extensions:["rs"],load:()=>import("./index-B46RgSF9.js").then(e=>e.rust())}),u.of({name:"Sass",extensions:["sass"],load:()=>import("./index-D9BPo-_o.js").then(e=>e.sass({indented:!0}))}),u.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-D9BPo-_o.js").then(e=>e.sass())}),u.of({name:"SQL",extensions:["sql"],load:()=>Pd("StandardSQL")}),u.of({name:"SQLite",load:()=>Pd("SQLite")}),u.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript({jsx:!0,typescript:!0}))}),u.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-BpFtavDh.js").then(e=>e.javascript({typescript:!0}))}),u.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-Bohl_WFx.js").then(e=>e.wast())}),u.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-D5AIo8KT.js").then(e=>e.xml())}),u.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-BDQ8194g.js").then(e=>e.yaml())}),u.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-CXdQSnD-.js").then(e=>Bd(e.apl))}),u.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-D5V0T9Cu.js").then(e=>Bd(e.asciiArmor))}),u.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-DWPaVWf6.js").then(e=>Bd(e.asn1({})))}),u.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-B46aRdXb.js").then(e=>Bd(e.asterisk))}),u.of({name:"Brainfuck",extensions:["b","bf"],load:()=>import("./brainfuck-CtZaYBKt.js").then(e=>Bd(e.brainfuck))}),u.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-stawOqaz.js").then(e=>Bd(e.cobol))}),u.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.csharp))}),u.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Bd(e.clojure))}),u.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Bd(e.clojure))}),u.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-C4GSMmGA.js").then(e=>Bd(e.gss))}),u.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-DXn5xaP-.js").then(e=>Bd(e.cmake))}),u.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-BTDxI-eT.js").then(e=>Bd(e.coffeeScript))}),u.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-vq6DHwts.js").then(e=>Bd(e.commonLisp))}),u.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-gJDei3ni.js").then(e=>Bd(e.cypher))}),u.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-On6Xi21R.js").then(e=>Bd(e.cython))}),u.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-CRzZ78HM.js").then(e=>Bd(e.crystal))}),u.of({name:"D",extensions:["d"],load:()=>import("./d-BShv7fp-.js").then(e=>Bd(e.d))}),u.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.dart))}),u.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-UJJ5BM9S.js").then(e=>Bd(e.diff))}),u.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-DVQ9Q8O9.js").then(e=>Bd(e.dockerFile))}),u.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-DI9Herc-.js").then(e=>Bd(e.dtd))}),u.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-DkEP81N9.js").then(e=>Bd(e.dylan))}),u.of({name:"EBNF",load:()=>import("./ebnf-B-Df8AvO.js").then(e=>Bd(e.ebnf))}),u.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-DPFc0Uaf.js").then(e=>Bd(e.ecl))}),u.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Bd(e.clojure))}),u.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-DR5c0IrL.js").then(e=>Bd(e.eiffel))}),u.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-DompmV0j.js").then(e=>Bd(e.elm))}),u.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-BuqgqA5h.js").then(e=>Bd(e.erlang))}),u.of({name:"Esper",load:()=>import("./sql-ByLYq2fX.js").then(e=>Bd(e.esper))}),u.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-Bk9_H-XT.js").then(e=>Bd(e.factor))}),u.of({name:"FCL",load:()=>import("./fcl-CVaBTCzQ.js").then(e=>Bd(e.fcl))}),u.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-POgR1ypr.js").then(e=>Bd(e.forth))}),u.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-DL7KluxX.js").then(e=>Bd(e.fortran))}),u.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Bd(e.fSharp))}),u.of({name:"Gas",extensions:["s"],load:()=>import("./gas-8mz5Q3qN.js").then(e=>Bd(e.gas))}),u.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-B6X1vGSW.js").then(e=>Bd(e.gherkin))}),u.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-DnIzCrpZ.js").then(e=>Bd(e.groovy))}),u.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-CLQs6EAM.js").then(e=>Bd(e.haskell))}),u.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Bd(e.haxe))}),u.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Bd(e.hxml))}),u.of({name:"HTTP",load:()=>import("./http-BKJkqRj4.js").then(e=>Bd(e.http))}),u.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-pcmmZuaN.js").then(e=>Bd(e.idl))}),u.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-BVaBnk3P.js").then(e=>Bd(e.jsonld))}),u.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-DjdwvFuI.js").then(e=>Bd(e.julia))}),u.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.kotlin))}),u.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-HO6ttBFx.js").then(e=>Bd(e.liveScript))}),u.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-BvgfYBhq.js").then(e=>Bd(e.lua))}),u.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-DkvFAiy5.js").then(e=>Bd(e.mirc))}),u.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-IIbmv7SK.js").then(e=>Bd(e.mathematica))}),u.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-DSrSSXCg.js").then(e=>Bd(e.modelica))}),u.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-zvxmGV4l.js").then(e=>Bd(e.mumps))}),u.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-z_N2Mo3d.js").then(e=>Bd(e.mbox))}),u.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-B4hAVlXN.js").then(e=>Bd(e.nginx))}),u.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-BFvJq6Vq.js").then(e=>Bd(e.nsis))}),u.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-BSwWqoLa.js").then(e=>Bd(e.ntriples))}),u.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.objectiveC))}),u.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.objectiveCpp))}),u.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Bd(e.oCaml))}),u.of({name:"Octave",extensions:["m"],load:()=>import("./octave-C4hdQ5Hf.js").then(e=>Bd(e.octave))}),u.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-qQq7irPq.js").then(e=>Bd(e.oz))}),u.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-CafrKXZF.js").then(e=>Bd(e.pascal))}),u.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-tdMlh9QA.js").then(e=>Bd(e.perl))}),u.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CwGJVRC4.js").then(e=>Bd(e.pig))}),u.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-D1ly3AHC.js").then(e=>Bd(e.powerShell))}),u.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-_nPj978X.js").then(e=>Bd(e.properties))}),u.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-B4y9do6W.js").then(e=>Bd(e.protobuf))}),u.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-Dlfivyh-.js").then(e=>Bd(e.pug))}),u.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-Bc-yJKzi.js").then(e=>Bd(e.puppet))}),u.of({name:"Q",extensions:["q"],load:()=>import("./q-mUfi2b_o.js").then(e=>Bd(e.q))}),u.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-BA4EbLKE.js").then(e=>Bd(e.r))}),u.of({name:"RPM Changes",load:()=>import("./rpm-DI_rRufH.js").then(e=>Bd(e.rpmChanges))}),u.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-DI_rRufH.js").then(e=>Bd(e.rpmSpec))}),u.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-D9chwFAN.js").then(e=>Bd(e.ruby))}),u.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-Bqaci40L.js").then(e=>Bd(e.sas))}),u.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.scala))}),u.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-qjP0V5Ag.js").then(e=>Bd(e.scheme))}),u.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-BLav31RL.js").then(e=>Bd(e.shell))}),u.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-r025o_jW.js").then(e=>Bd(e.sieve))}),u.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-C7J3IyEP.js").then(e=>Bd(e.smalltalk))}),u.of({name:"Solr",load:()=>import("./solr-78MBEUkU.js").then(e=>Bd(e.solr))}),u.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Bd(e.sml))}),u.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-BRLJFz69.js").then(e=>Bd(e.sparql))}),u.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-CGlWr0eM.js").then(e=>Bd(e.spreadsheet))}),u.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Bd(e.squirrel))}),u.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-Bdo_Aemu.js").then(e=>Bd(e.stylus))}),u.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-B_XXVlXX.js").then(e=>Bd(e.swift))}),u.of({name:"sTeX",load:()=>Promise.resolve().then(function(){return Hd}).then(e=>Bd(e.stex))}),u.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>Promise.resolve().then(function(){return Hd}).then(e=>Bd(e.stex))}),u.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Bd(e.verilog))}),u.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-B2fODqDH.js").then(e=>Bd(e.tcl))}),u.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-BuVhTOzU.js").then(e=>Bd(e.textile))}),u.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-BgR6AEZu.js").then(e=>Bd(e.tiddlyWiki))}),u.of({name:"Tiki wiki",load:()=>import("./tiki-CI-ztowC.js").then(e=>Bd(e.tiki))}),u.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-BVJm5Fzd.js").then(e=>Bd(e.toml))}),u.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-Ce85hlLp.js").then(e=>Bd(e.troff))}),u.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-BxnYHtq8.js").then(e=>Bd(e.ttcn))}),u.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-CKJxb-l2.js").then(e=>Bd(e.ttcnCfg))}),u.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-BkSuIpt-.js").then(e=>Bd(e.turtle))}),u.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-CGwyPRYs.js").then(e=>Bd(e.webIDL))}),u.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-BHgjm0DN.js").then(e=>Bd(e.vb))}),u.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-VzWlGt02.js").then(e=>Bd(e.vbScript))}),u.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-BdD_26Jv.js").then(e=>Bd(e.velocity))}),u.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Bd(e.verilog))}),u.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-CWWH2SUo.js").then(e=>Bd(e.vhdl))}),u.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-CVDBqZPY.js").then(e=>Bd(e.xQuery))}),u.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-I8QjZlxf.js").then(e=>Bd(e.yacas))}),u.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-DMVFMNEx.js").then(e=>Bd(e.z80))}),u.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Bd(e.mscgen))}),u.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Bd(e.xu))}),u.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Bd(e.msgenny))}),u.of({name:"Vue",extensions:["vue"],load:()=>import("./index-CmWQEzQl.js").then(e=>e.vue())}),u.of({name:"Angular Template",load:()=>import("./index-nNMK7HvL.js").then(e=>e.angular())})];function jd(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 r(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 o={};function i(e,t){e.f=t}function s(e,r){var s;if(e.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var c=e.current().slice(1);return t(r,s=new(s=o.hasOwnProperty(c)?o[c]:o.DEFAULT)),i(r,l),s.style}if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/\\]/))return"tag";if(e.match("\\["))return i(r,function(e,t){return a(e,t,"\\]")}),"keyword";if(e.match("\\("))return i(r,function(e,t){return a(e,t,"\\)")}),"keyword";if(e.match("$$"))return i(r,function(e,t){return a(e,t,"$$")}),"keyword";if(e.match("$"))return i(r,function(e,t){return a(e,t,"$")}),"keyword";var d=e.next();return"%"==d?(e.skipToEnd(),"comment"):"}"==d||"]"==d?(s=n(r))?(s.closeBracket(d),i(r,l),"bracket"):"error":"{"==d||"["==d?(t(r,s=new(s=o.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 r=t[n];if("DEFAULT"!=r.name)return r}return{styleIdentifier:function(){return null}}}(r),"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 r=e.next();return"{"==r||"}"==r||"["==r||"]"==r||"("==r||")"==r?"bracket":"%"==r?(e.skipToEnd(),"comment"):"error"}function l(e,t){var r=e.peek();return"{"==r||"["==r?(n(t).openBracket(r),e.eat(r),i(t,s),"bracket"):/[ \t\r]/.test(r)?(e.eat(r),null):(i(t,s),function(e){var t=e.cmdState.pop();t&&t.closeBracket()}(t),s(e,t))}return o.importmodule=r("importmodule","tag",["string","builtin"]),o.documentclass=r("documentclass","tag",["","atom"]),o.usepackage=r("usepackage","tag",["atom"]),o.begin=r("begin","tag",["atom"]),o.end=r("end","tag",["atom"]),o.label=r("label","tag",["atom"]),o.ref=r("ref","tag",["atom"]),o.eqref=r("eqref","tag",["atom"]),o.cite=r("cite","tag",["atom"]),o.bibitem=r("bibitem","tag",["atom"]),o.Bibitem=r("Bibitem","tag",["atom"]),o.RBibitem=r("RBibitem","tag",["atom"]),o.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 Vd=jd(!1);jd(!0);var Hd=Object.freeze({__proto__:null,stex:Vd});function $d(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);return!!i&&(!n||(r.node(i.depth-1).type==e?function(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new hr(i-1,s,i,s,new Jt(qt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new hn(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const a=gr(r);if(null==a)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(i,-1)-1);kr(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos);return t(o.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?qt.empty:qt.from(o))))return!1;let u=i.pos,h=u+s.nodeSize;return r.step(new hr(u-(a?1:0),h+(l?1:0),u+1,h-1,new Jt((a?qt.empty:qt.from(o.copy(qt.empty))).append(l?qt.empty:qt.from(o.copy(qt.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,i)))}}function qd(e){return String(e||"").toUpperCase()}function Fd(){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=qd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){const n=qd(e);return t.get(n)}}(e);ee(e,function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[te,n];if("imageReference"===e.type||"linkReference"===e.type){const o=t(e.identifier);if(o&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:o.url,title:o.title,alt:e.alt}:{type:"link",url:o.url,title:o.title,children:e.children},[te,n]}})}}function Wd(e){const t={...e};return t.position&&(t.position={start:{...t.position.start},end:{...t.position.end}}),delete t.children,t}var Ud=/^<br\s*\/?\s*>$/i;function Gd(e,t){if(!(t.childCount>=1&&"hardbreak"===t.lastChild?.type.name))return void e.next(t.content);const n=[];t.content.forEach((e,r,o)=>{o!==t.childCount-1&&n.push(e)}),e.next(qt.fromArray(n))}function Kd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}var Jd=Ad("emphasis");Kd(Jd,{displayName:"Attr<emphasis>",group:"Emphasis"});var Zd=Nd("emphasis",e=>({attrs:{marker:{default:e.get(gc).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})}}}));Kd(Zd.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),Kd(Zd.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Yd=vd("ToggleEmphasis",e=>()=>No(Zd.type(e)));Kd(Yd,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var Xd=yd(e=>li(/(?:^|[^*])\*([^*]+)\*$/,Zd.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));Kd(Xd,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var Qd=yd(e=>li(/\b_(?![_\s])(.*?[^_\s])_$/,Zd.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));Kd(Qd,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var eu=Ed("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(Oc);return()=>t.call(Yd.key)}}});Kd(eu.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),Kd(eu.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var tu=Ad("strong");Kd(tu,{displayName:"Attr<strong>",group:"Strong"});var nu=Nd("strong",e=>({attrs:{marker:{default:e.get(gc).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(tu.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})}}}));Kd(nu.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),Kd(nu.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var ru=vd("ToggleStrong",e=>()=>No(nu.type(e)));Kd(ru,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var ou=yd(e=>li(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,nu.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));Kd(ou,{displayName:"InputRule<strong>",group:"Strong"});var iu=Ed("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(Oc);return()=>t.call(ru.key)}}});Kd(iu.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),Kd(iu.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var su=Ad("inlineCode");Kd(su,{displayName:"Attr<inlineCode>",group:"InlineCode"});var au=Nd("inlineCode",e=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(su.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)}}));Kd(au.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),Kd(au.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var lu=vd("ToggleInlineCode",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(r.empty)return!1;const{from:i,to:s}=r;return t.doc.rangeHasMark(i,s,au.type(e))?(n?.(o.removeMark(i,s,au.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==au.type.name).map(e=>t.schema.marks[e]).forEach(e=>{o.removeMark(i,s,e)}),n?.(o.addMark(i,s,au.type(e).create())),!0)});Kd(lu,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var cu=yd(e=>li(/(?:`)([^`]+)(?:`)$/,au.type(e)));Kd(cu,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var du=Ed("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(Oc);return()=>t.call(lu.key)}}});Kd(du.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),Kd(du.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var uu=new Set(["http:","https:","mailto:","tel:","ftp:"]);function hu(e){return e<=32||e>=127&&e<=160||e>=8203&&e<=8205||8232===e||8233===e||65279===e}function pu(e){if("string"!=typeof e)return"";const t=e.trim();if(!t)return"";const n=function(e){let t="";for(const n of e)hu(n.codePointAt(0)??0)||(t+=n);return t}(t),r=/^([a-z][a-z0-9+.-]*):/i.exec(n)?.[1];return r?uu.has(`${r.toLowerCase()}:`)?t:"":t}var fu=Ad("link");Kd(fu,{displayName:"Attr<link>",group:"Link"});var mu=Nd("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ct(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(fu.key)(t),...t.attrs,href:pu(t.attrs.href)}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const r=t.url,o=t.title;e.openMark(n,{href:r,title:o}),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})}}}));Kd(mu.mark,{displayName:"MarkSchema<link>",group:"Link"});var gu=vd("ToggleLink",e=>(t={})=>No(mu.type(e),t));Kd(gu,{displayName:"Command<toggleLinkCommand>",group:"Link"});var vu=vd("UpdateLink",e=>(t={})=>(n,r)=>{if(!r)return!1;let o,i=-1;const{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(mu.type(e).isInSet(t.marks))return o=t,i=n,!1}),!o)return!1;const c=o.marks.find(({type:t})=>t===mu.type(e));if(!c)return!1;const d=i,u=i+o.nodeSize,{tr:h}=n,p=mu.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(d,u,c).addMark(d,u,p).setSelection(new qr(h.selection.$anchor)).scrollIntoView()),!0)});Kd(vu,{displayName:"Command<updateLinkCommand>",group:"Link"});var yu=bd("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");const n=t.childCount>0?t.child(t.childCount-1):null,r="paragraph"===n?.type.name&&0===n.content.size?t.content.cut(0,t.content.size-n.nodeSize):t.content;e.next(r)}}}));Kd(yu,{displayName:"NodeSchema<doc>",group:"Doc"});var wu=Object.freeze(["root","blockquote","listItem","footnoteDefinition"]),bu=new Set(["paragraph","heading","tableCell","link","linkReference","emphasis","strong","delete","footnote"]),xu=Sd(wu,"blockContainerTypes");Kd(xu,{displayName:"Ctx<blockContainerTypes>",group:"Remark"});var ku=new Set;function Cu(e){const t=e.isInjected(xu.key)?e.get(xu.key):wu,n=new Set;for(const e of t)bu.has(e)?ku.has(e)||(ku.add(e),console.warn(`[milkdown/preset-commonmark] "${e}" holds phrasing content and cannot be a block container; it is ignored in blockContainerTypes.`)):n.add(e);return n}var Su=new Set(["paragraph","tableCell"]);function Mu(e,t){return ne(e,e=>{return"html"===e.type&&("string"==typeof(t=e.value)&&Ud.test(t.trim()));var t},(e,n)=>{const r=n[n.length-1];if(r)if(Su.has(r.type))1===r.children.length&&(r.children=[]);else if(t.has(r.type)){const t=e;return t.children=[],delete t.value,t.type="paragraph",te}})}var Nu=Td("remark-preserve-empty-line",e=>()=>t=>Mu(t,Cu(e)));Kd(Nu.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),Kd(Nu.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Eu=Od("paragraph");Kd(Eu,{displayName:"Attr<paragraph>",group:"Paragraph"});var Ou=Md("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(Eu.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)=>{t.openNode("paragraph"),n.content&&0!==n.content.size||!function(e){return e.isInjected(Nu.options.key)}(e)?Gd(t,n):t.addNode("html",void 0,"<br />"),t.closeNode()}}}));Kd(Ou.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),Kd(Ou.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Au=vd("TurnIntoText",e=>()=>Mo(Ou.type(e)));Kd(Au,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Tu=Ed("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(Oc);return()=>t.call(Au.key)}}});Kd(Tu.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),Kd(Tu.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var Du=Array(6).fill(0).map((e,t)=>t+1);var _u=Sd(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");Kd(_u,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var Iu=Od("heading");Kd(Iu,{displayName:"Attr<heading>",group:"Heading"});var Ru=Md("heading",e=>{const t=e.get(_u.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:Du.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw Ct(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(Iu.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const r=t.depth;e.openNode(n,{level:r}),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}),Gd(e,t),e.closeNode()}}}});Kd(Ru.node,{displayName:"NodeSchema<heading>",group:"Heading"}),Kd(Ru.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var Lu=yd(e=>Bo(/^(?<hashes>#+)\s$/,Ru.type(e),t=>{const n=t.groups?.hashes?.length||0,{$from:r}=e.get(sc).state.selection,o=r.node();if("heading"===o.type.name){let e=Number(o.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));Kd(Lu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var Bu=vd("WrapInHeading",e=>t=>(t??=1,t<1?Mo(Ou.type(e)):Mo(Ru.type(e),{level:t})));Kd(Bu,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Pu=vd("DowngradeHeading",e=>()=>(t,n,r)=>{const{$from:o}=t.selection,i=o.node();if(i.type!==Ru.type(e)||!t.selection.empty||0!==o.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):Mo(Ou.type(e))(t,n)});Kd(Pu,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var zu=Ed("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(Oc);return()=>t.call(Bu.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(Oc);return()=>t.call(Pu.key)}}});Kd(zu.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),Kd(zu.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var ju=Od("blockquote");Kd(ju,{displayName:"Attr<blockquote>",group:"Blockquote"});var Vu=Md("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(ju.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()}}}));Kd(Vu.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),Kd(Vu.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var Hu=yd(e=>Lo(/^\s*>\s$/,Vu.type(e)));Kd(Hu,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var $u=vd("WrapInBlockquote",e=>()=>So(Vu.type(e)));Kd($u,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var qu=Ed("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(Oc);return()=>t.call($u.key)}}});Kd(qu.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),Kd(qu.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Fu=Od("codeBlock",()=>({pre:{},code:{}}));Kd(Fu,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Wu=Md("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 Ct(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(Fu.key)(t),r=t.attrs.language,o=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...o},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const r=t.lang??"",o=t.value;e.openNode(n,{language:r}),o&&e.addText(o),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})}}}));Kd(Wu.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),Kd(Wu.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Uu=yd(e=>Bo(/^```(?<language>[a-z]*)?[\s\n]$/,Wu.type(e),e=>({language:e.groups?.language??""})));Kd(Uu,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Gu=vd("CreateCodeBlock",e=>(t="")=>Mo(Wu.type(e),{language:t}));Kd(Gu,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),Kd(vd("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Ku=Ed("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(Oc);return()=>t.call(Gu.key)}}});Kd(Ku.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),Kd(Ku.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Ju=Od("image");Kd(Ju,{displayName:"Attr<image>",group:"Image"});var Zu=Md("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 Ct(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(Ju.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const r=t.url,o=t.alt??"",i=t.title??"";e.addNode(n,{src:r,alt:o,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})}}}));Kd(Zu.node,{displayName:"NodeSchema<image>",group:"Image"}),Kd(Zu.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Yu=vd("InsertImage",e=>(t={})=>(n,r)=>{if(!r)return!0;const{src:o="",alt:i="",title:s=""}=t,a=Zu.type(e).create({src:o,alt:i,title:s});return!a||(r(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});Kd(Yu,{displayName:"Command<insertImageCommand>",group:"Image"});var Xu=vd("UpdateImage",e=>(t={})=>(n,r)=>{const o=Ci(n.selection,Zu.type(e));if(!o)return!1;const{node:i,pos:s}=o,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),r?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});Kd(Xu,{displayName:"Command<updateImageCommand>",group:"Image"}),Kd(yd(e=>new Io(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,o)=>{const[i,s,a="",l]=n;return i?t.tr.replaceWith(r,o,Zu.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Qu=Od("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));Kd(Qu,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var eh=Md("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(Qu.key)(t)," "]:["br",e.get(Qu.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")}}}));Kd(eh.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),Kd(eh.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var th=vd("InsertHardbreak",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(!(r instanceof qr))return!1;if(r.empty){const e=r.$from.node();if(e.childCount>0&&"hardbreak"===e.lastChild?.type.name)return n?.(o.replaceRangeWith(r.to-1,r.to,t.schema.node("paragraph")).setSelection(jr.near(o.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(o.setMeta("hardbreak",!0).replaceSelectionWith(eh.type(e).create(),!1).scrollIntoView()),!0});Kd(th,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var nh=Ed("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(Oc);return()=>t.call(th.key)}}});Kd(nh.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),Kd(nh.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var rh=Od("hr");Kd(rh,{displayName:"Attr<hr>",group:"Hr"});var oh=Md("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(rh.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")}}}));Kd(oh.node,{displayName:"NodeSchema<hr>",group:"Hr"}),Kd(oh.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var ih=yd(e=>new Io(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,o)=>{const{tr:i}=t;return n[0]&&i.replaceWith(r-1,o,oh.type(e).create()),i}));Kd(ih,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var sh=vd("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;const r=Ou.node.type(e).create(),{tr:o,selection:i}=t,{from:s}=i,a=oh.type(e).create();if(!a)return!0;const l=o.replaceSelectionWith(a).insert(s,r),c=jr.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});Kd(sh,{displayName:"Command<insertHrCommand>",group:"Hr"});var ah=Od("bulletList");Kd(ah,{displayName:"Attr<bulletList>",group:"BulletList"});var lh=Md("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw Ct(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get(ah.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const r=t.spread??!1;e.openNode(n,{spread:r}).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()}}}));Kd(lh.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),Kd(lh.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var ch=yd(e=>Lo(/^\s*([-+*])\s$/,lh.type(e)));Kd(ch,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var dh=vd("WrapInBulletList",e=>()=>So(lh.type(e)));Kd(dh,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var uh=Ed("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(Oc);return()=>t.call(dh.key)}}});Kd(uh.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),Kd(uh.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var hh=Od("orderedList");Kd(hh,{displayName:"Attr<orderedList>",group:"OrderedList"});var ph=Md("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 Ct(e);return{spread:"true"===e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(hh.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 r=t.spread??!0;e.openNode(n,{spread:r,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:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));Kd(ph.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),Kd(ph.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var fh=yd(e=>Lo(/^\s*(\d+)\.\s$/,ph.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));Kd(fh,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var mh=vd("WrapInOrderedList",e=>()=>So(ph.type(e)));Kd(mh,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var gh=Ed("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(Oc);return()=>t.call(mh.key)}}});Kd(gh.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),Kd(gh.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var vh=Od("listItem");Kd(vh,{displayName:"Attr<listItem>",group:"ListItem"});var yh=Md("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 Ct(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(vh.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 r=null!=t.label?`${t.label}.`:"•",o=null!=t.label?"ordered":"bullet",i=t.spread??!0;e.openNode(n,{label:r,listType:o,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()}}}));Kd(yh.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),Kd(yh.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var wh=vd("SinkListItem",e=>()=>{return t=yh.type(e),function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,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 r=l.lastChild&&l.lastChild.type==a.type,o=qt.from(r?t.create():null),s=new Jt(qt.from(t.create(null,qt.from(a.type.create(null,o)))),r?3:1,0),c=i.start,d=i.end;n(e.tr.step(new hr(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0};var t});Kd(wh,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var bh=vd("LiftListItem",e=>()=>$d(yh.type(e)));Kd(bh,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var xh=vd("SplitListItem",e=>()=>(t,n,r)=>{return(o=yh.type(e),function(e,t){let{$from:n,$to:r,node:i}=e.selection;if(i&&i.isBlock||n.depth<2||!n.sameParent(r))return!1;let s=n.node(-1);if(s.type!=o)return!1;if(0==n.parent.content.size&&n.node(-1).childCount==n.indexAfter(-1)){if(3==n.depth||n.node(-3).type!=o||n.index(-2)!=n.node(-2).childCount-1)return!1;if(t){let r=qt.empty,i=n.index(-1)?1:n.index(-2)?2:3;for(let e=n.depth-i;e>=n.depth-3;e--)r=qt.from(n.node(e).copy(r));let s=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;r=r.append(qt.from(o.createAndFill()));let a=n.before(n.depth-(i-1)),l=e.tr.replace(a,n.after(-s),new Jt(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(jr.near(l.doc.resolve(c))),t(l.scrollIntoView())}return!0}let a=r.pos==n.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(n.pos,r.pos),c=a?[null,{type:a}]:void 0;return!!xr(l.doc,n.pos,2,c)&&(t&&t(l.split(n.pos,2,c).scrollIntoView()),!0)})(t,n&&(e=>{const{$from:r}=t.selection;if(0===r.parent.content.size&&r.node(-1).childCount===r.indexAfter(-1)){const{$from:t}=e.selection;e.setNodeMarkup(t.before(-1),void 0,r.node(-3).attrs)}n(e)}));var o});Kd(xh,{displayName:"Command<splitListItemCommand>",group:"ListItem"});var kh=vd("LiftFirstListItem",e=>()=>function(e){return(t,n,r)=>{const{selection:o}=t;if(!(o instanceof qr))return!1;const{empty:i,$from:s}=o;return!(!i||0!==s.parentOffset)&&s.node(-1).type===yh.type(e)&&uo(t,n,r)}}(e));Kd(kh,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var Ch=Ed("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(Oc);return()=>t.call(xh.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(Oc);return()=>t.call(wh.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(Oc);return()=>t.call(bh.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(Oc);return()=>t.call(kh.key)}}});Kd(Ch.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),Kd(Ch.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var Sh=bd("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)}}}));Kd(Sh,{displayName:"NodeSchema<text>",group:"Text"});var Mh=Od("html");Kd(Mh,{displayName:"Attr<html>",group:"Html"});var Nh=Md("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{const n=document.createElement("span"),r={...e.get(Mh.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,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)}}}));Kd(Nh.node,{displayName:"NodeSchema<html>",group:"Html"}),Kd(Nh.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var Eh=[yu,Eu,Ou,_u,Iu,Ru,Qu,eh,ju,Vu,Fu,Wu,rh,oh,Ju,Zu,ah,lh,hh,ph,vh,yh,Jd,Zd,tu,nu,su,au,fu,mu,Mh,Nh,Sh].flat(),Oh=[Hu,ch,fh,Uu,ih,Lu].flat(),Ah=[Xd,Qd,cu,ou],Th=vd("IsMarkSelected",()=>e=>t=>{if(!e)return!1;const{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),Dh=vd("IsNoteSelected",()=>e=>t=>!!e&&Si(t,e).hasNode),_h=vd("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr;const{$from:r,$to:o}=n.selection,{pos:i}=r,{pos:s}=o,a=i-r.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),Ih=vd("SetBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr,{from:s,to:a}=i.selection;try{i.setBlockType(s,a,r,o)}catch{return!1}return n?.(i),!0}),Rh=vd("WrapInBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;let i=t.tr;try{const{$from:e,$to:t}=i.selection,n=e.blockRange(t),s=n&&vr(n,r,o);if(!s)return!1;i=i.wrap(n,s)}catch{return!1}return n?.(i),!0}),Lh=vd("AddBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr;try{const e=r instanceof fn?r:r.createAndFill(o);if(!e)return!1;i.replaceSelectionWith(e)}catch{return!1}return n?.(i),!0}),Bh=vd("SelectTextNearPos",()=>e=>(t,n)=>{const{pos:r}=e??{};if(null==r)return!1;const o=t.tr;try{const e=t.doc.resolve((i=r,s=0,a=t.doc.content.size,Math.min(Math.max(i,s),a)));o.setSelection(qr.near(e))}catch{return!1}var i,s,a;return n?.(o.scrollIntoView()),!0}),Ph=[Au,$u,Bu,Pu,Gu,th,sh,Yu,Xu,mh,dh,wh,xh,bh,kh,Yd,lu,ru,gu,vu,Th,Dh,_h,Ih,Rh,Lh,Bh],zh=[qu,Ku,nh,zu,Ch,gh,uh,Tu,eu,du,iu].flat(),jh=Td("remarkAddOrderInList",()=>()=>e=>{ee(e,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});Kd(jh.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),Kd(jh.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var Vh=Td("remarkLineBreak",()=>()=>e=>{const t=/(?<![\t ])[\t ]*(?:\r?\n|\r)/g;ee(e,"text",(e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;const o=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&o.push({type:"text",value:e.value.slice(i,n)}),o.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return o.length>0&&r&&"number"==typeof n?(i<e.value.length&&o.push({type:"text",value:e.value.slice(i)}),r.children.splice(n,1,...o),n+o.length):void 0})});Kd(Vh.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),Kd(Vh.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var Hh=Td("remarkInlineLink",()=>Fd);Kd(Hh.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),Kd(Hh.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var $h=Td("remarkHTMLTransformer",e=>()=>t=>{const n=Cu(e);var r;r=(e,t,r)=>(e=>"html"===e.type)(e)?(r&&n.has(r.type)&&(e.children=[Wd(e)],delete e.value,e.type="paragraph"),[e]):[e],function e(t,n,o){if((e=>!!e.children)(t)){const n=[];for(let r=0,o=t.children.length;r<o;r++){const o=t.children[r];if(o){const i=e(o,r,t);if(i)for(let e=0,t=i.length;e<t;e++){const t=i[e];t&&n.push(t)}}}t.children=n}return r(t,n,o)}(t,0,null)[0]});Kd($h.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),Kd($h.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var qh=Td("remarkMarker",()=>()=>(e,t)=>{ee(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)})});Kd(qh.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),Kd(qh.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Fh=xd(()=>{let e=!1;const t=new ao("MILKDOWN_INLINE_NODES_CURSOR"),n=new oo({key:t,state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!(!(n&&r&&n.isInline&&!n.isText&&r.isInline)||r.isText)}},props:{handleDOMEvents:{compositionend:(t,r)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(n.getState(t.state)){const e=t.state.selection.from;r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e))}}),!0),compositionstart:t=>(n.getState(t.state)&&(e=!0),!1),beforeinput:(t,r)=>{if(n.getState(t.state)&&r instanceof InputEvent&&r.data&&!e){const e=t.state.selection.from;return r.preventDefault(),t.dispatch(t.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(n.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),r=Ml.widget(t,n,{side:-1}),o=document.createElement("span"),i=Ml.widget(t,o);return setTimeout(()=>{n.contentEditable="true",o.contentEditable="true"}),Ol.create(e.doc,[r,i])}return Ol.empty}}});return n});Kd(Fh,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var Wh=xd(e=>new oo({key:new ao("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;const o=eh.type(e);let i;return t.forEach((e,n)=>{e.steps.forEach((e,s)=>{if(!(e instanceof ar))return;const a=(e,r)=>t.slice(n).reduce((e,t,n)=>(0===n?t.mapping.slice(s+1):t.mapping).map(e,r),e),l=a(e.from,-1),c=a(e.to,1);r.doc.nodesBetween(l,c,(e,t)=>{e.type!==o||e.attrs.isInline||e.marks.length&&(i??=r.tr,i.setNodeMarkup(t,o,e.attrs,[]))})})}),i}}));Kd(Wh,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Uh=Sd(["table","code_block"],"hardbreakFilterNodes");Kd(Uh,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Gh=xd(e=>{const t=e.get(Uh.key);return new oo({key:new ao("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const r=e.getMeta("hardbreak"),[o]=e.steps;if(r&&o instanceof ur){const e=n.doc.resolve(o.from);let r=e.depth,i=!0;for(;r>0;)t.includes(e.node(r).type.name)&&(i=!1),r--;return i}return!0}})});Kd(Gh,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var Kh=xd(e=>{const t=new ao("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const r=e.get(_u.key),o=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants((n,a)=>{if(n.type===Ru.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let l=r(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(i=!0,o.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),i&&n.dispatch(o)};return new oo({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});Kd(Kh,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Jh=xd(e=>new oo({key:new ao("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;const o=ph.type(e),i=lh.type(e),s=yh.type(e),a=(e,t,n=1)=>{let r=!1;const o=`${t+n}.`;return e.label!==o&&(e.label=o,r=!0),r};let l=r.tr,c=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===i){const n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,o,{spread:!0}),e.descendants((e,t,n,r)=>{if(e.type===s){const n={...e.attrs};a(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===o){const o={...e.attrs};let i=!1;"ordered"!==o.listType&&(o.listType="ordered",i=!0),n?.maybeChild(0)&&(i=a(o,r,n?.attrs.order??1)),i&&(l=l.setNodeMarkup(t,void 0,o),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));Kd(Jh,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var Zh=[Eh,Oh,Ah,Ph,zh,[Wh,Uh,Gh,Fh,xu,jh,Hh,Vh,$h,qh,Nu,Kh,Jh].flat()].flat(),Yh=200,Xh=function(){};Xh.prototype.append=function(e){return e.length?(e=Xh.from(e),!this.length&&e||e.length<Yh&&this.leafAppend(e)||this.length<Yh&&e.leafPrepend(this)||this.appendInner(e)):this},Xh.prototype.prepend=function(e){return e.length?Xh.from(e).append(this):this},Xh.prototype.appendInner=function(e){return new ep(this,e)},Xh.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Xh.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Xh.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Xh.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)},Xh.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Xh.from=function(e){return e instanceof Xh?e:e&&e.length?new Qh(e):Xh.empty};var Qh=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,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Yh)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Yh)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}(Xh);Xh.empty=new Qh([]);var ep=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,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&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}(Xh);class tp{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=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(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new np(e.map));let t,o=e.step.map(n.slice(r));o&&a.maybeStep(o).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new np(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new tp(this.items.slice(0,o).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,r){let o=[],i=this.eventCount,s=this.items,a=!r&&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 np(e.mapping.maps[n],c,t);(l=a&&a.merge(d))&&(d=l,n?o.pop():s=s.slice(0,s.length-1)),o.push(d),t&&(i++,t=void 0),r||(a=d)}let l=i-n.depth;return l>op&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,l),i-=l),new tp(s.append(o),i)}remapping(e,t){let n=new nr;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new tp(this.items.append(e.map(e=>new np(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let a=t;this.items.forEach(t=>{let r=o.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(a+1,r));c&&s++,n.push(new np(l,i,c))}else n.push(new np(l))},r);let l=[];for(let e=t;e<i;e++)l.push(new np(o.maps[e]));let c=this.items.slice(0,r).append(l).append(n),d=new tp(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,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;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&&o++;let l,c=new np(s.invert(),e,a),d=r.length-1;(l=r.length&&r[d].merge(c))?r[d]=l:r.push(c)}}else i.map&&n--},this.items.length,0),new tp(Xh.from(r.reverse()),o)}}tp.empty=new tp(Xh.empty,0);class np{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new np(t.getMap().invert(),t,this.selection)}}}class rp{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const op=20;function ip(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,o)=>t.push(r,o));return t}function sp(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let ap=!1,lp=null;function cp(e){let t=e.plugins;if(lp!=t){ap=!1,lp=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){ap=!0;break}}return ap}const dp=new ao("history"),up=new ao("closeHistory");function hp(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new oo({key:dp,state:{init:()=>new rp(tp.empty,tp.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(dp);if(i)return i.historyState;n.getMeta(up)&&(e=new rp(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(dp))return s.getMeta(dp).redo?new rp(e.done.addTransform(n,void 0,r,cp(t)),e.undone,ip(n.mapping.maps),e.prevTime,e.prevComposition):new rp(e.done,e.undone.addTransform(n,void 0,r,cp(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new rp(e.done.rebased(n,o),e.undone.rebased(n,o),sp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new rp(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),sp(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),a=s?sp(e.prevRanges,n.mapping):ip(n.mapping.maps);return new rp(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,cp(t)),tp.empty,a,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?fp:"historyRedo"==n?mp:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function pp(e,t){return(n,r)=>{let o=dp.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=cp(t),o=dp.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),l=new rp(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(dp,{redo:n,historyState:l})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const fp=pp(!1,!0),mp=pp(!0,!0);
2
2
  /**
3
3
  * @vue/shared v3.5.32
4
4
  * (c) 2018-present Yuxi (Evan) You and Vue contributors