@tiptap/core 2.0.0-beta.18 → 2.0.0-beta.182

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 (333) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -2
  3. package/dist/packages/core/src/CommandManager.d.ts +13 -6
  4. package/dist/packages/core/src/Editor.d.ts +24 -19
  5. package/dist/packages/core/src/EventEmitter.d.ts +8 -4
  6. package/dist/packages/core/src/Extension.d.ts +99 -27
  7. package/dist/packages/core/src/ExtensionManager.d.ts +7 -13
  8. package/dist/packages/core/src/InputRule.d.ts +42 -0
  9. package/dist/packages/core/src/Mark.d.ts +131 -31
  10. package/dist/packages/core/src/Node.d.ts +157 -33
  11. package/dist/packages/core/src/NodeView.d.ts +8 -12
  12. package/dist/packages/core/src/PasteRule.d.ts +42 -0
  13. package/dist/packages/core/src/Tracker.d.ts +11 -0
  14. package/dist/packages/core/src/commands/blur.d.ts +3 -3
  15. package/dist/packages/core/src/commands/clearContent.d.ts +3 -3
  16. package/dist/packages/core/src/commands/clearNodes.d.ts +3 -3
  17. package/dist/packages/core/src/commands/command.d.ts +2 -2
  18. package/dist/packages/core/src/commands/createParagraphNear.d.ts +3 -3
  19. package/dist/packages/core/src/commands/deleteNode.d.ts +13 -0
  20. package/dist/packages/core/src/commands/deleteRange.d.ts +3 -3
  21. package/dist/packages/core/src/commands/deleteSelection.d.ts +3 -3
  22. package/dist/packages/core/src/commands/enter.d.ts +3 -3
  23. package/dist/packages/core/src/commands/exitCode.d.ts +3 -3
  24. package/dist/packages/core/src/commands/extendMarkRange.d.ts +3 -3
  25. package/dist/packages/core/src/commands/first.d.ts +3 -3
  26. package/dist/packages/core/src/commands/focus.d.ts +5 -3
  27. package/dist/packages/core/src/commands/forEach.d.ts +14 -0
  28. package/dist/packages/core/src/commands/index.d.ts +50 -0
  29. package/dist/packages/core/src/commands/insertContent.d.ts +7 -3
  30. package/dist/packages/core/src/commands/insertContentAt.d.ts +16 -0
  31. package/dist/packages/core/src/commands/joinBackward.d.ts +3 -3
  32. package/dist/packages/core/src/commands/joinForward.d.ts +3 -3
  33. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +3 -3
  34. package/dist/packages/core/src/commands/lift.d.ts +3 -3
  35. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +3 -3
  36. package/dist/packages/core/src/commands/liftListItem.d.ts +3 -3
  37. package/dist/packages/core/src/commands/newlineInCode.d.ts +3 -3
  38. package/dist/packages/core/src/commands/resetAttributes.d.ts +13 -0
  39. package/dist/packages/core/src/commands/scrollIntoView.d.ts +3 -3
  40. package/dist/packages/core/src/commands/selectAll.d.ts +3 -3
  41. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +3 -3
  42. package/dist/packages/core/src/commands/selectNodeForward.d.ts +3 -3
  43. package/dist/packages/core/src/commands/selectParentNode.d.ts +3 -3
  44. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +12 -0
  45. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +12 -0
  46. package/dist/packages/core/src/commands/setContent.d.ts +4 -3
  47. package/dist/packages/core/src/commands/setMark.d.ts +3 -3
  48. package/dist/packages/core/src/commands/setMeta.d.ts +12 -0
  49. package/dist/packages/core/src/commands/setNode.d.ts +3 -3
  50. package/dist/packages/core/src/commands/setNodeSelection.d.ts +12 -0
  51. package/dist/packages/core/src/commands/setTextSelection.d.ts +12 -0
  52. package/dist/packages/core/src/commands/sinkListItem.d.ts +3 -3
  53. package/dist/packages/core/src/commands/splitBlock.d.ts +3 -3
  54. package/dist/packages/core/src/commands/splitListItem.d.ts +3 -3
  55. package/dist/packages/core/src/commands/toggleList.d.ts +3 -3
  56. package/dist/packages/core/src/commands/toggleMark.d.ts +8 -3
  57. package/dist/packages/core/src/commands/toggleNode.d.ts +3 -3
  58. package/dist/packages/core/src/commands/toggleWrap.d.ts +3 -3
  59. package/dist/packages/core/src/commands/undoInputRule.d.ts +3 -3
  60. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +3 -3
  61. package/dist/packages/core/src/commands/unsetMark.d.ts +8 -3
  62. package/dist/packages/core/src/commands/updateAttributes.d.ts +13 -0
  63. package/dist/packages/core/src/commands/wrapIn.d.ts +3 -3
  64. package/dist/packages/core/src/commands/wrapInList.d.ts +3 -3
  65. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
  66. package/dist/packages/core/src/extensions/commands.d.ts +2 -95
  67. package/dist/packages/core/src/extensions/editable.d.ts +1 -1
  68. package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
  69. package/dist/packages/core/src/extensions/index.d.ts +1 -0
  70. package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
  71. package/dist/packages/core/src/extensions/tabindex.d.ts +2 -0
  72. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +7 -0
  73. package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
  74. package/dist/packages/core/src/helpers/createDocument.d.ts +3 -4
  75. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +4 -5
  76. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +2 -0
  77. package/dist/packages/core/src/helpers/findChildren.d.ts +3 -0
  78. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +6 -0
  79. package/dist/packages/core/src/helpers/findParentNode.d.ts +2 -3
  80. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +2 -2
  81. package/dist/packages/core/src/helpers/generateHTML.d.ts +2 -2
  82. package/dist/packages/core/src/helpers/generateJSON.d.ts +2 -0
  83. package/dist/packages/core/src/helpers/generateText.d.ts +5 -0
  84. package/dist/packages/core/src/helpers/getAttributes.d.ts +3 -0
  85. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +2 -2
  86. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -0
  87. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +8 -0
  88. package/dist/packages/core/src/helpers/getExtensionField.d.ts +2 -0
  89. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -2
  90. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +2 -3
  91. package/dist/packages/core/src/helpers/getMarkRange.d.ts +1 -1
  92. package/dist/packages/core/src/helpers/getMarkType.d.ts +1 -1
  93. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +2 -2
  94. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +2 -3
  95. package/dist/packages/core/src/helpers/getNodeType.d.ts +1 -1
  96. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +3 -3
  97. package/dist/packages/core/src/helpers/getSchema.d.ts +1 -1
  98. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +3 -0
  99. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +1 -1
  100. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +1 -1
  101. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +2 -2
  102. package/dist/packages/core/src/helpers/getText.d.ts +6 -0
  103. package/dist/packages/core/src/helpers/getTextBetween.d.ts +6 -0
  104. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +2 -0
  105. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +3 -0
  106. package/dist/packages/core/src/helpers/index.d.ts +33 -0
  107. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +1 -1
  108. package/dist/packages/core/src/helpers/isActive.d.ts +1 -2
  109. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
  110. package/dist/packages/core/src/helpers/isList.d.ts +1 -1
  111. package/dist/packages/core/src/helpers/isMarkActive.d.ts +2 -3
  112. package/dist/packages/core/src/helpers/isNodeActive.d.ts +2 -3
  113. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +1 -1
  114. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +1 -1
  115. package/dist/packages/core/src/helpers/isTextSelection.d.ts +1 -1
  116. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -0
  117. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -0
  118. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +1 -1
  119. package/dist/packages/core/src/helpers/splitExtensions.d.ts +6 -6
  120. package/dist/packages/core/src/index.d.ts +14 -21
  121. package/dist/packages/core/src/inputRules/index.d.ts +5 -0
  122. package/dist/packages/core/src/inputRules/markInputRule.d.ts +11 -2
  123. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +11 -2
  124. package/dist/packages/core/src/inputRules/textInputRule.d.ts +9 -0
  125. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +14 -0
  126. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +23 -0
  127. package/dist/packages/core/src/pasteRules/index.d.ts +3 -0
  128. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +11 -2
  129. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +12 -0
  130. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +9 -0
  131. package/dist/packages/core/src/style.d.ts +1 -2
  132. package/dist/packages/core/src/types.d.ts +112 -56
  133. package/dist/packages/core/src/utilities/callOrReturn.d.ts +2 -1
  134. package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -1
  135. package/dist/packages/core/src/utilities/deleteProps.d.ts +1 -2
  136. package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -1
  137. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +1 -0
  138. package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
  139. package/dist/packages/core/src/utilities/fromString.d.ts +1 -1
  140. package/dist/packages/core/src/utilities/index.d.ts +3 -0
  141. package/dist/packages/core/src/utilities/isClass.d.ts +1 -1
  142. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -1
  143. package/dist/packages/core/src/utilities/isFunction.d.ts +1 -0
  144. package/dist/packages/core/src/utilities/isMacOS.d.ts +1 -0
  145. package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
  146. package/dist/packages/core/src/utilities/isObject.d.ts +1 -1
  147. package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -1
  148. package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -0
  149. package/dist/packages/core/src/utilities/isiOS.d.ts +1 -0
  150. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -2
  151. package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -2
  152. package/dist/packages/core/src/utilities/minMax.d.ts +1 -1
  153. package/dist/packages/core/src/utilities/objectIncludes.d.ts +3 -2
  154. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -0
  155. package/dist/tiptap-core.cjs.js +2696 -1374
  156. package/dist/tiptap-core.cjs.js.map +1 -1
  157. package/dist/tiptap-core.esm.js +2630 -1342
  158. package/dist/tiptap-core.esm.js.map +1 -1
  159. package/dist/tiptap-core.umd.js +2648 -1325
  160. package/dist/tiptap-core.umd.js.map +1 -1
  161. package/package.json +17 -20
  162. package/src/CommandManager.ts +63 -64
  163. package/src/Editor.ts +115 -78
  164. package/src/EventEmitter.ts +14 -4
  165. package/src/Extension.ts +193 -43
  166. package/src/ExtensionManager.ts +232 -83
  167. package/src/InputRule.ts +265 -0
  168. package/src/Mark.ts +239 -49
  169. package/src/Node.ts +279 -57
  170. package/src/NodeView.ts +115 -47
  171. package/src/PasteRule.ts +247 -0
  172. package/src/Tracker.ts +42 -0
  173. package/src/commands/blur.ts +12 -6
  174. package/src/commands/clearContent.ts +3 -3
  175. package/src/commands/clearNodes.ts +30 -18
  176. package/src/commands/command.ts +2 -2
  177. package/src/commands/createParagraphNear.ts +4 -3
  178. package/src/commands/deleteNode.ts +37 -0
  179. package/src/commands/deleteRange.ts +3 -3
  180. package/src/commands/deleteSelection.ts +4 -3
  181. package/src/commands/enter.ts +3 -3
  182. package/src/commands/exitCode.ts +4 -3
  183. package/src/commands/extendMarkRange.ts +12 -11
  184. package/src/commands/first.ts +3 -3
  185. package/src/commands/focus.ts +47 -44
  186. package/src/commands/forEach.ts +24 -0
  187. package/src/commands/index.ts +50 -0
  188. package/src/commands/insertContent.ts +13 -24
  189. package/src/commands/insertContentAt.ts +108 -0
  190. package/src/commands/joinBackward.ts +4 -3
  191. package/src/commands/joinForward.ts +4 -3
  192. package/src/commands/keyboardShortcut.ts +6 -6
  193. package/src/commands/lift.ts +6 -5
  194. package/src/commands/liftEmptyBlock.ts +4 -3
  195. package/src/commands/liftListItem.ts +6 -5
  196. package/src/commands/newlineInCode.ts +4 -3
  197. package/src/commands/resetAttributes.ts +62 -0
  198. package/src/commands/scrollIntoView.ts +3 -3
  199. package/src/commands/selectAll.ts +8 -6
  200. package/src/commands/selectNodeBackward.ts +4 -3
  201. package/src/commands/selectNodeForward.ts +4 -3
  202. package/src/commands/selectParentNode.ts +4 -3
  203. package/src/commands/selectTextblockEnd.ts +20 -0
  204. package/src/commands/selectTextblockStart.ts +20 -0
  205. package/src/commands/setContent.ts +9 -15
  206. package/src/commands/setMark.ts +36 -12
  207. package/src/commands/setMeta.ts +18 -0
  208. package/src/commands/setNode.ts +29 -7
  209. package/src/commands/setNodeSelection.ts +29 -0
  210. package/src/commands/setTextSelection.ts +33 -0
  211. package/src/commands/sinkListItem.ts +6 -5
  212. package/src/commands/splitBlock.ts +16 -10
  213. package/src/commands/splitListItem.ts +45 -18
  214. package/src/commands/toggleList.ts +83 -18
  215. package/src/commands/toggleMark.ts +18 -7
  216. package/src/commands/toggleNode.ts +6 -5
  217. package/src/commands/toggleWrap.ts +9 -9
  218. package/src/commands/undoInputRule.ts +34 -5
  219. package/src/commands/unsetAllMarks.ts +7 -11
  220. package/src/commands/unsetMark.ts +35 -22
  221. package/src/commands/updateAttributes.ts +73 -0
  222. package/src/commands/wrapIn.ts +5 -10
  223. package/src/commands/wrapInList.ts +6 -5
  224. package/src/extensions/clipboardTextSerializer.ts +14 -35
  225. package/src/extensions/commands.ts +3 -141
  226. package/src/extensions/editable.ts +1 -0
  227. package/src/extensions/focusEvents.ts +3 -5
  228. package/src/extensions/index.ts +1 -0
  229. package/src/extensions/keymap.ts +110 -13
  230. package/src/extensions/tabindex.ts +18 -0
  231. package/src/helpers/combineTransactionSteps.ts +18 -0
  232. package/src/helpers/createChainableState.ts +38 -0
  233. package/src/helpers/createDocument.ts +5 -6
  234. package/src/helpers/createNodeFromContent.ts +17 -19
  235. package/src/helpers/defaultBlockAt.ts +13 -0
  236. package/src/helpers/findChildren.ts +18 -0
  237. package/src/helpers/findChildrenInRange.ts +32 -0
  238. package/src/helpers/findParentNode.ts +3 -2
  239. package/src/helpers/findParentNodeClosestToPos.ts +3 -2
  240. package/src/helpers/generateHTML.ts +6 -5
  241. package/src/helpers/generateJSON.ts +14 -0
  242. package/src/helpers/generateText.ts +30 -0
  243. package/src/helpers/getAttributes.ts +28 -0
  244. package/src/helpers/getAttributesFromExtensions.ts +42 -14
  245. package/src/helpers/getChangedRanges.ts +83 -0
  246. package/src/helpers/getDebugJSON.ts +54 -0
  247. package/src/helpers/getExtensionField.ts +25 -0
  248. package/src/helpers/getHTMLFromFragment.ts +6 -5
  249. package/src/helpers/getMarkAttributes.ts +14 -10
  250. package/src/helpers/getMarkRange.ts +41 -8
  251. package/src/helpers/getMarkType.ts +5 -1
  252. package/src/helpers/getMarksBetween.ts +32 -10
  253. package/src/helpers/getNodeAttributes.ts +9 -9
  254. package/src/helpers/getNodeType.ts +5 -1
  255. package/src/helpers/getRenderedAttributes.ts +6 -7
  256. package/src/helpers/getSchema.ts +7 -133
  257. package/src/helpers/getSchemaByResolvedExtensions.ts +148 -0
  258. package/src/helpers/getSchemaTypeByName.ts +2 -10
  259. package/src/helpers/getSchemaTypeNameByName.ts +1 -1
  260. package/src/helpers/getSplittedAttributes.ts +4 -4
  261. package/src/helpers/getText.ts +19 -0
  262. package/src/helpers/getTextBetween.ts +49 -0
  263. package/src/helpers/getTextContentFromNodes.ts +17 -0
  264. package/src/helpers/getTextSerializersFromSchema.ts +10 -0
  265. package/src/helpers/index.ts +33 -0
  266. package/src/helpers/injectExtensionAttributesToParseRule.ts +17 -19
  267. package/src/helpers/isActive.ts +5 -5
  268. package/src/helpers/isExtensionRulesEnabled.ts +15 -0
  269. package/src/helpers/isList.ts +14 -7
  270. package/src/helpers/isMarkActive.ts +45 -20
  271. package/src/helpers/isNodeActive.ts +28 -35
  272. package/src/helpers/isNodeEmpty.ts +1 -1
  273. package/src/helpers/isNodeSelection.ts +3 -2
  274. package/src/helpers/isTextSelection.ts +3 -2
  275. package/src/helpers/posToDOMRect.ts +35 -0
  276. package/src/helpers/resolveFocusPosition.ts +43 -0
  277. package/src/helpers/selectionToInsertionEnd.ts +2 -2
  278. package/src/helpers/splitExtensions.ts +3 -3
  279. package/src/index.ts +15 -24
  280. package/src/inputRules/index.ts +5 -0
  281. package/src/inputRules/markInputRule.ts +59 -39
  282. package/src/inputRules/nodeInputRule.ts +45 -11
  283. package/src/inputRules/textInputRule.ts +35 -0
  284. package/src/inputRules/textblockTypeInputRule.ts +38 -0
  285. package/src/inputRules/wrappingInputRule.ts +60 -0
  286. package/src/pasteRules/index.ts +3 -0
  287. package/src/pasteRules/markPasteRule.ts +62 -53
  288. package/src/pasteRules/nodePasteRule.ts +39 -0
  289. package/src/pasteRules/textPasteRule.ts +35 -0
  290. package/src/style.ts +16 -3
  291. package/src/types.ts +129 -43
  292. package/src/utilities/callOrReturn.ts +6 -3
  293. package/src/utilities/createStyleTag.ts +12 -1
  294. package/src/utilities/deleteProps.ts +2 -4
  295. package/src/utilities/elementFromString.ts +4 -5
  296. package/src/utilities/escapeForRegEx.ts +4 -0
  297. package/src/utilities/findDuplicates.ts +5 -0
  298. package/src/utilities/fromString.ts +2 -2
  299. package/src/utilities/index.ts +3 -0
  300. package/src/utilities/isClass.ts +2 -2
  301. package/src/utilities/isEmptyObject.ts +2 -2
  302. package/src/utilities/isFunction.ts +3 -0
  303. package/src/utilities/isMacOS.ts +5 -0
  304. package/src/utilities/isNumber.ts +3 -0
  305. package/src/utilities/isObject.ts +6 -6
  306. package/src/utilities/isPlainObject.ts +8 -5
  307. package/src/utilities/isRegExp.ts +3 -0
  308. package/src/utilities/isString.ts +3 -0
  309. package/src/utilities/isiOS.ts +12 -0
  310. package/src/utilities/mergeAttributes.ts +2 -3
  311. package/src/utilities/mergeDeep.ts +2 -3
  312. package/src/utilities/minMax.ts +1 -1
  313. package/src/utilities/objectIncludes.ts +17 -5
  314. package/src/utilities/removeDuplicates.ts +15 -0
  315. package/CHANGELOG.md +0 -335
  316. package/dist/packages/core/src/commands/insertHTML.d.ts +0 -12
  317. package/dist/packages/core/src/commands/insertNode.d.ts +0 -13
  318. package/dist/packages/core/src/commands/insertText.d.ts +0 -12
  319. package/dist/packages/core/src/commands/replace.d.ts +0 -13
  320. package/dist/packages/core/src/commands/replaceRange.d.ts +0 -13
  321. package/dist/packages/core/src/commands/resetNodeAttributes.d.ts +0 -13
  322. package/dist/packages/core/src/commands/updateNodeAttributes.d.ts +0 -13
  323. package/dist/packages/core/src/utilities/removeElement.d.ts +0 -1
  324. package/dist/tiptap-core.bundle.umd.min.js +0 -17
  325. package/dist/tiptap-core.bundle.umd.min.js.map +0 -1
  326. package/src/commands/insertHTML.ts +0 -30
  327. package/src/commands/insertNode.ts +0 -33
  328. package/src/commands/insertText.ts +0 -22
  329. package/src/commands/replace.ts +0 -20
  330. package/src/commands/replaceRange.ts +0 -36
  331. package/src/commands/resetNodeAttributes.ts +0 -31
  332. package/src/commands/updateNodeAttributes.ts +0 -33
  333. package/src/utilities/removeElement.ts +0 -5
@@ -1,17 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@tiptap/core"]={})}(this,(function(t){"use strict";function e(t){this.content=t}e.prototype={constructor:e,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,n,r){var o=r&&r!=t?this.remove(r):this,i=o.find(t),s=o.content.slice();return-1==i?s.push(r||t,n):(s[i+1]=n,r&&(s[i]=r)),new e(s)},remove:function(t){var n=this.find(t);if(-1==n)return this;var r=this.content.slice();return r.splice(n,2),new e(r)},addToStart:function(t,n){return new e([t,n].concat(this.remove(t).content))},addToEnd:function(t,n){var r=this.remove(t).content.slice();return r.push(t,n),new e(r)},addBefore:function(t,n,r){var o=this.remove(n),i=o.content.slice(),s=o.find(t);return i.splice(-1==s?i.length:s,0,n,r),new e(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=e.from(t)).size?new e(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=e.from(t)).size?new e(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var n=this;t=e.from(t);for(var r=0;r<t.content.length;r+=2)n=n.remove(t.content[r]);return n},get size(){return this.content.length>>1}},e.from=function(t){if(t instanceof e)return t;var n=[];if(t)for(var r in t)n.push(r,t[r]);return new e(n)};var n=e;function r(t,e,n){for(var o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;var i=t.child(o),s=e.child(o);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(var a=0;i.text[a]==s.text[a];a++)n++;return n}if(i.content.size||s.content.size){var c=r(i.content,s.content,n+1);if(null!=c)return c}n+=i.nodeSize}else n+=i.nodeSize}}function o(t,e,n,r){for(var i=t.childCount,s=e.childCount;;){if(0==i||0==s)return i==s?null:{a:n,b:r};var a=t.child(--i),c=e.child(--s),p=a.nodeSize;if(a!=c){if(!a.sameMarkup(c))return{a:n,b:r};if(a.isText&&a.text!=c.text){for(var l=0,h=Math.min(a.text.length,c.text.length);l<h&&a.text[a.text.length-l-1]==c.text[c.text.length-l-1];)l++,n--,r--;return{a:n,b:r}}if(a.content.size||c.content.size){var f=o(a.content,c.content,n-1,r-1);if(f)return f}n-=p,r-=p}else n-=p,r-=p}}var i=function(t,e){if(this.content=t,this.size=e||0,null==e)for(var n=0;n<t.length;n++)this.size+=t[n].nodeSize},s={firstChild:{configurable:!0},lastChild:{configurable:!0},childCount:{configurable:!0}};i.prototype.nodesBetween=function(t,e,n,r,o){void 0===r&&(r=0);for(var i=0,s=0;s<e;i++){var a=this.content[i],c=s+a.nodeSize;if(c>t&&!1!==n(a,r+s,o,i)&&a.content.size){var p=s+1;a.nodesBetween(Math.max(0,t-p),Math.min(a.content.size,e-p),n,r+p)}s=c}},i.prototype.descendants=function(t){this.nodesBetween(0,this.size,t)},i.prototype.textBetween=function(t,e,n,r){var o="",i=!0;return this.nodesBetween(t,e,(function(s,a){s.isText?(o+=s.text.slice(Math.max(t,a)-a,e-a),i=!n):s.isLeaf&&r?(o+=r,i=!n):!i&&s.isBlock&&(o+=n,i=!0)}),0),o},i.prototype.append=function(t){if(!t.size)return this;if(!this.size)return t;var e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new i(r,this.size+t.size)},i.prototype.cut=function(t,e){if(null==e&&(e=this.size),0==t&&e==this.size)return this;var n=[],r=0;if(e>t)for(var o=0,s=0;s<e;o++){var a=this.content[o],c=s+a.nodeSize;c>t&&((s<t||c>e)&&(a=a.isText?a.cut(Math.max(0,t-s),Math.min(a.text.length,e-s)):a.cut(Math.max(0,t-s-1),Math.min(a.content.size,e-s-1))),n.push(a),r+=a.nodeSize),s=c}return new i(n,r)},i.prototype.cutByIndex=function(t,e){return t==e?i.empty:0==t&&e==this.content.length?this:new i(this.content.slice(t,e))},i.prototype.replaceChild=function(t,e){var n=this.content[t];if(n==e)return this;var r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new i(r,o)},i.prototype.addToStart=function(t){return new i([t].concat(this.content),this.size+t.nodeSize)},i.prototype.addToEnd=function(t){return new i(this.content.concat(t),this.size+t.nodeSize)},i.prototype.eq=function(t){if(this.content.length!=t.content.length)return!1;for(var e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))return!1;return!0},s.firstChild.get=function(){return this.content.length?this.content[0]:null},s.lastChild.get=function(){return this.content.length?this.content[this.content.length-1]:null},s.childCount.get=function(){return this.content.length},i.prototype.child=function(t){var e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e},i.prototype.maybeChild=function(t){return this.content[t]},i.prototype.forEach=function(t){for(var e=0,n=0;e<this.content.length;e++){var r=this.content[e];t(r,n,e),n+=r.nodeSize}},i.prototype.findDiffStart=function(t,e){return void 0===e&&(e=0),r(this,t,e)},i.prototype.findDiffEnd=function(t,e,n){return void 0===e&&(e=this.size),void 0===n&&(n=t.size),o(this,t,e,n)},i.prototype.findIndex=function(t,e){if(void 0===e&&(e=-1),0==t)return c(0,t);if(t==this.size)return c(this.content.length,t);if(t>this.size||t<0)throw new RangeError("Position "+t+" outside of fragment ("+this+")");for(var n=0,r=0;;n++){var o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?c(n+1,o):c(n,r);r=o}},i.prototype.toString=function(){return"<"+this.toStringInner()+">"},i.prototype.toStringInner=function(){return this.content.join(", ")},i.prototype.toJSON=function(){return this.content.length?this.content.map((function(t){return t.toJSON()})):null},i.fromJSON=function(t,e){if(!e)return i.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new i(e.map(t.nodeFromJSON))},i.fromArray=function(t){if(!t.length)return i.empty;for(var e,n=0,r=0;r<t.length;r++){var o=t[r];n+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(e||(e=t.slice(0,r)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}return new i(e||t,n)},i.from=function(t){if(!t)return i.empty;if(t instanceof i)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new i([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))},Object.defineProperties(i.prototype,s);var a={index:0,offset:0};function c(t,e){return a.index=t,a.offset=e,a}function p(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(!p(t[r],e[r]))return!1}else{for(var o in t)if(!(o in e)||!p(t[o],e[o]))return!1;for(var i in e)if(!(i in t))return!1}return!0}i.empty=new i([],0);var l=function(t,e){this.type=t,this.attrs=e};function h(t){var e=Error.call(this,t);return e.__proto__=h.prototype,e}l.prototype.addToSet=function(t){for(var e,n=!1,r=0;r<t.length;r++){var o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e},l.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t},l.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1},l.prototype.eq=function(t){return this==t||this.type==t.type&&p(this.attrs,t.attrs)},l.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return t},l.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");var n=t.marks[e.type];if(!n)throw new RangeError("There is no mark type "+e.type+" in this schema");return n.create(e.attrs)},l.sameSet=function(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0},l.setFrom=function(t){if(!t||0==t.length)return l.none;if(t instanceof l)return[t];var e=t.slice();return e.sort((function(t,e){return t.type.rank-e.type.rank})),e},l.none=[],h.prototype=Object.create(Error.prototype),h.prototype.constructor=h,h.prototype.name="ReplaceError";var f=function(t,e,n){this.content=t,this.openStart=e,this.openEnd=n},d={size:{configurable:!0}};function u(t,e,n){var r=t.findIndex(e),o=r.index,i=r.offset,s=t.maybeChild(o),a=t.findIndex(n),c=a.index,p=a.offset;if(i==e||s.isText){if(p!=n&&!t.child(c).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=c)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(u(s.content,e-i-1,n-i-1)))}function m(t,e,n,r){var o=t.findIndex(e),i=o.index,s=o.offset,a=t.maybeChild(i);if(s==e||a.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));var c=m(a.content,e-s-1,n);return c&&t.replaceChild(i,a.copy(c))}function v(t,e,n){if(n.openStart>t.depth)throw new h("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new h("Inconsistent open depths");return g(t,e,n,0)}function g(t,e,n,r){var o=t.index(r),s=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){var a=g(t,e,n,r+1);return s.copy(s.content.replaceChild(o,a))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){var c=function(t,e){for(var n=e.depth-t.openStart,r=e.node(n).copy(t.content),o=n-1;o>=0;o--)r=e.node(o).copy(i.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return x(s,S(t,c.start,c.end,e,r))}var p=t.parent,l=p.content;return x(p,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}return x(s,O(t,e,r))}function y(t,e){if(!e.type.compatibleContent(t.type))throw new h("Cannot join "+e.type.name+" onto "+t.type.name)}function b(t,e,n){var r=t.node(n);return y(r,e.node(n)),r}function w(t,e){var n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function k(t,e,n,r){var o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(w(t.nodeAfter,r),i++));for(var a=i;a<s;a++)w(o.child(a),r);e&&e.depth==n&&e.textOffset&&w(e.nodeBefore,r)}function x(t,e){if(!t.type.validContent(e))throw new h("Invalid content for node "+t.type.name);return t.copy(e)}function S(t,e,n,r,o){var s=t.depth>o&&b(t,e,o+1),a=r.depth>o&&b(n,r,o+1),c=[];return k(null,t,o,c),s&&a&&e.index(o)==n.index(o)?(y(s,a),w(x(s,S(t,e,n,r,o+1)),c)):(s&&w(x(s,O(t,e,o+1)),c),k(e,n,o,c),a&&w(x(a,O(n,r,o+1)),c)),k(r,null,o,c),new i(c)}function O(t,e,n){var r=[];(k(null,t,n,r),t.depth>n)&&w(x(b(t,e,n+1),O(t,e,n+1)),r);return k(e,null,n,r),new i(r)}d.size.get=function(){return this.content.size-this.openStart-this.openEnd},f.prototype.insertAt=function(t,e){var n=m(this.content,t+this.openStart,e,null);return n&&new f(n,this.openStart,this.openEnd)},f.prototype.removeBetween=function(t,e){return new f(u(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)},f.prototype.eq=function(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd},f.prototype.toString=function(){return this.content+"("+this.openStart+","+this.openEnd+")"},f.prototype.toJSON=function(){if(!this.content.size)return null;var t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t},f.fromJSON=function(t,e){if(!e)return f.empty;var n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new f(i.fromJSON(t,e.content),n,r)},f.maxOpen=function(t,e){void 0===e&&(e=!0);for(var n=0,r=0,o=t.firstChild;o&&!o.isLeaf&&(e||!o.type.spec.isolating);o=o.firstChild)n++;for(var i=t.lastChild;i&&!i.isLeaf&&(e||!i.type.spec.isolating);i=i.lastChild)r++;return new f(t,n,r)},Object.defineProperties(f.prototype,d),f.empty=new f(i.empty,0,0);var M=function(t,e,n){this.pos=t,this.path=e,this.depth=e.length/3-1,this.parentOffset=n},C={parent:{configurable:!0},doc:{configurable:!0},textOffset:{configurable:!0},nodeAfter:{configurable:!0},nodeBefore:{configurable:!0}};M.prototype.resolveDepth=function(t){return null==t?this.depth:t<0?this.depth+t:t},C.parent.get=function(){return this.node(this.depth)},C.doc.get=function(){return this.node(0)},M.prototype.node=function(t){return this.path[3*this.resolveDepth(t)]},M.prototype.index=function(t){return this.path[3*this.resolveDepth(t)+1]},M.prototype.indexAfter=function(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)},M.prototype.start=function(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1},M.prototype.end=function(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size},M.prototype.before=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]},M.prototype.after=function(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize},C.textOffset.get=function(){return this.pos-this.path[this.path.length-1]},C.nodeAfter.get=function(){var t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;var n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r},C.nodeBefore.get=function(){var t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)},M.prototype.posAtIndex=function(t,e){e=this.resolveDepth(e);for(var n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1,o=0;o<t;o++)r+=n.child(o).nodeSize;return r},M.prototype.marks=function(){var t=this.parent,e=this.index();if(0==t.content.size)return l.none;if(this.textOffset)return t.child(e).marks;var n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){var o=n;n=r,r=o}for(var i=n.marks,s=0;s<i.length;s++)!1!==i[s].type.spec.inclusive||r&&i[s].isInSet(r.marks)||(i=i[s--].removeFromSet(i));return i},M.prototype.marksAcross=function(t){var e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;for(var n=e.marks,r=t.parent.maybeChild(t.index()),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},M.prototype.sharedDepth=function(t){for(var e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0},M.prototype.blockRange=function(t,e){if(void 0===t&&(t=this),t.pos<this.pos)return t.blockRange(this);for(var n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new D(this,t,n)},M.prototype.sameParent=function(t){return this.pos-this.parentOffset==t.pos-t.parentOffset},M.prototype.max=function(t){return t.pos>this.pos?t:this},M.prototype.min=function(t){return t.pos<this.pos?t:this},M.prototype.toString=function(){for(var t="",e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset},M.resolve=function(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");for(var n=[],r=0,o=e,i=t;;){var s=i.content.findIndex(o),a=s.index,c=s.offset,p=o-c;if(n.push(i,a,r+c),!p)break;if((i=i.child(a)).isText)break;o=p-1,r+=c+1}return new M(e,n,o)},M.resolveCached=function(t,e){for(var n=0;n<N.length;n++){var r=N[n];if(r.pos==e&&r.doc==t)return r}var o=N[T]=M.resolve(t,e);return T=(T+1)%E,o},Object.defineProperties(M.prototype,C);var N=[],T=0,E=12,D=function(t,e,n){this.$from=t,this.$to=e,this.depth=n},A={start:{configurable:!0},end:{configurable:!0},parent:{configurable:!0},startIndex:{configurable:!0},endIndex:{configurable:!0}};A.start.get=function(){return this.$from.before(this.depth+1)},A.end.get=function(){return this.$to.after(this.depth+1)},A.parent.get=function(){return this.$from.node(this.depth)},A.startIndex.get=function(){return this.$from.index(this.depth)},A.endIndex.get=function(){return this.$to.indexAfter(this.depth)},Object.defineProperties(D.prototype,A);var _=Object.create(null),z=function(t,e,n,r){this.type=t,this.attrs=e,this.content=n||i.empty,this.marks=r||l.none},R={nodeSize:{configurable:!0},childCount:{configurable:!0},textContent:{configurable:!0},firstChild:{configurable:!0},lastChild:{configurable:!0},isBlock:{configurable:!0},isTextblock:{configurable:!0},inlineContent:{configurable:!0},isInline:{configurable:!0},isText:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};R.nodeSize.get=function(){return this.isLeaf?1:2+this.content.size},R.childCount.get=function(){return this.content.childCount},z.prototype.child=function(t){return this.content.child(t)},z.prototype.maybeChild=function(t){return this.content.maybeChild(t)},z.prototype.forEach=function(t){this.content.forEach(t)},z.prototype.nodesBetween=function(t,e,n,r){void 0===r&&(r=0),this.content.nodesBetween(t,e,n,r,this)},z.prototype.descendants=function(t){this.nodesBetween(0,this.content.size,t)},R.textContent.get=function(){return this.textBetween(0,this.content.size,"")},z.prototype.textBetween=function(t,e,n,r){return this.content.textBetween(t,e,n,r)},R.firstChild.get=function(){return this.content.firstChild},R.lastChild.get=function(){return this.content.lastChild},z.prototype.eq=function(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)},z.prototype.sameMarkup=function(t){return this.hasMarkup(t.type,t.attrs,t.marks)},z.prototype.hasMarkup=function(t,e,n){return this.type==t&&p(this.attrs,e||t.defaultAttrs||_)&&l.sameSet(this.marks,n||l.none)},z.prototype.copy=function(t){return void 0===t&&(t=null),t==this.content?this:new this.constructor(this.type,this.attrs,t,this.marks)},z.prototype.mark=function(t){return t==this.marks?this:new this.constructor(this.type,this.attrs,this.content,t)},z.prototype.cut=function(t,e){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))},z.prototype.slice=function(t,e,n){if(void 0===e&&(e=this.content.size),void 0===n&&(n=!1),t==e)return f.empty;var r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new f(a,r.depth-i,o.depth-i)},z.prototype.replace=function(t,e,n){return v(this.resolve(t),this.resolve(e),n)},z.prototype.nodeAt=function(t){for(var e=this;;){var n=e.content.findIndex(t),r=n.index,o=n.offset;if(!(e=e.maybeChild(r)))return null;if(o==t||e.isText)return e;t-=o+1}},z.prototype.childAfter=function(t){var e=this.content.findIndex(t),n=e.index,r=e.offset;return{node:this.content.maybeChild(n),index:n,offset:r}},z.prototype.childBefore=function(t){if(0==t)return{node:null,index:0,offset:0};var e=this.content.findIndex(t),n=e.index,r=e.offset;if(r<t)return{node:this.content.child(n),index:n,offset:r};var o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}},z.prototype.resolve=function(t){return M.resolveCached(this,t)},z.prototype.resolveNoCache=function(t){return M.resolve(this,t)},z.prototype.rangeHasMark=function(t,e,n){var r=!1;return e>t&&this.nodesBetween(t,e,(function(t){return n.isInSet(t.marks)&&(r=!0),!r})),r},R.isBlock.get=function(){return this.type.isBlock},R.isTextblock.get=function(){return this.type.isTextblock},R.inlineContent.get=function(){return this.type.inlineContent},R.isInline.get=function(){return this.type.isInline},R.isText.get=function(){return this.type.isText},R.isLeaf.get=function(){return this.type.isLeaf},R.isAtom.get=function(){return this.type.isAtom},z.prototype.toString=function(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);var t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),P(this.marks,t)},z.prototype.contentMatchAt=function(t){var e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e},z.prototype.canReplace=function(t,e,n,r,o){void 0===n&&(n=i.empty),void 0===r&&(r=0),void 0===o&&(o=n.childCount);var s=this.contentMatchAt(t).matchFragment(n,r,o),a=s&&s.matchFragment(this.content,e);if(!a||!a.validEnd)return!1;for(var c=r;c<o;c++)if(!this.type.allowsMarks(n.child(c).marks))return!1;return!0},z.prototype.canReplaceWith=function(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;var o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd},z.prototype.canAppend=function(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)},z.prototype.check=function(){if(!this.type.validContent(this.content))throw new RangeError("Invalid content for node "+this.type.name+": "+this.content.toString().slice(0,50));for(var t=l.none,e=0;e<this.marks.length;e++)t=this.marks[e].addToSet(t);if(!l.sameSet(t,this.marks))throw new RangeError("Invalid collection of marks for node "+this.type.name+": "+this.marks.map((function(t){return t.type.name})));this.content.forEach((function(t){return t.check()}))},z.prototype.toJSON=function(){var t={type:this.type.name};for(var e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((function(t){return t.toJSON()}))),t},z.fromJSON=function(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");var n=null;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}var r=i.fromJSON(t,e.content);return t.nodeType(e.type).create(e.attrs,r,n)},Object.defineProperties(z.prototype,R);var I=function(t){function e(e,n,r,o){if(t.call(this,e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={textContent:{configurable:!0},nodeSize:{configurable:!0}};return e.prototype.toString=function(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):P(this.marks,JSON.stringify(this.text))},n.textContent.get=function(){return this.text},e.prototype.textBetween=function(t,e){return this.text.slice(t,e)},n.nodeSize.get=function(){return this.text.length},e.prototype.mark=function(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)},e.prototype.withText=function(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)},e.prototype.cut=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.text.length),0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))},e.prototype.eq=function(t){return this.sameMarkup(t)&&this.text==t.text},e.prototype.toJSON=function(){var e=t.prototype.toJSON.call(this);return e.text=this.text,e},Object.defineProperties(e.prototype,n),e}(z);function P(t,e){for(var n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var j=function(t){this.validEnd=t,this.next=[],this.wrapCache=[]},$={inlineContent:{configurable:!0},defaultType:{configurable:!0},edgeCount:{configurable:!0}};j.parse=function(t,e){var n=new B(t,e);if(null==n.next)return j.empty;var r=F(n);n.next&&n.err("Unexpected trailing text");var o=function(t){var e=Object.create(null);return n(H(t,0));function n(r){var o=[];r.forEach((function(e){t[e].forEach((function(e){var n=e.term,r=e.to;if(n){var i=o.indexOf(n),s=i>-1&&o[i+1];H(t,r).forEach((function(t){s||o.push(n,s=[]),-1==s.indexOf(t)&&s.push(t)}))}}))}));for(var i=e[r.join(",")]=new j(r.indexOf(t.length-1)>-1),s=0;s<o.length;s+=2){var a=o[s+1].sort(K);i.next.push(o[s],e[a.join(",")]||n(a))}return i}}(function(t){var e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){var o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((function(t){return t.to=e}))}function i(t,e){if("choice"==t.type)return t.exprs.reduce((function(t,n){return t.concat(i(n,e))}),[]);if("seq"==t.type)for(var s=0;;s++){var a=i(t.exprs[s],e);if(s==t.exprs.length-1)return a;o(a,e=n())}else{if("star"==t.type){var c=n();return r(e,c),o(i(t.expr,c),c),[r(c)]}if("plus"==t.type){var p=n();return o(i(t.expr,e),p),o(i(t.expr,p),p),[r(p)]}if("opt"==t.type)return[r(e)].concat(i(t.expr,e));if("range"==t.type){for(var l=e,h=0;h<t.min;h++){var f=n();o(i(t.expr,l),f),l=f}if(-1==t.max)o(i(t.expr,l),l);else for(var d=t.min;d<t.max;d++){var u=n();r(l,u),o(i(t.expr,l),u),l=u}return[r(l)]}if("name"==t.type)return[r(e,null,t.value)]}}}(r));return function(t,e){for(var n=0,r=[t];n<r.length;n++){for(var o=r[n],i=!o.validEnd,s=[],a=0;a<o.next.length;a+=2){var c=o.next[a],p=o.next[a+1];s.push(c.name),!i||c.isText||c.hasRequiredAttrs()||(i=!1),-1==r.indexOf(p)&&r.push(p)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o},j.prototype.matchType=function(t){for(var e=0;e<this.next.length;e+=2)if(this.next[e]==t)return this.next[e+1];return null},j.prototype.matchFragment=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=t.childCount);for(var r=this,o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r},$.inlineContent.get=function(){var t=this.next[0];return!!t&&t.isInline},$.defaultType.get=function(){for(var t=0;t<this.next.length;t+=2){var e=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}},j.prototype.compatible=function(t){for(var e=0;e<this.next.length;e+=2)for(var n=0;n<t.next.length;n+=2)if(this.next[e]==t.next[n])return!0;return!1},j.prototype.fillBefore=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=0);var r=[this];return function o(s,a){var c=s.matchFragment(t,n);if(c&&(!e||c.validEnd))return i.from(a.map((function(t){return t.createAndFill()})));for(var p=0;p<s.next.length;p+=2){var l=s.next[p],h=s.next[p+1];if(!l.isText&&!l.hasRequiredAttrs()&&-1==r.indexOf(h)){r.push(h);var f=o(h,a.concat(l));if(f)return f}}}(this,[])},j.prototype.findWrapping=function(t){for(var e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];var n=this.computeWrapping(t);return this.wrapCache.push(t,n),n},j.prototype.computeWrapping=function(t){for(var e=Object.create(null),n=[{match:this,type:null,via:null}];n.length;){var r=n.shift(),o=r.match;if(o.matchType(t)){for(var i=[],s=r;s.type;s=s.via)i.push(s.type);return i.reverse()}for(var a=0;a<o.next.length;a+=2){var c=o.next[a];c.isLeaf||c.hasRequiredAttrs()||c.name in e||r.type&&!o.next[a+1].validEnd||(n.push({match:c.contentMatch,type:c,via:r}),e[c.name]=!0)}}},$.edgeCount.get=function(){return this.next.length>>1},j.prototype.edge=function(t){var e=t<<1;if(e>=this.next.length)throw new RangeError("There's no "+t+"th edge in this content match");return{type:this.next[e],next:this.next[e+1]}},j.prototype.toString=function(){var t=[];return function e(n){t.push(n);for(var r=1;r<n.next.length;r+=2)-1==t.indexOf(n.next[r])&&e(n.next[r])}(this),t.map((function(e,n){for(var r=n+(e.validEnd?"*":" ")+" ",o=0;o<e.next.length;o+=2)r+=(o?", ":"")+e.next[o].name+"->"+t.indexOf(e.next[o+1]);return r})).join("\n")},Object.defineProperties(j.prototype,$),j.empty=new j(!0);var B=function(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()},V={next:{configurable:!0}};function F(t){var e=[];do{e.push(L(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function L(t){var e=[];do{e.push(J(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function J(t){for(var e=function(t){if(t.eat("(")){var e=F(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){var n=function(t,e){var n=t.nodeTypes,r=n[e];if(r)return[r];var o=[];for(var i in n){var s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}0==o.length&&t.err("No node type or group '"+e+"' found");return o}(t,t.next).map((function(e){return null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e}}));return t.pos++,1==n.length?n[0]:{type:"choice",exprs:n}}t.err("Unexpected token '"+t.next+"'")}(t);;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=q(t,e)}return e}function W(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");var e=Number(t.next);return t.pos++,e}function q(t,e){var n=W(t),r=n;return t.eat(",")&&(r="}"!=t.next?W(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function K(t,e){return e-t}function H(t,e){var n=[];return function e(r){var o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(var i=0;i<o.length;i++){var s=o[i],a=s.term,c=s.to;a||-1!=n.indexOf(c)||e(c)}}(e),n.sort(K)}function U(t){var e=Object.create(null);for(var n in t){var r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function G(t,e){var n=Object.create(null);for(var r in t){var o=e&&e[r];if(void 0===o){var i=t[r];if(!i.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=i.default}n[r]=o}return n}function X(t){var e=Object.create(null);if(t)for(var n in t)e[n]=new Z(t[n]);return e}V.next.get=function(){return this.tokens[this.pos]},B.prototype.eat=function(t){return this.next==t&&(this.pos++||!0)},B.prototype.err=function(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")},Object.defineProperties(B.prototype,V);var Y=function(t,e,n){this.name=t,this.schema=e,this.spec=n,this.groups=n.group?n.group.split(" "):[],this.attrs=X(n.attrs),this.defaultAttrs=U(this.attrs),this.contentMatch=null,this.markSet=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t},Q={isInline:{configurable:!0},isTextblock:{configurable:!0},isLeaf:{configurable:!0},isAtom:{configurable:!0}};Q.isInline.get=function(){return!this.isBlock},Q.isTextblock.get=function(){return this.isBlock&&this.inlineContent},Q.isLeaf.get=function(){return this.contentMatch==j.empty},Q.isAtom.get=function(){return this.isLeaf||this.spec.atom},Y.prototype.hasRequiredAttrs=function(){for(var t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1},Y.prototype.compatibleContent=function(t){return this==t||this.contentMatch.compatible(t.contentMatch)},Y.prototype.computeAttrs=function(t){return!t&&this.defaultAttrs?this.defaultAttrs:G(this.attrs,t)},Y.prototype.create=function(t,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new z(this,this.computeAttrs(t),i.from(e),l.setFrom(n))},Y.prototype.createChecked=function(t,e,n){if(e=i.from(e),!this.validContent(e))throw new RangeError("Invalid content for node "+this.name);return new z(this,this.computeAttrs(t),e,l.setFrom(n))},Y.prototype.createAndFill=function(t,e,n){if(t=this.computeAttrs(t),(e=i.from(e)).size){var r=this.contentMatch.fillBefore(e);if(!r)return null;e=r.append(e)}var o=this.contentMatch.matchFragment(e).fillBefore(i.empty,!0);return o?new z(this,t,e.append(o),l.setFrom(n)):null},Y.prototype.validContent=function(t){var e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(var n=0;n<t.childCount;n++)if(!this.allowsMarks(t.child(n).marks))return!1;return!0},Y.prototype.allowsMarkType=function(t){return null==this.markSet||this.markSet.indexOf(t)>-1},Y.prototype.allowsMarks=function(t){if(null==this.markSet)return!0;for(var e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0},Y.prototype.allowedMarks=function(t){if(null==this.markSet)return t;for(var e,n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:l.empty:t},Y.compile=function(t,e){var n=Object.create(null);t.forEach((function(t,r){return n[t]=new Y(t,e,r)}));var r=e.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(var o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n},Object.defineProperties(Y.prototype,Q);var Z=function(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default},tt={isRequired:{configurable:!0}};tt.isRequired.get=function(){return!this.hasDefault},Object.defineProperties(Z.prototype,tt);var et=function(t,e,n,r){this.name=t,this.schema=n,this.spec=r,this.attrs=X(r.attrs),this.rank=e,this.excluded=null;var o=U(this.attrs);this.instance=o&&new l(this,o)};et.prototype.create=function(t){return!t&&this.instance?this.instance:new l(this,G(this.attrs,t))},et.compile=function(t,e){var n=Object.create(null),r=0;return t.forEach((function(t,o){return n[t]=new et(t,r++,e,o)})),n},et.prototype.removeFromSet=function(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t},et.prototype.isInSet=function(t){for(var e=0;e<t.length;e++)if(t[e].type==this)return t[e]},et.prototype.excludes=function(t){return this.excluded.indexOf(t)>-1};var nt=function(t){for(var e in this.spec={},t)this.spec[e]=t[e];this.spec.nodes=n.from(t.nodes),this.spec.marks=n.from(t.marks),this.nodes=Y.compile(this.spec.nodes,this),this.marks=et.compile(this.spec.marks,this);var r=Object.create(null);for(var o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");var i=this.nodes[o],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=r[s]||(r[s]=j.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet="_"==a?null:a?rt(this,a.split(" ")):""!=a&&i.inlineContent?null:[]}for(var c in this.marks){var p=this.marks[c],l=p.spec.excludes;p.excluded=null==l?[p]:""==l?[]:rt(this,l.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached=Object.create(null),this.cached.wrappings=Object.create(null)};function rt(t,e){for(var n=[],r=0;r<e.length;r++){var o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(var a in t.marks){var c=t.marks[a];("_"==o||c.spec.group&&c.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=c)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}nt.prototype.node=function(t,e,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof Y))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)},nt.prototype.text=function(t,e){var n=this.nodes.text;return new I(n,n.defaultAttrs,t,l.setFrom(e))},nt.prototype.mark=function(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)},nt.prototype.nodeFromJSON=function(t){return z.fromJSON(this,t)},nt.prototype.markFromJSON=function(t){return l.fromJSON(this,t)},nt.prototype.nodeType=function(t){var e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e};var ot=function(t,e){var n=this;this.schema=t,this.rules=e,this.tags=[],this.styles=[],e.forEach((function(t){t.tag?n.tags.push(t):t.style&&n.styles.push(t)})),this.normalizeLists=!this.tags.some((function(e){if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;var n=t.nodes[e.node];return n.contentMatch.matchType(n)}))};ot.prototype.parse=function(t,e){void 0===e&&(e={});var n=new lt(this,e,!1);return n.addAll(t,null,e.from,e.to),n.finish()},ot.prototype.parseSlice=function(t,e){void 0===e&&(e={});var n=new lt(this,e,!0);return n.addAll(t,null,e.from,e.to),f.maxOpen(n.finish())},ot.prototype.matchTag=function(t,e,n){for(var r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){var o=this.tags[r];if(ft(t,o.tag)&&(void 0===o.namespace||t.namespaceURI==o.namespace)&&(!o.context||e.matchesContext(o.context))){if(o.getAttrs){var i=o.getAttrs(t);if(!1===i)continue;o.attrs=i}return o}}},ot.prototype.matchStyle=function(t,e,n,r){for(var o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){var i=this.styles[o];if(!(0!=i.style.indexOf(t)||i.context&&!n.matchesContext(i.context)||i.style.length>t.length&&(61!=i.style.charCodeAt(t.length)||i.style.slice(t.length+1)!=e))){if(i.getAttrs){var s=i.getAttrs(e);if(!1===s)continue;i.attrs=s}return i}}},ot.schemaRules=function(t){var e=[];function n(t){for(var n=null==t.priority?50:t.priority,r=0;r<e.length;r++){var o=e[r];if((null==o.priority?50:o.priority)<n)break}e.splice(r,0,t)}var r=function(e){var r=t.marks[e].spec.parseDOM;r&&r.forEach((function(t){n(t=dt(t)),t.mark=e}))};for(var o in t.marks)r(o);var i;for(var s in t.nodes)i=void 0,(i=t.nodes[s].spec.parseDOM)&&i.forEach((function(t){n(t=dt(t)),t.node=s}));return e},ot.fromSchema=function(t){return t.cached.domParser||(t.cached.domParser=new ot(t,ot.schemaRules(t)))};var it={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},st={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},at={ol:!0,ul:!0};function ct(t){return(t?1:0)|("full"===t?2:0)}var pt=function(t,e,n,r,o,i,s){this.type=t,this.attrs=e,this.solid=o,this.match=i||(4&s?null:t.contentMatch),this.options=s,this.content=[],this.marks=n,this.activeMarks=l.none,this.pendingMarks=r,this.stashMarks=[]};pt.prototype.findWrapping=function(t){if(!this.match){if(!this.type)return[];var e=this.type.contentMatch.fillBefore(i.from(t));if(!e){var n,r=this.type.contentMatch;return(n=r.findWrapping(t.type))?(this.match=r,n):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)},pt.prototype.finish=function(t){if(!(1&this.options)){var e,n=this.content[this.content.length-1];n&&n.isText&&(e=/[ \t\r\n\u000c]+$/.exec(n.text))&&(n.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)))}var r=i.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r},pt.prototype.popFromStashMark=function(t){for(var e=this.stashMarks.length-1;e>=0;e--)if(t.eq(this.stashMarks[e]))return this.stashMarks.splice(e,1)[0]},pt.prototype.applyPending=function(t){for(var e=0,n=this.pendingMarks;e<n.length;e++){var r=n[e];(this.type?this.type.allowsMarkType(r.type):ut(r.type,t))&&!r.isInSet(this.activeMarks)&&(this.activeMarks=r.addToSet(this.activeMarks),this.pendingMarks=r.removeFromSet(this.pendingMarks))}};var lt=function(t,e,n){this.parser=t,this.options=e,this.isOpen=n;var r,o=e.topNode,i=ct(e.preserveWhitespace)|(n?4:0);r=o?new pt(o.type,o.attrs,l.none,l.none,!0,e.topMatch||o.type.contentMatch,i):new pt(n?null:t.schema.topNodeType,null,l.none,l.none,!0,null,i),this.nodes=[r],this.open=0,this.find=e.findPositions,this.needsBlock=!1},ht={top:{configurable:!0},currentPos:{configurable:!0}};function ft(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function dt(t){var e={};for(var n in t)e[n]=t[n];return e}function ut(t,e){var n=e.schema.nodes,r=function(r){var o=n[r];if(o.allowsMarkType(t)){var i=[],s=function(t){i.push(t);for(var n=0;n<t.edgeCount;n++){var r=t.edge(n),o=r.type,a=r.next;if(o==e)return!0;if(i.indexOf(a)<0&&s(a))return!0}};return s(o.contentMatch)?{v:!0}:void 0}};for(var o in n){var i=r(o);if(i)return i.v}}ht.top.get=function(){return this.nodes[this.open]},lt.prototype.addDOM=function(t){if(3==t.nodeType)this.addTextNode(t);else if(1==t.nodeType){var e=t.getAttribute("style"),n=e?this.readStyles(function(t){var e,n=/\s*([\w-]+)\s*:\s*([^;]+)/g,r=[];for(;e=n.exec(t);)r.push(e[1],e[2].trim());return r}(e)):null,r=this.top;if(null!=n)for(var o=0;o<n.length;o++)this.addPendingMark(n[o]);if(this.addElement(t),null!=n)for(var i=0;i<n.length;i++)this.removePendingMark(n[i],r)}},lt.prototype.addTextNode=function(t){var e=t.nodeValue,n=this.top;if((n.type?n.type.inlineContent:n.content.length&&n.content[0].isInline)||/[^ \t\r\n\u000c]/.test(e)){if(1&n.options)e=2&n.options?e.replace(/\r\n?/g,"\n"):e.replace(/\r?\n|\r/g," ");else if(e=e.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(e)&&this.open==this.nodes.length-1){var r=n.content[n.content.length-1],o=t.previousSibling;(!r||o&&"BR"==o.nodeName||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(e=e.slice(1))}e&&this.insertNode(this.parser.schema.text(e)),this.findInText(t)}else this.findInside(t)},lt.prototype.addElement=function(t,e){var n,r=t.nodeName.toLowerCase();at.hasOwnProperty(r)&&this.parser.normalizeLists&&function(t){for(var e=t.firstChild,n=null;e;e=e.nextSibling){var r=1==e.nodeType?e.nodeName.toLowerCase():null;r&&at.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):"li"==r?n=e:r&&(n=null)}}(t);var o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(n=this.parser.matchTag(t,this,e));if(o?o.ignore:st.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);var i,s=this.top,a=this.needsBlock;if(it.hasOwnProperty(r))i=!0,s.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t);this.addAll(t),i&&this.sync(s),this.needsBlock=a}else this.addElementByRule(t,o,!1===o.consuming?n:null)},lt.prototype.leafFallback=function(t){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"))},lt.prototype.ignoreFallback=function(t){"BR"!=t.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"))},lt.prototype.readStyles=function(t){var e=l.none;t:for(var n=0;n<t.length;n+=2)for(var r=null;;){var o=this.parser.matchStyle(t[n],t[n+1],this,r);if(!o)continue t;if(o.ignore)return null;if(e=this.parser.schema.marks[o.mark].create(o.attrs).addToSet(e),!1!==o.consuming)break;r=o}return e},lt.prototype.addElementByRule=function(t,e,n){var r,o,i,s=this;e.node?(o=this.parser.schema.nodes[e.node]).isLeaf?this.insertNode(o.create(e.attrs))||this.leafFallback(t):r=this.enter(o,e.attrs,e.preserveWhitespace):(i=this.parser.schema.marks[e.mark].create(e.attrs),this.addPendingMark(i));var a=this.top;if(o&&o.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((function(t){return s.insertNode(t)}));else{var c=e.contentElement;"string"==typeof c?c=t.querySelector(c):"function"==typeof c&&(c=c(t)),c||(c=t),this.findAround(t,c,!0),this.addAll(c,r)}r&&(this.sync(a),this.open--),i&&this.removePendingMark(i,a)},lt.prototype.addAll=function(t,e,n,r){for(var o=n||0,i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i),e&&it.hasOwnProperty(i.nodeName.toLowerCase())&&this.sync(e);this.findAtPoint(t,o)},lt.prototype.findPlace=function(t){for(var e,n,r=this.open;r>=0;r--){var o=this.nodes[r],i=o.findWrapping(t);if(i&&(!e||e.length>i.length)&&(e=i,n=o,!i.length))break;if(o.solid)break}if(!e)return!1;this.sync(n);for(var s=0;s<e.length;s++)this.enterInner(e[s],null,!1);return!0},lt.prototype.insertNode=function(t){if(t.isInline&&this.needsBlock&&!this.top.type){var e=this.textblockFromContext();e&&this.enterInner(e)}if(this.findPlace(t)){this.closeExtra();var n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));for(var r=n.activeMarks,o=0;o<t.marks.length;o++)n.type&&!n.type.allowsMarkType(t.marks[o].type)||(r=t.marks[o].addToSet(r));return n.content.push(t.mark(r)),!0}return!1},lt.prototype.enter=function(t,e,n){var r=this.findPlace(t.create(e));return r&&this.enterInner(t,e,!0,n),r},lt.prototype.enterInner=function(t,e,n,r){this.closeExtra();var o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t,e);var i=null==r?-5&o.options:ct(r);4&o.options&&0==o.content.length&&(i|=4),this.nodes.push(new pt(t,e,o.activeMarks,o.pendingMarks,n,null,i)),this.open++},lt.prototype.closeExtra=function(t){var e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}},lt.prototype.finish=function(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)},lt.prototype.sync=function(t){for(var e=this.open;e>=0;e--)if(this.nodes[e]==t)return void(this.open=e)},ht.currentPos.get=function(){this.closeExtra();for(var t=0,e=this.open;e>=0;e--){for(var n=this.nodes[e].content,r=n.length-1;r>=0;r--)t+=n[r].nodeSize;e&&t++}return t},lt.prototype.findAtPoint=function(t,e){if(this.find)for(var n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)},lt.prototype.findInside=function(t){if(this.find)for(var e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)},lt.prototype.findAround=function(t,e,n){if(t!=e&&this.find)for(var r=0;r<this.find.length;r++){if(null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node))e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}},lt.prototype.findInText=function(t){if(this.find)for(var e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))},lt.prototype.matchesContext=function(t){var e=this;if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);var n=t.split("/"),r=this.options.context,o=!(this.isOpen||r&&r.parent.type!=this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=function(t,a){for(;t>=0;t--){var c=n[t];if(""==c){if(t==n.length-1||0==t)continue;for(;a>=i;a--)if(s(t-1,a))return!0;return!1}var p=a>0||0==a&&o?e.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!p||p.name!=c&&-1==p.groups.indexOf(c))return!1;a--}return!0};return s(n.length-1,this.open)},lt.prototype.textblockFromContext=function(){var t=this.options.context;if(t)for(var e=t.depth;e>=0;e--){var n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(var r in this.parser.schema.nodes){var o=this.parser.schema.nodes[r];if(o.isTextblock&&o.defaultAttrs)return o}},lt.prototype.addPendingMark=function(t){var e=function(t,e){for(var n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}(t,this.top.pendingMarks);e&&this.top.stashMarks.push(e),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)},lt.prototype.removePendingMark=function(t,e){for(var n=this.open;n>=0;n--){var r=this.nodes[n];if(r.pendingMarks.lastIndexOf(t)>-1)r.pendingMarks=t.removeFromSet(r.pendingMarks);else{r.activeMarks=t.removeFromSet(r.activeMarks);var o=r.popFromStashMark(t);o&&r.type&&r.type.allowsMarkType(o.type)&&(r.activeMarks=o.addToSet(r.activeMarks))}if(r==e)break}},Object.defineProperties(lt.prototype,ht);var mt=function(t,e){this.nodes=t||{},this.marks=e||{}};function vt(t){var e={};for(var n in t){var r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function gt(t){return t.document||window.document}mt.prototype.serializeFragment=function(t,e,n){var r=this;void 0===e&&(e={}),n||(n=gt(e).createDocumentFragment());var o=n,i=null;return t.forEach((function(t){if(i||t.marks.length){i||(i=[]);for(var n=0,s=0;n<i.length&&s<t.marks.length;){var a=t.marks[s];if(r.marks[a.type.name]){if(!a.eq(i[n])||!1===a.type.spec.spanning)break;n+=2,s++}else s++}for(;n<i.length;)o=i.pop(),i.pop();for(;s<t.marks.length;){var c=t.marks[s++],p=r.serializeMark(c,t.isInline,e);p&&(i.push(c,o),o.appendChild(p.dom),o=p.contentDOM||p.dom)}}o.appendChild(r.serializeNode(t,e))})),n},mt.prototype.serializeNode=function(t,e){void 0===e&&(e={});var n=mt.renderSpec(gt(e),this.nodes[t.type.name](t)),r=n.dom,o=n.contentDOM;if(o){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");e.onContent?e.onContent(t,o,e):this.serializeFragment(t.content,e,o)}return r},mt.prototype.serializeNodeAndMarks=function(t,e){void 0===e&&(e={});for(var n=this.serializeNode(t,e),r=t.marks.length-1;r>=0;r--){var o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n},mt.prototype.serializeMark=function(t,e,n){void 0===n&&(n={});var r=this.marks[t.type.name];return r&&mt.renderSpec(gt(n),r(t,e))},mt.renderSpec=function(t,e,n){if(void 0===n&&(n=null),"string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;var r=e[0],o=r.indexOf(" ");o>0&&(n=r.slice(0,o),r=r.slice(o+1));var i=null,s=n?t.createElementNS(n,r):t.createElement(r),a=e[1],c=1;if(a&&"object"==typeof a&&null==a.nodeType&&!Array.isArray(a))for(var p in c=2,a)if(null!=a[p]){var l=p.indexOf(" ");l>0?s.setAttributeNS(p.slice(0,l),p.slice(l+1),a[p]):s.setAttribute(p,a[p])}for(var h=c;h<e.length;h++){var f=e[h];if(0===f){if(h<e.length-1||h>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}var d=mt.renderSpec(t,f,n),u=d.dom,m=d.contentDOM;if(s.appendChild(u),m){if(i)throw new RangeError("Multiple content holes");i=m}}return{dom:s,contentDOM:i}},mt.fromSchema=function(t){return t.cached.domSerializer||(t.cached.domSerializer=new mt(this.nodesFromSchema(t),this.marksFromSchema(t)))},mt.nodesFromSchema=function(t){var e=vt(t.nodes);return e.text||(e.text=function(t){return t.text}),e},mt.marksFromSchema=function(t){return vt(t.marks)};var yt=Math.pow(2,16);function bt(t){return 65535&t}var wt=function(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=null),this.pos=t,this.deleted=e,this.recover=n},kt=function(t,e){void 0===e&&(e=!1),this.ranges=t,this.inverted=e};kt.prototype.recover=function(t){var e=0,n=bt(t);if(!this.inverted)for(var r=0;r<n;r++)e+=this.ranges[3*r+2]-this.ranges[3*r+1];return this.ranges[3*n]+e+function(t){return(t-(65535&t))/yt}(t)},kt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},kt.prototype.map=function(t,e){return void 0===e&&(e=1),this._map(t,e,!0)},kt.prototype._map=function(t,e,n){for(var r=0,o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?r:0);if(a>t)break;var c=this.ranges[s+o],p=this.ranges[s+i],l=a+c;if(t<=l){var h=a+r+((c?t==a?-1:t==l?1:e:e)<0?0:p);if(n)return h;var f=t==(e<0?a:l)?null:s/3+(t-a)*yt;return new wt(h,e<0?t!=a:t!=l,f)}r+=p-c}return n?t+r:new wt(t+r)},kt.prototype.touches=function(t,e){for(var n=0,r=bt(e),o=this.inverted?2:1,i=this.inverted?1:2,s=0;s<this.ranges.length;s+=3){var a=this.ranges[s]-(this.inverted?n:0);if(a>t)break;var c=this.ranges[s+o];if(t<=a+c&&s==3*r)return!0;n+=this.ranges[s+i]-c}return!1},kt.prototype.forEach=function(t){for(var e=this.inverted?2:1,n=this.inverted?1:2,r=0,o=0;r<this.ranges.length;r+=3){var i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[r+e],p=this.ranges[r+n];t(s,s+c,a,a+p),o+=p-c}},kt.prototype.invert=function(){return new kt(this.ranges,!this.inverted)},kt.prototype.toString=function(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)},kt.offset=function(t){return 0==t?kt.empty:new kt(t<0?[0,-t,0]:[0,0,t])},kt.empty=new kt([]);var xt=function(t,e,n,r){this.maps=t||[],this.from=n||0,this.to=null==r?this.maps.length:r,this.mirror=e};function St(t){var e=Error.call(this,t);return e.__proto__=St.prototype,e}xt.prototype.slice=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=this.maps.length),new xt(this.maps,this.mirror,t,e)},xt.prototype.copy=function(){return new xt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)},xt.prototype.appendMap=function(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)},xt.prototype.appendMapping=function(t){for(var e=0,n=this.maps.length;e<t.maps.length;e++){var r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:null)}},xt.prototype.getMirror=function(t){if(this.mirror)for(var e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]},xt.prototype.setMirror=function(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)},xt.prototype.appendMappingInverted=function(t){for(var e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){var r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:null)}},xt.prototype.invert=function(){var t=new xt;return t.appendMappingInverted(this),t},xt.prototype.map=function(t,e){if(void 0===e&&(e=1),this.mirror)return this._map(t,e,!0);for(var n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t},xt.prototype.mapResult=function(t,e){return void 0===e&&(e=1),this._map(t,e,!1)},xt.prototype._map=function(t,e,n){for(var r=!1,o=this.from;o<this.to;o++){var i=this.maps[o].mapResult(t,e);if(null!=i.recover){var s=this.getMirror(o);if(null!=s&&s>o&&s<this.to){o=s,t=this.maps[s].recover(i.recover);continue}}i.deleted&&(r=!0),t=i.pos}return n?t:new wt(t,r)},St.prototype=Object.create(Error.prototype),St.prototype.constructor=St,St.prototype.name="TransformError";var Ot=function(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new xt},Mt={before:{configurable:!0},docChanged:{configurable:!0}};function Ct(){throw new Error("Override me")}Mt.before.get=function(){return this.docs.length?this.docs[0]:this.doc},Ot.prototype.step=function(t){var e=this.maybeStep(t);if(e.failed)throw new St(e.failed);return this},Ot.prototype.maybeStep=function(t){var e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e},Mt.docChanged.get=function(){return this.steps.length>0},Ot.prototype.addStep=function(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e},Object.defineProperties(Ot.prototype,Mt);var Nt=Object.create(null),Tt=function(){};Tt.prototype.apply=function(t){return Ct()},Tt.prototype.getMap=function(){return kt.empty},Tt.prototype.invert=function(t){return Ct()},Tt.prototype.map=function(t){return Ct()},Tt.prototype.merge=function(t){return null},Tt.prototype.toJSON=function(){return Ct()},Tt.fromJSON=function(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");var n=Nt[e.stepType];if(!n)throw new RangeError("No step type "+e.stepType+" defined");return n.fromJSON(t,e)},Tt.jsonID=function(t,e){if(t in Nt)throw new RangeError("Duplicate use of step JSON ID "+t);return Nt[t]=e,e.prototype.jsonID=t,e};var Et=function(t,e){this.doc=t,this.failed=e};Et.ok=function(t){return new Et(t,null)},Et.fail=function(t){return new Et(null,t)},Et.fromReplace=function(t,e,n,r){try{return Et.ok(t.replace(e,n,r))}catch(t){if(t instanceof h)return Et.fail(t.message);throw t}};var Dt=function(t){function e(e,n,r,o){t.call(this),this.from=e,this.to=n,this.slice=r,this.structure=!!o}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){return this.structure&&_t(t,this.from,this.to)?Et.fail("Structure replace would overwrite content"):Et.fromReplace(t,this.from,this.to,this.slice)},e.prototype.getMap=function(){return new kt([this.from,this.to-this.from,this.slice.size])},e.prototype.invert=function(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice)},e.prototype.merge=function(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;var n=this.slice.size+t.slice.size==0?f.empty:new f(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}var r=this.slice.size+t.slice.size==0?f.empty:new f(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),r,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new e(n.from,n.to,f.fromJSON(t,n.slice),!!n.structure)},e}(Tt);Tt.jsonID("replace",Dt);var At=function(t){function e(e,n,r,o,i,s,a){t.call(this),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=!!a}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){if(this.structure&&(_t(t,this.from,this.gapFrom)||_t(t,this.gapTo,this.to)))return Et.fail("Structure gap-replace would overwrite content");var e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Et.fail("Gap is not a flat range");var n=this.slice.insertAt(this.insert,e.content);return n?Et.fromReplace(t,this.from,this.to,n):Et.fail("Content does not fit in gap")},e.prototype.getMap=function(){return new kt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])},e.prototype.invert=function(t){var n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),o=t.map(this.gapFrom,-1),i=t.map(this.gapTo,1);return n.deleted&&r.deleted||o<n.pos||i>r.pos?null:new e(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)},e.prototype.toJSON=function(){var t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to||"number"!=typeof n.gapFrom||"number"!=typeof n.gapTo||"number"!=typeof n.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new e(n.from,n.to,n.gapFrom,n.gapTo,f.fromJSON(t,n.slice),n.insert,!!n.structure)},e}(Tt);function _t(t,e,n){for(var r=t.resolve(e),o=n-e,i=r.depth;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0)for(var s=r.node(i).maybeChild(r.indexAfter(i));o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}return!1}function zt(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rt(t){for(var e=t.parent.content.cutByIndex(t.startIndex,t.endIndex),n=t.depth;;--n){var r=t.$from.node(n),o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||r.type.spec.isolating||!zt(r,o,i))break}}function It(t,e,n,r){void 0===r&&(r=t);var o=function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;var s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}(t,e),i=o&&function(t,e){var n=t.parent,r=t.startIndex,o=t.endIndex,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;for(var a=(s.length?s[s.length-1]:e).contentMatch,c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);if(!a||!a.validEnd)return null;return s}(r,e);return i?o.map(Pt).concat({type:e,attrs:n}).concat(i.map(Pt)):null}function Pt(t){return{type:t,attrs:null}}function jt(t,e,n,r){void 0===n&&(n=1);var o=t.resolve(e),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(var a=o.depth-1,c=n-2;a>i;a--,c--){var p=o.node(a),l=o.index(a);if(p.type.spec.isolating)return!1;var h=p.content.cutByIndex(l,p.childCount),f=r&&r[c]||p;if(f!=p&&(h=h.replaceChild(0,f.type.create(f.attrs))),!p.canReplace(l+1,p.childCount)||!f.type.validContent(h))return!1}var d=o.indexAfter(i),u=r&&r[0];return o.node(i).canReplaceWith(d,d,u?u.type:o.node(i+1).type)}function $t(t,e){var n,r,o=t.resolve(e),i=o.index();return n=o.nodeBefore,r=o.nodeAfter,n&&r&&!n.isLeaf&&n.canAppend(r)&&o.parent.canReplace(i,i+1)}function Bt(t,e,n){for(var r=[],o=0;o<t.childCount;o++){var s=t.child(o);s.content.size&&(s=s.copy(Bt(s.content,e,s))),s.isInline&&(s=e(s,n,o)),r.push(s)}return i.fromArray(r)}Tt.jsonID("replaceAround",At),Ot.prototype.lift=function(t,e){for(var n=t.$from,r=t.$to,o=t.depth,s=n.before(o+1),a=r.after(o+1),c=s,p=a,l=i.empty,h=0,d=o,u=!1;d>e;d--)u||n.index(d)>0?(u=!0,l=i.from(n.node(d).copy(l)),h++):c--;for(var m=i.empty,v=0,g=o,y=!1;g>e;g--)y||r.after(g+1)<r.end(g)?(y=!0,m=i.from(r.node(g).copy(m)),v++):p++;return this.step(new At(c,p,s,a,new f(l.append(m),h,v),l.size-h,!0))},Ot.prototype.wrap=function(t,e){for(var n=i.empty,r=e.length-1;r>=0;r--)n=i.from(e[r].type.create(e[r].attrs,n));var o=t.start,s=t.end;return this.step(new At(o,s,o,s,new f(n,0,0),e.length,!0))},Ot.prototype.setBlockType=function(t,e,n,r){var o=this;if(void 0===e&&(e=t),!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");var s=this.steps.length;return this.doc.nodesBetween(t,e,(function(t,e){if(t.isTextblock&&!t.hasMarkup(n,r)&&function(t,e,n){var r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(o.doc,o.mapping.slice(s).map(e),n)){o.clearIncompatible(o.mapping.slice(s).map(e,1),n);var a=o.mapping.slice(s),c=a.map(e,1),p=a.map(e+t.nodeSize,1);return o.step(new At(c,p,c+1,p-1,new f(i.from(n.create(r,null,t.marks)),0,0),1,!0)),!1}})),this},Ot.prototype.setNodeMarkup=function(t,e,n,r){var o=this.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");e||(e=o.type);var s=e.create(n,null,r||o.marks);if(o.isLeaf)return this.replaceWith(t,t+o.nodeSize,s);if(!e.validContent(o.content))throw new RangeError("Invalid content for node type "+e.name);return this.step(new At(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new f(i.from(s),0,0),1,!0))},Ot.prototype.split=function(t,e,n){void 0===e&&(e=1);for(var r=this.doc.resolve(t),o=i.empty,s=i.empty,a=r.depth,c=r.depth-e,p=e-1;a>c;a--,p--){o=i.from(r.node(a).copy(o));var l=n&&n[p];s=i.from(l?l.type.create(l.attrs,s):r.node(a).copy(s))}return this.step(new Dt(t,t,new f(o.append(s),e,e),!0))},Ot.prototype.join=function(t,e){void 0===e&&(e=1);var n=new Dt(t-e,t+e,f.empty,!0);return this.step(n)};var Vt=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=t.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new f(Bt(n.content,(function(t,n){return t.isAtom&&n.type.allowsMarkType(e.mark.type)?t.mark(e.mark.addToSet(t.marks)):t}),o),n.openStart,n.openEnd);return Et.fromReplace(t,this.from,this.to,i)},e.prototype.invert=function(){return new Ft(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Tt);Tt.jsonID("addMark",Vt);var Ft=function(t){function e(e,n,r){t.call(this),this.from=e,this.to=n,this.mark=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.apply=function(t){var e=this,n=t.slice(this.from,this.to),r=new f(Bt(n.content,(function(t){return t.mark(e.mark.removeFromSet(t.marks))})),n.openStart,n.openEnd);return Et.fromReplace(t,this.from,this.to,r)},e.prototype.invert=function(){return new Vt(this.from,this.to,this.mark)},e.prototype.map=function(t){var n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)},e.prototype.merge=function(t){if(t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from)return new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark)},e.prototype.toJSON=function(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}},e.fromJSON=function(t,n){if("number"!=typeof n.from||"number"!=typeof n.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new e(n.from,n.to,t.markFromJSON(n.mark))},e}(Tt);function Lt(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}Tt.jsonID("removeMark",Ft),Ot.prototype.addMark=function(t,e,n){var r=this,o=[],i=[],s=null,a=null;return this.doc.nodesBetween(t,e,(function(r,c,p){if(r.isInline){var l=r.marks;if(!n.isInSet(l)&&p.type.allowsMarkType(n.type)){for(var h=Math.max(c,t),f=Math.min(c+r.nodeSize,e),d=n.addToSet(l),u=0;u<l.length;u++)l[u].isInSet(d)||(s&&s.to==h&&s.mark.eq(l[u])?s.to=f:o.push(s=new Ft(h,f,l[u])));a&&a.to==h?a.to=f:i.push(a=new Vt(h,f,n))}}})),o.forEach((function(t){return r.step(t)})),i.forEach((function(t){return r.step(t)})),this},Ot.prototype.removeMark=function(t,e,n){var r=this;void 0===n&&(n=null);var o=[],i=0;return this.doc.nodesBetween(t,e,(function(r,s){if(r.isInline){i++;var a=null;if(n instanceof et)for(var c,p=r.marks;c=n.isInSet(p);)(a||(a=[])).push(c),p=c.removeFromSet(p);else n?n.isInSet(r.marks)&&(a=[n]):a=r.marks;if(a&&a.length)for(var l=Math.min(s+r.nodeSize,e),h=0;h<a.length;h++){for(var f=a[h],d=void 0,u=0;u<o.length;u++){var m=o[u];m.step==i-1&&f.eq(o[u].style)&&(d=m)}d?(d.to=l,d.step=i):o.push({style:f,from:Math.max(s,t),to:l,step:i})}}})),o.forEach((function(t){return r.step(new Ft(t.from,t.to,t.style))})),this},Ot.prototype.clearIncompatible=function(t,e,n){void 0===n&&(n=e.contentMatch);for(var r=this.doc.nodeAt(t),o=[],s=t+1,a=0;a<r.childCount;a++){var c=r.child(a),p=s+c.nodeSize,l=n.matchType(c.type,c.attrs);if(l){n=l;for(var h=0;h<c.marks.length;h++)e.allowsMarkType(c.marks[h].type)||this.step(new Ft(s,p,c.marks[h]))}else o.push(new Dt(s,p,f.empty));s=p}if(!n.validEnd){var d=n.fillBefore(i.empty,!0);this.replace(s,s,new f(d,0,0))}for(var u=o.length-1;u>=0;u--)this.step(o[u]);return this},Ot.prototype.replace=function(t,e,n){void 0===e&&(e=t),void 0===n&&(n=f.empty);var r=function(t,e,n,r){if(void 0===n&&(n=e),void 0===r&&(r=f.empty),e==n&&!r.size)return null;var o=t.resolve(e),i=t.resolve(n);return Lt(o,i,r)?new Dt(e,n,r):new Jt(o,i,r).fit()}(this.doc,t,e,n);return r&&this.step(r),this},Ot.prototype.replaceWith=function(t,e,n){return this.replace(t,e,new f(i.from(n),0,0))},Ot.prototype.delete=function(t,e){return this.replace(t,e,f.empty)},Ot.prototype.insert=function(t,e){return this.replaceWith(t,t,e)};var Jt=function(t,e,n){this.$to=e,this.$from=t,this.unplaced=n,this.frontier=[];for(var r=0;r<=t.depth;r++){var o=t.node(r);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(r))})}this.placed=i.empty;for(var s=t.depth;s>0;s--)this.placed=i.from(t.node(s).copy(this.placed))},Wt={depth:{configurable:!0}};function qt(t,e,n){return 0==e?t.cutByIndex(n):t.replaceChild(0,t.firstChild.copy(qt(t.firstChild.content,e-1,n)))}function Kt(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Kt(t.lastChild.content,e-1,n)))}function Ht(t,e){for(var n=0;n<e;n++)t=t.firstChild.content;return t}function Ut(t,e,n){if(e<=0)return t;var r=t.content;return e>1&&(r=r.replaceChild(0,Ut(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(i.empty,!0)))),t.copy(r)}function Gt(t,e,n,r,o){var i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;var a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(var r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function Xt(t,e,n,r,o){if(e<n){var s=t.firstChild;t=t.replaceChild(0,s.copy(Xt(s.content,e+1,n,r,s)))}if(e>r){var a=o.contentMatchAt(0),c=a.fillBefore(t).append(t);t=c.append(a.matchFragment(c).fillBefore(i.empty,!0))}return t}function Yt(t,e){for(var n=[],r=Math.min(t.depth,e.depth);r>=0;r--){var o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;o==e.start(r)&&n.push(r)}return n}Wt.depth.get=function(){return this.frontier.length-1},Jt.prototype.fit=function(){for(;this.unplaced.size;){var t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}var e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;for(var i=this.placed,s=r.depth,a=o.depth;s&&a&&1==i.childCount;)i=i.firstChild.content,s--,a--;var c=new f(i,s,a);return e>-1?new At(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new Dt(r.pos,o.pos,c):void 0},Jt.prototype.findFittable=function(){for(var t=1;t<=2;t++)for(var e=this.unplaced.openStart;e>=0;e--)for(var n=void 0,r=(e?(n=Ht(this.unplaced.content,e-1).firstChild).content:this.unplaced.content).firstChild,o=this.depth;o>=0;o--){var s=this.frontier[o],a=s.type,c=s.match,p=void 0,l=void 0;if(1==t&&(r?c.matchType(r.type)||(l=c.fillBefore(i.from(r),!1)):a.compatibleContent(n.type)))return{sliceDepth:e,frontierDepth:o,parent:n,inject:l};if(2==t&&r&&(p=c.findWrapping(r.type)))return{sliceDepth:e,frontierDepth:o,parent:n,wrap:p};if(n&&c.matchType(n.type))break}},Jt.prototype.openMore=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=Ht(e,n);return!(!o.childCount||o.firstChild.isLeaf)&&(this.unplaced=new f(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)},Jt.prototype.dropNode=function(){var t=this.unplaced,e=t.content,n=t.openStart,r=t.openEnd,o=Ht(e,n);if(o.childCount<=1&&n>0){var i=e.size-n<=n+o.size;this.unplaced=new f(qt(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new f(qt(e,n,1),n,r)},Jt.prototype.placeNodes=function(t){for(var e=t.sliceDepth,n=t.frontierDepth,r=t.parent,o=t.inject,s=t.wrap;this.depth>n;)this.closeFrontierNode();if(s)for(var a=0;a<s.length;a++)this.openFrontierNode(s[a]);var c=this.unplaced,p=r?r.content:c.content,l=c.openStart-e,h=0,d=[],u=this.frontier[n],m=u.match,v=u.type;if(o){for(var g=0;g<o.childCount;g++)d.push(o.child(g));m=m.matchFragment(o)}for(var y=p.size+e-(c.content.size-c.openEnd);h<p.childCount;){var b=p.child(h),w=m.matchType(b.type);if(!w)break;(++h>1||0==l||b.content.size)&&(m=w,d.push(Ut(b.mark(v.allowedMarks(b.marks)),1==h?l:0,h==p.childCount?y:-1)))}var k=h==p.childCount;k||(y=-1),this.placed=Kt(this.placed,n,i.from(d)),this.frontier[n].match=m,k&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(var x=0,S=p;x<y;x++){var O=S.lastChild;this.frontier.push({type:O.type,match:O.contentMatchAt(O.childCount)}),S=O.content}this.unplaced=k?0==e?f.empty:new f(qt(c.content,e-1,1),e-1,y<0?c.openEnd:e-1):new f(qt(c.content,e,h),c.openStart,c.openEnd)},Jt.prototype.mustMoveInline=function(){if(!this.$to.parent.isTextblock||this.$to.end()==this.$to.pos)return-1;var t,e=this.frontier[this.depth];if(!e.type.isTextblock||!Gt(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;for(var n=this.$to.depth,r=this.$to.after(n);n>1&&r==this.$to.end(--n);)++r;return r},Jt.prototype.findCloseLevel=function(t){t:for(var e=Math.min(this.depth,t.depth);e>=0;e--){var n=this.frontier[e],r=n.match,o=n.type,i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Gt(t,e,o,r,i);if(s){for(var a=e-1;a>=0;a--){var c=this.frontier[a],p=c.match,l=Gt(t,a,c.type,p,!0);if(!l||l.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}},Jt.prototype.close=function(t){var e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Kt(this.placed,e.depth,e.fit)),t=e.move;for(var n=e.depth+1;n<=t.depth;n++){var r=t.node(n),o=r.type.contentMatch.fillBefore(r.content,!0,t.index(n));this.openFrontierNode(r.type,r.attrs,o)}return t},Jt.prototype.openFrontierNode=function(t,e,n){var r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=Kt(this.placed,this.depth,i.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})},Jt.prototype.closeFrontierNode=function(){var t=this.frontier.pop().match.fillBefore(i.empty,!0);t.childCount&&(this.placed=Kt(this.placed,this.frontier.length,t))},Object.defineProperties(Jt.prototype,Wt),Ot.prototype.replaceRange=function(t,e,n){if(!n.size)return this.deleteRange(t,e);var r=this.doc.resolve(t),o=this.doc.resolve(e);if(Lt(r,o,n))return this.step(new Dt(t,e,n));var i=Yt(r,this.doc.resolve(e));0==i[i.length-1]&&i.pop();var s=-(r.depth+1);i.unshift(s);for(var a=r.depth,c=r.pos-1;a>0;a--,c--){var p=r.node(a).type.spec;if(p.defining||p.isolating)break;i.indexOf(a)>-1?s=a:r.before(a)==c&&i.splice(1,0,-a)}for(var l=i.indexOf(s),h=[],d=n.openStart,u=n.content,m=0;;m++){var v=u.firstChild;if(h.push(v),m==n.openStart)break;u=v.content}d>0&&h[d-1].type.spec.defining&&r.node(l).type!=h[d-1].type?d-=1:d>=2&&h[d-1].isTextblock&&h[d-2].type.spec.defining&&r.node(l).type!=h[d-2].type&&(d-=2);for(var g=n.openStart;g>=0;g--){var y=(g+d+1)%(n.openStart+1),b=h[y];if(b)for(var w=0;w<i.length;w++){var k=i[(w+l)%i.length],x=!0;k<0&&(x=!1,k=-k);var S=r.node(k-1),O=r.index(k-1);if(S.canReplaceWith(O,O,b.type,b.marks))return this.replace(r.before(k),x?o.after(k):e,new f(Xt(n.content,0,n.openStart,y),y,n.openEnd))}}for(var M=this.steps.length,C=i.length-1;C>=0&&(this.replace(t,e,n),!(this.steps.length>M));C--){var N=i[C];N<0||(t=r.before(N),e=o.after(N))}return this},Ot.prototype.replaceRangeWith=function(t,e,n){if(!n.isInline&&t==e&&this.doc.resolve(t).parent.content.size){var r=function(t,e,n){var r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(var o=r.depth-1;o>=0;o--){var i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(var s=r.depth-1;s>=0;s--){var a=r.indexAfter(s);if(r.node(s).canReplaceWith(a,a,n))return r.after(s+1);if(a<r.node(s).childCount)return null}}(this.doc,t,n.type);null!=r&&(t=e=r)}return this.replaceRange(t,e,new f(i.from(n),0,0))},Ot.prototype.deleteRange=function(t,e){for(var n=this.doc.resolve(t),r=this.doc.resolve(e),o=Yt(n,r),i=0;i<o.length;i++){var s=o[i],a=i==o.length-1;if(a&&0==s||n.node(s).type.contentMatch.validEnd)return this.delete(n.start(s),r.end(s));if(s>0&&(a||n.node(s-1).canReplace(n.index(s-1),r.indexAfter(s-1))))return this.delete(n.before(s),r.after(s))}for(var c=1;c<=n.depth&&c<=r.depth;c++)if(t-n.start(c)==n.depth-c&&e>n.end(c)&&r.end(c)-e!=r.depth-c)return this.delete(n.before(c),e);return this.delete(t,e)};var Qt=Object.create(null),Zt=function(t,e,n){this.ranges=n||[new ee(t.min(e),t.max(e))],this.$anchor=t,this.$head=e},te={anchor:{configurable:!0},head:{configurable:!0},from:{configurable:!0},to:{configurable:!0},$from:{configurable:!0},$to:{configurable:!0},empty:{configurable:!0}};te.anchor.get=function(){return this.$anchor.pos},te.head.get=function(){return this.$head.pos},te.from.get=function(){return this.$from.pos},te.to.get=function(){return this.$to.pos},te.$from.get=function(){return this.ranges[0].$from},te.$to.get=function(){return this.ranges[0].$to},te.empty.get=function(){for(var t=this.ranges,e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0},Zt.prototype.content=function(){return this.$from.node(0).slice(this.from,this.to,!0)},Zt.prototype.replace=function(t,e){void 0===e&&(e=f.empty);for(var n=e.content.lastChild,r=null,o=0;o<e.openEnd;o++)r=n,n=n.lastChild;for(var i=t.steps.length,s=this.ranges,a=0;a<s.length;a++){var c=s[a],p=c.$from,l=c.$to,h=t.mapping.slice(i);t.replaceRange(h.map(p.pos),h.map(l.pos),a?f.empty:e),0==a&&pe(t,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}},Zt.prototype.replaceWith=function(t,e){for(var n=t.steps.length,r=this.ranges,o=0;o<r.length;o++){var i=r[o],s=i.$from,a=i.$to,c=t.mapping.slice(n),p=c.map(s.pos),l=c.map(a.pos);o?t.deleteRange(p,l):(t.replaceRangeWith(p,l,e),pe(t,n,e.isInline?-1:1))}},Zt.findFrom=function(t,e,n){var r=t.parent.inlineContent?new ne(t):ce(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(var o=t.depth-1;o>=0;o--){var i=e<0?ce(t.node(0),t.node(o),t.before(o+1),t.index(o),e,n):ce(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,e,n);if(i)return i}},Zt.near=function(t,e){return void 0===e&&(e=1),this.findFrom(t,e)||this.findFrom(t,-e)||new se(t.node(0))},Zt.atStart=function(t){return ce(t,t,0,0,1)||new se(t)},Zt.atEnd=function(t){return ce(t,t,t.content.size,t.childCount,-1)||new se(t)},Zt.fromJSON=function(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");var n=Qt[e.type];if(!n)throw new RangeError("No selection type "+e.type+" defined");return n.fromJSON(t,e)},Zt.jsonID=function(t,e){if(t in Qt)throw new RangeError("Duplicate use of selection JSON ID "+t);return Qt[t]=e,e.prototype.jsonID=t,e},Zt.prototype.getBookmark=function(){return ne.between(this.$anchor,this.$head).getBookmark()},Object.defineProperties(Zt.prototype,te),Zt.prototype.visible=!0;var ee=function(t,e){this.$from=t,this.$to=e},ne=function(t){function e(e,n){void 0===n&&(n=e),t.call(this,e,n)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={$cursor:{configurable:!0}};return n.$cursor.get=function(){return this.$anchor.pos==this.$head.pos?this.$head:null},e.prototype.map=function(n,r){var o=n.resolve(r.map(this.head));if(!o.parent.inlineContent)return t.near(o);var i=n.resolve(r.map(this.anchor));return new e(i.parent.inlineContent?i:o,o)},e.prototype.replace=function(e,n){if(void 0===n&&(n=f.empty),t.prototype.replace.call(this,e,n),n==f.empty){var r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head},e.prototype.getBookmark=function(){return new re(this.anchor,this.head)},e.prototype.toJSON=function(){return{type:"text",anchor:this.anchor,head:this.head}},e.fromJSON=function(t,n){if("number"!=typeof n.anchor||"number"!=typeof n.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new e(t.resolve(n.anchor),t.resolve(n.head))},e.create=function(t,e,n){void 0===n&&(n=e);var r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))},e.between=function(n,r,o){var i=n.pos-r.pos;if(o&&!i||(o=i>=0?1:-1),!r.parent.inlineContent){var s=t.findFrom(r,o,!0)||t.findFrom(r,-o,!0);if(!s)return t.near(r,o);r=s.$head}return n.parent.inlineContent||(0==i||(n=(t.findFrom(n,-o,!0)||t.findFrom(n,o,!0)).$anchor).pos<r.pos!=i<0)&&(n=r),new e(n,r)},Object.defineProperties(e.prototype,n),e}(Zt);Zt.jsonID("text",ne);var re=function(t,e){this.anchor=t,this.head=e};re.prototype.map=function(t){return new re(t.map(this.anchor),t.map(this.head))},re.prototype.resolve=function(t){return ne.between(t.resolve(this.anchor),t.resolve(this.head))};var oe=function(t){function e(e){var n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);t.call(this,e,r),this.node=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.map=function(n,r){var o=r.mapResult(this.anchor),i=o.deleted,s=o.pos,a=n.resolve(s);return i?t.near(a):new e(a)},e.prototype.content=function(){return new f(i.from(this.node),0,0)},e.prototype.eq=function(t){return t instanceof e&&t.anchor==this.anchor},e.prototype.toJSON=function(){return{type:"node",anchor:this.anchor}},e.prototype.getBookmark=function(){return new ie(this.anchor)},e.fromJSON=function(t,n){if("number"!=typeof n.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new e(t.resolve(n.anchor))},e.create=function(t,e){return new this(t.resolve(e))},e.isSelectable=function(t){return!t.isText&&!1!==t.type.spec.selectable},e}(Zt);oe.prototype.visible=!1,Zt.jsonID("node",oe);var ie=function(t){this.anchor=t};ie.prototype.map=function(t){var e=t.mapResult(this.anchor),n=e.deleted,r=e.pos;return n?new re(r,r):new ie(r)},ie.prototype.resolve=function(t){var e=t.resolve(this.anchor),n=e.nodeAfter;return n&&oe.isSelectable(n)?new oe(e):Zt.near(e)};var se=function(t){function e(e){t.call(this,e.resolve(0),e.resolve(e.content.size))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.replace=function(e,n){if(void 0===n&&(n=f.empty),n==f.empty){e.delete(0,e.doc.content.size);var r=t.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else t.prototype.replace.call(this,e,n)},e.prototype.toJSON=function(){return{type:"all"}},e.fromJSON=function(t){return new e(t)},e.prototype.map=function(t){return new e(t)},e.prototype.eq=function(t){return t instanceof e},e.prototype.getBookmark=function(){return ae},e}(Zt);Zt.jsonID("all",se);var ae={map:function(){return this},resolve:function(t){return new se(t)}};function ce(t,e,n,r,o,i){if(e.inlineContent)return ne.create(t,n);for(var s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){var a=e.child(s);if(a.isAtom){if(!i&&oe.isSelectable(a))return oe.create(t,n-(o<0?a.nodeSize:0))}else{var c=ce(t,a,n+o,o<0?a.childCount:0,o,i);if(c)return c}n+=a.nodeSize*o}}function pe(t,e,n){var r=t.steps.length-1;if(!(r<e)){var o,i=t.steps[r];if(i instanceof Dt||i instanceof At)t.mapping.maps[r].forEach((function(t,e,n,r){null==o&&(o=r)})),t.setSelection(Zt.near(t.doc.resolve(o),n))}}var le=function(t){function e(e){t.call(this,e.doc),this.time=Date.now(),this.curSelection=e.selection,this.curSelectionFor=0,this.storedMarks=e.storedMarks,this.updated=0,this.meta=Object.create(null)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={selection:{configurable:!0},selectionSet:{configurable:!0},storedMarksSet:{configurable:!0},isGeneric:{configurable:!0},scrolledIntoView:{configurable:!0}};return n.selection.get=function(){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},e.prototype.setSelection=function(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this},n.selectionSet.get=function(){return(1&this.updated)>0},e.prototype.setStoredMarks=function(t){return this.storedMarks=t,this.updated|=2,this},e.prototype.ensureMarks=function(t){return l.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this},e.prototype.addStoredMark=function(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))},e.prototype.removeStoredMark=function(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))},n.storedMarksSet.get=function(){return(2&this.updated)>0},e.prototype.addStep=function(e,n){t.prototype.addStep.call(this,e,n),this.updated=-3&this.updated,this.storedMarks=null},e.prototype.setTime=function(t){return this.time=t,this},e.prototype.replaceSelection=function(t){return this.selection.replace(this,t),this},e.prototype.replaceSelectionWith=function(t,e){var n=this.selection;return!1!==e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||l.none))),n.replaceWith(this,t),this},e.prototype.deleteSelection=function(){return this.selection.replace(this),this},e.prototype.insertText=function(t,e,n){void 0===n&&(n=e);var r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();if(!t)return this.deleteRange(e,n);var o=this.storedMarks;if(!o){var i=this.doc.resolve(e);o=n==e?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(Zt.near(this.selection.$to)),this},e.prototype.setMeta=function(t,e){return this.meta["string"==typeof t?t:t.key]=e,this},e.prototype.getMeta=function(t){return this.meta["string"==typeof t?t:t.key]},n.isGeneric.get=function(){for(var t in this.meta)return!1;return!0},e.prototype.scrollIntoView=function(){return this.updated|=4,this},n.scrolledIntoView.get=function(){return(4&this.updated)>0},Object.defineProperties(e.prototype,n),e}(Ot);function he(t,e){return e&&t?t.bind(e):t}var fe=function(t,e,n){this.name=t,this.init=he(e.init,n),this.apply=he(e.apply,n)},de=[new fe("doc",{init:function(t){return t.doc||t.schema.topNodeType.createAndFill()},apply:function(t){return t.doc}}),new fe("selection",{init:function(t,e){return t.selection||Zt.atStart(e.doc)},apply:function(t){return t.selection}}),new fe("storedMarks",{init:function(t){return t.storedMarks||null},apply:function(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new fe("scrollToSelection",{init:function(){return 0},apply:function(t,e){return t.scrolledIntoView?e+1:e}})],ue=function(t,e){var n=this;this.schema=t,this.fields=de.concat(),this.plugins=[],this.pluginsByKey=Object.create(null),e&&e.forEach((function(t){if(n.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");n.plugins.push(t),n.pluginsByKey[t.key]=t,t.spec.state&&n.fields.push(new fe(t.key,t.spec.state,t))}))},me=function(t){this.config=t},ve={schema:{configurable:!0},plugins:{configurable:!0},tr:{configurable:!0}};ve.schema.get=function(){return this.config.schema},ve.plugins.get=function(){return this.config.plugins},me.prototype.apply=function(t){return this.applyTransaction(t).state},me.prototype.filterTransaction=function(t,e){void 0===e&&(e=-1);for(var n=0;n<this.config.plugins.length;n++)if(n!=e){var r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,t,this))return!1}return!0},me.prototype.applyTransaction=function(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};for(var e=[t],n=this.applyInner(t),r=null;;){for(var o=!1,i=0;i<this.config.plugins.length;i++){var s=this.config.plugins[i];if(s.spec.appendTransaction){var a=r?r[i].n:0,c=r?r[i].state:this,p=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,c,n);if(p&&n.filterTransaction(p,i)){if(p.setMeta("appendedTransaction",t),!r){r=[];for(var l=0;l<this.config.plugins.length;l++)r.push(l<i?{state:n,n:e.length}:{state:this,n:0})}e.push(p),n=n.applyInner(p),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}},me.prototype.applyInner=function(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");for(var e=new me(this.config),n=this.config.fields,r=0;r<n.length;r++){var o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}for(var i=0;i<ge.length;i++)ge[i](this,t,e);return e},ve.tr.get=function(){return new le(this)},me.create=function(t){for(var e=new ue(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new me(e),r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n},me.prototype.reconfigure=function(t){for(var e=new ue(this.schema,t.plugins),n=e.fields,r=new me(e),o=0;o<n.length;o++){var i=n[o].name;r[i]=this.hasOwnProperty(i)?this[i]:n[o].init(t,r)}return r},me.prototype.toJSON=function(t){var e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((function(t){return t.toJSON()}))),t&&"object"==typeof t)for(var n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");var r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e},me.fromJSON=function(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");var r=new ue(t.schema,t.plugins),o=new me(r);return r.fields.forEach((function(r){if("doc"==r.name)o.doc=z.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=Zt.fromJSON(o.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(var i in n){var s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(o[r.name]=a.fromJSON.call(s,t,e[i],o))}o[r.name]=r.init(t,o)}})),o},me.addApplyListener=function(t){ge.push(t)},me.removeApplyListener=function(t){var e=ge.indexOf(t);e>-1&&ge.splice(e,1)},Object.defineProperties(me.prototype,ve);var ge=[];function ye(t,e,n){for(var r in t){var o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=ye(o,e,{})),n[r]=o}return n}var be=function(t){this.props={},t.props&&ye(t.props,this,this.props),this.spec=t,this.key=t.key?t.key.key:ke("plugin")};be.prototype.getState=function(t){return t[this.key]};var we=Object.create(null);function ke(t){return t in we?t+"$"+ ++we[t]:(we[t]=0,t+"$")}var xe=function(t){void 0===t&&(t="key"),this.key=ke(t)};xe.prototype.get=function(t){return t.config.pluginsByKey[this.key]},xe.prototype.getState=function(t){return t[this.key]};var Se={};if("undefined"!=typeof navigator&&"undefined"!=typeof document){var Oe=/Edge\/(\d+)/.exec(navigator.userAgent),Me=/MSIE \d/.test(navigator.userAgent),Ce=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);Se.mac=/Mac/.test(navigator.platform);var Ne=Se.ie=!!(Me||Ce||Oe);Se.ie_version=Me?document.documentMode||6:Ce?+Ce[1]:Oe?+Oe[1]:null,Se.gecko=!Ne&&/gecko\/(\d+)/i.test(navigator.userAgent),Se.gecko_version=Se.gecko&&+(/Firefox\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];var Te=!Ne&&/Chrome\/(\d+)/.exec(navigator.userAgent);Se.chrome=!!Te,Se.chrome_version=Te&&+Te[1],Se.safari=!Ne&&/Apple Computer/.test(navigator.vendor),Se.ios=Se.safari&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),Se.android=/Android \d/.test(navigator.userAgent),Se.webkit="webkitFontSmoothing"in document.documentElement.style,Se.webkit_version=Se.webkit&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]}var Ee=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},De=function(t){var e=t.parentNode;return e&&11==e.nodeType?e.host:e},Ae=null,_e=function(t,e,n){var r=Ae||(Ae=document.createRange());return r.setEnd(t,null==n?t.nodeValue.length:n),r.setStart(t,e||0),r},ze=function(t,e,n,r){return n&&(Ie(t,e,n,r,-1)||Ie(t,e,n,r,1))},Re=/^(img|br|input|textarea|hr)$/i;function Ie(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Pe(t))){var i=t.parentNode;if(1!=i.nodeType||je(t)||Re.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Ee(t)+(o<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?Pe(t):0}}}function Pe(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function je(t){for(var e,n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var $e=function(t){var e=t.isCollapsed;return e&&Se.chrome&&t.rangeCount&&!t.getRangeAt(0).collapsed&&(e=!1),e};function Be(t,e){var n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Ve(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Fe(t,e){return"number"==typeof t?t:t[e]}function Le(t){var e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Je(t,e,n){for(var r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument,s=n||t.dom;s;s=De(s))if(1==s.nodeType){var a=s==i.body||1!=s.nodeType,c=a?Ve(i):Le(s),p=0,l=0;if(e.top<c.top+Fe(r,"top")?l=-(c.top-e.top+Fe(o,"top")):e.bottom>c.bottom-Fe(r,"bottom")&&(l=e.bottom-c.bottom+Fe(o,"bottom")),e.left<c.left+Fe(r,"left")?p=-(c.left-e.left+Fe(o,"left")):e.right>c.right-Fe(r,"right")&&(p=e.right-c.right+Fe(o,"right")),p||l)if(a)i.defaultView.scrollBy(p,l);else{var h=s.scrollLeft,f=s.scrollTop;l&&(s.scrollTop+=l),p&&(s.scrollLeft+=p);var d=s.scrollLeft-h,u=s.scrollTop-f;e={left:e.left-d,top:e.top-u,right:e.right-d,bottom:e.bottom-u}}if(a)break}}function We(t){for(var e=[],n=t.ownerDocument;t&&(e.push({dom:t,top:t.scrollTop,left:t.scrollLeft}),t!=n);t=De(t));return e}function qe(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=r.dom,i=r.top,s=r.left;o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var Ke=null;function He(t,e){for(var n,r,o=2e8,i=0,s=e.top,a=e.top,c=t.firstChild,p=0;c;c=c.nextSibling,p++){var l=void 0;if(1==c.nodeType)l=c.getClientRects();else{if(3!=c.nodeType)continue;l=_e(c).getClientRects()}for(var h=0;h<l.length;h++){var f=l[h];if(f.top<=s&&f.bottom>=a){s=Math.max(f.bottom,s),a=Math.min(f.top,a);var d=f.left>e.left?f.left-e.left:f.right<e.left?e.left-f.right:0;if(d<o){n=c,o=d,r=d&&3==n.nodeType?{left:f.right<e.left?f.right:f.left,top:e.top}:e,1==c.nodeType&&d&&(i=p+(e.left>=(f.left+f.right)/2?1:0));continue}}!n&&(e.left>=f.right&&e.top>=f.top||e.left>=f.left&&e.top>=f.bottom)&&(i=p+1)}}return n&&3==n.nodeType?function(t,e){for(var n=t.nodeValue.length,r=document.createRange(),o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);var i=Ye(r,1);if(i.top!=i.bottom&&Ue(e,i))return{node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||o&&1==n.nodeType?{node:t,offset:i}:He(n,r)}function Ue(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ge(t,e,n){var r=t.childNodes.length;if(r&&n.top<n.bottom)for(var o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){var s=t.childNodes[i];if(1==s.nodeType)for(var a=s.getClientRects(),c=0;c<a.length;c++){var p=a[c];if(Ue(e,p))return Ge(s,e,p)}if((i=(i+1)%r)==o)break}return t}function Xe(t,e){var n,r,o,i,s=t.root;if(s.caretPositionFromPoint)try{var a=s.caretPositionFromPoint(e.left,e.top);a&&(o=(n=a).offsetNode,i=n.offset)}catch(t){}if(!o&&s.caretRangeFromPoint){var c=s.caretRangeFromPoint(e.left,e.top);c&&(o=(r=c).startContainer,i=r.startOffset)}var p,l=s.elementFromPoint(e.left,e.top+1);if(!l||!t.dom.contains(1!=l.nodeType?l.parentNode:l)){var h=t.dom.getBoundingClientRect();if(!Ue(e,h))return null;if(!(l=Ge(t.dom,e,h)))return null}if(Se.safari&&l.draggable&&(o=i=null),l=function(t,e){var n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(l,e),o){if(Se.gecko&&1==o.nodeType&&(i=Math.min(i,o.childNodes.length))<o.childNodes.length){var f,d=o.childNodes[i];"IMG"==d.nodeName&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}o==t.dom&&i==o.childNodes.length-1&&1==o.lastChild.nodeType&&e.top>o.lastChild.getBoundingClientRect().bottom?p=t.state.doc.content.size:0!=i&&1==o.nodeType&&"BR"==o.childNodes[i-1].nodeName||(p=function(t,e,n,r){for(var o=-1,i=e;i!=t.dom;){var s=t.docView.nearestDesc(i,!0);if(!s)return null;if(s.node.isBlock&&s.parent){var a=s.dom.getBoundingClientRect();if(a.left>r.left||a.top>r.top)o=s.posBefore;else{if(!(a.right<r.left||a.bottom<r.top))break;o=s.posAfter}}i=s.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n)}(t,o,i,e))}null==p&&(p=function(t,e,n){var r=He(e,n),o=r.node,i=r.offset,s=-1;if(1==o.nodeType&&!o.firstChild){var a=o.getBoundingClientRect();s=a.left!=a.right&&n.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}(t,l,e));var u=t.docView.nearestDesc(l,!0);return{pos:p,inside:u?u.posAtStart-u.border:-1}}function Ye(t,e){var n=t.getClientRects();return n.length?n[e<0?0:n.length-1]:t.getBoundingClientRect()}var Qe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ze(t,e,n){var r=t.docView.domFromPos(e,n<0?-1:1),o=r.node,i=r.offset,s=Se.webkit||Se.gecko;if(3==o.nodeType){if(!s||!Qe.test(o.nodeValue)&&(n<0?i:i!=o.nodeValue.length)){var a=i,c=i,p=n<0?1:-1;return n<0&&!i?(c++,p=-1):n>=0&&i==o.nodeValue.length?(a--,p=1):n<0?a--:c++,tn(Ye(_e(o,a,c),p),p<0)}var l=Ye(_e(o,i,i),n);if(Se.gecko&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){var h=Ye(_e(o,i-1,i-1),-1);if(h.top==l.top){var f=Ye(_e(o,i,i+1),-1);if(f.top!=l.top)return tn(f,f.left<h.left)}}return l}if(!t.state.doc.resolve(e).parent.inlineContent){if(i&&(n<0||i==Pe(o))){var d=o.childNodes[i-1];if(1==d.nodeType)return en(d.getBoundingClientRect(),!1)}if(i<Pe(o)){var u=o.childNodes[i];if(1==u.nodeType)return en(u.getBoundingClientRect(),!0)}return en(o.getBoundingClientRect(),n>=0)}if(i&&(n<0||i==Pe(o))){var m=o.childNodes[i-1],v=3==m.nodeType?_e(m,Pe(m)-(s?0:1)):1!=m.nodeType||"BR"==m.nodeName&&m.nextSibling?null:m;if(v)return tn(Ye(v,1),!1)}if(i<Pe(o)){var g=o.childNodes[i],y=3==g.nodeType?_e(g,0,s?0:1):1==g.nodeType?g:null;if(y)return tn(Ye(y,-1),!0)}return tn(Ye(3==o.nodeType?_e(o):o,-n),n>=0)}function tn(t,e){if(0==t.width)return t;var n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function en(t,e){if(0==t.height)return t;var n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function nn(t,e,n){var r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}var rn=/[\u0590-\u08ac]/;var on=null,sn=null,an=!1;function cn(t,e,n){return on==e&&sn==n?an:(on=e,sn=n,an="up"==n||"down"==n?function(t,e,n){var r=e.selection,o="up"==n?r.$from:r.$to;return nn(t,e,(function(){for(var e=t.docView.domFromPos(o.pos,"up"==n?-1:1).node;;){var r=t.docView.nearestDesc(e,!0);if(!r)break;if(r.node.isBlock){e=r.dom;break}e=r.dom.parentNode}for(var i=Ze(t,o.pos,1),s=e.firstChild;s;s=s.nextSibling){var a=void 0;if(1==s.nodeType)a=s.getClientRects();else{if(3!=s.nodeType)continue;a=_e(s,0,s.nodeValue.length).getClientRects()}for(var c=0;c<a.length;c++){var p=a[c];if(p.bottom>p.top&&("up"==n?p.bottom<i.top+1:p.top>i.bottom-1))return!1}}return!0}))}(t,e,n):function(t,e,n){var r=e.selection.$head;if(!r.parent.isTextblock)return!1;var o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=getSelection();return rn.test(r.parent.textContent)&&a.modify?nn(t,e,(function(){var e=a.getRangeAt(0),o=a.focusNode,i=a.focusOffset,s=a.caretBidiLevel;a.modify("move",n,"character");var c=!(r.depth?t.docView.domAfterPos(r.before()):t.dom).contains(1==a.focusNode.nodeType?a.focusNode:a.focusNode.parentNode)||o==a.focusNode&&i==a.focusOffset;return a.removeAllRanges(),a.addRange(e),null!=s&&(a.caretBidiLevel=s),c})):"left"==n||"backward"==n?i:s}(t,e,n))}var pn=function(t,e,n,r){this.parent=t,this.children=e,this.dom=n,n.pmViewDesc=this,this.contentDOM=r,this.dirty=0},ln={beforePosition:{configurable:!0},size:{configurable:!0},border:{configurable:!0},posBefore:{configurable:!0},posAtStart:{configurable:!0},posAfter:{configurable:!0},posAtEnd:{configurable:!0},contentLost:{configurable:!0},domAtom:{configurable:!0}};pn.prototype.matchesWidget=function(){return!1},pn.prototype.matchesMark=function(){return!1},pn.prototype.matchesNode=function(){return!1},pn.prototype.matchesHack=function(){return!1},ln.beforePosition.get=function(){return!1},pn.prototype.parseRule=function(){return null},pn.prototype.stopEvent=function(){return!1},ln.size.get=function(){for(var t=0,e=0;e<this.children.length;e++)t+=this.children[e].size;return t},ln.border.get=function(){return 0},pn.prototype.destroy=function(){this.parent=null,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=null);for(var t=0;t<this.children.length;t++)this.children[t].destroy()},pn.prototype.posBeforeChild=function(t){for(var e=0,n=this.posAtStart;e<this.children.length;e++){var r=this.children[e];if(r==t)return n;n+=r.size}},ln.posBefore.get=function(){return this.parent.posBeforeChild(this)},ln.posAtStart.get=function(){return this.parent?this.parent.posBeforeChild(this)+this.border:0},ln.posAfter.get=function(){return this.posBefore+this.size},ln.posAtEnd.get=function(){return this.posAtStart+this.size-2*this.border},pn.prototype.localPosFromDOM=function(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){var r,o;if(t==this.contentDOM)r=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;r=t.previousSibling}for(;r&&(!(o=r.pmViewDesc)||o.parent!=this);)r=r.previousSibling;return r?this.posBeforeChild(o)+o.size:this.posAtStart}var i,s;if(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&(!(s=i.pmViewDesc)||s.parent!=this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}var a;if(t==this.dom&&this.contentDOM)a=e>Ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(var c=t;;c=c.parentNode){if(c==this.dom){a=!1;break}if(c.parentNode.firstChild!=c)break}if(null==a&&e==t.childNodes.length)for(var p=t;;p=p.parentNode){if(p==this.dom){a=!0;break}if(p.parentNode.lastChild!=p)break}}return(null==a?n>0:a)?this.posAtEnd:this.posAtStart},pn.prototype.nearestDesc=function(t,e){for(var n=!0,r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o&&(!e||o.node)){if(!n||!o.nodeDOM||(1==o.nodeDOM.nodeType?o.nodeDOM.contains(1==t.nodeType?t:t.parentNode):o.nodeDOM==t))return o;n=!1}}},pn.prototype.getDesc=function(t){for(var e=t.pmViewDesc,n=e;n;n=n.parent)if(n==this)return e},pn.prototype.posFromDOM=function(t,e,n){for(var r=t;r;r=r.parentNode){var o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1},pn.prototype.descAt=function(t){for(var e=0,n=0;e<this.children.length;e++){var r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}},pn.prototype.domFromPos=function(t,e){if(!this.contentDOM)return{node:this.dom,offset:0};for(var n=0,r=0,o=!0;;r++,o=!1){for(;r<this.children.length&&(this.children[r].beforePosition||this.children[r].dom.parentNode!=this.contentDOM);)n+=this.children[r++].size;var i=r==this.children.length?null:this.children[r];if(n==t&&(0==e||!i||!i.size||i.border||e<0&&o)||i&&i.domAtom&&t<n+i.size)return{node:this.contentDOM,offset:i?Ee(i.dom):this.contentDOM.childNodes.length};if(!i)throw new Error("Invalid position "+t);var s=n+i.size;if(!i.domAtom&&(e<0&&!i.border?s>=t:s>t)&&(s>t||r+1>=this.children.length||!this.children[r+1].beforePosition))return i.domFromPos(t-n-i.border,e);n=s}},pn.prototype.parseRange=function(t,e,n){if(void 0===n&&(n=0),0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};for(var r=-1,o=-1,i=n,s=0;;s++){var a=this.children[s],c=i+a.size;if(-1==r&&t<=c){var p=i+a.border;if(t>=p&&e<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(t,e,p);t=i;for(var l=s;l>0;l--){var h=this.children[l-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){r=Ee(h.dom)+1;break}t-=h.size}-1==r&&(r=0)}if(r>-1&&(c>e||s==this.children.length-1)){e=c;for(var f=s+1;f<this.children.length;f++){var d=this.children[f];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=Ee(d.dom);break}e+=d.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}},pn.prototype.emptyChildAt=function(t){if(this.border||!this.contentDOM||!this.children.length)return!1;var e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)},pn.prototype.domAfterPos=function(t){var e=this.domFromPos(t,0),n=e.node,r=e.offset;if(1!=n.nodeType||r==n.childNodes.length)throw new RangeError("No node after pos "+t);return n.childNodes[r]},pn.prototype.setSelection=function(t,e,n,r){for(var o=Math.min(t,e),i=Math.max(t,e),s=0,a=0;s<this.children.length;s++){var c=this.children[s],p=a+c.size;if(o>a&&i<p)return c.setSelection(t-a-c.border,e-a-c.border,n,r);a=p}var l=this.domFromPos(t,t?-1:1),h=e==t?l:this.domFromPos(e,e?-1:1),f=n.getSelection(),d=!1;if((Se.gecko||Se.safari)&&t==e){var u=l.node,m=l.offset;if(3==u.nodeType)(d=m&&"\n"==u.nodeValue[m-1])&&m==u.nodeValue.length&&u.nextSibling&&"BR"==u.nextSibling.nodeName&&(l=h={node:u.parentNode,offset:Ee(u)+1});else{var v=u.childNodes[m-1];d=v&&("BR"==v.nodeName||"false"==v.contentEditable)}}if(r||d&&Se.safari||!ze(l.node,l.offset,f.anchorNode,f.anchorOffset)||!ze(h.node,h.offset,f.focusNode,f.focusOffset)){var g=!1;if((f.extend||t==e)&&!d){f.collapse(l.node,l.offset);try{t!=e&&f.extend(h.node,h.offset),g=!0}catch(t){if(!(t instanceof DOMException))throw t}}if(!g){if(t>e){var y=l;l=h,h=y}var b=document.createRange();b.setEnd(h.node,h.offset),b.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(b)}}},pn.prototype.ignoreMutation=function(t){return!this.contentDOM&&"selection"!=t.type},ln.contentLost.get=function(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)},pn.prototype.markDirty=function(t,e){for(var n=0,r=0;r<this.children.length;r++){var o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){var s=n+o.border,a=i-o.border;if(t>=s&&e<=a)return this.dirty=t==n||e==i?2:1,void(t!=s||e!=a||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-s,e-s):o.dirty=3);o.dirty=3}n=i}this.dirty=2},pn.prototype.markParentsDirty=function(){for(var t=1,e=this.parent;e;e=e.parent,t++){var n=1==t?2:1;e.dirty<n&&(e.dirty=n)}},ln.domAtom.get=function(){return!1},Object.defineProperties(pn.prototype,ln);var hn=[],fn=function(t){function e(e,n,r,o){var i,s=n.type.toDOM;if("function"==typeof s&&(s=s(r,(function(){return i?i.parent?i.parent.posBeforeChild(i):void 0:o}))),!n.type.spec.raw){if(1!=s.nodeType){var a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable=!1,s.classList.add("ProseMirror-widget")}t.call(this,e,hn,s,null),this.widget=n,i=this}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={beforePosition:{configurable:!0},domAtom:{configurable:!0}};return n.beforePosition.get=function(){return this.widget.type.side<0},e.prototype.matchesWidget=function(t){return 0==this.dirty&&t.type.eq(this.widget.type)},e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.stopEvent=function(t){var e=this.widget.spec.stopEvent;return!!e&&e(t)},e.prototype.ignoreMutation=function(t){return"selection"!=t.type||this.widget.spec.ignoreSelection},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(pn),dn=function(t){function e(e,n,r,o){t.call(this,e,hn,n,null),this.textDOM=r,this.text=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0}};return n.size.get=function(){return this.text.length},e.prototype.localPosFromDOM=function(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e},e.prototype.domFromPos=function(t){return{node:this.textDOM,offset:t}},e.prototype.ignoreMutation=function(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue},Object.defineProperties(e.prototype,n),e}(pn),un=function(t){function e(e,n,r,o){t.call(this,e,[],r,o),this.mark=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.create=function(t,n,r,o){var i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return s&&s.dom||(s=mt.renderSpec(document,n.type.spec.toDOM(n,r))),new e(t,n,s.dom,s.contentDOM||s.dom)},e.prototype.parseRule=function(){return{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}},e.prototype.matchesMark=function(t){return 3!=this.dirty&&this.mark.eq(t)},e.prototype.markDirty=function(e,n){if(t.prototype.markDirty.call(this,e,n),0!=this.dirty){for(var r=this.parent;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=0}},e.prototype.slice=function(t,n,r){var o=e.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=An(i,n,s,r)),t>0&&(i=An(i,0,t,r));for(var a=0;a<i.length;a++)i[a].parent=o;return o.children=i,o},e}(pn),mn=function(t){function e(e,n,r,o,i,s,a,c,p){t.call(this,e,n.isLeaf?hn:[],i,s),this.nodeDOM=a,this.node=n,this.outerDeco=r,this.innerDeco=o,s&&this.updateChildren(c,p)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={size:{configurable:!0},border:{configurable:!0},domAtom:{configurable:!0}};return e.create=function(t,n,r,o,i,s){var a,c,p=i.nodeViews[n.type.name],l=p&&p(n,i,(function(){return c?c.parent?c.parent.posBeforeChild(c):void 0:s}),r,o),h=l&&l.dom,f=l&&l.contentDOM;if(n.isText)if(h){if(3!=h.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else h=document.createTextNode(n.text);else h||(h=(a=mt.renderSpec(document,n.type.spec.toDOM(n))).dom,f=a.contentDOM);f||n.isText||"BR"==h.nodeName||(h.hasAttribute("contenteditable")||(h.contentEditable=!1),n.type.spec.draggable&&(h.draggable=!0));var d=h;return h=Cn(h,r,n),l?c=new bn(t,n,r,o,h,f,d,l,i,s+1):n.isText?new gn(t,n,r,o,h,d,i):new e(t,n,r,o,h,f,d,i,s+1)},e.prototype.parseRule=function(){var t=this;if(this.node.type.spec.reparseInView)return null;var e={node:this.node.type.name,attrs:this.node.attrs};return this.node.type.spec.code&&(e.preserveWhitespace="full"),this.contentDOM&&!this.contentLost?e.contentElement=this.contentDOM:e.getContent=function(){return t.contentDOM?i.empty:t.node.content},e},e.prototype.matchesNode=function(t,e,n){return 0==this.dirty&&t.eq(this.node)&&Nn(e,this.outerDeco)&&n.eq(this.innerDeco)},n.size.get=function(){return this.node.nodeSize},n.border.get=function(){return this.node.isLeaf?0:1},e.prototype.updateChildren=function(t,e){var n=this,r=this.node.inlineContent,o=e,i=r&&t.composing&&this.localCompositionNode(t,e),s=new En(this,i&&i.node);!function(t,e,n,r){var o=e.locals(t),i=0;if(0==o.length){for(var s=0;s<t.childCount;s++){var a=t.child(s);r(a,o,e.forChild(i,a),s),i+=a.nodeSize}return}for(var c=0,p=[],l=null,h=0;;){if(c<o.length&&o[c].to==i){for(var f=o[c++],d=void 0;c<o.length&&o[c].to==i;)(d||(d=[f])).push(o[c++]);if(d){d.sort(Dn);for(var u=0;u<d.length;u++)n(d[u],h,!!l)}else n(f,h,!!l)}var m=void 0,v=void 0;if(l)v=-1,m=l,l=null;else{if(!(h<t.childCount))break;v=h,m=t.child(h++)}for(var g=0;g<p.length;g++)p[g].to<=i&&p.splice(g--,1);for(;c<o.length&&o[c].from<=i&&o[c].to>i;)p.push(o[c++]);var y=i+m.nodeSize;if(m.isText){var b=y;c<o.length&&o[c].from<b&&(b=o[c].from);for(var w=0;w<p.length;w++)p[w].to<b&&(b=p[w].to);b<y&&(l=m.cut(b-i),m=m.cut(0,b-i),y=b,v=-1)}r(m,p.length?m.isInline&&!m.isLeaf?p.filter((function(t){return!t.inline})):p.slice():hn,e.forChild(i,m),v),i=y}}(this.node,this.innerDeco,(function(e,i,a){e.spec.marks?s.syncToMarks(e.spec.marks,r,t):e.type.side>=0&&!a&&s.syncToMarks(i==n.node.childCount?l.none:n.node.child(i).marks,r,t),s.placeWidget(e,t,o)}),(function(e,n,i,a){s.syncToMarks(e.marks,r,t),s.findNodeMatch(e,n,i,a)||s.updateNextNode(e,n,i,t,a)||s.addNode(e,n,i,t,o),o+=e.nodeSize})),s.syncToMarks(hn,r,t),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),wn(this.contentDOM,this.children,t),Se.ios&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){var e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))},e.prototype.localCompositionNode=function(t,e){var n=t.state.selection,r=n.from,o=n.to;if(!(!(t.state.selection instanceof ne)||r<e||o>e+this.node.content.size)){var i=t.root.getSelection(),s=function(t,e){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0){if(t.childNodes.length>e&&3==t.childNodes[e].nodeType)return t.childNodes[e];e=Pe(t=t.childNodes[e-1])}else{if(!(1==t.nodeType&&e<t.childNodes.length))return null;t=t.childNodes[e],e=0}}}(i.focusNode,i.focusOffset);if(s&&this.dom.contains(s.parentNode)){var a=s.nodeValue,c=function(t,e,n,r){for(var o=0,i=0;o<t.childCount&&i<=r;){var s=t.child(o++),a=i;if(i+=s.nodeSize,s.isText){for(var c=s.text;o<t.childCount;){var p=t.child(o++);if(i+=p.nodeSize,!p.isText)break;c+=p.text}if(i>=n){var l=c.lastIndexOf(e,r-a);if(l>=0&&l+e.length+a>=n)return a+l}}}return-1}(this.node.content,a,r-e,o-e);return c<0?null:{node:s,pos:c,text:a}}}},e.prototype.protectLocalComposition=function(t,e){var n=e.node,r=e.pos,o=e.text;if(!this.getDesc(n)){for(var i=n;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=null)}var s=new dn(this,i,n,o);t.compositionNodes.push(s),this.children=An(this.children,r,r+o.length,t,s)}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)},e.prototype.updateInner=function(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0},e.prototype.updateOuterDeco=function(t){if(!Nn(t,this.outerDeco)){var e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=On(this.dom,this.nodeDOM,Sn(this.outerDeco,this.node,e),Sn(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=null,this.dom.pmViewDesc=this),this.outerDeco=t}},e.prototype.selectNode=function(){this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.dom.draggable=!0)},e.prototype.deselectNode=function(){this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.dom.removeAttribute("draggable")},n.domAtom.get=function(){return this.node.isAtom},Object.defineProperties(e.prototype,n),e}(pn);function vn(t,e,n,r,o){return Cn(r,e,t),new mn(null,t,e,n,r,r,r,o,0)}var gn=function(t){function e(e,n,r,o,i,s,a){t.call(this,e,n,r,o,i,null,s,a)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){for(var t=this.nodeDOM.parentNode;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}},e.prototype.update=function(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),0==this.dirty&&t.text==this.node.text||t.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)},e.prototype.inParent=function(){for(var t=this.parent.contentDOM,e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1},e.prototype.domFromPos=function(t){return{node:this.nodeDOM,offset:t}},e.prototype.localPosFromDOM=function(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):t.prototype.localPosFromDOM.call(this,e,n,r)},e.prototype.ignoreMutation=function(t){return"characterData"!=t.type&&"selection"!=t.type},e.prototype.slice=function(t,n,r){var o=this.node.cut(t,n),i=document.createTextNode(o.text);return new e(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)},n.domAtom.get=function(){return!1},Object.defineProperties(e.prototype,n),e}(mn),yn=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={domAtom:{configurable:!0}};return e.prototype.parseRule=function(){return{ignore:!0}},e.prototype.matchesHack=function(){return 0==this.dirty},n.domAtom.get=function(){return!0},Object.defineProperties(e.prototype,n),e}(pn),bn=function(t){function e(e,n,r,o,i,s,a,c,p,l){t.call(this,e,n,r,o,i,s,a,p,l),this.spec=c}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.update=function(e,n,r,o){if(3==this.dirty)return!1;if(this.spec.update){var i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}return!(!this.contentDOM&&!e.isLeaf)&&t.prototype.update.call(this,e,n,r,o)},e.prototype.selectNode=function(){this.spec.selectNode?this.spec.selectNode():t.prototype.selectNode.call(this)},e.prototype.deselectNode=function(){this.spec.deselectNode?this.spec.deselectNode():t.prototype.deselectNode.call(this)},e.prototype.setSelection=function(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):t.prototype.setSelection.call(this,e,n,r,o)},e.prototype.destroy=function(){this.spec.destroy&&this.spec.destroy(),t.prototype.destroy.call(this)},e.prototype.stopEvent=function(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)},e.prototype.ignoreMutation=function(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):t.prototype.ignoreMutation.call(this,e)},e}(mn);function wn(t,e,n){for(var r=t.firstChild,o=!1,i=0;i<e.length;i++){var s=e[i],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=Tn(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(s instanceof un){var c=r?r.previousSibling:t.lastChild;wn(s.contentDOM,s.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=Tn(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}function kn(t){t&&(this.nodeName=t)}kn.prototype=Object.create(null);var xn=[new kn];function Sn(t,e,n){if(0==t.length)return xn;for(var r=n?xn[0]:new kn,o=[r],i=0;i<t.length;i++){var s=t[i].type.attrs;if(s)for(var a in s.nodeName&&o.push(r=new kn(s.nodeName)),s){var c=s[a];null!=c&&(n&&1==o.length&&o.push(r=new kn(e.isInline?"span":"div")),"class"==a?r.class=(r.class?r.class+" ":"")+c:"style"==a?r.style=(r.style?r.style+";":"")+c:"nodeName"!=a&&(r[a]=c))}}return o}function On(t,e,n,r){if(n==xn&&r==xn)return e;for(var o=e,i=0;i<r.length;i++){var s=r[i],a=n[i];if(i){var c=void 0;a&&a.nodeName==s.nodeName&&o!=t&&(c=o.parentNode)&&c.tagName.toLowerCase()==s.nodeName||((c=document.createElement(s.nodeName)).pmIsDeco=!0,c.appendChild(o),a=xn[0]),o=c}Mn(o,a||xn[0],s)}return o}function Mn(t,e,n){for(var r in e)"class"==r||"style"==r||"nodeName"==r||r in n||t.removeAttribute(r);for(var o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){for(var i=e.class?e.class.split(" ").filter(Boolean):hn,s=n.class?n.class.split(" ").filter(Boolean):hn,a=0;a<i.length;a++)-1==s.indexOf(i[a])&&t.classList.remove(i[a]);for(var c=0;c<s.length;c++)-1==i.indexOf(s[c])&&t.classList.add(s[c])}if(e.style!=n.style){if(e.style)for(var p,l=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;p=l.exec(e.style);)t.style.removeProperty(p[1]);n.style&&(t.style.cssText+=n.style)}}function Cn(t,e,n){return On(t,t,xn,Sn(e,n,1!=t.nodeType))}function Nn(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Tn(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}var En=function(t,e){this.top=t,this.lock=e,this.index=0,this.stack=[],this.changed=!1,this.preMatch=function(t,e){for(var n=t.childCount,r=e.length,o=new Map;n>0&&r>0;r--){var i=e[r-1],s=i.node;if(s){if(s!=t.child(n-1))break;--n,o.set(i,n)}}return{index:n,matched:o}}(t.node.content,t.children)};function Dn(t,e){return t.type.side-e.type.side}function An(t,e,n,r,o){for(var i=[],s=0,a=0;s<t.length;s++){var c=t[s],p=a,l=a+=c.size;p>=n||l<=e?i.push(c):(p<e&&i.push(c.slice(0,e-p,r)),o&&(i.push(o),o=null),l>n&&i.push(c.slice(n-p,c.size,r)))}return i}function _n(t,e){var n=t.root.getSelection(),r=t.state.doc;if(!n.focusNode)return null;var o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset);if(s<0)return null;var a,c,p=r.resolve(s);if($e(n)){for(a=p;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&oe.isSelectable(o.node)&&o.parent&&(!o.node.isInline||!function(t,e,n){for(var r=0==e,o=e==Pe(t);r||o;){if(t==n)return!0;var i=Ee(t);if(!(t=t.parentNode))return!1;r=r&&0==i,o=o&&i==Pe(t)}}(n.focusNode,n.focusOffset,o.dom))){var l=o.posBefore;c=new oe(s==l?p:r.resolve(l))}}else{var h=t.docView.posFromDOM(n.anchorNode,n.anchorOffset);if(h<0)return null;a=r.resolve(h)}c||(c=Fn(t,a,p,"pointer"==e||t.state.selection.head<p.pos&&!i?1:-1));return c}function zn(t){return t.editable?t.hasFocus():Ln(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Rn(t,e){var n=t.state.selection;if(Bn(t,n),zn(t)){if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){var e=t.root.getSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setEnd(r.parentNode,Ee(r)+1):n.setEnd(r,0);n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&Se.ie&&Se.ie_version<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{var r,o,i=n.anchor,s=n.head;!In||n instanceof ne||(n.$from.parent.inlineContent||(r=Pn(t,n.from)),n.empty||n.$from.parent.inlineContent||(o=Pn(t,n.to))),t.docView.setSelection(i,s,t.root,e),In&&(r&&$n(r),o&&$n(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){var e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.hideSelectionGuard);var n=t.root.getSelection(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.hideSelectionGuard=function(){n.anchorNode==r&&n.anchorOffset==o||(e.removeEventListener("selectionchange",t.hideSelectionGuard),setTimeout((function(){zn(t)&&!t.state.selection.visible||t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}En.prototype.destroyBetween=function(t,e){if(t!=e){for(var n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}},En.prototype.destroyRest=function(){this.destroyBetween(this.index,this.top.children.length)},En.prototype.syncToMarks=function(t,e,n){for(var r=0,o=this.stack.length>>1,i=Math.min(o,t.length);r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);for(var s=-1,a=this.index;a<Math.min(this.index+3,this.top.children.length);a++)if(this.top.children[a].matchesMark(t[o])){s=a;break}if(s>-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{var c=un.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}},En.prototype.findNodeMatch=function(t,e,n,r){var o=this.top.children,i=-1;if(r>=this.preMatch.index){for(var s=this.index;s<o.length;s++)if(o[s].matchesNode(t,e,n)){i=s;break}}else for(var a=this.index,c=Math.min(o.length,a+1);a<c;a++){var p=o[a];if(p.matchesNode(t,e,n)&&!this.preMatch.matched.has(p)){i=a;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)},En.prototype.updateNextNode=function(t,e,n,r,o){for(var i=this.index;i<this.top.children.length;i++){var s=this.top.children[i];if(s instanceof mn){var a=this.preMatch.matched.get(s);if(null!=a&&a!=o)return!1;var c=s.dom;if(!(this.lock&&(c==this.lock||1==c.nodeType&&c.contains(this.lock.parentNode))&&!(t.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==t.text&&3!=s.dirty&&Nn(e,s.outerDeco)))&&s.update(t,e,n,r))return this.destroyBetween(this.index,i),s.dom!=c&&(this.changed=!0),this.index++,!0;break}}return!1},En.prototype.addNode=function(t,e,n,r,o){this.top.children.splice(this.index++,0,mn.create(this.top,t,e,n,r,o)),this.changed=!0},En.prototype.placeWidget=function(t,e,n){var r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){var o=new fn(this.top,t,e,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++},En.prototype.addTextblockHacks=function(){for(var t=this.top.children[this.index-1];t instanceof un;)t=t.children[t.children.length-1];if(!t||!(t instanceof gn)||/\n$/.test(t.node.text))if(this.index<this.top.children.length&&this.top.children[this.index].matchesHack())this.index++;else{var e=document.createElement("br");this.top.children.splice(this.index++,0,new yn(this.top,hn,e,null)),this.changed=!0}};var In=Se.safari||Se.chrome&&Se.chrome_version<63;function Pn(t,e){var n=t.docView.domFromPos(e,0),r=n.node,o=n.offset,i=o<r.childNodes.length?r.childNodes[o]:null,s=o?r.childNodes[o-1]:null;if(Se.safari&&i&&"false"==i.contentEditable)return jn(i);if(!(i&&"false"!=i.contentEditable||s&&"false"!=s.contentEditable)){if(i)return jn(i);if(s)return jn(s)}}function jn(t){return t.contentEditable="true",Se.safari&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function $n(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Bn(t,e){if(e instanceof oe){var n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Vn(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Vn(t)}function Vn(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=null)}function Fn(t,e,n,r){return t.someProp("createSelectionBetween",(function(r){return r(t,e,n)}))||ne.between(e,n,r)}function Ln(t){var e=t.root.getSelection();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Jn(t,e){var n=t.selection,r=n.$anchor,o=n.$head,i=e>0?r.max(o):r.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Zt.findFrom(s,e)}function Wn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function qn(t,e,n){var r=t.state.selection;if(!(r instanceof ne)){if(r instanceof oe&&r.node.isInline)return Wn(t,new ne(e>0?r.$to:r.$from));var o=Jn(t.state,e);return!!o&&Wn(t,o)}if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"right":"left")){var i=Jn(t.state,e);return!!(i&&i instanceof oe)&&Wn(t,i)}if(!(Se.mac&&n.indexOf("m")>-1)){var s,a=r.$head,c=a.textOffset?null:e<0?a.nodeBefore:a.nodeAfter;if(!c||c.isText)return!1;var p=e<0?a.pos-c.nodeSize:a.pos;return!!(c.isAtom||(s=t.docView.descAt(p))&&!s.contentDOM)&&(oe.isSelectable(c)?Wn(t,new oe(e<0?t.state.doc.resolve(a.pos-c.nodeSize):a)):!!Se.webkit&&Wn(t,new ne(t.state.doc.resolve(e<0?p:p+c.nodeSize))))}}function Kn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Hn(t){var e=t.pmViewDesc;return e&&0==e.size&&(t.nextSibling||"BR"!=t.nodeName)}function Un(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){var o,i,s=!1;for(Se.gecko&&1==n.nodeType&&r<Kn(n)&&Hn(n.childNodes[r])&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;var a=n.childNodes[r-1];if(Hn(a))o=n,i=--r;else{if(3!=a.nodeType)break;r=(n=a).nodeValue.length}}else{if(Xn(n))break;for(var c=n.previousSibling;c&&Hn(c);)o=n.parentNode,i=Ee(c),c=c.previousSibling;if(c)r=Kn(n=c);else{if((n=n.parentNode)==t.dom)break;r=0}}s?Yn(t,e,n,r):o&&Yn(t,e,o,i)}}function Gn(t){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n){for(var o,i,s=Kn(n);;)if(r<s){if(1!=n.nodeType)break;if(!Hn(n.childNodes[r]))break;o=n,i=++r}else{if(Xn(n))break;for(var a=n.nextSibling;a&&Hn(a);)o=a.parentNode,i=Ee(a)+1,a=a.nextSibling;if(a)r=0,s=Kn(n=a);else{if((n=n.parentNode)==t.dom)break;r=s=0}}o&&Yn(t,e,o,i)}}function Xn(t){var e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Yn(t,e,n,r){if($e(e)){var o=document.createRange();o.setEnd(n,r),o.setStart(n,r),e.removeAllRanges(),e.addRange(o)}else e.extend&&e.extend(n,r);t.domObserver.setCurSelection();var i=t.state;setTimeout((function(){t.state==i&&Rn(t)}),50)}function Qn(t,e,n){var r=t.state.selection;if(r instanceof ne&&!r.empty||n.indexOf("s")>-1)return!1;if(Se.mac&&n.indexOf("m")>-1)return!1;var o=r.$from,i=r.$to;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){var s=Jn(t.state,e);if(s&&s instanceof oe)return Wn(t,s)}if(!o.parent.inlineContent){var a=e<0?o:i,c=r instanceof se?Zt.near(a,e):Zt.findFrom(a,e);return!!c&&Wn(t,c)}return!1}function Zn(t,e){if(!(t.state.selection instanceof ne))return!0;var n=t.state.selection,r=n.$head,o=n.$anchor,i=n.empty;if(!r.sameParent(o))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;var s=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(s&&!s.isText){var a=t.state.tr;return e<0?a.delete(r.pos-s.nodeSize,r.pos):a.delete(r.pos,r.pos+s.nodeSize),t.dispatch(a),!0}return!1}function tr(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function er(t,e){var n=e.keyCode,r=function(t){var e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);return 8==n||Se.mac&&72==n&&"c"==r?Zn(t,-1)||Un(t):46==n||Se.mac&&68==n&&"c"==r?Zn(t,1)||Gn(t):13==n||27==n||(37==n?qn(t,-1,r)||Un(t):39==n?qn(t,1,r)||Gn(t):38==n?Qn(t,-1,r)||Un(t):40==n?function(t){if(Se.safari&&!(t.state.selection.$head.parentOffset>0)){var e=t.root.getSelection(),n=e.focusNode,r=e.focusOffset;if(n&&1==n.nodeType&&0==r&&n.firstChild&&"false"==n.firstChild.contentEditable){var o=n.firstChild;tr(t,o,!0),setTimeout((function(){return tr(t,o,!1)}),20)}}}(t)||Qn(t,1,r)||Gn(t):r==(Se.mac?"m":"c")&&(66==n||73==n||89==n||90==n))}function nr(t){var e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(Se.safari&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){var n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}if(t.parentNode.lastChild==t||Se.safari&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0}}function rr(t,e,n,r,o){if(e<0){var s=t.lastSelectionTime>Date.now()-50?t.lastSelectionOrigin:null,a=_n(t,s);if(a&&!t.state.selection.eq(a)){var c=t.state.tr.setSelection(a);"pointer"==s?c.setMeta("pointer",!0):"key"==s&&c.scrollIntoView(),t.dispatch(c)}}else{var p=t.state.doc.resolve(e),l=p.sharedDepth(n);e=p.before(l+1),n=t.state.doc.resolve(n).after(l+1);var h=t.state.selection,f=function(t,e,n){var r=t.docView.parseRange(e,n),o=r.node,i=r.fromOffset,s=r.toOffset,a=r.from,c=r.to,p=t.root.getSelection(),l=null,h=p.anchorNode;if(h&&t.dom.contains(1==h.nodeType?h:h.parentNode)&&(l=[{node:h,offset:p.anchorOffset}],$e(p)||l.push({node:p.focusNode,offset:p.focusOffset})),Se.chrome&&8===t.lastKeyCode)for(var f=s;f>i;f--){var d=o.childNodes[f-1],u=d.pmViewDesc;if("BR"==d.nodeType&&!u){s=f;break}if(!u||u.size)break}var m=t.state.doc,v=t.someProp("domParser")||ot.fromSchema(t.state.schema),g=m.resolve(a),y=null,b=v.parse(o,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:!g.parent.type.spec.code||"full",editableContent:!0,findPositions:l,ruleFromNode:nr,context:g});if(l&&null!=l[0].pos){var w=l[0].pos,k=l[1]&&l[1].pos;null==k&&(k=w),y={anchor:w+a,head:k+a}}return{doc:b,sel:y,from:a,to:c}}(t,e,n);if(Se.chrome&&t.cursorWrapper&&f.sel&&f.sel.anchor==t.cursorWrapper.deco.from){var d=t.cursorWrapper.deco.type.toDOM.nextSibling,u=d&&d.nodeValue?d.nodeValue.length:1;f.sel={anchor:f.sel.anchor+u,head:f.sel.anchor+u}}var m,v,g=t.state.doc,y=g.slice(f.from,f.to);8===t.lastKeyCode&&Date.now()-100<t.lastKeyCodeTime?(m=t.state.selection.to,v="end"):(m=t.state.selection.from,v="start"),t.lastKeyCode=null;var b=function(t,e,n,r,o){var i=t.findDiffStart(e,n);if(null==i)return null;var s=t.findDiffEnd(e,n+t.size,n+e.size),a=s.a,c=s.b;if("end"==o){r-=a+Math.max(0,i-Math.min(a,c))-i}if(a<i&&t.size<e.size){c=(i-=r<=i&&r>=a?i-r:0)+(c-a),a=i}else if(c<i){a=(i-=r<=i&&r>=c?i-r:0)+(a-c),c=i}return{start:i,endA:a,endB:c}}(y.content,f.doc.content,f.from,m,v);if(!b){if(!(r&&h instanceof ne&&!h.empty&&h.$head.sameParent(h.$anchor))||t.composing||f.sel&&f.sel.anchor!=f.sel.head){if(Se.ios&&t.lastIOSEnter>Date.now()-225&&o.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName}))&&t.someProp("handleKeyDown",(function(e){return e(t,Be(13,"Enter"))})))return void(t.lastIOSEnter=0);if(f.sel){var w=or(t,t.state.doc,f.sel);w&&!w.eq(t.state.selection)&&t.dispatch(t.state.tr.setSelection(w))}return}b={start:h.from,endA:h.to,endB:h.to}}t.domChangeCount++,t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof ne&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),Se.ie&&Se.ie_version<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>f.from&&"  "==f.doc.textBetween(b.start-f.from-1,b.start-f.from+1)&&(b.start--,b.endA--,b.endB--);var k,x=f.doc.resolveNoCache(b.start-f.from),S=f.doc.resolveNoCache(b.endB-f.from),O=x.sameParent(S)&&x.parent.inlineContent;if((Se.ios&&t.lastIOSEnter>Date.now()-225&&(!O||o.some((function(t){return"DIV"==t.nodeName||"P"==t.nodeName})))||!O&&x.pos<f.doc.content.size&&(k=Zt.findFrom(f.doc.resolve(x.pos+1),1,!0))&&k.head==S.pos)&&t.someProp("handleKeyDown",(function(e){return e(t,Be(13,"Enter"))})))t.lastIOSEnter=0;else if(t.state.selection.anchor>b.start&&function(t,e,n,r,o){if(!r.parent.isTextblock||n-e<=o.pos-r.pos||ir(r,!0,!1)<o.pos)return!1;var i=t.resolve(e);if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;var s=t.resolve(ir(i,!0,!0));if(!s.parent.isTextblock||s.pos>n||ir(s,!0,!1)<n)return!1;return r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(g,b.start,b.endA,x,S)&&t.someProp("handleKeyDown",(function(e){return e(t,Be(8,"Backspace"))})))Se.android&&Se.chrome&&t.domObserver.suppressSelectionUpdates();else{Se.android&&!O&&x.start()!=S.start()&&0==S.parentOffset&&x.depth==S.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==b.endA&&(b.endB-=2,S=f.doc.resolveNoCache(b.endB-f.from),setTimeout((function(){t.someProp("handleKeyDown",(function(e){return e(t,Be(13,"Enter"))}))}),20));var M,C,N,T,E=b.start,D=b.endA;if(O)if(x.pos==S.pos)Se.ie&&Se.ie_version<=11&&0==x.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((function(){return Rn(t)}),20)),M=t.state.tr.delete(E,D),C=g.resolve(b.start).marksAcross(g.resolve(b.endA));else if(b.endA==b.endB&&(T=g.resolve(b.start))&&(N=function(t,e){for(var n,r,o,s=t.firstChild.marks,a=e.firstChild.marks,c=s,p=a,l=0;l<a.length;l++)c=a[l].removeFromSet(c);for(var h=0;h<s.length;h++)p=s[h].removeFromSet(p);if(1==c.length&&0==p.length)r=c[0],n="add",o=function(t){return t.mark(r.addToSet(t.marks))};else{if(0!=c.length||1!=p.length)return null;r=p[0],n="remove",o=function(t){return t.mark(r.removeFromSet(t.marks))}}for(var f=[],d=0;d<e.childCount;d++)f.push(o(e.child(d)));if(i.from(f).eq(t))return{mark:r,type:n}}(x.parent.content.cut(x.parentOffset,S.parentOffset),T.parent.content.cut(T.parentOffset,b.endA-T.start()))))M=t.state.tr,"add"==N.type?M.addMark(E,D,N.mark):M.removeMark(E,D,N.mark);else if(x.parent.child(x.index()).isText&&x.index()==S.index()-(S.textOffset?0:1)){var A=x.parent.textBetween(x.parentOffset,S.parentOffset);if(t.someProp("handleTextInput",(function(e){return e(t,E,D,A)})))return;M=t.state.tr.insertText(A,E,D)}if(M||(M=t.state.tr.replace(E,D,f.doc.slice(b.start-f.from,b.endB-f.from))),f.sel){var _=or(t,M.doc,f.sel);_&&!(Se.chrome&&Se.android&&t.composing&&_.empty&&(_.head==E||_.head==M.mapping.map(D)-1)||Se.ie&&_.empty&&_.head==E)&&M.setSelection(_)}C&&M.ensureMarks(C),t.dispatch(M.scrollIntoView())}}}function or(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Fn(t,e.resolve(n.anchor),e.resolve(n.head))}function ir(t,e,n){for(var r=t.depth,o=e?t.end():t.pos;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n)for(var i=t.node(r).maybeChild(t.indexAfter(r));i&&!i.isLeaf;)i=i.firstChild,o++;return o}function sr(t,e){for(var n=[],r=e.content,o=e.openStart,i=e.openEnd;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;var s=r.firstChild;n.push(s.type.name,s.attrs!=s.type.defaultAttrs?s.attrs:null),r=s.content}var a=t.someProp("clipboardSerializer")||mt.fromSchema(t.state.schema),c=ur(),p=c.createElement("div");p.appendChild(a.serializeFragment(r,{document:c}));for(var l,h=p.firstChild;h&&1==h.nodeType&&(l=fr[h.nodeName.toLowerCase()]);){for(var f=l.length-1;f>=0;f--){for(var d=c.createElement(l[f]);p.firstChild;)d.appendChild(p.firstChild);p.appendChild(d)}h=p.firstChild}return h&&1==h.nodeType&&h.setAttribute("data-pm-slice",o+" "+i+" "+JSON.stringify(n)),{dom:p,text:t.someProp("clipboardTextSerializer",(function(t){return t(e)}))||e.content.textBetween(0,e.content.size,"\n\n")}}function ar(t,e,n,r,o){var s,a,c=o.parent.type.spec.code;if(!n&&!e)return null;var p=e&&(r||c||!n);if(p){if(t.someProp("transformPastedText",(function(t){e=t(e,c||r)})),c)return new f(i.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0);var l=t.someProp("clipboardTextParser",(function(t){return t(e,o,r)}));l?a=l:(s=document.createElement("div"),e.trim().split(/(?:\r\n?|\n)+/).forEach((function(t){s.appendChild(document.createElement("p")).textContent=t})))}else t.someProp("transformPastedHTML",(function(t){n=t(n)})),s=function(t){var e=/(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));var n,r=ur().createElement("div"),o=/(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(t),i=0;(n=o&&fr[o[1].toLowerCase()])&&(t=n.map((function(t){return"<"+t+">"})).join("")+t+n.map((function(t){return"</"+t+">"})).reverse().join(""),i=n.length);r.innerHTML=t;for(var s=0;s<i;s++)r=r.firstChild;return r}(n);var h=s&&s.querySelector("[data-pm-slice]"),d=h&&/^(\d+) (\d+) (.*)/.exec(h.getAttribute("data-pm-slice"));if(!a){var u=t.someProp("clipboardParser")||t.someProp("domParser")||ot.fromSchema(t.state.schema);a=u.parseSlice(s,{preserveWhitespace:!(!p&&!d),context:o})}return a=d?function(t,e){if(!t.size)return t;var n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch(e){return t}for(var o=t.content,s=t.openStart,a=t.openEnd,c=n.length-2;c>=0;c-=2){var p=r.nodes[n[c]];if(!p||p.hasRequiredAttrs())break;o=i.from(p.create(n[c+1],o)),s++,a++}return new f(o,s,a)}(function(t,e,n){e<t.openStart&&(t=new f(hr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd));n<t.openEnd&&(t=new f(hr(t.content,1,n,t.openEnd,0,0),t.openStart,n));return t}(a,+d[1],+d[2]),d[3]):f.maxOpen(function(t,e){if(t.childCount<2)return t;for(var n=function(n){var r=e.node(n).contentMatchAt(e.index(n)),o=void 0,s=[];if(t.forEach((function(t){if(s){var e,n=r.findWrapping(t.type);if(!n)return s=null;if(e=s.length&&o.length&&pr(n,o,t,s[s.length-1],0))s[s.length-1]=e;else{s.length&&(s[s.length-1]=lr(s[s.length-1],o.length));var i=cr(t,n);s.push(i),r=r.matchType(i.type,i.attrs),o=n}}})),s)return{v:i.from(s)}},r=e.depth;r>=0;r--){var o=n(r);if(o)return o.v}return t}(a.content,o),!1),t.someProp("transformPasted",(function(t){a=t(a)})),a}function cr(t,e,n){void 0===n&&(n=0);for(var r=e.length-1;r>=n;r--)t=e[r].create(null,i.from(t));return t}function pr(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){var s=pr(t,e,n,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(i.from(cr(n,t,o+1))))}}function lr(t,e){if(0==e)return t;var n=t.content.replaceChild(t.childCount-1,lr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(i.empty,!0);return t.copy(n.append(r))}function hr(t,e,n,r,o,s){var a=e<0?t.firstChild:t.lastChild,c=a.content;return o<r-1&&(c=hr(c,e,n,r,o+1,s)),o>=n&&(c=e<0?a.contentMatchAt(0).fillBefore(c,t.childCount>1||s<=o).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(i.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(c))}var fr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]},dr=null;function ur(){return dr||(dr=document.implementation.createHTMLDocument("title"))}var mr={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vr=Se.ie&&Se.ie_version<=11,gr=function(){this.anchorNode=this.anchorOffset=this.focusNode=this.focusOffset=null};gr.prototype.set=function(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset},gr.prototype.eq=function(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset};var yr=function(t,e){var n=this;this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=window.MutationObserver&&new window.MutationObserver((function(t){for(var e=0;e<t.length;e++)n.queue.push(t[e]);Se.ie&&Se.ie_version<=11&&t.some((function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length}))?n.flushSoon():n.flush()})),this.currentSelection=new gr,vr&&(this.onCharData=function(t){n.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),n.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.suppressingSelectionUpdates=!1};yr.prototype.flushSoon=function(){var t=this;this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((function(){t.flushingSoon=-1,t.flush()}),20))},yr.prototype.forceFlush=function(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())},yr.prototype.start=function(){this.observer&&this.observer.observe(this.view.dom,mr),vr&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()},yr.prototype.stop=function(){var t=this;if(this.observer){var e=this.observer.takeRecords();if(e.length){for(var n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout((function(){return t.flush()}),20)}this.observer.disconnect()}vr&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()},yr.prototype.connectSelection=function(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)},yr.prototype.disconnectSelection=function(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)},yr.prototype.suppressSelectionUpdates=function(){var t=this;this.suppressingSelectionUpdates=!0,setTimeout((function(){return t.suppressingSelectionUpdates=!1}),50)},yr.prototype.onSelectionChange=function(){if((!(t=this.view).editable||t.root.activeElement==t.dom)&&Ln(t)){var t;if(this.suppressingSelectionUpdates)return Rn(this.view);if(Se.ie&&Se.ie_version<=11&&!this.view.state.selection.empty){var e=this.view.root.getSelection();if(e.focusNode&&ze(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}},yr.prototype.setCurSelection=function(){this.currentSelection.set(this.view.root.getSelection())},yr.prototype.ignoreSelectionChange=function(t){if(0==t.rangeCount)return!0;var e=t.getRangeAt(0).commonAncestorContainer,n=this.view.docView.nearestDesc(e);return n&&n.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0},yr.prototype.flush=function(){if(this.view.docView&&!(this.flushingSoon>-1)){var t=this.observer?this.observer.takeRecords():[];this.queue.length&&(t=this.queue.concat(t),this.queue.length=0);var e=this.view.root.getSelection(),n=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(e)&&Ln(this.view)&&!this.ignoreSelectionChange(e),r=-1,o=-1,i=!1,s=[];if(this.view.editable)for(var a=0;a<t.length;a++){var c=this.registerMutation(t[a],s);c&&(r=r<0?c.from:Math.min(c.from,r),o=o<0?c.to:Math.max(c.to,o),c.typeOver&&(i=!0))}if(Se.gecko&&s.length>1){var p=s.filter((function(t){return"BR"==t.nodeName}));if(2==p.length){var l=p[0],h=p[1];l.parentNode&&l.parentNode.parentNode==h.parentNode?h.remove():l.remove()}}(r>-1||n)&&(r>-1&&(this.view.docView.markDirty(r,o),function(t){if(br)return;br=!0,"normal"==getComputedStyle(t.dom).whiteSpace&&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.")}(this.view)),this.handleDOMChange(r,o,i,s),this.view.docView.dirty?this.view.updateState(this.view.state):this.currentSelection.eq(e)||Rn(this.view),this.currentSelection.set(e))}},yr.prototype.registerMutation=function(t,e){if(e.indexOf(t.target)>-1)return null;var n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(t))return null;if("childList"==t.type){if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};var r=t.previousSibling,o=t.nextSibling;if(Se.ie&&Se.ie_version<=11&&t.addedNodes.length)for(var i=0;i<t.addedNodes.length;i++){var s=t.addedNodes[i],a=s.previousSibling,c=s.nextSibling;(!a||Array.prototype.indexOf.call(t.addedNodes,a)<0)&&(r=a),(!c||Array.prototype.indexOf.call(t.addedNodes,c)<0)&&(o=c)}for(var p=r&&r.parentNode==t.target?Ee(r)+1:0,l=n.localPosFromDOM(t.target,p,-1),h=o&&o.parentNode==t.target?Ee(o):t.target.childNodes.length,f=0;f<t.addedNodes.length;f++)e.push(t.addedNodes[f]);return{from:l,to:n.localPosFromDOM(t.target,h,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}};var br=!1;var wr={},kr={};function xr(t,e){t.lastSelectionOrigin=e,t.lastSelectionTime=Date.now()}function Sr(t){t.someProp("handleDOMEvents",(function(e){for(var n in e)t.eventHandlers[n]||t.dom.addEventListener(n,t.eventHandlers[n]=function(e){return Or(t,e)})}))}function Or(t,e){return t.someProp("handleDOMEvents",(function(n){var r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function Mr(t){return{left:t.clientX,top:t.clientY}}function Cr(t,e,n,r,o){if(-1==r)return!1;for(var i=t.state.doc.resolve(r),s=function(r){if(t.someProp(e,(function(e){return r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1)})))return{v:!0}},a=i.depth+1;a>0;a--){var c=s(a);if(c)return c.v}return!1}function Nr(t,e,n){t.focused||t.focus();var r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function Tr(t,e,n,r,o){return Cr(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(function(n){return n(t,e,r)}))||(o?function(t,e){if(-1==e)return!1;var n,r,o=t.state.selection;o instanceof oe&&(n=o.node);for(var i=t.state.doc.resolve(e),s=i.depth+1;s>0;s--){var a=s>i.depth?i.nodeAfter:i.node(s);if(oe.isSelectable(a)){r=n&&o.$from.depth>0&&s>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(s);break}}return null!=r&&(Nr(t,oe.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;var n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&oe.isSelectable(r))&&(Nr(t,new oe(n),"pointer"),!0)}(t,n))}function Er(t,e,n,r){return Cr(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(function(n){return n(t,e,r)}))}function Dr(t,e,n,r){return Cr(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(function(n){return n(t,e,r)}))||function(t,e){var n=t.state.doc;if(-1==e)return!!n.inlineContent&&(Nr(t,ne.create(n,0,n.content.size),"pointer"),!0);for(var r=n.resolve(e),o=r.depth+1;o>0;o--){var i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)Nr(t,ne.create(n,s+1,s+1+i.content.size),"pointer");else{if(!oe.isSelectable(i))continue;Nr(t,oe.create(n,s),"pointer")}return!0}}(t,n)}function Ar(t){return $r(t)}kr.keydown=function(t,e){if(t.shiftKey=16==e.keyCode||e.shiftKey,!Rr(t,e))if(t.domObserver.forceFlush(),t.lastKeyCode=e.keyCode,t.lastKeyCodeTime=Date.now(),!Se.ios||13!=e.keyCode||e.ctrlKey||e.altKey||e.metaKey)t.someProp("handleKeyDown",(function(n){return n(t,e)}))||er(t,e)?e.preventDefault():xr(t,"key");else{var n=Date.now();t.lastIOSEnter=n,t.lastIOSEnterFallbackTimeout=setTimeout((function(){t.lastIOSEnter==n&&(t.someProp("handleKeyDown",(function(e){return e(t,Be(13,"Enter"))})),t.lastIOSEnter=0)}),200)}},kr.keyup=function(t,e){16==e.keyCode&&(t.shiftKey=!1)},kr.keypress=function(t,e){if(!(Rr(t,e)||!e.charCode||e.ctrlKey&&!e.altKey||Se.mac&&e.metaKey))if(t.someProp("handleKeyPress",(function(n){return n(t,e)})))e.preventDefault();else{var n=t.state.selection;if(!(n instanceof ne&&n.$from.sameParent(n.$to))){var r=String.fromCharCode(e.charCode);t.someProp("handleTextInput",(function(e){return e(t,n.$from.pos,n.$to.pos,r)}))||t.dispatch(t.state.tr.insertText(r).scrollIntoView()),e.preventDefault()}}};var _r=Se.mac?"metaKey":"ctrlKey";wr.mousedown=function(t,e){t.shiftKey=e.shiftKey;var n=Ar(t),r=Date.now(),o="singleClick";r-t.lastClick.time<500&&function(t,e){var n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(e,t.lastClick)&&!e[_r]&&("singleClick"==t.lastClick.type?o="doubleClick":"doubleClick"==t.lastClick.type&&(o="tripleClick")),t.lastClick={time:r,x:e.clientX,y:e.clientY,type:o};var i=t.posAtCoords(Mr(e));i&&("singleClick"==o?t.mouseDown=new zr(t,i,e,n):("doubleClick"==o?Er:Dr)(t,i.pos,i.inside,e)?e.preventDefault():xr(t,"pointer"))};var zr=function(t,e,n,r){var o,i,s=this;if(this.view=t,this.startDoc=t.state.doc,this.pos=e,this.event=n,this.flushed=r,this.selectNode=n[_r],this.allowDefault=n.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{var a=t.state.doc.resolve(e.pos);o=a.parent,i=a.depth?a.before():0}this.mightDrag=null;var c=r?null:n.target,p=c?t.docView.nearestDesc(c,!0):null;this.target=p?p.dom:null,(o.type.spec.draggable&&!1!==o.type.spec.selectable||t.state.selection instanceof oe&&i==t.state.selection.from)&&(this.mightDrag={node:o,pos:i,addAttr:this.target&&!this.target.draggable,setUneditable:this.target&&Se.gecko&&!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((function(){return s.target.setAttribute("contentEditable","false")}),20),this.view.domObserver.start()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),xr(t,"pointer")};function Rr(t,e){return!!t.composing||!!(Se.safari&&Math.abs(e.timeStamp-t.compositionEndedAt)<500)&&(t.compositionEndedAt=-2e8,!0)}zr.prototype.done=function(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.view.mouseDown=null},zr.prototype.up=function(t){if(this.done(),this.view.dom.contains(3==t.target.nodeType?t.target.parentNode:t.target)){var e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Mr(t))),this.allowDefault||!e?xr(this.view,"pointer"):Tr(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():this.flushed||Se.safari&&this.mightDrag&&!this.mightDrag.node.isAtom||Se.chrome&&!(this.view.state.selection instanceof ne)&&(e.pos==this.view.state.selection.from||e.pos==this.view.state.selection.to)?(Nr(this.view,Zt.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):xr(this.view,"pointer")}},zr.prototype.move=function(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0),xr(this.view,"pointer")},wr.touchdown=function(t){Ar(t),xr(t,"pointer")},wr.contextmenu=function(t){return Ar(t)};var Ir=Se.android?5e3:-1;function Pr(t,e){clearTimeout(t.composingTimeout),e>-1&&(t.composingTimeout=setTimeout((function(){return $r(t)}),e))}function jr(t){for(t.composing=!1;t.compositionNodes.length>0;)t.compositionNodes.pop().markParentsDirty()}function $r(t,e){if(t.domObserver.forceFlush(),jr(t),e||t.docView.dirty){var n=_n(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}kr.compositionstart=kr.compositionupdate=function(t){if(!t.composing){t.domObserver.flush();var e=t.state,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((function(t){return!1===t.type.spec.inclusive}))))t.markCursor=t.state.storedMarks||n.marks(),$r(t,!0),t.markCursor=null;else if($r(t),Se.gecko&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(var r=t.root.getSelection(),o=r.focusNode,i=r.focusOffset;o&&1==o.nodeType&&0!=i;){var s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(3==s.nodeType){r.collapse(s,s.nodeValue.length);break}o=s,i=-1}t.composing=!0}Pr(t,Ir)},kr.compositionend=function(t,e){t.composing&&(t.composing=!1,t.compositionEndedAt=e.timeStamp,Pr(t,20))};var Br=Se.ie&&Se.ie_version<15||Se.ios&&Se.webkit_version<604;function Vr(t,e,n,r){var o=ar(t,e,n,t.shiftKey,t.state.selection.$from);if(t.someProp("handlePaste",(function(e){return e(t,r,o||f.empty)})))return!0;if(!o)return!1;var i=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(o),s=i?t.state.tr.replaceSelectionWith(i,t.shiftKey):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}wr.copy=kr.cut=function(t,e){var n=t.state.selection,r="cut"==e.type;if(!n.empty){var o=Br?null:e.clipboardData,i=sr(t,n.content()),s=i.dom,a=i.text;o?(e.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",a)):function(t,e){if(t.dom.parentNode){var n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";var r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((function(){n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}}(t,s),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))}},kr.paste=function(t,e){var n=Br?null:e.clipboardData;n&&Vr(t,n.getData("text/plain"),n.getData("text/html"),e)?e.preventDefault():function(t,e){if(t.dom.parentNode){var n=t.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus(),setTimeout((function(){t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Vr(t,r.value,null,e):Vr(t,r.textContent,r.innerHTML,e)}),50)}}(t,e)};var Fr=function(t,e){this.slice=t,this.move=e},Lr=Se.mac?"altKey":"ctrlKey";for(var Jr in wr.dragstart=function(t,e){var n=t.mouseDown;if(n&&n.done(),e.dataTransfer){var r=t.state.selection,o=r.empty?null:t.posAtCoords(Mr(e));if(o&&o.pos>=r.from&&o.pos<=(r instanceof oe?r.to-1:r.to));else if(n&&n.mightDrag)t.dispatch(t.state.tr.setSelection(oe.create(t.state.doc,n.mightDrag.pos)));else if(e.target&&1==e.target.nodeType){var i=t.docView.nearestDesc(e.target,!0);if(!i||!i.node.type.spec.draggable||i==t.docView)return;t.dispatch(t.state.tr.setSelection(oe.create(t.state.doc,i.posBefore)))}var s=t.state.selection.content(),a=sr(t,s),c=a.dom,p=a.text;e.dataTransfer.clearData(),e.dataTransfer.setData(Br?"Text":"text/html",c.innerHTML),Br||e.dataTransfer.setData("text/plain",p),t.dragging=new Fr(s,!e[Lr])}},wr.dragend=function(t){var e=t.dragging;window.setTimeout((function(){t.dragging==e&&(t.dragging=null)}),50)},kr.dragover=kr.dragenter=function(t,e){return e.preventDefault()},kr.drop=function(t,e){var n=t.dragging;if(t.dragging=null,e.dataTransfer){var r=t.posAtCoords(Mr(e));if(r){var o=t.state.doc.resolve(r.pos);if(o){var i=n&&n.slice||ar(t,e.dataTransfer.getData(Br?"Text":"text/plain"),Br?null:e.dataTransfer.getData("text/html"),!1,o),s=n&&!e[Lr];if(t.someProp("handleDrop",(function(n){return n(t,e,i||f.empty,s)})))e.preventDefault();else if(i){e.preventDefault();var a=i?function(t,e,n){var r=t.resolve(e);if(!n.content.size)return e;for(var o=n.content,i=0;i<n.openStart;i++)o=o.firstChild.content;for(var s=1;s<=(0==n.openStart&&n.size?2:1);s++)for(var a=r.depth;a>=0;a--){var c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,p=r.index(a)+(c>0?1:0),l=r.node(a),h=!1;if(1==s)h=l.canReplace(p,p,o);else{var f=l.contentMatchAt(p).findWrapping(o.firstChild.type);h=f&&l.canReplaceWith(p,p,f[0])}if(h)return 0==c?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}(t.state.doc,o.pos,i):o.pos;null==a&&(a=o.pos);var c=t.state.tr;s&&c.deleteSelection();var p=c.mapping.map(a),l=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,h=c.doc;if(l?c.replaceRangeWith(p,p,i.content.firstChild):c.replaceRange(p,p,i),!c.doc.eq(h)){var d=c.doc.resolve(p);if(l&&oe.isSelectable(i.content.firstChild)&&d.nodeAfter&&d.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new oe(d));else{var u=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((function(t,e,n,r){return u=r})),c.setSelection(Fn(t,d,c.doc.resolve(u)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}}}}}},wr.focus=function(t){t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((function(){t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.root.getSelection())&&Rn(t)}),20))},wr.blur=function(t){t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),t.domObserver.currentSelection.set({}),t.focused=!1)},wr.beforeinput=function(t,e){if(Se.chrome&&Se.android&&"deleteContentBackward"==e.inputType){var n=t.domChangeCount;setTimeout((function(){if(t.domChangeCount==n&&(t.dom.blur(),t.focus(),!t.someProp("handleKeyDown",(function(e){return e(t,Be(8,"Backspace"))})))){var e=t.state.selection.$cursor;e&&e.pos>0&&t.dispatch(t.state.tr.delete(e.pos-1,e.pos).scrollIntoView())}}),50)}},kr)wr[Jr]=kr[Jr];function Wr(t,e){if(t==e)return!0;for(var n in t)if(t[n]!==e[n])return!1;for(var r in e)if(!(r in t))return!1;return!0}var qr=function(t,e){this.spec=e||Yr,this.side=this.spec.side||0,this.toDOM=t};qr.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,this.side<0?-1:1),i=o.pos;return o.deleted?null:new Ur(i-n,i-n,this)},qr.prototype.valid=function(){return!0},qr.prototype.eq=function(t){return this==t||t instanceof qr&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Wr(this.spec,t.spec))};var Kr=function(t,e){this.spec=e||Yr,this.attrs=t};Kr.prototype.map=function(t,e,n,r){var o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ur(o,i,this)},Kr.prototype.valid=function(t,e){return e.from<e.to},Kr.prototype.eq=function(t){return this==t||t instanceof Kr&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)},Kr.is=function(t){return t.type instanceof Kr};var Hr=function(t,e){this.spec=e||Yr,this.attrs=t};Hr.prototype.map=function(t,e,n,r){var o=t.mapResult(e.from+r,1);if(o.deleted)return null;var i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ur(o.pos-n,i.pos-n,this)},Hr.prototype.valid=function(t,e){var n=t.content.findIndex(e.from),r=n.index,o=n.offset;return o==e.from&&o+t.child(r).nodeSize==e.to},Hr.prototype.eq=function(t){return this==t||t instanceof Hr&&Wr(this.attrs,t.attrs)&&Wr(this.spec,t.spec)};var Ur=function(t,e,n){this.from=t,this.to=e,this.type=n},Gr={spec:{configurable:!0},inline:{configurable:!0}};Ur.prototype.copy=function(t,e){return new Ur(t,e,this.type)},Ur.prototype.eq=function(t,e){return void 0===e&&(e=0),this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to},Ur.prototype.map=function(t,e,n){return this.type.map(t,this,e,n)},Ur.widget=function(t,e,n){return new Ur(t,t,new qr(e,n))},Ur.inline=function(t,e,n,r){return new Ur(t,e,new Kr(n,r))},Ur.node=function(t,e,n,r){return new Ur(t,e,new Hr(n,r))},Gr.spec.get=function(){return this.type.spec},Gr.inline.get=function(){return this.type instanceof Kr},Object.defineProperties(Ur.prototype,Gr);var Xr=[],Yr={},Qr=function(t,e){this.local=t&&t.length?t:Xr,this.children=e&&e.length?e:Xr};Qr.create=function(t,e){return e.length?oo(e,t,0,Yr):Zr},Qr.prototype.find=function(t,e,n){var r=[];return this.findInner(null==t?0:t,null==e?1e9:e,r,0,n),r},Qr.prototype.findInner=function(t,e,n,r,o){for(var i=0;i<this.local.length;i++){var s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(var a=0;a<this.children.length;a+=3)if(this.children[a]<e&&this.children[a+1]>t){var c=this.children[a]+1;this.children[a+2].findInner(t-c,e-c,n,r+c,o)}},Qr.prototype.map=function(t,e,n){return this==Zr||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Yr)},Qr.prototype.mapInner=function(t,e,n,r,o){for(var i,s=0;s<this.local.length;s++){var a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){for(var a=t.slice(),c=function(t,e,n,r){for(var s=0;s<a.length;s+=3){var c=a[s+1],p=void 0;-1==c||t>c+i||(e>=a[s]+i?a[s+1]=-1:n>=o&&(p=r-n-(e-t))&&(a[s]+=p,a[s+1]+=p))}},p=0;p<n.maps.length;p++)n.maps[p].forEach(c);for(var l=!1,h=0;h<a.length;h+=3)if(-1==a[h+1]){var f=n.map(t[h]+i),d=f-o;if(d<0||d>=r.content.size){l=!0;continue}var u=n.map(t[h+1]+i,-1)-o,m=r.content.findIndex(d),v=m.index,g=m.offset,y=r.maybeChild(v);if(y&&g==d&&g+y.nodeSize==u){var b=a[h+2].mapInner(n,y,f+1,t[h]+i+1,s);b!=Zr?(a[h]=d,a[h+1]=u,a[h+2]=b):(a[h+1]=-2,l=!0)}else l=!0}if(l){var w=oo(function(t,e,n,r,o,i,s){function a(t,e){for(var i=0;i<t.local.length;i++){var c=t.local[i].map(r,o,e);c?n.push(c):s.onRemove&&s.onRemove(t.local[i].spec)}for(var p=0;p<t.children.length;p+=3)a(t.children[p+2],t.children[p]+e+1)}for(var c=0;c<t.length;c+=3)-1==t[c+1]&&a(t[c+2],e[c]+i+1);return n}(a,t,e||[],n,o,i,s),r,0,s);e=w.local;for(var k=0;k<a.length;k+=3)a[k+1]<0&&(a.splice(k,3),k-=3);for(var x=0,S=0;x<w.children.length;x+=3){for(var O=w.children[x];S<a.length&&a[S]<O;)S+=3;a.splice(S,0,w.children[x],w.children[x+1],w.children[x+2])}}return new Qr(e&&e.sort(io),a)}(this.children,i,t,e,n,r,o):i?new Qr(i.sort(io)):Zr},Qr.prototype.add=function(t,e){return e.length?this==Zr?Qr.create(t,e):this.addInner(t,e,0):this},Qr.prototype.addInner=function(t,e,n){var r,o=this,i=0;t.forEach((function(t,s){var a,c=s+n;if(a=no(e,t,c)){for(r||(r=o.children.slice());i<r.length&&r[i]<s;)i+=3;r[i]==s?r[i+2]=r[i+2].addInner(t,a,c+1):r.splice(i,0,s,s+t.nodeSize,oo(a,t,c+1,Yr)),i+=3}}));for(var s=eo(i?ro(e):e,-n),a=0;a<s.length;a++)s[a].type.valid(t,s[a])||s.splice(a--,1);return new Qr(s.length?this.local.concat(s).sort(io):this.local,r||this.children)},Qr.prototype.remove=function(t){return 0==t.length||this==Zr?this:this.removeInner(t,0)},Qr.prototype.removeInner=function(t,e){for(var n=this.children,r=this.local,o=0;o<n.length;o+=3){for(var i=void 0,s=n[o]+e,a=n[o+1]+e,c=0,p=void 0;c<t.length;c++)(p=t[c])&&p.from>s&&p.to<a&&(t[c]=null,(i||(i=[])).push(p));if(i){n==this.children&&(n=this.children.slice());var l=n[o+2].removeInner(i,s+1);l!=Zr?n[o+2]=l:(n.splice(o,3),o-=3)}}if(r.length)for(var h=0,f=void 0;h<t.length;h++)if(f=t[h])for(var d=0;d<r.length;d++)r[d].eq(f,e)&&(r==this.local&&(r=this.local.slice()),r.splice(d--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Qr(r,n):Zr},Qr.prototype.forChild=function(t,e){if(this==Zr)return this;if(e.isLeaf)return Qr.empty;for(var n,r,o=0;o<this.children.length;o+=3)if(this.children[o]>=t){this.children[o]==t&&(n=this.children[o+2]);break}for(var i=t+1,s=i+e.content.size,a=0;a<this.local.length;a++){var c=this.local[a];if(c.from<s&&c.to>i&&c.type instanceof Kr){var p=Math.max(i,c.from)-i,l=Math.min(s,c.to)-i;p<l&&(r||(r=[])).push(c.copy(p,l))}}if(r){var h=new Qr(r.sort(io));return n?new to([h,n]):h}return n||Zr},Qr.prototype.eq=function(t){if(this==t)return!0;if(!(t instanceof Qr)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(var e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(var n=0;n<this.children.length;n+=3)if(this.children[n]!=t.children[n]||this.children[n+1]!=t.children[n+1]||!this.children[n+2].eq(t.children[n+2]))return!1;return!0},Qr.prototype.locals=function(t){return so(this.localsInner(t))},Qr.prototype.localsInner=function(t){if(this==Zr)return Xr;if(t.inlineContent||!this.local.some(Kr.is))return this.local;for(var e=[],n=0;n<this.local.length;n++)this.local[n].type instanceof Kr||e.push(this.local[n]);return e};var Zr=new Qr;Qr.empty=Zr,Qr.removeOverlap=so;var to=function(t){this.members=t};function eo(t,e){if(!e||!t.length)return t;for(var n=[],r=0;r<t.length;r++){var o=t[r];n.push(new Ur(o.from+e,o.to+e,o.type))}return n}function no(t,e,n){if(e.isLeaf)return null;for(var r=n+e.nodeSize,o=null,i=0,s=void 0;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function ro(t){for(var e=[],n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function oo(t,e,n,r){var o=[],i=!1;e.forEach((function(e,s){var a=no(t,e,s+n);if(a){i=!0;var c=oo(a,e,n+s+1,r);c!=Zr&&o.push(s,s+e.nodeSize,c)}}));for(var s=eo(i?ro(t):t,-n).sort(io),a=0;a<s.length;a++)s[a].type.valid(e,s[a])||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1));return s.length||o.length?new Qr(s,o):Zr}function io(t,e){return t.from-e.from||t.to-e.to}function so(t){for(var e=t,n=0;n<e.length-1;n++){var r=e[n];if(r.from!=r.to)for(var o=n+1;o<e.length;o++){var i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),ao(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),ao(e,o+1,i.copy(r.to,i.to)))}}return e}function ao(t,e,n){for(;e<t.length&&io(n,t[e])>0;)e++;t.splice(e,0,n)}function co(t){var e=[];return t.someProp("decorations",(function(n){var r=n(t.state);r&&r!=Zr&&e.push(r)})),t.cursorWrapper&&e.push(Qr.create(t.state.doc,[t.cursorWrapper.deco])),to.from(e)}to.prototype.forChild=function(t,e){if(e.isLeaf)return Qr.empty;for(var n=[],r=0;r<this.members.length;r++){var o=this.members[r].forChild(t,e);o!=Zr&&(o instanceof to?n=n.concat(o.members):n.push(o))}return to.from(n)},to.prototype.eq=function(t){if(!(t instanceof to)||t.members.length!=this.members.length)return!1;for(var e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0},to.prototype.locals=function(t){for(var e,n=!0,r=0;r<this.members.length;r++){var o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(var i=0;i<o.length;i++)e.push(o[i])}else e=o}return e?so(n?e:e.sort(io)):Xr},to.from=function(t){switch(t.length){case 0:return Zr;case 1:return t[0];default:return new to(t)}};var po=function(t,e){this._props=e,this.state=e.state,this.dispatch=this.dispatch.bind(this),this._root=null,this.focused=!1,this.trackWrites=null,this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):t.apply?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=uo(this),this.markCursor=null,this.cursorWrapper=null,fo(this),this.nodeViews=mo(this),this.docView=vn(this.state.doc,ho(this),co(this),this.dom,this),this.lastSelectedViewDesc=null,this.dragging=null,function(t){t.shiftKey=!1,t.mouseDown=null,t.lastKeyCode=null,t.lastKeyCodeTime=0,t.lastClick={time:0,x:0,y:0,type:""},t.lastSelectionOrigin=null,t.lastSelectionTime=0,t.lastIOSEnter=0,t.lastIOSEnterFallbackTimeout=null,t.composing=!1,t.composingTimeout=null,t.compositionNodes=[],t.compositionEndedAt=-2e8,t.domObserver=new yr(t,(function(e,n,r,o){return rr(t,e,n,r,o)})),t.domObserver.start(),t.domChangeCount=0,t.eventHandlers=Object.create(null);var e=function(e){var n=wr[e];t.dom.addEventListener(e,t.eventHandlers[e]=function(e){!function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}(t,e)||Or(t,e)||!t.editable&&e.type in kr||n(t,e)})};for(var n in wr)e(n);Se.safari&&t.dom.addEventListener("input",(function(){return null})),Sr(t)}(this),this.pluginViews=[],this.updatePluginViews()},lo={props:{configurable:!0},root:{configurable:!0}};function ho(t){var e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(function(n){if("function"==typeof n&&(n=n(t.state)),n)for(var r in n)"class"==r?e.class+=" "+n[r]:e[r]||"contenteditable"==r||"nodeName"==r||(e[r]=String(n[r]))})),[Ur.node(0,t.state.doc.content.size,e)]}function fo(t){if(t.markCursor){var e=document.createElement("img");e.setAttribute("mark-placeholder","true"),t.cursorWrapper={dom:e,deco:Ur.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function uo(t){return!t.someProp("editable",(function(e){return!1===e(t.state)}))}function mo(t){var e={};return t.someProp("nodeViews",(function(t){for(var n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])})),e}function vo(t,e){return"string"==typeof t?e.nodes[t]:t}function go(t,e){return"string"==typeof t?e.marks[t]:t}function yo(t,e){const n=go(e,t.schema),{from:r,to:o,empty:i}=t.selection;let s=[];i?s=t.selection.$head.marks():t.doc.nodesBetween(r,o,(t=>{s=[...s,...t.marks]}));const a=s.find((t=>t.type.name===n.name));return a?{...a.attrs}:{}}function bo(t,e){const n=Object.keys(e);return!n.length||!!n.filter((n=>e[n]===t[n])).length}function wo(t,e,n={}){const{from:r,to:o,empty:i}=t.selection,s=e?vo(e,t.schema):null;let a=[];if(t.doc.nodesBetween(r,o,((t,e)=>{if(!t.isText){const n=Math.max(r,e),i=Math.min(o,e+t.nodeSize);a=[...a,{node:t,from:n,to:i}]}})),i)return!!a.filter((t=>!s||s.name===t.node.type.name)).find((t=>bo(t.node.attrs,n)));const c=o-r;return a.filter((t=>!s||s.name===t.node.type.name)).filter((t=>bo(t.node.attrs,n))).reduce(((t,e)=>t+(e.to-e.from)),0)>=c}function ko(t,e,n={}){const{from:r,to:o,empty:i}=t.selection,s=e?go(e,t.schema):null;if(i)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!s||s.name===t.type.name)).find((t=>bo(t.attrs,n)));let a=0,c=[];if(t.doc.nodesBetween(r,o,((t,e)=>{if(t.isText){const n=Math.max(r,e),i=Math.min(o,e+t.nodeSize);a+=i-n,c=[...c,...t.marks.map((t=>({mark:t,from:n,to:i})))]}})),0===a)return!1;return c.filter((t=>!s||s.name===t.mark.type.name)).filter((t=>bo(t.mark.attrs,n))).reduce(((t,e)=>t+(e.to-e.from)),0)>=a}function xo(t,e,n={}){if(!e)return wo(t,null,n)||ko(t,null,n);const r=function(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}(e,t.schema);return"node"===r?wo(t,e,n):"mark"===r&&ko(t,e,n)}function So(t){const e=`<div>${t}</div>`;return(new window.DOMParser).parseFromString(e,"text/html").body}function Oo(t,e,n){if(n={slice:!0,parseOptions:{},...n},t&&"object"==typeof t)try{return e.nodeFromJSON(t)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Oo("",e,n)}if("string"==typeof t){if(t.trim().startsWith("<")&&t.trim().endsWith(">")||!n.slice){const r=ot.fromSchema(e);return n.slice?r.parseSlice(So(t),n.parseOptions).content:r.parse(So(t),n.parseOptions)}return t}return Oo("",e,n)}function Mo(t,e,n={}){return Oo(t,e,{slice:!1,parseOptions:n})}function Co(t,e){const n=mt.fromSchema(e).serializeFragment(t.content),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function No(t){var e;const n=null===(e=t.type.createAndFill())||void 0===e?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}lo.props.get=function(){if(this._props.state!=this.state){var t=this._props;for(var e in this._props={},t)this._props[e]=t[e];this._props.state=this.state}return this._props},po.prototype.update=function(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Sr(this),this._props=t,this.updateStateInner(t.state,!0)},po.prototype.setProps=function(t){var e={};for(var n in this._props)e[n]=this._props[n];for(var r in e.state=this.state,t)e[r]=t[r];this.update(e)},po.prototype.updateState=function(t){this.updateStateInner(t,this.state.plugins!=t.plugins)},po.prototype.updateStateInner=function(t,e){var n=this,r=this.state,o=!1,i=!1;if(t.storedMarks&&this.composing&&(jr(this),i=!0),this.state=t,e){var s=mo(this);(function(t,e){var n=0,r=0;for(var o in t){if(t[o]!=e[o])return!0;n++}for(var i in e)r++;return n!=r})(s,this.nodeViews)&&(this.nodeViews=s,o=!0),Sr(this)}this.editable=uo(this),fo(this);var a=co(this),c=ho(this),p=e?"reset":t.scrollToSelection>r.scrollToSelection?"to selection":"preserve",l=o||!this.docView.matchesNode(t.doc,c,a);!l&&t.selection.eq(r.selection)||(i=!0);var h,f,d,u,m,v,g,y,b,w,k,x="preserve"==p&&i&&null==this.dom.style.overflowAnchor&&function(t){for(var e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top),i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){var a=t.root.elementFromPoint(i,s);if(a!=t.dom&&t.dom.contains(a)){var c=a.getBoundingClientRect();if(c.top>=o-20){e=a,n=c.top;break}}}return{refDOM:e,refTop:n,stack:We(t.dom)}}(this);if(i){this.domObserver.stop();var S=l&&(Se.ie||Se.chrome)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&(u=r.selection,m=t.selection,v=Math.min(u.$anchor.sharedDepth(u.head),m.$anchor.sharedDepth(m.head)),u.$anchor.start(v)!=m.$anchor.start(v));if(l){var O=Se.chrome?this.trackWrites=this.root.getSelection().focusNode:null;!o&&this.docView.update(t.doc,c,a,this)||(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=vn(t.doc,c,a,this.dom,this)),O&&!this.trackWrites&&(S=!0)}S||!(this.mouseDown&&this.domObserver.currentSelection.eq(this.root.getSelection())&&(h=this,f=h.docView.domFromPos(h.state.selection.anchor,0),d=h.root.getSelection(),ze(f.node,f.offset,d.anchorNode,d.anchorOffset)))?Rn(this,S):(Bn(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}if(this.updatePluginViews(r),"reset"==p)this.dom.scrollTop=0;else if("to selection"==p){var M=this.root.getSelection().focusNode;this.someProp("handleScrollToSelection",(function(t){return t(n)}))||(t.selection instanceof oe?Je(this,this.docView.domAfterPos(t.selection.from).getBoundingClientRect(),M):Je(this,this.coordsAtPos(t.selection.head,1),M))}else x&&(y=(g=x).refDOM,b=g.refTop,w=g.stack,k=y?y.getBoundingClientRect().top:0,qe(w,0==k?0:k-b))},po.prototype.destroyPluginViews=function(){for(var t;t=this.pluginViews.pop();)t.destroy&&t.destroy()},po.prototype.updatePluginViews=function(t){if(t&&t.plugins==this.state.plugins)for(var e=0;e<this.pluginViews.length;e++){var n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.destroyPluginViews();for(var r=0;r<this.state.plugins.length;r++){var o=this.state.plugins[r];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}},po.prototype.someProp=function(t,e){var n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;var o=this.state.plugins;if(o)for(var i=0;i<o.length;i++){var s=o[i].props[t];if(null!=s&&(n=e?e(s):s))return n}},po.prototype.hasFocus=function(){return this.root.activeElement==this.dom},po.prototype.focus=function(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Ke)return t.focus(Ke);var e=We(t);t.focus(null==Ke?{get preventScroll(){return Ke={preventScroll:!0},!0}}:void 0),Ke||(Ke=!1,qe(e,0))}(this.dom),Rn(this),this.domObserver.start()},lo.root.get=function(){var t=this._root;if(null==t)for(var e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=function(){return document.getSelection()}),this._root=e;return t||document},po.prototype.posAtCoords=function(t){return Xe(this,t)},po.prototype.coordsAtPos=function(t,e){return void 0===e&&(e=1),Ze(this,t,e)},po.prototype.domAtPos=function(t,e){return void 0===e&&(e=0),this.docView.domFromPos(t,e)},po.prototype.nodeDOM=function(t){var e=this.docView.descAt(t);return e?e.nodeDOM:null},po.prototype.posAtDOM=function(t,e,n){void 0===n&&(n=-1);var r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r},po.prototype.endOfTextblock=function(t,e){return cn(this,e||this.state,t)},po.prototype.destroy=function(){this.docView&&(!function(t){for(var e in t.domObserver.stop(),t.eventHandlers)t.dom.removeEventListener(e,t.eventHandlers[e]);clearTimeout(t.composingTimeout),clearTimeout(t.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],co(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)},po.prototype.dispatchEvent=function(t){return function(t,e){Or(t,e)||!wr[e.type]||!t.editable&&e.type in kr||wr[e.type](t,e)}(this,t)},po.prototype.dispatch=function(t){var e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))},Object.defineProperties(po.prototype,lo);class To{constructor(t,e){this.editor=t,this.commands=e}createCommands(){const{commands:t,editor:e}=this,{state:n,view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(i);return o.getMeta("preventDispatch")||r.dispatch(o),n}])))}createChain(t,e=!0){const{commands:n,editor:r}=this,{state:o,view:i}=r,s=[],a=!!t,c=t||o.tr,p={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const r=this.buildProps(c,e),o=n(...t)(r);return s.push(o),p}]))),run:()=>(a||!e||c.getMeta("preventDispatch")||i.dispatch(c),()=>s.every((t=>!0===t)))};return p}createCan(t){const{commands:e,editor:n}=this,{state:r}=n,o=void 0,i=t||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...s,dispatch:o})]))),chain:()=>this.createChain(i,o)}}buildProps(t,e=!0){const{editor:n,commands:r}=this,{state:o,view:i}=n;o.storedMarks&&t.setStoredMarks(o.storedMarks);const s={tr:t,editor:n,view:i,state:this.chainableState(t,o),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map((([t,e])=>[t,(...t)=>e(...t)(s)])))}};return s}chainableState(t,e){let{selection:n}=t,{doc:r}=t,{storedMarks:o}=t;return{...e,schema:e.schema,plugins:e.plugins,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return n},get doc(){return r},get tr(){return n=t.selection,r=t.doc,o=t.storedMarks,t}}}}for(var Eo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},Do={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},Ao="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),_o="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),zo="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),Ro="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Io="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Po=Ao&&(Ro||+Ao[1]<57)||zo&&Ro,jo=0;jo<10;jo++)Eo[48+jo]=Eo[96+jo]=String(jo);for(jo=1;jo<=24;jo++)Eo[jo+111]="F"+jo;for(jo=65;jo<=90;jo++)Eo[jo]=String.fromCharCode(jo+32),Do[jo]=String.fromCharCode(jo);for(var $o in Eo)Do.hasOwnProperty($o)||(Do[$o]=Eo[$o]);var Bo="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);function Vo(t){var e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(var a=0;a<i.length-1;a++){var c=i[a];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))e=!0;else if(/^(c|ctrl|control)$/i.test(c))n=!0;else if(/^s(hift)?$/i.test(c))r=!0;else{if(!/^mod$/i.test(c))throw new Error("Unrecognized modifier name: "+c);Bo?o=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Fo(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}function Lo(t){var e=function(t){var e=Object.create(null);for(var n in t)e[Vo(n)]=t[n];return e}(t);return function(t,n){var r,o=function(t){var e=!(Po&&(t.ctrlKey||t.altKey||t.metaKey)||(_o||Io)&&t.shiftKey&&t.key&&1==t.key.length)&&t.key||(t.shiftKey?Do:Eo)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=1==o.length&&" "!=o,s=e[Fo(o,n,!i)];if(s&&s(t.state,t.dispatch,t))return!0;if(i&&(n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=Eo[n.keyCode])&&r!=o){var a=e[Fo(r,n,!0)];if(a&&a(t.state,t.dispatch,t))return!0}else if(i&&n.shiftKey){var c=e[Fo(o,n,!0)];if(c&&c(t.state,t.dispatch,t))return!0}return!1}}var Jo=function(t,e){var n;this.match=t,this.handler="string"==typeof e?(n=e,function(t,e,r,o){var i=n;if(e[1]){var s=e[0].lastIndexOf(e[1]);i+=e[0].slice(s+e[1].length);var a=(r+=s)-o;a>0&&(i=e[0].slice(s-a,s)+i,r=o)}return t.tr.insertText(i,r,o)}):e};var Wo;function qo(t,e,n,r,o,i){if(t.composing)return!1;var s=t.state,a=s.doc.resolve(e);if(a.parent.type.spec.code)return!1;for(var c=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,null,"")+r,p=0;p<o.length;p++){var l=o[p].match.exec(c),h=l&&o[p].handler(s,l,e-(l[0].length-r.length),n);if(h)return t.dispatch(h.setMeta(i,{transform:h,from:e,to:n,text:r})),!0}return!1}function Ko(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function Ho(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ko(t),o=[...n,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0};return t.forEach((t=>{const n={options:t.options};if(!t.config.addGlobalAttributes)return;t.config.addGlobalAttributes.bind(n)().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...i,...r}})}))}))}))})),o.forEach((t=>{const n={options:t.options};if(!t.config.addAttributes)return;const r=t.config.addAttributes.bind(n)();Object.entries(r).forEach((([n,r])=>{e.push({type:t.config.name,name:n,attribute:{...i,...r}})}))})),e}function Uo(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{n[t]?n[t]="class"===t?[n[t],e].join(" "):"style"===t?[n[t],e].join("; "):e:n[t]=e})),n}),{})}function Go(t,e){return e.filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>Uo(t,e)),{})}function Xo(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===r)return!1;const o=e.filter((t=>t.attribute.rendered)).reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n)||{}:{[e.name]:(o=n.getAttribute(e.name),"string"!=typeof o?o:o.match(/^\d*(\.\d+)?$/)?Number(o):"true"===o||"false"!==o&&o)};var o;return{...t,...Object.fromEntries(Object.entries(r).filter((([,t])=>null!=t)))}}),{});return{...r,...o}}}}function Yo(t,e,...n){return"function"==typeof t?e?t.bind(e)(...n):t(...n):t}function Qo(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function Zo(t){var e;const n=Ho(t),{nodeExtensions:r,markExtensions:o}=Ko(t),i=null===(e=r.find((t=>t.config.topNode)))||void 0===e?void 0:e.config.name,s=[],a=[];t.forEach((t=>{"function"==typeof t.config.extendNodeSchema&&s.push(t.config.extendNodeSchema),"function"==typeof t.config.extendMarkSchema&&a.push(t.config.extendMarkSchema)}));const c=Object.fromEntries(r.map((t=>{var e;const r=n.filter((e=>e.type===t.config.name)),o={options:t.options},i=Qo({...s.reduce(((e,n)=>({...e,...Yo(n,o,t)})),{}),content:Yo(t.config.content,o),marks:Yo(t.config.marks,o),group:Yo(t.config.group,o),inline:Yo(t.config.inline,o),atom:Yo(t.config.atom,o),selectable:Yo(t.config.selectable,o),draggable:Yo(t.config.draggable,o),code:Yo(t.config.code,o),defining:Yo(t.config.defining,o),isolating:Yo(t.config.isolating,o),attrs:Object.fromEntries(r.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))});return t.config.parseHTML&&(i.parseDOM=null===(e=t.config.parseHTML.bind(o)())||void 0===e?void 0:e.map((t=>Xo(t,r)))),t.config.renderHTML&&(i.toDOM=e=>{var n;return null===(n=t.config.renderHTML)||void 0===n?void 0:n.bind(o)({node:e,HTMLAttributes:Go(e,r)})}),[t.config.name,i]}))),p=Object.fromEntries(o.map((t=>{var e;const r=n.filter((e=>e.type===t.config.name)),o={options:t.options},i=Qo({...a.reduce(((e,n)=>({...e,...Yo(n,o,t)})),{}),inclusive:Yo(t.config.inclusive,o),excludes:Yo(t.config.excludes,o),group:Yo(t.config.group,o),spanning:Yo(t.config.spanning,o),attrs:Object.fromEntries(r.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))});return t.config.parseHTML&&(i.parseDOM=null===(e=t.config.parseHTML.bind(o)())||void 0===e?void 0:e.map((t=>Xo(t,r)))),t.config.renderHTML&&(i.toDOM=e=>{var n;return null===(n=t.config.renderHTML)||void 0===n?void 0:n.bind(o)({mark:e,HTMLAttributes:Go(e,r)})}),[t.config.name,i]})));return new nt({topNode:i,nodes:c,marks:p})}function ti(t,e){return e.nodes[t]?e.nodes[t]:e.marks[t]?e.marks[t]:null}class ei{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=this.sort(t),this.schema=Zo(this.extensions),this.extensions.forEach((t=>{var e;const n={options:t.options,editor:this.editor,type:ti(t.config.name,this.schema)};if("mark"===t.type){(null===(e=Yo(t.config.keepOnSplit,n))||void 0===e||e)&&this.splittableMarks.push(t.config.name)}"function"==typeof t.config.onCreate&&this.editor.on("create",t.config.onCreate.bind(n)),"function"==typeof t.config.onUpdate&&this.editor.on("update",t.config.onUpdate.bind(n)),"function"==typeof t.config.onSelectionUpdate&&this.editor.on("selectionUpdate",t.config.onSelectionUpdate.bind(n)),"function"==typeof t.config.onViewUpdate&&this.editor.on("viewUpdate",t.config.onViewUpdate.bind(n)),"function"==typeof t.config.onTransaction&&this.editor.on("transaction",t.config.onTransaction.bind(n)),"function"==typeof t.config.onFocus&&this.editor.on("focus",t.config.onFocus.bind(n)),"function"==typeof t.config.onBlur&&this.editor.on("blur",t.config.onBlur.bind(n)),"function"==typeof t.config.onDestroy&&this.editor.on("destroy",t.config.onDestroy.bind(n))}))}sort(t){const e=100;return t.sort(((t,n)=>(t.config.priority||e)>(n.config.priority||e)?-1:(t.config.priority||e)<(n.config.priority||e)?1:0))}get commands(){return this.extensions.reduce(((t,e)=>{const n={options:e.options,editor:this.editor,type:ti(e.config.name,this.schema)};return e.config.addCommands?{...t,...e.config.addCommands.bind(n)()}:t}),{})}get plugins(){return[...this.extensions].reverse().map((t=>{const e={options:t.options,editor:this.editor,type:ti(t.config.name,this.schema)},n=[];if(t.config.addKeyboardShortcuts){const o=(r=t.config.addKeyboardShortcuts.bind(e)(),new be({props:{handleKeyDown:Lo(r)}}));n.push(o)}var r,o,i,s;if(this.editor.options.enableInputRules&&t.config.addInputRules){const r=t.config.addInputRules.bind(e)(),a=r.length?[(o={rules:r},i=o.rules,s=new be({state:{init:function(){return null},apply:function(t,e){var n=t.getMeta(this);return n||(t.selectionSet||t.docChanged?null:e)}},props:{handleTextInput:function(t,e,n,r){return qo(t,e,n,r,i,s)},handleDOMEvents:{compositionend:function(t){setTimeout((function(){var e=t.state.selection.$cursor;e&&qo(t,e.pos,e.pos,"",i,s)}))}}},isInputRules:!0}),s)]:[];n.push(...a)}if(this.editor.options.enablePasteRules&&t.config.addPasteRules){const r=t.config.addPasteRules.bind(e)();n.push(...r)}if(t.config.addProseMirrorPlugins){const r=t.config.addProseMirrorPlugins.bind(e)();n.push(...r)}return n})).flat()}get attributes(){return Ho(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Ko(this.extensions);return Object.fromEntries(e.filter((t=>!!t.config.addNodeView)).map((e=>{var n;const r=this.attributes.filter((t=>t.type===e.config.name)),o={options:e.options,editor:t,type:vo(e.config.name,this.schema)},i=null===(n=e.config.addNodeView)||void 0===n?void 0:n.call(o);return[e.config.name,(n,o,s,a)=>{const c=Go(n,r);return i({editor:t,node:n,getPos:s,decorations:a,HTMLAttributes:c,extension:e})}]})))}get textSerializers(){const{editor:t}=this,{nodeExtensions:e}=Ko(this.extensions);return Object.fromEntries(e.filter((t=>!!t.config.renderText)).map((e=>{const n={options:e.options,editor:t,type:vo(e.config.name,this.schema)};return[e.config.name,t=>{var r;return null===(r=e.config.renderText)||void 0===r?void 0:r.call(n,t)}]})))}}
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */
16
- function ni(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}function ri(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function oi(t,e){const n={...t};return ri(t)&&ri(e)&&Object.keys(e).forEach((r=>{ri(e[r])?r in t?n[r]=oi(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})})),n}class ii{constructor(t){this.type="extension",this.config={name:"extension",priority:100,defaultOptions:{}},Wo.set(this,(t=>(this.options=oi(this.config.defaultOptions,t),this))),this.config={...this.config,...t},this.options=this.config.defaultOptions}static create(t){return new ii(t)}configure(t={}){var e;return ni(e=ii.create(this.config),Wo).call(e,t)}extend(t){return new ii({...this.config,...t})}}Wo=new WeakMap;const si=ii.create({name:"editable",addProseMirrorPlugins(){return[new be({key:new xe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{from:e,to:n}=t.state.selection;return((t,e,n,r,o)=>{let i="",s=!0;return t.state.doc.nodesBetween(e,n,((a,c)=>{var p;const l=t.extensionManager.textSerializers[a.type.name];l?(i+=l({node:a}),s=!r):a.isText?(i+=null===(p=null==a?void 0:a.text)||void 0===p?void 0:p.slice(Math.max(e,c)-c,n-c),s=!r):a.isLeaf&&o?(i+=o,s=!r):!s&&a.isBlock&&(i+=r,s=!0)}),0),i})(t,e,n,"\n")}}})]}});var ai=Object.freeze({__proto__:null,blur:()=>({view:t})=>(t.dom.blur(),!0)});var ci=Object.freeze({__proto__:null,clearContent:(t=!1)=>({commands:e})=>e.setContent("",t)});var pi=Object.freeze({__proto__:null,clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:o}=r;return o.forEach((r=>{t.doc.nodesBetween(r.$from.pos,r.$to.pos,((r,o)=>{if(!r.type.isText){const i=e.doc.resolve(e.mapping.map(o+1)),s=e.doc.resolve(e.mapping.map(o+r.nodeSize-1)),a=i.blockRange(s);if(a){const o=Rt(a);r.type.isTextblock&&n&&e.setNodeMarkup(a.start,t.doc.type.contentMatch.defaultType),(o||0===o)&&n&&e.lift(a,o)}}}))})),!0}});var li=Object.freeze({__proto__:null,command:t=>e=>t(e)});function hi(t,e){return!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0)}function fi(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("backward",t):r.parentOffset>0))return!1;var o=mi(r);if(!o){var i=r.blockRange(),s=i&&Rt(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}var a=o.nodeBefore;if(!a.type.spec.isolating&&Ci(t,o,e))return!0;if(0==r.parent.content.size&&(di(a,"end")||oe.isSelectable(a))){if(e){var c=t.tr.deleteRange(r.before(),r.after());c.setSelection(di(a,"end")?Zt.findFrom(c.doc.resolve(c.mapping.map(o.pos,-1)),-1):oe.create(c.doc,o.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}return!(!a.isAtom||o.depth!=r.depth-1)&&(e&&e(t.tr.delete(o.pos-a.nodeSize,o.pos).scrollIntoView()),!0)}function di(t,e){for(;t;t="start"==e?t.firstChild:t.lastChild)if(t.isTextblock)return!0;return!1}function ui(t,e,n){var r=t.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;i=mi(o)}var s=i&&i.nodeBefore;return!(!s||!oe.isSelectable(s))&&(e&&e(t.tr.setSelection(oe.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)}function mi(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function vi(t,e,n){var r=t.selection.$cursor;if(!r||(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size))return!1;var o=yi(r);if(!o)return!1;var i=o.nodeAfter;if(Ci(t,o,e))return!0;if(0==r.parent.content.size&&(di(i,"start")||oe.isSelectable(i))){if(e){var s=t.tr.deleteRange(r.before(),r.after());s.setSelection(di(i,"start")?Zt.findFrom(s.doc.resolve(s.mapping.map(o.pos)),1):oe.create(s.doc,s.mapping.map(o.pos))),e(s.scrollIntoView())}return!0}return!(!i.isAtom||o.depth!=r.depth-1)&&(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0)}function gi(t,e,n){var r=t.selection,o=r.$head,i=o;if(!r.empty)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;i=yi(o)}var s=i&&i.nodeAfter;return!(!s||!oe.isSelectable(s))&&(e&&e(t.tr.setSelection(oe.create(t.doc,i.pos)).scrollIntoView()),!0)}function yi(t){if(!t.parent.type.spec.isolating)for(var e=t.depth-1;e>=0;e--){var n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function bi(t,e){var n=t.selection,r=n.$from,o=n.$to,i=r.blockRange(o),s=i&&Rt(i);return null!=s&&(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)}function wi(t,e){var n=t.selection,r=n.$head,o=n.$anchor;return!(!r.parent.type.spec.code||!r.sameParent(o))&&(e&&e(t.tr.insertText("\n").scrollIntoView()),!0)}function ki(t){for(var e=0;e<t.edgeCount;e++){var n=t.edge(e).type;if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function xi(t,e){var n=t.selection,r=n.$head,o=n.$anchor;if(!r.parent.type.spec.code||!r.sameParent(o))return!1;var i=r.node(-1),s=r.indexAfter(-1),a=ki(i.contentMatchAt(s));if(!i.canReplaceWith(s,s,a))return!1;if(e){var c=r.after(),p=t.tr.replaceWith(c,c,a.createAndFill());p.setSelection(Zt.near(p.doc.resolve(c),1)),e(p.scrollIntoView())}return!0}function Si(t,e){var n=t.selection,r=n.$from,o=n.$to;if(n instanceof se||r.parent.inlineContent||o.parent.inlineContent)return!1;var i=ki(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){var s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=t.tr.insert(s,i.createAndFill());a.setSelection(ne.create(a.doc,s+1)),e(a.scrollIntoView())}return!0}function Oi(t,e){var n=t.selection.$cursor;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){var r=n.before();if(jt(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}var o=n.blockRange(),i=o&&Rt(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)}function Mi(t,e){return e&&e(t.tr.setSelection(new se(t.doc))),!0}function Ci(t,e,n){var r,o,s=e.nodeBefore,a=e.nodeAfter;if(s.type.spec.isolating||a.type.spec.isolating)return!1;if(function(t,e,n){var r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!o.isTextblock&&!$t(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;var c=e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(o=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&o.matchType(r[0]||a.type).validEnd){if(n){for(var p=e.pos+a.nodeSize,l=i.empty,h=r.length-1;h>=0;h--)l=i.from(r[h].create(null,l));l=i.from(s.copy(l));var d=t.tr.step(new At(e.pos-1,p,e.pos,p,new f(l,1,0),r.length,!0)),u=p+2*r.length;$t(d.doc,u)&&d.join(u),n(d.scrollIntoView())}return!0}var m=Zt.findFrom(e,1),v=m&&m.$from.blockRange(m.$to),g=v&&Rt(v);if(null!=g&&g>=e.depth)return n&&n(t.tr.lift(v,g).scrollIntoView()),!0;if(c&&a.isTextblock&&di(s,"end")){for(var y=s,b=[];b.push(y),!y.isTextblock;)y=y.lastChild;if(y.canReplace(y.childCount,y.childCount,a.content)){if(n){for(var w=i.empty,k=b.length-1;k>=0;k--)w=i.from(b[k].copy(w));n(t.tr.step(new At(e.pos-b.length,e.pos+a.nodeSize,e.pos+1,e.pos+a.nodeSize-1,new f(w,b.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ni(t,e){return function(n,r){var o=n.selection,i=o.$from,s=o.$to,a=i.blockRange(s),c=a&&It(a,t,e);return!!c&&(r&&r(n.tr.wrap(a,c).scrollIntoView()),!0)}}function Ti(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return function(e,n,r){for(var o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}Ti(hi,fi,ui),Ti(hi,vi,gi);Ti(wi,Si,Oi,(function(t,e){var n=t.selection,r=n.$from,o=n.$to;if(t.selection instanceof oe&&t.selection.node.isBlock)return!(!r.parentOffset||!jt(t.doc,r.pos))&&(e&&e(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(e){var s=o.parentOffset==o.parent.content.size,a=t.tr;(t.selection instanceof ne||t.selection instanceof se)&&a.deleteSelection();var c=0==r.depth?null:ki(r.node(-1).contentMatchAt(r.indexAfter(-1))),p=s&&c?[{type:c}]:null,l=jt(a.doc,a.mapping.map(r.pos),1,p);p||l||!jt(a.doc,a.mapping.map(r.pos),1,c&&[{type:c}])||(p=[{type:c}],l=!0),l&&(a.split(a.mapping.map(r.pos),1,p),s||r.parentOffset||r.parent.type==c||!r.node(-1).canReplace(r.index(-1),r.indexAfter(-1),i.from([c.create(),r.parent]))||a.setNodeMarkup(a.mapping.map(r.before()),c)),e(a.scrollIntoView())}return!0})),"undefined"!=typeof navigator?/Mac/.test(navigator.platform):"undefined"!=typeof os&&os.platform();var Ei=Object.freeze({__proto__:null,createParagraphNear:()=>({state:t,dispatch:e})=>Si(t,e)});var Di=Object.freeze({__proto__:null,deleteRange:t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0}});var Ai=Object.freeze({__proto__:null,deleteSelection:()=>({state:t,dispatch:e})=>hi(t,e)});var _i=Object.freeze({__proto__:null,enter:()=>({commands:t})=>t.keyboardShortcut("Enter")});var zi=Object.freeze({__proto__:null,exitCode:()=>({state:t,dispatch:e})=>xi(t,e)});function Ri(t,e){if(!t||!e)return;const n=t.parent.childAfter(t.parentOffset);if(!n.node)return;const r=n.node.marks.find((t=>t.type===e));if(!r)return;let o=t.index(),i=t.start()+n.offset,s=o+1,a=i+n.node.nodeSize;for(;o>0&&r.isInSet(t.parent.child(o-1).marks);)o-=1,i-=t.parent.child(o).nodeSize;for(;s<t.parent.childCount&&r.isInSet(t.parent.child(s).marks);)a+=t.parent.child(s).nodeSize,s+=1;return{from:i,to:a}}var Ii=Object.freeze({__proto__:null,extendMarkRange:t=>({tr:e,state:n,dispatch:r})=>{const o=go(t,n.schema),{doc:i,selection:s}=e,{$from:a,empty:c}=s;if(c&&r){const t=Ri(a,o);if(t){const n=ne.create(i,t.from,t.to);e.setSelection(n)}}return!0}});var Pi=Object.freeze({__proto__:null,first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1}});function ji(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function $i(t){return t&&"object"==typeof t&&!Array.isArray(t)&&!function(t){var e;return"class"===(null===(e=t.constructor)||void 0===e?void 0:e.toString().substring(0,5))}(t)}function Bi(t){return $i(t)&&t instanceof ne}var Vi=Object.freeze({__proto__:null,focus:(t=null)=>({editor:e,view:n,tr:r,dispatch:o})=>{if(n.hasFocus()&&null===t||!1===t)return!0;if(o&&null===t&&!Bi(e.state.selection))return n.focus(),!0;const{from:i,to:s}=function(t,e=null){if(!e)return null;if("start"===e||!0===e)return{from:0,to:0};if("end"===e){const{size:e}=t.doc.content;return{from:e,to:e}}return{from:e,to:e}}(e.state,t)||e.state.selection,{doc:a,storedMarks:c}=r,p=ji(i,0,a.content.size),l=ji(s,0,a.content.size),h=ne.create(a,p,l),f=e.state.selection.eq(h);return o&&(r.setSelection(h),f&&c&&r.setStoredMarks(c),n.focus()),!0}});function Fi(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof Dt||o instanceof At))return;const i=t.mapping.maps[r];let s=0;i.forEach(((t,e,n,r)=>{0===s&&(s=r)})),t.setSelection(Zt.near(t.doc.resolve(s),n))}var Li=Object.freeze({__proto__:null,insertContent:t=>({tr:e,dispatch:n,editor:r})=>{if(n){const n=Oo(t,r.schema);if("string"==typeof n)return e.insertText(n),!0;e.selection.empty||e.deleteSelection(),e.insert(e.selection.anchor,n),Fi(e,e.steps.length-1,-1)}return!0}});var Ji=Object.freeze({__proto__:null,insertHTML:t=>({tr:e,state:n,dispatch:r})=>{console.warn("[tiptap warn]: insertHTML() is deprecated. please use insertContent() instead.");const{selection:o}=e,i=So(t),s=ot.fromSchema(n.schema).parseSlice(i);return r&&(e.insert(o.anchor,s.content),Fi(e,e.steps.length-1,-1)),!0}});var Wi=Object.freeze({__proto__:null,insertNode:(t,e={})=>({tr:n,state:r,dispatch:o})=>{console.warn("[tiptap warn]: insertNode() is deprecated. please use insertContent() instead.");const{selection:i}=n,s=vo(t,r.schema);if(!s)return!1;const a=s.create(e);return o&&n.insert(i.anchor,a),!0}});var qi=Object.freeze({__proto__:null,insertText:t=>({tr:e,dispatch:n})=>(console.warn("[tiptap warn]: insertText() is deprecated. please use insertContent() instead."),n&&e.insertText(t),!0)});var Ki=Object.freeze({__proto__:null,joinBackward:()=>({state:t,dispatch:e})=>fi(t,e)});var Hi=Object.freeze({__proto__:null,joinForward:()=>({state:t,dispatch:e})=>vi(t,e)});const Ui="undefined"!=typeof navigator&&/Mac/.test(navigator.platform);var Gi=Object.freeze({__proto__:null,keyboardShortcut:t=>({editor:e,view:n,tr:r,dispatch:o})=>{const i=function(t){const e=t.split(/-(?!$)/);let n,r,o,i,s=e[e.length-1];"Space"===s&&(s=" ");for(let t=0;t<e.length-1;t+=1){const s=e[t];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);Ui?i=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),o&&(s=`Shift-${s}`),s}(t).split(/-(?!$)/),s=i.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,a)))}));return null==c||c.steps.forEach((t=>{const e=t.map(r.mapping);e&&o&&r.maybeStep(e)})),!0}});var Xi=Object.freeze({__proto__:null,lift:(t,e={})=>({state:n,dispatch:r})=>!!wo(n,vo(t,n.schema),e)&&bi(n,r)});var Yi=Object.freeze({__proto__:null,liftEmptyBlock:()=>({state:t,dispatch:e})=>Oi(t,e)});function Qi(t,e){return function(n,r){var o=n.selection,s=o.$from,a=o.$to,c=s.blockRange(a),p=!1,l=c;if(!c)return!1;if(c.depth>=2&&s.node(c.depth-1).type.compatibleContent(t)&&0==c.startIndex){if(0==s.index(c.depth-1))return!1;var h=n.doc.resolve(c.start-2);l=new D(h,h,c.depth),c.endIndex<c.parent.childCount&&(c=new D(s,n.doc.resolve(a.end(c.depth)),c.depth)),p=!0}var d=It(l,t,e,c);return!!d&&(r&&r(function(t,e,n,r,o){for(var s=i.empty,a=n.length-1;a>=0;a--)s=i.from(n[a].type.create(n[a].attrs,s));t.step(new At(e.start-(r?2:0),e.end,e.start,e.end,new f(s,0,0),n.length,!0));for(var c=0,p=0;p<n.length;p++)n[p].type==o&&(c=p+1);for(var l=n.length-c,h=e.start+n.length-(r?2:0),d=e.parent,u=e.startIndex,m=e.endIndex,v=!0;u<m;u++,v=!1)!v&&jt(t.doc,h,l)&&(t.split(h,l),h+=2*l),h+=d.child(u).nodeSize;return t}(n.tr,c,d,p,t).scrollIntoView()),!0)}}function Zi(t){return function(e,n){var r=e.selection,o=r.$from,s=r.$to,a=o.blockRange(s,(function(e){return e.childCount&&e.firstChild.type==t}));return!!a&&(!n||(o.node(a.depth-1).type==t?function(t,e,n,r){var o=t.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(o.step(new At(s-1,a,s,a,new f(i.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new D(o.doc.resolve(r.$from.pos),o.doc.resolve(a),r.depth));return e(o.lift(r,Rt(r)).scrollIntoView()),!0}(e,n,t,a):function(t,e,n){for(var r=t.tr,o=n.parent,s=n.end,a=n.endIndex-1,c=n.startIndex;a>c;a--)s-=o.child(a).nodeSize,r.delete(s-1,s+1);var p=r.doc.resolve(n.start),l=p.nodeAfter,h=0==n.startIndex,d=n.endIndex==o.childCount,u=p.node(-1),m=p.index(-1);if(!u.canReplace(m+(h?0:1),m+1,l.content.append(d?i.empty:i.from(o))))return!1;var v=p.pos,g=v+l.nodeSize;return r.step(new At(v-(h?1:0),g+(d?1:0),v+1,g-1,new f((h?i.empty:i.from(o.copy(i.empty))).append(d?i.empty:i.from(o.copy(i.empty))),h?0:1,d?0:1),h?0:1)),e(r.scrollIntoView()),!0}(e,n,a)))}}var ts=Object.freeze({__proto__:null,liftListItem:t=>({state:e,dispatch:n})=>Zi(vo(t,e.schema))(e,n)});var es=Object.freeze({__proto__:null,newlineInCode:()=>({state:t,dispatch:e})=>wi(t,e)});var ns=Object.freeze({__proto__:null,replace:(t,e={})=>({state:n,commands:r})=>{const{from:o,to:i}=n.selection,s={from:o,to:i};return r.replaceRange(s,t,e)}});var rs=Object.freeze({__proto__:null,replaceRange:(t,e,n={})=>({tr:r,state:o,dispatch:i})=>{const s=vo(e,o.schema),{from:a,to:c}=t,p=r.doc.resolve(a),l=p.index();return!!p.parent.canReplaceWith(l,l,s)&&(i&&r.replaceWith(a,c,s.create(n)),!0)}});var is=Object.freeze({__proto__:null,resetNodeAttributes:(t,e)=>({tr:n,state:r,dispatch:o})=>{const i=vo(t,r.schema),{selection:s}=n,{ranges:a}=s;return a.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{t.type===i&&o&&n.setNodeMarkup(r,void 0,function(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,r)=>(n.includes(r)||(e[r]=t[r]),e)),{})}(t.attrs,e))}))})),!0}});var ss=Object.freeze({__proto__:null,scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0)});var as=Object.freeze({__proto__:null,selectAll:()=>({state:t,dispatch:e})=>Mi(t,e)});var cs=Object.freeze({__proto__:null,selectNodeBackward:()=>({state:t,dispatch:e})=>ui(t,e)});var ps=Object.freeze({__proto__:null,selectNodeForward:()=>({state:t,dispatch:e})=>gi(t,e)});var ls=Object.freeze({__proto__:null,selectParentNode:()=>({state:t,dispatch:e})=>function(t,e){var n,r=t.selection,o=r.$from,i=r.to,s=o.sharedDepth(i);return 0!=s&&(n=o.before(s),e&&e(t.tr.setSelection(oe.create(t.doc,n))),!0)}(t,e)});var hs=Object.freeze({__proto__:null,setContent:(t,e=!1,n={})=>({tr:r,editor:o,dispatch:i})=>{const{doc:s}=r,a=Mo(t,o.schema,n),c=ne.create(s,0,s.content.size);return i&&r.setSelection(c).replaceSelectionWith(a,!1).setMeta("preventUpdate",!e),!0}});var fs=Object.freeze({__proto__:null,setMark:(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:a}=i,c=go(t,r.schema),p={...yo(r,c),...e};return o&&(s?n.addStoredMark(c.create(p)):a.forEach((t=>{n.addMark(t.$from.pos,t.$to.pos,c.create(p))}))),!0}});var ds=Object.freeze({__proto__:null,setNode:(t,e={})=>({state:n,dispatch:r})=>{const o=vo(t,n.schema);return(i=o,s=e,function(t,e){var n=t.selection,r=n.from,o=n.to,a=!1;return t.doc.nodesBetween(r,o,(function(e,n){if(a)return!1;if(e.isTextblock&&!e.hasMarkup(i,s))if(e.type==i)a=!0;else{var r=t.doc.resolve(n),o=r.index();a=r.parent.canReplaceWith(o,o+1,i)}})),!!a&&(e&&e(t.tr.setBlockType(r,o,i,s).scrollIntoView()),!0)})(n,r);var i,s}});var us=Object.freeze({__proto__:null,sinkListItem:t=>({state:e,dispatch:n})=>{const r=vo(t,e.schema);return(o=r,function(t,e){var n=t.selection,r=n.$from,s=n.$to,a=r.blockRange(s,(function(t){return t.childCount&&t.firstChild.type==o}));if(!a)return!1;var c=a.startIndex;if(0==c)return!1;var p=a.parent,l=p.child(c-1);if(l.type!=o)return!1;if(e){var h=l.lastChild&&l.lastChild.type==p.type,d=i.from(h?o.create():null),u=new f(i.from(o.create(null,i.from(p.type.create(null,d)))),h?3:1,0),m=a.start,v=a.end;e(t.tr.step(new At(m-(h?3:1),v,m,v,u,1,!0)).scrollIntoView())}return!0})(e,n);var o}});function ms(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));return!!r&&r.attribute.keepOnSplit})))}function vs(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}var gs=Object.freeze({__proto__:null,splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{const{selection:s,doc:a}=e,{$from:c,$to:p}=s,l=ms(o.extensionManager.attributes,c.node().type.name,c.node().attrs);if(s instanceof oe&&s.node.isBlock)return!(!c.parentOffset||!jt(a,c.pos))&&(r&&(t&&vs(n,o.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;if(r){const r=p.parentOffset===p.parent.content.size;s instanceof ne&&e.deleteSelection();const a=0===c.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(c.node(-1).contentMatchAt(c.indexAfter(-1)));let h=r&&a?[{type:a,attrs:l}]:void 0,f=jt(e.doc,e.mapping.map(c.pos),1,h);h||f||!jt(e.doc,e.mapping.map(c.pos),1,a?[{type:a}]:void 0)||(f=!0,h=a?[{type:a,attrs:l}]:void 0),f&&(e.split(e.mapping.map(c.pos),1,h),r||c.parentOffset||c.parent.type===a||!c.node(-1).canReplace(c.index(-1),c.indexAfter(-1),i.from(null==a?void 0:a.create()))||e.setNodeMarkup(e.mapping.map(c.before()),a||void 0)),t&&vs(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return!0}});var ys=Object.freeze({__proto__:null,splitListItem:t=>({tr:e,state:n,dispatch:r,editor:o})=>{var s;const a=vo(t,n.schema),{$from:c,$to:p}=n.selection,l=n.selection.node;if(l&&l.isBlock||c.depth<2||!c.sameParent(p))return!1;const h=c.node(-1);if(h.type!==a)return!1;const d=o.extensionManager.attributes;if(0===c.parent.content.size&&c.node(-1).childCount===c.indexAfter(-1)){if(2===c.depth||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let t=i.empty;const n=c.index(-1)>0;for(let e=c.depth-(n?1:2);e>=c.depth-3;e-=1)t=i.from(c.node(e).copy(t));const r=ms(d,c.node().type.name,c.node().attrs),o=(null===(s=a.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(r))||void 0;t=t.append(i.from(a.createAndFill(null,o)||void 0)),e.replace(c.before(n?void 0:-1),c.after(-3),new f(t,n?3:2,2)).setSelection(ne.near(e.doc.resolve(c.pos+(n?3:2)))).scrollIntoView()}return!0}const u=p.pos===c.end()?h.contentMatchAt(0).defaultType:null,m=ms(d,h.type.name,h.attrs),v=ms(d,c.node().type.name,c.node().attrs);e.delete(c.pos,p.pos);const g=u?[{type:a,attrs:m},{type:u,attrs:v}]:[{type:a,attrs:m}];return!!jt(e.doc,c.pos,2)&&(r&&e.split(c.pos,2,g).scrollIntoView(),!0)}});function bs(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function ws(t,e){const{nodeExtensions:n}=Ko(e),r=n.find((e=>e.config.name===t));if(!r)return!1;const o=Yo(r.config.group,{options:r.options});return"string"==typeof o&&o.split(" ").includes("list")}var ks=Object.freeze({__proto__:null,toggleList:(t,e)=>({editor:n,tr:r,state:o,dispatch:i,chain:s,commands:a,can:c})=>{const{extensions:p}=n.options,l=vo(t,o.schema),h=vo(e,o.schema),{selection:f}=o,{$from:d,$to:u}=f,m=d.blockRange(u);if(!m)return!1;const v=(g=t=>ws(t.type.name,p),t=>bs(t.$from,g))(f);var g;if(m.depth>=1&&v&&m.depth-v.depth<=1){if(v.node.type===l)return a.liftListItem(h);if(ws(v.node.type.name,p)&&l.validContent(v.node.content)&&i)return r.setNodeMarkup(v.pos,l),!0}return c().wrapInList(l)?a.wrapInList(l):s().clearNodes().wrapInList(l).run()}});var xs=Object.freeze({__proto__:null,toggleMark:(t,e={})=>({state:n,commands:r})=>{const o=go(t,n.schema);return ko(n,o,e)?r.unsetMark(o):r.setMark(o,e)}});var Ss=Object.freeze({__proto__:null,toggleNode:(t,e,n={})=>({state:r,commands:o})=>{const i=vo(t,r.schema),s=vo(e,r.schema);return wo(r,i,n)?o.setNode(s):o.setNode(i,n)}});var Os=Object.freeze({__proto__:null,toggleWrap:(t,e={})=>({state:n,dispatch:r})=>{const o=vo(t,n.schema);return wo(n,o,e)?bi(n,r):Ni(o,e)(n,r)}});var Ms=Object.freeze({__proto__:null,undoInputRule:()=>({state:t,dispatch:e})=>function(t,e){for(var n=t.plugins,r=0;r<n.length;r++){var o=n[r],i=void 0;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){for(var s=t.tr,a=i.transform,c=a.steps.length-1;c>=0;c--)s.step(a.steps[c].invert(a.docs[c]));if(i.text){var p=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,p))}else s.delete(i.from,i.to);e(s)}return!0}}return!1}(t,e)});var Cs=Object.freeze({__proto__:null,unsetAllMarks:()=>({tr:t,state:e,dispatch:n})=>{const{selection:r}=t,{empty:o,ranges:i}=r;return o||n&&Object.entries(e.schema.marks).forEach((([,e])=>{i.forEach((n=>{t.removeMark(n.$from.pos,n.$to.pos,e)}))})),!0}});var Ns=Object.freeze({__proto__:null,unsetMark:t=>({tr:e,state:n,dispatch:r})=>{const{selection:o}=e,i=go(t,n.schema),{$from:s,empty:a,ranges:c}=o;if(r){if(a){let{from:t,to:n}=o;const r=Ri(s,i);r&&(t=r.from,n=r.to),e.removeMark(t,n,i)}else c.forEach((t=>{e.removeMark(t.$from.pos,t.$to.pos,i)}));e.removeStoredMark(i)}return!0}});var Ts=Object.freeze({__proto__:null,updateNodeAttributes:(t,e={})=>({tr:n,state:r,dispatch:o})=>{const i=vo(t,r.schema),{selection:s}=n,{ranges:a}=s;return a.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{t.type===i&&o&&n.setNodeMarkup(r,void 0,{...t.attrs,...e})}))})),!0}});var Es=Object.freeze({__proto__:null,wrapIn:(t,e={})=>({state:n,dispatch:r})=>{const o=vo(t,n.schema);return!wo(n,o,e)&&Ni(o,e)(n,r)}});var Ds=Object.freeze({__proto__:null,wrapInList:(t,e={})=>({state:n,dispatch:r})=>Qi(vo(t,n.schema),e)(n,r)});const As=ii.create({name:"commands",addCommands:()=>({...ai,...ci,...pi,...li,...Ei,...Di,...Ai,..._i,...zi,...Ii,...Pi,...Vi,...Li,...Ji,...Wi,...qi,...Ki,...Hi,...Gi,...Xi,...Yi,...ts,...es,...ns,...rs,...is,...ss,...as,...cs,...ps,...ls,...hs,...fs,...ds,...us,...gs,...ys,...ks,...xs,...Ss,...Os,...Ms,...Cs,...Ns,...Ts,...Es,...Ds})}),_s=ii.create({name:"editable",addProseMirrorPlugins(){return[new be({key:new xe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),zs=ii.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new be({key:new xe("focusEvents"),props:{attributes:{tabindex:"0"},handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Rs=ii.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.joinForward(),()=>t.selectNodeForward()]));return{Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:()=>t(),"Mod-Backspace":()=>t(),Delete:()=>e(),"Mod-Delete":()=>e()}}});var Is=Object.freeze({__proto__:null,ClipboardTextSerializer:si,Commands:As,Editable:_s,FocusEvents:zs,Keymap:Rs});var Ps,js;class $s{constructor(t){this.type="node",this.config={name:"node",priority:100,defaultOptions:{}},Ps.set(this,(t=>(this.options=oi(this.config.defaultOptions,t),this))),this.config={...this.config,...t},this.options=this.config.defaultOptions}static create(t){return new $s(t)}configure(t={}){var e;return ni(e=$s.create(this.config),Ps).call(e,t)}extend(t){return new $s({...this.config,...t})}}Ps=new WeakMap;class Bs{constructor(t){this.type="mark",this.config={name:"mark",priority:100,defaultOptions:{}},js.set(this,(t=>(this.options=oi(this.config.defaultOptions,t),this))),this.config={...this.config,...t},this.options=this.config.defaultOptions}static create(t){return new Bs(t)}configure(t={}){var e;return ni(e=Bs.create(this.config),js).call(e,t)}extend(t){return new Bs({...this.config,...t})}}js=new WeakMap;t.Editor=class extends class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}{constructor(t={}){super(),this.isFocused=!1,this.options={element:document.createElement("div"),content:"",injectCSS:!0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},enableInputRules:!0,enablePasteRules:!0,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onViewUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onResize:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("viewUpdate",this.options.onViewUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout((()=>{this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),window.ResizeObserver&&(this.resizeObserver=new ResizeObserver((()=>{this.emit("resize",{editor:this})})),this.resizeObserver.observe(this.view.dom))}),0)}get commands(){return this.commandManager.createCommands()}chain(){return this.commandManager.createChain()}can(){return this.commandManager.createCan()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t){const e=document.createElement("style");return e.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(e),e}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}'))}setOptions(t={}){this.options={...this.options,...t}}setEditable(t){this.setOptions({editable:t}),this.view&&this.state&&!this.isDestroyed&&this.view.updateState(this.state)}get isEditable(){return this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n="function"==typeof e?e(t,this.state.plugins):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});this.view.updateState(r)}unregisterPlugin(t){if(this.isDestroyed)return;const e="string"==typeof t?`${t}$`:t.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((t=>!t.key.startsWith(e)))});this.view.updateState(n)}createExtensionManager(){const t=[...Object.entries(Is).map((([,t])=>t)),...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new ei(t,this)}createCommandManager(){this.commandManager=new To(this,this.extensionManager.commands)}createSchema(){this.schema=this.extensionManager.schema}createView(){this.view=new po(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:me.create({doc:Mo(this.options.content,this.schema,this.options.parseOptions)})});const t=this.state.reconfigure({plugins:[new be({view:()=>({update:()=>this.emit("viewUpdate",{editor:this})})}),...this.extensionManager.plugins]});this.view.updateState(t),this.createNodeViews();this.view.dom.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(t.docChanged&&!this.isEditable)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this});const r=t.getMeta("focus"),o=t.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event}),o&&this.emit("blur",{editor:this,event:o.event}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getNodeAttributes(t){return function(t,e){const n=vo(e,t.schema),{from:r,to:o}=t.selection;let i=[];t.doc.nodesBetween(r,o,(t=>{i=[...i,t]}));const s=i.reverse().find((t=>t.type.name===n.name));return s?{...s.attrs}:{}}(this.state,t)}getMarkAttributes(t){return yo(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,r="string"==typeof t?e:t;return xo(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Co(this.state.doc,this.schema)}get isEmpty(){return No(this.state.doc)}getCharacterCount(){return this.state.doc.content.size-2}destroy(){var t,e;null===(t=this.resizeObserver)||void 0===t||t.unobserve(this.view.dom),this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners(),(e=this.css)&&e.parentNode&&e.parentNode.removeChild(e)}get isDestroyed(){var t;return!(null===(t=this.view)||void 0===t?void 0:t.docView)}},t.Extension=ii,t.Mark=Bs,t.Node=$s,t.NodeView=class{constructor(t,e,n){this.isDragging=!1,this.options={stopEvent:null,update:null},this.component=t,this.options={...this.options,...n},this.editor=e.editor,this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return null}get contentDOM(){return null}onDragStart(t){var e,n;if(!this.dom)return;const{view:r}=this.editor,o=t.target;if(null===(e=this.contentDOM)||void 0===e?void 0:e.contains(o))return;null===(n=t.dataTransfer)||void 0===n||n.setDragImage(this.dom,0,0);const i=oe.create(r.state.doc,this.getPos()),s=r.state.tr.setSelection(i);r.dispatch(s)}stopEvent(t){var e;if(!this.dom)return!1;if("function"==typeof this.options.stopEvent)return this.options.stopEvent(t);const n=t.target;if(!(this.dom.contains(n)&&!(null===(e=this.contentDOM)||void 0===e?void 0:e.contains(n))))return!1;if(["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)return!0;const{isEditable:r}=this.editor,{isDragging:o}=this,i=!!this.node.type.spec.draggable,s=oe.isSelectable(this.node),a="copy"===t.type,c="paste"===t.type,p="cut"===t.type,l="mousedown"===t.type,h=t.type.startsWith("drag")||"drop"===t.type;if(!i&&s&&h&&t.preventDefault(),i&&h&&!o)return t.preventDefault(),!1;if(i&&r&&!o&&l){const t=n.closest("[data-drag-handle]");t&&(this.dom===t||this.dom.contains(t))&&(this.isDragging=!0,document.addEventListener("dragend",(()=>{this.isDragging=!1}),{once:!0}),document.addEventListener("mouseup",(()=>{this.isDragging=!1}),{once:!0}))}return!(o||a||c||p||l&&s)}ignoreMutation(t){if("selection"===t.type)return!!this.node.isLeaf;if(!this.contentDOM)return!0;return!this.contentDOM.contains(t.target)||this.contentDOM===t.target}updateAttributes(t){if(!this.editor.view.editable)return;const{state:e}=this.editor.view,n=this.getPos(),r=e.tr.setNodeMarkup(n,void 0,{...this.node.attrs,...t});this.editor.view.dispatch(r)}},t.callOrReturn=Yo,t.extensions=Is,t.findParentNodeClosestToPos=bs,t.generateHTML=function(t,e){const n=Zo(e);return Co(z.fromJSON(n,t),n)},t.getHTMLFromFragment=Co,t.getMarkAttributes=yo,t.getSchema=Zo,t.isActive=xo,t.isMarkActive=ko,t.isNodeActive=wo,t.isNodeEmpty=No,t.isNodeSelection=function(t){return $i(t)&&t instanceof oe},t.isTextSelection=Bi,t.markInputRule=function(t,e,n){return new Jo(t,((t,r,o,i)=>{const s=n instanceof Function?n(r):n,{tr:a}=t,c=r[r.length-1],p=r[0];let l=i;if(c){const n=p.search(/\S/),r=o+p.indexOf(c),h=r+c.length;if(function(t,e,n){let r=[];return n.doc.nodesBetween(t,e,((t,e)=>{r=[...r,...t.marks.map((n=>({from:e,to:e+t.nodeSize,mark:n})))]})),r}(o,i,t).filter((t=>{const{excluded:n}=t.mark.type;return n.find((t=>t.name===e.name))})).filter((t=>t.to>r)).length)return null;h<i&&a.delete(h,i),r>o&&a.delete(o+n,r),l=o+n+c.length,a.addMark(o+n,l,e.create(s)),a.removeStoredMark(e)}return a}))},t.markPasteRule=function(t,e,n){const r=(o,s)=>{const a=[];return o.forEach((o=>{if(o.isText&&o.text){const{text:r}=o;let i,c=0;for(;null!==(i=t.exec(r));){const t=Math.max(i.length-2,0),r=Math.max(i.length-1,0);if(null==s?void 0:s.type.allowsMarkType(e)){const s=i.index+i[0].indexOf(i[t]),p=s+i[t].length,l=s+i[t].lastIndexOf(i[r]),h=l+i[r].length,f=n instanceof Function?n(i):n;s>0&&a.push(o.cut(c,s)),a.push(o.cut(l,h).mark(e.create(f).addToSet(o.marks))),c=p}}c<r.length&&a.push(o.cut(c))}else a.push(o.copy(r(o.content,o)))})),i.fromArray(a)};return new be({key:new xe("markPasteRule"),props:{transformPasted:t=>new f(r(t.content),t.openStart,t.openEnd)}})},t.mergeAttributes=Uo,t.nodeInputRule=function(t,e,n){return new Jo(t,((t,r,o,i)=>{const s=n instanceof Function?n(r):n,{tr:a}=t;return r[0]&&a.replaceWith(o-1,i,e.create(s)),a}))},Object.defineProperty(t,"__esModule",{value:!0})}));
17
- //# sourceMappingURL=tiptap-core.bundle.umd.min.js.map