@navette-js/panels 0.0.0-stage → 1.0.0-beta.2

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 (207) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -2
  3. package/THIRD-PARTY-NOTICES.md +12 -0
  4. package/dist/FILAMENT-LICENSE.md +21 -0
  5. package/dist/filament/css/filament/filament/app.css +2 -0
  6. package/dist/filament/fonts/INTER-LICENSE.txt +92 -0
  7. package/dist/filament/fonts/filament/filament/inter/index.css +1 -0
  8. package/dist/filament/fonts/filament/filament/inter/inter-cyrillic-ext-wght-normal-SP7Z6XGK.woff2 +0 -0
  9. package/dist/filament/fonts/filament/filament/inter/inter-cyrillic-wght-normal-DR6K5BQD.woff2 +0 -0
  10. package/dist/filament/fonts/filament/filament/inter/inter-greek-ext-wght-normal-A2J6H3EX.woff2 +0 -0
  11. package/dist/filament/fonts/filament/filament/inter/inter-greek-wght-normal-ZABHMKQG.woff2 +0 -0
  12. package/dist/filament/fonts/filament/filament/inter/inter-latin-ext-wght-normal-ZIT2UBIY.woff2 +0 -0
  13. package/dist/filament/fonts/filament/filament/inter/inter-latin-wght-normal-DIHYUR35.woff2 +0 -0
  14. package/dist/filament/fonts/filament/filament/inter/inter-vietnamese-wght-normal-VWEHJHBA.woff2 +0 -0
  15. package/dist/filament/js/filament/actions/actions.js +1 -0
  16. package/dist/filament/js/filament/filament/app.js +1 -0
  17. package/dist/filament/js/filament/filament/echo.js +13 -0
  18. package/dist/filament/js/filament/forms/components/builder.js +1 -0
  19. package/dist/filament/js/filament/forms/components/checkbox-list.js +1 -0
  20. package/dist/filament/js/filament/forms/components/code-editor.js +38 -0
  21. package/dist/filament/js/filament/forms/components/color-picker.js +1 -0
  22. package/dist/filament/js/filament/forms/components/date-time-picker.js +1 -0
  23. package/dist/filament/js/filament/forms/components/file-upload.js +116 -0
  24. package/dist/filament/js/filament/forms/components/js-field.js +1 -0
  25. package/dist/filament/js/filament/forms/components/key-value.js +1 -0
  26. package/dist/filament/js/filament/forms/components/markdown-editor.js +51 -0
  27. package/dist/filament/js/filament/forms/components/repeater.js +1 -0
  28. package/dist/filament/js/filament/forms/components/rich-editor.js +161 -0
  29. package/dist/filament/js/filament/forms/components/select.js +11 -0
  30. package/dist/filament/js/filament/forms/components/slider.js +1 -0
  31. package/dist/filament/js/filament/forms/components/tags-input.js +1 -0
  32. package/dist/filament/js/filament/forms/components/text-input/password-reveal.js +1 -0
  33. package/dist/filament/js/filament/forms/components/textarea.js +1 -0
  34. package/dist/filament/js/filament/forms/components/toggle-buttons.js +1 -0
  35. package/dist/filament/js/filament/notifications/notifications.js +1 -0
  36. package/dist/filament/js/filament/schemas/components/actions.js +1 -0
  37. package/dist/filament/js/filament/schemas/components/js-component.js +1 -0
  38. package/dist/filament/js/filament/schemas/components/tabs.js +1 -0
  39. package/dist/filament/js/filament/schemas/components/wizard.js +1 -0
  40. package/dist/filament/js/filament/schemas/schemas.js +1 -0
  41. package/dist/filament/js/filament/support/support.js +46 -0
  42. package/dist/filament/js/filament/tables/components/columns/checkbox.js +1 -0
  43. package/dist/filament/js/filament/tables/components/columns/select.js +11 -0
  44. package/dist/filament/js/filament/tables/components/columns/text-input.js +1 -0
  45. package/dist/filament/js/filament/tables/components/columns/toggle.js +1 -0
  46. package/dist/filament/js/filament/tables/tables.js +1 -0
  47. package/dist/filament/js/filament/widgets/components/chart.js +31 -0
  48. package/dist/filament/js/filament/widgets/components/js-widget.js +1 -0
  49. package/dist/filament/js/filament/widgets/components/stats-overview/stat/chart.js +20 -0
  50. package/dist/navette/navette/calendar.css +108 -0
  51. package/dist/navette/navette/motion.css +101 -0
  52. package/dist/navette/navette/motion.js +49 -0
  53. package/lib/auth.d.ts +61 -0
  54. package/lib/auth.js +140 -0
  55. package/lib/calendar.d.ts +82 -0
  56. package/lib/calendar.js +107 -0
  57. package/lib/index.d.ts +1624 -0
  58. package/lib/index.js +3532 -0
  59. package/lib/notifications.d.ts +76 -0
  60. package/lib/notifications.js +112 -0
  61. package/lib/topbar.d.ts +90 -0
  62. package/lib/topbar.js +240 -0
  63. package/package.json +58 -4
  64. package/resources/filament/LICENSE.md +21 -0
  65. package/resources/filament/README.md +2 -0
  66. package/resources/filament/packages/actions/resources/css/actions.css +30 -0
  67. package/resources/filament/packages/actions/resources/css/index.css +1 -0
  68. package/resources/filament/packages/forms/dist/index.css +1 -0
  69. package/resources/filament/packages/forms/resources/css/components/builder.css +206 -0
  70. package/resources/filament/packages/forms/resources/css/components/checkbox-list.css +55 -0
  71. package/resources/filament/packages/forms/resources/css/components/code-editor.css +79 -0
  72. package/resources/filament/packages/forms/resources/css/components/color-picker.css +17 -0
  73. package/resources/filament/packages/forms/resources/css/components/date-time-picker.css +127 -0
  74. package/resources/filament/packages/forms/resources/css/components/field.css +88 -0
  75. package/resources/filament/packages/forms/resources/css/components/file-upload/filepond-plugin-media-preview.css +104 -0
  76. package/resources/filament/packages/forms/resources/css/components/file-upload.css +199 -0
  77. package/resources/filament/packages/forms/resources/css/components/key-value.css +57 -0
  78. package/resources/filament/packages/forms/resources/css/components/markdown-editor.css +343 -0
  79. package/resources/filament/packages/forms/resources/css/components/modal-table-select.css +17 -0
  80. package/resources/filament/packages/forms/resources/css/components/radio.css +41 -0
  81. package/resources/filament/packages/forms/resources/css/components/repeater.css +401 -0
  82. package/resources/filament/packages/forms/resources/css/components/rich-editor.css +666 -0
  83. package/resources/filament/packages/forms/resources/css/components/select.css +13 -0
  84. package/resources/filament/packages/forms/resources/css/components/slider.css +54 -0
  85. package/resources/filament/packages/forms/resources/css/components/tags-input.css +33 -0
  86. package/resources/filament/packages/forms/resources/css/components/text-input.css +20 -0
  87. package/resources/filament/packages/forms/resources/css/components/textarea.css +26 -0
  88. package/resources/filament/packages/forms/resources/css/components/toggle-buttons.css +49 -0
  89. package/resources/filament/packages/forms/resources/css/index.css +32 -0
  90. package/resources/filament/packages/infolists/resources/css/components/code.css +21 -0
  91. package/resources/filament/packages/infolists/resources/css/components/color.css +34 -0
  92. package/resources/filament/packages/infolists/resources/css/components/entry.css +68 -0
  93. package/resources/filament/packages/infolists/resources/css/components/icon.css +39 -0
  94. package/resources/filament/packages/infolists/resources/css/components/image.css +161 -0
  95. package/resources/filament/packages/infolists/resources/css/components/key-value.css +24 -0
  96. package/resources/filament/packages/infolists/resources/css/components/repeatable.css +136 -0
  97. package/resources/filament/packages/infolists/resources/css/components/text.css +234 -0
  98. package/resources/filament/packages/infolists/resources/css/index.css +14 -0
  99. package/resources/filament/packages/notifications/resources/css/database-notifications.css +56 -0
  100. package/resources/filament/packages/notifications/resources/css/index.css +3 -0
  101. package/resources/filament/packages/notifications/resources/css/notification.css +109 -0
  102. package/resources/filament/packages/notifications/resources/css/notifications.css +29 -0
  103. package/resources/filament/packages/panels/resources/css/base.css +13 -0
  104. package/resources/filament/packages/panels/resources/css/components/global-search.css +93 -0
  105. package/resources/filament/packages/panels/resources/css/components/header.css +56 -0
  106. package/resources/filament/packages/panels/resources/css/components/layout.css +182 -0
  107. package/resources/filament/packages/panels/resources/css/components/logo.css +11 -0
  108. package/resources/filament/packages/panels/resources/css/components/page.css +60 -0
  109. package/resources/filament/packages/panels/resources/css/components/sidebar.css +311 -0
  110. package/resources/filament/packages/panels/resources/css/components/tenant-menu.css +49 -0
  111. package/resources/filament/packages/panels/resources/css/components/theme-switcher.css +15 -0
  112. package/resources/filament/packages/panels/resources/css/components/topbar.css +89 -0
  113. package/resources/filament/packages/panels/resources/css/components/user-menu.css +46 -0
  114. package/resources/filament/packages/panels/resources/css/index.css +40 -0
  115. package/resources/filament/packages/panels/resources/css/theme.css +2 -0
  116. package/resources/filament/packages/panels/resources/css/utilities.css +3 -0
  117. package/resources/filament/packages/panels/resources/css/widgets/account-widget.css +21 -0
  118. package/resources/filament/packages/panels/resources/css/widgets/filament-info-widget.css +21 -0
  119. package/resources/filament/packages/schemas/resources/css/components/actions.css +29 -0
  120. package/resources/filament/packages/schemas/resources/css/components/flex.css +106 -0
  121. package/resources/filament/packages/schemas/resources/css/components/form.css +7 -0
  122. package/resources/filament/packages/schemas/resources/css/components/fused-group.css +337 -0
  123. package/resources/filament/packages/schemas/resources/css/components/icon.css +11 -0
  124. package/resources/filament/packages/schemas/resources/css/components/image.css +12 -0
  125. package/resources/filament/packages/schemas/resources/css/components/section.css +24 -0
  126. package/resources/filament/packages/schemas/resources/css/components/tabs.css +77 -0
  127. package/resources/filament/packages/schemas/resources/css/components/text.css +77 -0
  128. package/resources/filament/packages/schemas/resources/css/components/unordered-list.css +15 -0
  129. package/resources/filament/packages/schemas/resources/css/components/wizard.css +177 -0
  130. package/resources/filament/packages/schemas/resources/css/index.css +12 -0
  131. package/resources/filament/packages/schemas/resources/css/schema.css +132 -0
  132. package/resources/filament/packages/support/dist/index.css +1 -0
  133. package/resources/filament/packages/support/resources/css/base.css +23 -0
  134. package/resources/filament/packages/support/resources/css/components/avatar.css +15 -0
  135. package/resources/filament/packages/support/resources/css/components/badge.css +90 -0
  136. package/resources/filament/packages/support/resources/css/components/breadcrumbs.css +25 -0
  137. package/resources/filament/packages/support/resources/css/components/button.css +214 -0
  138. package/resources/filament/packages/support/resources/css/components/callout.css +57 -0
  139. package/resources/filament/packages/support/resources/css/components/dropdown/header.css +21 -0
  140. package/resources/filament/packages/support/resources/css/components/dropdown/index.css +79 -0
  141. package/resources/filament/packages/support/resources/css/components/dropdown/list/index.css +7 -0
  142. package/resources/filament/packages/support/resources/css/components/dropdown/list/item.css +74 -0
  143. package/resources/filament/packages/support/resources/css/components/empty-state.css +67 -0
  144. package/resources/filament/packages/support/resources/css/components/fieldset.css +23 -0
  145. package/resources/filament/packages/support/resources/css/components/grid.css +511 -0
  146. package/resources/filament/packages/support/resources/css/components/icon-button.css +124 -0
  147. package/resources/filament/packages/support/resources/css/components/icon.css +31 -0
  148. package/resources/filament/packages/support/resources/css/components/input/checkbox.css +32 -0
  149. package/resources/filament/packages/support/resources/css/components/input/index.css +55 -0
  150. package/resources/filament/packages/support/resources/css/components/input/one-time-code.css +7 -0
  151. package/resources/filament/packages/support/resources/css/components/input/radio.css +11 -0
  152. package/resources/filament/packages/support/resources/css/components/input/select.css +154 -0
  153. package/resources/filament/packages/support/resources/css/components/input/wrapper.css +107 -0
  154. package/resources/filament/packages/support/resources/css/components/link.css +90 -0
  155. package/resources/filament/packages/support/resources/css/components/loading-indicator.css +3 -0
  156. package/resources/filament/packages/support/resources/css/components/loading-section.css +3 -0
  157. package/resources/filament/packages/support/resources/css/components/modal.css +494 -0
  158. package/resources/filament/packages/support/resources/css/components/pagination.css +160 -0
  159. package/resources/filament/packages/support/resources/css/components/section.css +234 -0
  160. package/resources/filament/packages/support/resources/css/components/tabs.css +70 -0
  161. package/resources/filament/packages/support/resources/css/components/toggle.css +60 -0
  162. package/resources/filament/packages/support/resources/css/components/tooltip.css +36 -0
  163. package/resources/filament/packages/support/resources/css/index.css +133 -0
  164. package/resources/filament/packages/support/resources/css/sortable.css +3 -0
  165. package/resources/filament/packages/support/resources/css/utilities.css +897 -0
  166. package/resources/filament/packages/tables/resources/css/actions.css +51 -0
  167. package/resources/filament/packages/tables/resources/css/cell.css +139 -0
  168. package/resources/filament/packages/tables/resources/css/column-manager.css +48 -0
  169. package/resources/filament/packages/tables/resources/css/columns/checkbox.css +54 -0
  170. package/resources/filament/packages/tables/resources/css/columns/color.css +76 -0
  171. package/resources/filament/packages/tables/resources/css/columns/icon.css +81 -0
  172. package/resources/filament/packages/tables/resources/css/columns/image.css +207 -0
  173. package/resources/filament/packages/tables/resources/css/columns/layout/grid.css +49 -0
  174. package/resources/filament/packages/tables/resources/css/columns/layout/panel.css +3 -0
  175. package/resources/filament/packages/tables/resources/css/columns/layout/split.css +35 -0
  176. package/resources/filament/packages/tables/resources/css/columns/layout/stack.css +29 -0
  177. package/resources/filament/packages/tables/resources/css/columns/select.css +36 -0
  178. package/resources/filament/packages/tables/resources/css/columns/summaries/icon-count.css +43 -0
  179. package/resources/filament/packages/tables/resources/css/columns/summaries/range.css +27 -0
  180. package/resources/filament/packages/tables/resources/css/columns/summaries/text.css +29 -0
  181. package/resources/filament/packages/tables/resources/css/columns/summaries/values.css +33 -0
  182. package/resources/filament/packages/tables/resources/css/columns/text-input.css +36 -0
  183. package/resources/filament/packages/tables/resources/css/columns/text.css +319 -0
  184. package/resources/filament/packages/tables/resources/css/columns/toggle.css +54 -0
  185. package/resources/filament/packages/tables/resources/css/container.css +311 -0
  186. package/resources/filament/packages/tables/resources/css/content.css +342 -0
  187. package/resources/filament/packages/tables/resources/css/empty-state.css +31 -0
  188. package/resources/filament/packages/tables/resources/css/group-header.css +54 -0
  189. package/resources/filament/packages/tables/resources/css/header-cell.css +224 -0
  190. package/resources/filament/packages/tables/resources/css/index.css +26 -0
  191. package/resources/filament/packages/tables/resources/css/row.css +47 -0
  192. package/resources/filament/packages/tables/resources/css/table.css +394 -0
  193. package/resources/filament/packages/widgets/resources/css/chart-widget.css +88 -0
  194. package/resources/filament/packages/widgets/resources/css/index.css +3 -0
  195. package/resources/filament/packages/widgets/resources/css/stats-overview-widget.css +67 -0
  196. package/resources/filament/packages/widgets/resources/css/widget.css +3 -0
  197. package/theme.css +17 -0
  198. package/views/components/logo.ejs +9 -0
  199. package/views/components/tenant-menu.ejs +13 -0
  200. package/views/components/user-menu.ejs +82 -0
  201. package/views/layout/base.ejs +129 -0
  202. package/views/layout/index.ejs +41 -0
  203. package/views/layout/simple.ejs +19 -0
  204. package/views/livewire/sidebar.ejs +123 -0
  205. package/views/livewire/topbar.ejs +47 -0
  206. package/views/pages/page.ejs +143 -0
  207. package/views/pages/simple.ejs +32 -0
@@ -0,0 +1,161 @@
1
+ var $g=Object.defineProperty;var Po=(t,e)=>{for(var n in e)$g(t,n,{get:e[n],enumerable:!0})};var Ni={};Po(Ni,{CommandManager:()=>On,DECORATION_MANAGER_PLUGIN_KEY:()=>En,Decoration:()=>ho,DecorationManager:()=>Qf,Editor:()=>Dx,Extendable:()=>Ai,Extension:()=>Z,Fragment:()=>Bx,InlineDecoration:()=>Sh,InputRule:()=>ln,MappablePosition:()=>Ca,Mark:()=>ie,MarkView:()=>vx,Node:()=>W,NodeDecoration:()=>Ch,NodePos:()=>kh,NodeView:()=>Wx,PasteRule:()=>yr,ResizableNodeView:()=>Oi,ResizableNodeview:()=>Vx,Tracker:()=>Ux,WidgetDecoration:()=>vh,attrsEqual:()=>Ma,callOrReturn:()=>G,canInsertNode:()=>Ta,combineTransactionSteps:()=>bi,commands:()=>jf,createAtomBlockMarkdownSpec:()=>oh,createBlockMarkdownSpec:()=>gr,createChainableState:()=>io,createDocument:()=>pi,createElement:()=>Hx,createInlineMarkdownSpec:()=>ih,createMappablePosition:()=>Ff,createNodeFromContent:()=>Rn,createStyleTag:()=>Zf,createWidgetDecoration:()=>Px,decodeHtmlEntities:()=>ax,defaultBlockAt:()=>pr,deleteProps:()=>ia,elementFromString:()=>dr,encodeHtmlEntities:()=>cx,escapeForRegEx:()=>Aa,extensions:()=>Ox,findChildren:()=>mr,findChildrenInRange:()=>ha,findDuplicates:()=>Df,findParentNode:()=>Ht,findParentNodeClosestToPos:()=>dt,flattenExtensions:()=>wi,fromString:()=>Rf,generateHTML:()=>aw,generateJSON:()=>cw,generateText:()=>dw,getAttributes:()=>Ci,getAttributesFromExtensions:()=>ma,getChangedRanges:()=>Ln,getDebugJSON:()=>Pf,getExtensionField:()=>B,getHTMLFromFragment:()=>lo,getMarkAttributes:()=>fa,getMarkRange:()=>yi,getMarkType:()=>xt,getMarksBetween:()=>ao,getNodeAtPosition:()=>wa,getNodeAttributes:()=>Lf,getNodeType:()=>ce,getPreviousBlockSibling:()=>xa,getRenderedAttributes:()=>zt,getSchema:()=>ki,getSchemaByResolvedExtensions:()=>ga,getSchemaTypeByName:()=>An,getSchemaTypeNameByName:()=>so,getSplittedAttributes:()=>no,getStyleProperty:()=>Ea,getText:()=>ba,getTextBetween:()=>ya,getTextContentFromNodes:()=>$f,getTextSerializersFromSchema:()=>Si,getUpdatedPosition:()=>Hf,h:()=>Hx,injectExtensionAttributesToParseRule:()=>sa,inputRulesPlugin:()=>sh,isActive:()=>vi,isAndroid:()=>oo,isAtEndOfNode:()=>ka,isAtStartOfNode:()=>Sa,isEmptyObject:()=>Nf,isExtensionRulesEnabled:()=>la,isFirefox:()=>dx,isFunction:()=>pa,isList:()=>fi,isMacOS:()=>ua,isMarkActive:()=>mi,isNodeActive:()=>ct,isNodeEmpty:()=>In,isNodeSelection:()=>co,isNodeViewSelected:()=>fw,isNumber:()=>eh,isPlainObject:()=>eo,isProseMirrorAddMarkStep:()=>hw,isProseMirrorAddNodeMarkStep:()=>pw,isProseMirrorAttrStep:()=>mw,isProseMirrorCellSelection:()=>gw,isProseMirrorDocAttrStep:()=>yw,isProseMirrorFragment:()=>Bf,isProseMirrorNodeSelection:()=>bw,isProseMirrorRemoveMarkStep:()=>ww,isProseMirrorRemoveNodeMarkStep:()=>xw,isProseMirrorReplaceAroundStep:()=>kw,isProseMirrorReplaceStep:()=>Sw,isProseMirrorSlice:()=>Cw,isProseMirrorStep:()=>Ft,isProseMirrorStepResult:()=>vw,isRegExp:()=>gi,isSafari:()=>Tf,isString:()=>fx,isTextSelection:()=>hr,isiOS:()=>Nn,liveWidgetKeys:()=>Yf,markInputRule:()=>Ie,markPasteRule:()=>Ne,markdown:()=>Sx,marksEqual:()=>Cx,mergeAttributes:()=>L,mergeDeep:()=>Na,minMax:()=>wt,nodeInputRule:()=>po,nodePasteRule:()=>jx,objectIncludes:()=>ro,parseAttributes:()=>Mi,parseIndentedBlocks:()=>uo,pasteRulesPlugin:()=>ah,posToDOMRect:()=>va,removeDuplicates:()=>If,renderNestedMarkdownContent:()=>fo,resolveExtensions:()=>xi,resolveFocusPosition:()=>hi,rewriteUnknownContent:()=>Mw,selectionToInsertionEnd:()=>da,serializeAttributes:()=>Ti,sortExtensions:()=>ur,splitExtensions:()=>Dn,textInputRule:()=>$x,textPasteRule:()=>_x,textblockTypeInputRule:()=>br,updateMarkViewAttributes:()=>Ra,wrappingInputRule:()=>Vt});var _c=Object.defineProperty,$o=(t,e)=>{let n={};for(var r in t)_c(n,r,{get:t[r],enumerable:!0});return e||_c(n,Symbol.toStringTag,{value:"Module"}),n};function Te(t){this.content=t}Te.prototype={constructor:Te,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 e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return o==-1?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new Te(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Te(n)},addToStart:function(t,e){return new Te([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Te(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(i==-1?o.length:i,0,e,n),new Te(o)},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=Te.from(t),t.size?new Te(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Te.from(t),t.size?new Te(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Te.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Te.from=function(t){if(t instanceof Te)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Te(e)};var Vs=Te;function ed(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)n++;return a&&a<s.length&&a<l.length&&rd(s.charCodeAt(a-1))&&nd(s.charCodeAt(a))&&n--,n}if(o.content.size||i.content.size){let s=ed(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function td(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=s.text,d=l.text,u=c.length,f=d.length;for(;u>0&&f>0&&c[u-1]==d[f-1];)u--,f--,n--,r--;return u&&f&&u<c.length&&rd(c.charCodeAt(u-1))&&nd(c.charCodeAt(u))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=td(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function nd(t){return t>=56320&&t<57344}function rd(t){return t>=55296&&t<56320}var S=class t{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,i){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new t(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let i=0,s=0;s<n;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new t(r,o)}cutByIndex(e,n){return e==n?t.empty:e==0&&n==this.content.length?this:new t(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new t(o,i)}addToStart(e){return new t([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new t(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return ed(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return td(this,e,n,r)}findIndex(e){if(e==0)return Bo(0,e);if(e==this.size)return Bo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?Bo(n+1,i):Bo(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return t.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return t.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return t.empty;let n,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(n||(n=e.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new t(n||e,r)}static from(e){if(!e)return t.empty;if(e instanceof t)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new t([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};S.empty=new S([],0);var Ws={index:0,offset:0};function Bo(t,e){return Ws.index=t,Ws.offset=e,Ws}function Fo(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Fo(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Fo(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}var Q=class t{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};Q.none=[];var Et=class extends Error{},E=class t{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=id(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new t(r,this.openStart,this.openEnd)}removeBetween(e,n){return new t(od(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return t.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new t(S.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new t(e,r,o)}};E.empty=new E(S.empty,0,0);function od(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(od(i.content,e-o-1,n-o-1)))}function id(t,e,n,r,o,i){let{index:s,offset:l}=t.findIndex(e),a=t.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=id(a.content,e-l-1,n,s==0?r-1:0,s==t.childCount-1?o-1:0,a);return c&&t.replaceChild(s,a.copy(c))}function Bg(t,e,n){if(n.openStart>t.depth)throw new Et("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Et("Inconsistent open depths");return sd(t,e,n,0)}function sd(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=sd(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return pn(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=zg(n,t);return pn(i,ad(t,s,l,e,r))}else return pn(i,Vo(t,e,r))}function ld(t,e){if(!e.type.compatibleContent(t.type))throw new Et("Cannot join "+e.type.name+" onto "+t.type.name)}function js(t,e,n){let r=t.node(n);return ld(r,e.node(n)),r}function hn(t,e){let 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 Er(t,e,n,r){let 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&&(hn(t.nodeAfter,r),i++));for(let l=i;l<s;l++)hn(o.child(l),r);e&&e.depth==n&&e.textOffset&&hn(e.nodeBefore,r)}function pn(t,e){if(!t.type.validContent(e))throw new Et("Invalid content for node "+t.type.name);return t.copy(e)}function ad(t,e,n,r,o){let i=t.depth>o&&js(t,e,o+1),s=r.depth>o&&js(n,r,o+1),l=[];return Er(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(ld(i,s),hn(pn(i,ad(t,e,n,r,o+1)),l)):(i&&hn(pn(i,Vo(t,e,o+1)),l),Er(e,n,o,l),s&&hn(pn(s,Vo(n,r,o+1)),l)),Er(r,null,o,l),new S(l)}function Vo(t,e,n){let r=[];if(Er(null,t,n,r),t.depth>n){let o=js(t,e,n+1);hn(pn(o,Vo(t,e,n+1)),r)}return Er(e,null,n,r),new S(r)}function zg(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(S.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var Nr=class t{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Q.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Yt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new t(n,r,i)}static resolveCached(e,n){let r=Uc.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else Uc.set(e,r=new _s);let o=r.elts[r.i]=t.resolve(e,n);return r.i=(r.i+1)%Hg,o}},_s=class{constructor(){this.elts=[],this.i=0}},Hg=12,Uc=new WeakMap,Yt=class{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Fg=Object.create(null),ge=class t{constructor(e,n,r,o=Q.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Fo(this.attrs,n||e.defaultAttrs||Fg)&&Q.sameSet(this.marks,r||Q.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return E.empty;let o=this.resolve(e),i=this.resolve(n),s=r?0:o.sharedDepth(n),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new E(c,o.depth-s,i.depth-s)}replace(e,n,r){return Bg(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return Nr.resolveCached(this,e)}resolveNoCache(e){return Nr.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),cd(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=S.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Q.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Q.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=S.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};ge.prototype.text=void 0;var Us=class t extends ge{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):cd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new t(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function cd(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}var Qt=class t{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Ks(e,n);if(r.next==null)return t.empty;let o=dd(r);r.next&&r.err("Unexpected trailing text");let i=qg(Kg(o));return Jg(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let i=n;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return S.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let f=i(u,l.concat(d));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
2
+ `)}};Qt.empty=new Qt(!0);var Ks=class{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function dd(t){let e=[];do e.push(Vg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Vg(t){let e=[];do e.push(Wg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Wg(t){let e=Ug(t);for(;;)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("{"))e=jg(t,e);else break;return e}function Kc(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function jg(t,e){let n=Kc(t),r=n;return t.eat(",")&&(t.next!="}"?r=Kc(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _g(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function Ug(t){if(t.eat("(")){let e=dd(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=_g(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Kg(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let d=n();o(i(s.expr,a),d),a=d}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let d=n();r(a,d),o(i(s.expr,a),d),a=d}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function ud(t,e){return e-t}function qc(t,e){let n=[];return r(e),n.sort(ud);function r(o){let i=t[o];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&n.indexOf(a)==-1&&r(a)}}}function qg(t){let e=Object.create(null);return n(qc(t,0));function n(r){let o=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<o.length;d++)o[d][0]==l&&(c=o[d][1]);qc(t,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Qt(r.indexOf(t.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(ud);i.next.push({type:o[s][0],next:e[l.join(",")]||n(l)})}return i}}function Jg(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function fd(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function hd(t,e){let n=Object.create(null);for(let r in t){let o=e&&e[r];if(o===void 0){let i=t[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=o}return n}function pd(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let o in t)t[o].validate&&t[o].validate(e[o])}function md(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new qs(t,r,e[r]);return n}var Rr=class t{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=md(e,r.attrs),this.defaultAttrs=fd(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Qt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:hd(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ge(this,this.computeAttrs(e),S.from(n),Q.setFrom(r))}createChecked(e=null,n,r){return n=S.from(n),this.checkContent(n),new ge(this,this.computeAttrs(e),n,Q.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=S.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(S.empty,!0);return i?new ge(this,e,n.append(i),Q.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){pd(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Q.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new t(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Gg(t,e,n){let r=n.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}var qs=class{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Gg(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Jn=class t{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=md(e,o.attrs),this.excluded=null;let i=fd(this.attrs);this.instance=i?new Q(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Q(this,hd(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new t(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){pd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Gn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=Vs.from(e.nodes),n.marks=Vs.from(e.marks||{}),this.nodes=Rr.compile(this.spec.nodes,this),this.marks=Jn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Qt.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Jc(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Jc(this,s.split(" "))}this.nodeFromJSON=o=>ge.fromJSON(this,o),this.markFromJSON=o=>Q.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Rr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Us(r,r.defaultAttrs,e,Q.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Jc(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function Xg(t){return t.tag!=null}function Yg(t){return t.style!=null}var Ve=class t{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(Xg(o))this.tags.push(o);else if(Yg(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Wo(this,n,!1);return r.addAll(e,Q.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Wo(this,n,!0);return r.addAll(e,Q.none,n.from,n.to),E.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(ey(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<i)break}n.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Xc(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Xc(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t(e,t.schemaRules(e)))}},gd={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Qg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},yd={ol:!0,ul:!0},Dr=1,Js=2,Or=4;function Gc(t,e,n){return e!=null?(e?Dr:0)|(e==="full"?Js:0):t&&t.whitespace=="pre"?Dr|Js:n&~Or}var qn=class{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=Q.none,this.match=i||(s&Or?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(S.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Dr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=S.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!gd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Wo=class{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=Gc(null,n.preserveWhitespace,0)|(r?Or:0);o?i=new qn(o.type,o.attrs,Q.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new qn(null,null,Q.none,!0,null,s):i=new qn(e.schema.topNodeType,null,Q.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&Js?"full":this.localPreserveWS||(o.options&Dr)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
3
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;yd.hasOwnProperty(s)&&this.parser.normalizeLists&&Zg(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Qg.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(gd.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=a&&a.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)n=this.enterInner(o[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=Q.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Yc(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,o){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,o)),i}enterInner(e,n,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Gc(e,i,s.options);s.options&Or&&s.content.length==0&&(l|=Or);let a=Q.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Yc(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new qn(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Dr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.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=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}};function Zg(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&yd.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ey(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xc(t){let e={};for(let n in t)e[n]=t[n];return e}function Yc(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&s(d))return!0}};if(s(o.contentMatch))return!0}}var yt=class t{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=zo(n).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],d=this.serializeMark(c,s.isInline,n);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){if(e.isText)return zo(n).createTextNode(e.text);let{dom:r,contentDOM:o}=Ho(zo(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&Ho(zo(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return typeof n=="string"?{dom:e.createTextNode(n)}:Ho(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new t(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Qc(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Qc(e.marks)}};function Qc(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zo(t){return t.document||window.document}var Zc=new WeakMap;function ty(t){let e=Zc.get(t);return e===void 0&&Zc.set(t,e=ny(t)),e}function ny(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function Ho(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=ty(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=Ho(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var xd=65535,kd=Math.pow(2,16);function ry(t,e){return t+e*kd}function bd(t){return t&xd}function oy(t){return(t-(t&xd))/kd}var Sd=1,Cd=2,jo=4,vd=8,Pr=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&vd)>0}get deletedBefore(){return(this.delInfo&(Sd|jo))>0}get deletedAfter(){return(this.delInfo&(Cd|jo))>0}get deletedAcross(){return(this.delInfo&jo)>0}},Ot=class t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&t.empty)return t.empty}recover(e){let n=0,r=bd(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+oy(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:n:n,h=a+o+(f<0?0:d);if(r)return h;let p=e==(n<0?a:u)?null:ry(l/3,e-a),g=e==a?Cd:e==u?Sd:jo;return(n<0?e!=a:e!=u)&&(g|=vd),new Pr(h,g,p)}o+=d-c}return r?e+o:new Pr(e+o,0,null)}touches(e,n){let r=0,o=bd(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+n],d=this.ranges[o+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?t.empty:new t(e<0?[0,-e,0]:[0,0,e])}};Ot.empty=new Ot([]);var $r=class t{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new t(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let o=e.getMirror(n);this.appendMap(e._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new t;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Pr(e,o,null)}},Gs=Object.create(null),ye=class{getMap(){return Ot.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Gs[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Gs)throw new RangeError("Duplicate use of step JSON ID "+e);return Gs[e]=n,n.prototype.jsonID=e,n}},ke=class t{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new t(e,null)}static fail(e){return new t(null,e)}static fromReplace(e,n,r,o){try{return t.ok(e.replace(n,r,o))}catch(i){if(i instanceof Et)return t.fail(i.message);throw i}}};function el(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(el(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return S.fromArray(r)}var Br=class t extends ye{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new E(el(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,i)}invert(){return new Nt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ye.jsonID("addMark",Br);var Nt=class t extends ye{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new E(el(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return ke.fromReplace(e,this.from,this.to,r)}invert(){return new Br(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new t(n.pos,r.pos,this.mark)}merge(e){return e instanceof t&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new t(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new t(n.from,n.to,e.markFromJSON(n.mark))}};ye.jsonID("removeMark",Nt);var zr=class t extends ye{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new E(S.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new t(this.pos,n.marks[o]);return new t(this.pos,this.mark)}}return new Xn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};ye.jsonID("addNodeMark",zr);var Xn=class t extends ye{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ke.fromReplace(e,this.pos,this.pos+1,new E(S.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new zr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new t(n.pos,e.markFromJSON(n.mark))}};ye.jsonID("removeNodeMark",Xn);var be=class t extends ye{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&Qs(e,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ot([this.from,this.to-this.from,this.slice.size])}invert(e){return new t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new t(n.from,n.to,E.fromJSON(e,n.slice),!!n.structure)}};be.MAP_BIAS=1;ye.jsonID("replace",be);var ue=class t extends ye{constructor(e,n,r,o,i,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Qs(e,this.from,this.gapFrom)||Qs(e,this.gapTo,this.to)))return ke.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ke.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ke.fromReplace(e,this.from,this.to,r):ke.fail("Content does not fit in gap")}getMap(){return new Ot([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new t(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new t(n.from,n.to,n.gapFrom,n.gapTo,E.fromJSON(e,n.slice),n.insert,!!n.structure)}};ye.jsonID("replaceAround",ue);function Qs(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function iy(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(p)||(s&&s.to==f&&s.mark.eq(u[g])?s.to=h:o.push(s=new Nt(f,h,u[g])));l&&l.to==f?l.to=h:i.push(l=new Br(f,h,r))}}),o.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function sy(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Jn){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==i-1&&u.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=i):o.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>t.step(new Nt(s.from,s.to,s.style)))}function tl(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)s.push(new be(l,d,E.empty));else{r=u;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new Nt(l,d,c.marks[f]));if(o&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new E(S.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new be(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(S.empty,!0);t.replace(l,l,new E(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function ly(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Rt(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,o=0,i=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+o,a=t.$to.indexAfter(r)-i;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!ly(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function ay(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,d=S.empty,u=0;for(let p=i,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,d=S.from(r.node(p).copy(d)),u++):a--;let f=S.empty,h=0;for(let p=i,g=!1;p>n;p--)g||o.after(p+1)<o.end(p)?(g=!0,f=S.from(o.node(p).copy(f)),h++):c++;t.step(new ue(a,c,s,l,new E(d.append(f),u,h),d.size-u,!0))}function Qn(t,e,n=null,r=t){let o=cy(t,e),i=o&&dy(r,e);return i?o.map(wd).concat({type:e,attrs:n}).concat(i.map(wd)):null}function wd(t){return{type:t,attrs:null}}function cy(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}function dy(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function uy(t,e,n){let r=S.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=S.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new ue(o,i,o,i,new E(r,0,0),n.length,!0))}function fy(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&hy(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Td(t,s,l,i),tl(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let d=t.mapping.slice(i),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return t.step(new ue(u,f,u+1,f-1,new E(S.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Md(t,s,l,i),!1}})}function Md(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Td(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`
5
+ `))}})}function hy(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function py(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ue(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new E(S.from(s),0,0),1,!0))}function Ke(t,e,n=1,r){let 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(let c=o.depth-1,d=n-2;c>i;c--,d--){let u=o.node(c),f=o.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!g.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function my(t,e,n=1,r){let o=t.doc.resolve(e),i=S.empty,s=S.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=S.from(o.node(l).copy(i));let d=r&&r[c];s=S.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}t.step(new be(e,e,new E(i.append(s),n,n),!0))}function lt(t,e){let n=t.resolve(e),r=n.index();return Ad(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function gy(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Ad(t,e){return!!(t&&e&&!t.isLeaf&&gy(t,e))}function Zn(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&Ad(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function yy(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Td(t,d.node(),d.before(),l)}s.inlineContent&&tl(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new be(c,a.map(e+n,-1),E.empty,!0)),r===!0){let d=t.doc.resolve(c);Md(t,d.node(),d.before(),t.steps.length)}return t}function by(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let 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(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Ko(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let i=0;i<n.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Hr(t,e,n=e,r=E.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return Ed(o,i,r)?new be(e,n,r):new Zs(o,i,r).fit()}function Ed(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var Zs=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=S.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let 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;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new E(i,s,l);return e>-1?new ue(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new be(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Xs(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(n==1&&(s?c.matchType(s.type)||(u=c.fillBefore(S.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Xs(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new E(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Xs(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new E(Lr(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new E(Lr(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[n];if(o){for(let g=0;g<o.childCount;g++)d.push(o.child(g));u=u.matchFragment(o)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let g=l.child(c),m=u.matchType(g.type);if(!m)break;c++,(c>1||a==0||g.content.size)&&(u=m,d.push(Od(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Ir(this.placed,n,S.from(d)),this.frontier[n].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g<h;g++){let y=m.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),m=y.content}this.unplaced=p?e==0?E.empty:new E(Lr(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new E(Lr(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Ys(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=Ys(e,n,o,r,i);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Ys(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ir(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Ir(this.placed,this.depth,S.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(S.empty,!0);n.childCount&&(this.placed=Ir(this.placed,this.frontier.length,n))}};function Lr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Lr(t.firstChild.content,e-1,n)))}function Ir(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ir(t.lastChild.content,e-1,n)))}function Xs(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Od(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Od(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),t.copy(r)}function Ys(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!wy(n,i.content,s)?l:null}function wy(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function xy(t){return t.spec.defining||t.spec.definingForContent}function ky(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if(Ed(o,i,r))return t.step(new be(e,n,r));let s=Rd(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=xy(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<s.length;g++){let m=s[(g+a)%s.length],y=!0;m<0&&(y=!1,m=-m);let w=o.node(m-1),x=o.index(m-1);if(w.canReplaceWith(x,x,p.type,p.marks))return t.replace(o.before(m),y?i.after(m):n,new E(Nd(r.content,0,r.openStart,h),h,r.openEnd))}}let u=t.steps.length;for(let f=s.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>u));f--){let h=s[f];h<0||(e=o.before(h),n=i.after(h))}}function Nd(t,e,n,r,o){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Nd(i.content,e+1,n,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(S.empty,!0))}return t}function Sy(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=by(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new E(S.from(r),0,0))}function Cy(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&n==o.start(a);a--)n=o.before(a);r=t.doc.resolve(e),o=t.doc.resolve(n)}}let i=Rd(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function Rd(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(i<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}var _o=class t extends ye{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return ke.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return ke.fromReplace(e,this.pos,this.pos+1,new E(S.from(o),0,n.isLeaf?0:1))}getMap(){return Ot.empty}invert(e){return new t(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new t(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new t(n.pos,n.attr,n.value)}};ye.jsonID("attr",_o);var Uo=class t extends ye{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ke.ok(r)}getMap(){return Ot.empty}invert(e){return new t(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new t(n.attr,n.value)}};ye.jsonID("docAttr",Uo);var Yn=class extends Error{};Yn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Yn.prototype=Object.create(Error.prototype);Yn.prototype.constructor=Yn;Yn.prototype.name="TransformError";var Zt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new $r}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Yn(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),n=o.map(n,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=E.empty){let o=Hr(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new E(S.from(r),0,0))}delete(e,n){return this.replace(e,n,E.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return ky(this,e,n,r),this}replaceRangeWith(e,n,r){return Sy(this,e,n,r),this}deleteRange(e,n){return Cy(this,e,n),this}lift(e,n){return ay(this,e,n),this}join(e,n=1){return yy(this,e,n),this}wrap(e,n){return uy(this,e,n),this}setBlockType(e,n=e,r,o=null){return fy(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return py(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new _o(e,n,r)),this}setDocAttribute(e,n){return this.step(new Uo(e,n)),this}addNodeMark(e,n){return this.step(new zr(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Q)n.isInSet(r.marks)&&this.step(new Xn(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new Xn(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return my(this,e,n,r),this}addMark(e,n,r){return iy(this,e,n,r),this}removeMark(e,n,r){return sy(this,e,n,r),this}clearIncompatible(e,n,r){return tl(this,e,n,r),this}};var nl=Object.create(null),z=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new gn(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=E.empty){let r=n.content.lastChild,o=null;for(let l=0;l<n.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?E.empty:n),l==0&&Id(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),Id(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new R(e):er(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=n<0?er(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):er(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Ae(e.node(0))}static atStart(e){return er(e,e,0,0,1)||new Ae(e)}static atEnd(e){return er(e,e,e.content.size,e.childCount,-1)||new Ae(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=nl[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in nl)throw new RangeError("Duplicate use of selection JSON ID "+e);return nl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}};z.prototype.visible=!0;var gn=class{constructor(e,n){this.$from=e,this.$to=n}},Dd=!1;function Ld(t){!Dd&&!t.parent.inlineContent&&(Dd=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var R=class t extends z{constructor(e,n=e){Ld(e),Ld(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return z.near(r);let o=e.resolve(n.map(this.anchor));return new t(o.parent.inlineContent?o:r,r)}replace(e,n=E.empty){if(super.replace(e,n),n==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof t&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Jo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new t(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=z.findFrom(n,r,!0)||z.findFrom(n,-r,!0);if(i)n=i.$head;else return z.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(z.findFrom(e,-r,!0)||z.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new t(e,n)}};z.jsonID("text",R);var Jo=class t{constructor(e,n){this.anchor=e,this.head=n}map(e){return new t(e.map(this.anchor),e.map(this.head))}resolve(e){return R.between(e.resolve(this.anchor),e.resolve(this.head))}},$=class t extends z{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),i=e.resolve(o);return r?z.near(i):new t(i)}content(){return new E(S.from(this.node),0,0)}eq(e){return e instanceof t&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ol(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new t(e.resolve(n.anchor))}static create(e,n){return new t(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};$.prototype.visible=!1;z.jsonID("node",$);var ol=class t{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Jo(r,r):new t(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&$.isSelectable(r)?new $(n):z.near(n)}},Ae=class t extends z{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=E.empty){if(n==E.empty){e.delete(0,e.doc.content.size);let r=z.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new t(e)}map(e){return new t(e)}eq(e){return e instanceof t}getBookmark(){return vy}};z.jsonID("all",Ae);var vy={map(){return this},resolve(t){return new Ae(t)}};function er(t,e,n,r,o,i=!1){if(e.inlineContent)return R.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&$.isSelectable(l))return $.create(t,n-(o<0?l.nodeSize:0))}else{let a=er(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function Id(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof be||o instanceof ue))return;let i=t.mapping.maps[r],s;i.forEach((l,a,c,d)=>{s==null&&(s=d)}),t.setSelection(z.near(t.doc.resolve(s),n))}var Pd=1,qo=2,$d=4,Go=class extends Zt{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Pd)&~qo,this.storedMarks=null,this}get selectionSet(){return(this.updated&Pd)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=qo,this}ensureMarks(e){return Q.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&qo)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~qo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Q.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(z.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=$d,this}get scrolledIntoView(){return(this.updated&$d)>0}};function Bd(t,e){return!e||!t?t:t.bind(e)}var mn=class{constructor(e,n,r){this.name=e,this.init=Bd(n.init,r),this.apply=Bd(n.apply,r)}},My=[new mn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new mn("selection",{init(t,e){return t.selection||z.atStart(e.doc)},apply(t){return t.selection}}),new mn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new mn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],Fr=class{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=My.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new mn(r.key,r.spec.state,r))})}},tr=class t{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,d=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),i=!0}o&&(o[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new t(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new Go(this)}static create(e){let n=new Fr(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new t(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new Fr(this.schema,e.plugins),r=n.fields,o=new t(n);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Fr(e.schema,e.plugins),i=new t(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=ge.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=z.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function zd(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=zd(o,e,{})),n[r]=o}return n}var F=class{constructor(e){this.spec=e,this.props={},e.props&&zd(e.props,this,this.props),this.key=e.key?e.key.key:Hd("plugin")}getState(e){return e[this.key]}},rl=Object.create(null);function Hd(t){return t in rl?t+"$"+ ++rl[t]:(rl[t]=0,t+"$")}var j=class{constructor(e="key"){this.key=Hd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Vd=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Wd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var sl=(t,e,n)=>{let r=Wd(t,n);if(!r)return!1;let o=al(r);if(!o){let s=r.blockRange(),l=s&&Rt(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Yd(t,o,e,-1))return!0;if(r.parent.content.size==0&&(nr(i,"end")||$.isSelectable(i)))for(let s=r.depth;;s--){let l=Hr(t.doc,r.before(s),r.after(s),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(nr(i,"end")?z.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):$.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},jd=(t,e,n)=>{let r=Wd(t,n);if(!r)return!1;let o=al(r);return o?Ud(t,o,e):!1},_d=(t,e,n)=>{let r=Kd(t,n);if(!r)return!1;let o=ul(r);return o?Ud(t,o,e):!1};function Ud(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=Hr(t.doc,i,a,E.empty);if(!c||c.from!=i||c instanceof be&&c.slice.size>=a-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(R.create(d.doc,i)),n(d.scrollIntoView())}return!0}function nr(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var ll=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=al(r)}let s=i&&i.nodeBefore;return!s||!$.isSelectable(s)?!1:(e&&e(t.tr.setSelection($.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function al(t){if(!t.parent.type.spec.isolating)for(let 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 Kd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}var cl=(t,e,n)=>{let r=Kd(t,n);if(!r)return!1;let o=ul(r);if(!o)return!1;let i=o.nodeAfter;if(Yd(t,o,e,1))return!0;if(r.parent.content.size==0&&(nr(i,"start")||$.isSelectable(i))){let s=Hr(t.doc,r.before(),r.after(),E.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(nr(i,"start")?z.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):$.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},dl=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=ul(r)}let s=i&&i.nodeAfter;return!s||!$.isSelectable(s)?!1:(e&&e(t.tr.setSelection($.create(t.doc,i.pos)).scrollIntoView()),!0)};function ul(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let 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}var qd=(t,e)=>{let n=t.selection,r=n instanceof $,o;if(r){if(n.node.isTextblock||!lt(t.doc,n.from))return!1;o=n.from}else if(o=Zn(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection($.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},Jd=(t,e)=>{let n=t.selection,r;if(n instanceof $){if(n.node.isTextblock||!lt(t.doc,n.to))return!1;r=n.to}else if(r=Zn(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Gd=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&Rt(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},fl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
6
+ `).scrollIntoView()),!0)};function hl(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var pl=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=hl(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(z.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},ml=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof Ae||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=hl(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=t.tr.insert(s,i.createAndFill());l.setSelection(R.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},gl=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ke(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Rt(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function Ty(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof $&&e.selection.node.isBlock)return!r.parentOffset||!Ke(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=hl(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let g=t&&t(o.parent,a,r);i.unshift(g||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof R||e.selection instanceof Ae)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=Ke(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Ke(d.doc,u,i.length,i)),!f)return!1;if(d.split(u,i.length,i),!a&&c&&r.node(s).type!=l){let h=d.mapping.map(r.before(s)),p=d.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return n&&n(d.scrollIntoView()),!0}}var Ay=Ty();var Xd=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection($.create(t.doc,o))),!0)},Ey=(t,e)=>(e&&e(t.tr.setSelection(new Ae(t.doc))),!0);function Oy(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!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||lt(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Yd(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Oy(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=S.empty;for(let y=s.length-1;y>=0;y--)p=S.from(s[y].create(null,p));p=S.from(o.copy(p));let g=t.tr.step(new ue(e.pos-1,h,e.pos,h,new E(p,1,0),s.length,!0)),m=g.doc.resolve(h+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&lt(g.doc,m.pos)&&g.join(m.pos),n(g.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:z.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Rt(u);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(u,f).scrollIntoView()),!0;if(c&&nr(i,"start",!0)&&nr(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=i,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(n){let y=S.empty;for(let x=p.length-1;x>=0;x--)y=S.from(p[x].copy(y));let w=t.tr.step(new ue(e.pos-p.length,e.pos+i.nodeSize,e.pos+m,e.pos+i.nodeSize-m,new E(y,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function Qd(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(R.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}var yl=Qd(-1),bl=Qd(1);function Zd(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&Qn(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function wl(t,e=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let d=n.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function xl(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}var il=xl(Vd,sl,ll),Fd=xl(Vd,cl,dl),en={Enter:xl(fl,ml,gl,Ay),"Mod-Enter":pl,Backspace:il,"Mod-Backspace":il,"Shift-Backspace":il,Delete:Fd,"Mod-Delete":Fd,"Mod-a":Ey},Ny={"Ctrl-h":en.Backspace,"Alt-Backspace":en["Mod-Backspace"],"Ctrl-d":en.Delete,"Ctrl-Alt-Backspace":en["Mod-Delete"],"Alt-Delete":en["Mod-Delete"],"Alt-d":en["Mod-Delete"],"Ctrl-a":yl,"Ctrl-e":bl};for(let t in en)Ny[t]=en[t];var Rv=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1;var Xo={};Po(Xo,{AllSelection:()=>Ae,EditorState:()=>tr,NodeSelection:()=>$,Plugin:()=>F,PluginKey:()=>j,Selection:()=>z,SelectionRange:()=>gn,TextSelection:()=>R,Transaction:()=>Go});var kl={};Po(kl,{ContentMatch:()=>Qt,DOMParser:()=>Ve,DOMSerializer:()=>yt,Fragment:()=>S,Mark:()=>Q,MarkType:()=>Jn,Node:()=>ge,NodeRange:()=>Yt,NodeType:()=>Rr,ReplaceError:()=>Et,ResolvedPos:()=>Nr,Schema:()=>Gn,Slice:()=>E});function eu(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return Ry(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Ry(t,e,n,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Yt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Yt(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=Qn(i,n,r,e);return l?(t&&Dy(t,e,l,o,n),!0):!1}function Dy(t,e,n,r,o){let i=S.empty;for(let d=n.length-1;d>=0;d--)i=S.from(n[d].type.create(n[d].attrs,i));t.step(new ue(e.start-(r?2:0),e.end,e.start,e.end,new E(i,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==o&&(s=d+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&Ke(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return t}function tu(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?Ly(e,n,t,i):Iy(e,n,i):!0:!1}}function Ly(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new ue(i-1,s,i,s,new E(S.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Yt(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));let l=Rt(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return lt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Iy(t,e,n){let r=t.tr,o=n.parent;for(let h=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?S.empty:S.from(o))))return!1;let u=i.pos,f=u+s.nodeSize;return r.step(new ue(u-(l?1:0),f+(a?1:0),u+1,f-1,new E((l?S.empty:S.from(o.copy(S.empty))).append(a?S.empty:S.from(o.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function nu(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,d=S.from(c?t.create():null),u=new E(S.from(t.create(null,S.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new ue(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}var ta={};Po(ta,{Decoration:()=>re,DecorationSet:()=>Y,EditorView:()=>ar,__endComposition:()=>ab,__parseFromClipboard:()=>lb});var Se=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},sr=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},Tl=null,Lt=function(t,e,n){let r=Tl||(Tl=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Py=function(){Tl=null},vn=function(t,e,n,r){return n&&(ru(t,e,n,r,-1)||ru(t,e,n,r,1))},$y=/^(img|br|input|textarea|hr)$/i;function ru(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Je(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Gr(t)||$y.test(t.nodeName)||t.contentEditable=="false")return!1;e=Se(t)+(o<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?Je(t):0}else return!1}}function Je(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function By(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Je(t)}else if(t.parentNode&&!Gr(t))e=Se(t),t=t.parentNode;else return null}}function zy(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Gr(t))e=Se(t)+1,t=t.parentNode;else return null}}function Hy(t,e,n){for(let r=e==0,o=e==Je(t);r||o;){if(t==n)return!0;let i=Se(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==Je(t)}}function Gr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var li=function(t){return t.focusNode&&vn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function yn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Fy(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Vy(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Je(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Je(r.startContainer),r.startOffset)}}}var bt=typeof navigator<"u"?navigator:null,ou=typeof document<"u"?document:null,sn=bt&&bt.userAgent||"",Al=/Edge\/(\d+)/.exec(sn),Lu=/MSIE \d/.exec(sn),El=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(sn),$e=!!(Lu||El||Al),rn=Lu?document.documentMode:El?+El[1]:Al?+Al[1]:0,Ge=!$e&&/gecko\/(\d+)/i.test(sn);Ge&&+(/Firefox\/(\d+)/.exec(sn)||[0,0])[1];var Ol=!$e&&/Chrome\/(\d+)/.exec(sn),Ce=!!Ol,Iu=Ol?+Ol[1]:0,Oe=!$e&&!!bt&&/Apple Computer/.test(bt.vendor),lr=Oe&&(/Mobile\/\w+/.test(sn)||!!bt&&bt.maxTouchPoints>2),qe=lr||(bt?/Mac/.test(bt.platform):!1),Pu=bt?/Win/.test(bt.platform):!1,It=/Android \d/.test(sn),Xr=!!ou&&"webkitFontSmoothing"in ou.documentElement.style,Wy=Xr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function jy(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Dt(t,e){return typeof t=="number"?t:t[e]}function _y(t){let 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 iu(t,e,n){if(!Nl(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=sr(s);continue}let l=s,a=l==i.body,c=a?jy(i):_y(l),d=0,u=0;if(e.top<c.top+Dt(r,"top")?u=-(c.top-e.top+Dt(o,"top")):e.bottom>c.bottom-Dt(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Dt(o,"top")-c.top:e.bottom-c.bottom+Dt(o,"bottom")),e.left<c.left+Dt(r,"left")?d=-(c.left-e.left+Dt(o,"left")):e.right>c.right-Dt(r,"right")&&(d=e.right-c.right+Dt(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let g=l.scrollLeft-h,m=l.scrollTop-p;e={left:e.left-g,top:e.top-m,right:e.right-g,bottom:e.bottom-m}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:sr(s)}}function Uy(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(i,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:$u(t.dom)}}function $u(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=sr(r));return e}function Ky({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Bu(n,r==0?0:r-e)}function Bu(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var rr=null;function qy(t){if(t.setActive)return t.setActive();if(rr)return t.focus(rr);let e=$u(t);t.focus(rr==null?{get preventScroll(){return rr={preventScroll:!0},!0}}:void 0),rr||(rr=!1,Bu(e,0))}function zu(t,e){let n,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let d=t.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Lt(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=d,r=g,o=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&g&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!n&&a&&(n=a,o=c,r=0),n&&n.nodeType==3?Jy(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:zu(n,o)}function Jy(t,e){let n=t.nodeValue.length,r=document.createRange(),o;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=tn(r,1);if(s.top!=s.bottom&&Kl(e,s)){o={node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:t,offset:0}}function Kl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Gy(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Xy(t,e,n){let{node:r,offset:o}=zu(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function Yy(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}function Hu(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=t.childNodes[i];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Kl(e,c))return Hu(s,e,c)}}if((i=(i+1)%r)==o)break}return t}function Qy(t,e){let n=t.dom.ownerDocument,r,o=0,i=Vy(n,e.left,e.top);i&&({node:r,offset:o}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!Kl(e,c)||(s=Hu(t.dom,e,c),!s))return null}if(Oe)for(let c=s;r&&c;c=sr(c))c.draggable&&(r=void 0);if(s=Gy(s,e),r){if(Ge&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;Xr&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=Yy(t,r,o,e))}l==null&&(l=Xy(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Nl(t){return t.top<t.bottom||t.left<t.right}function tn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Nl(r))return r}return Array.prototype.find.call(n,Nl)||t.getBoundingClientRect()}var Zy=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Fu(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Xr||Ge;if(r.nodeType==3)if(s&&(Zy.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=tn(Lt(r,o,o),n);if(Ge&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=tn(Lt(r,o-1,o-1),-1);if(c.top==a.top){let d=tn(Lt(r,o,o+1),-1);if(d.top!=a.top)return Vr(d,d.left<c.left)}}return a}else{let a=o,c=o,d=n<0?1:-1;return n<0&&!o?(c++,d=-1):n>=0&&o==r.nodeValue.length?(a--,d=1):n<0?a--:c++,Vr(tn(Lt(r,a,c),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==Je(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Sl(a.getBoundingClientRect(),!1)}if(i==null&&o<Je(r)){let a=r.childNodes[o];if(a.nodeType==1)return Sl(a.getBoundingClientRect(),!0)}return Sl(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==Je(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Lt(a,Je(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Vr(tn(c,1),!1)}if(i==null&&o<Je(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Lt(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Vr(tn(c,-1),!0)}return Vr(tn(r.nodeType==3?Lt(r):r,-n),n>=0)}function Vr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Sl(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Vu(t,e,n){let 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()}}function e0(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Vu(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Fu(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Lt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var t0=/[\u0590-\u08ac]/;function n0(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!t0.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:Vu(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),m=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),m}):r.pos==r.start()||r.pos==r.end()}var su=null,lu=null,au=!1;function r0(t,e,n){return su==e&&lu==n?au:(su=e,lu=n,au=n=="up"||n=="down"?e0(t,e,n):n0(t,e,n))}var Xe=0,cu=1,bn=2,at=3,Mn=class{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=Xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>Se(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e||s instanceof Zo){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Yo&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Se(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Se(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let d=s+a.border;if(e>=d&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=Se(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=Se(u.dom);break}n+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,o=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let g=this.children[h],m=p+g.size;if(i>p&&s<m)return g.setSelection(e-p-g.border,n-p-g.border,r,o);p=m}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((Ge||Oe)&&e==n){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
7
+ `),u&&p==h.nodeValue.length)for(let g=h,m;g;g=g.parentNode){if(m=g.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:Se(m)+1});break}let y=g.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let g=h.childNodes[p-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Ge&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||u&&Oe)&&vn(l.node,l.offset,d.anchorNode,d.anchorOffset)&&vn(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(u&&Ge)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?bn:cu,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=at:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?bn:at}r=s}this.dirty=bn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?bn:cu;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Yo=class extends Mn{constructor(e,n,r,o){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.hasAttribute("contenteditable")||(s.contentEditable="false"),s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Rl=class extends Mn{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},xn=class t extends Mn{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=yt.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new t(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&at||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=at&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xe}}slice(e,n,r){let o=t.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Pl(i,n,s,r)),e>0&&(i=Pl(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},on=class t extends Mn{constructor(e,n,r,o,i,s,l){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=yt.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let f=d;return d=_u(d,r,n),c?a=new Dl(e,n,r,o,d,u||null,f,c):n.isText?new Qo(e,n,r,o,d,f):new t(e,n,r,o,d,u||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){n.contentElement=o.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(o=>o.nodeType==1&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?n.contentElement=r:n.getContent=()=>S.empty}}return n}matchesNode(e,n,r){return this.dirty==Xe&&e.eq(this.node)&&ei(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Il(this,s&&s.node,e);l0(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Q.none:this.node.child(d).marks,r,e,d),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==bn)&&(s&&this.protectLocalComposition(e,s),Wu(this.contentDOM,this.children,e),lr&&a0(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof R)||r<n||o>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=c0(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;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=void 0)}let s=new Rl(this,i,n,o);e.input.compositionNodes.push(s),this.children=Pl(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==at||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Xe}updateOuterDeco(e){if(ei(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ju(this.dom,this.nodeDOM,Ll(this.outerDeco,this.node,n),Ll(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function du(t,e,n,r,o){_u(r,e,t);let i=new on(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}var Qo=class t extends on{constructor(e,n,r,o,i,s){super(e,n,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==at||this.dirty!=Xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Xe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new t(this.parent,o,this.outerDeco,this.innerDeco,i,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=at)}get domAtom(){return!1}isText(e){return this.node.text==e}},Zo=class extends Mn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Dl=class extends on{constructor(e,n,r,o,i,s,l,a){super(e,n,r,o,i,s,l),this.spec=a}update(e,n,r,o){if(this.dirty==at)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Wu(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=uu(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(l,r);if(s instanceof xn){let a=r?r.previousSibling:t.lastChild;Wu(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=uu(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}var jr=function(t){t&&(this.nodeName=t)};jr.prototype=Object.create(null);var wn=[new jr];function Ll(t,e,n){if(t.length==0)return wn;let r=n?wn[0]:new jr,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new jr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new jr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function ju(t,e,n,r){if(n==wn&&r==wn)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=t&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=wn[0]),o=a}o0(o,l||wn[0],s)}return o}function o0(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&t.classList.add(o[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function _u(t,e,n){return ju(t,t,wn,Ll(e,n,t.nodeType!=1))}function ei(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function uu(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Il=class{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=i0(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Xe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){a=d;break}}if(a<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof xn&&d.dirty!=at&&d.mark.type==e[s].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[s])&&(d.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=xn.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,o,i){let s=this.top.children[o];return s.dirty==at&&s.dom==s.contentDOM&&(s.dirty=bn),s.update(e,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof on){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=at&&ei(n,a.outerDeco));if(!f&&a.update(e,n,r,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=bn,u.updateChildren(o,s+1),u.dirty=Xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!ei(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=on.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,o,i){let s=on.create(this.top,e,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Yo(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof xn;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Qo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Oe||Ce)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Zo(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function i0(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof xn)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function s0(t,e){return t.type.side-e.type.side}function l0(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,u;for(;s<o.length&&o[s].to==i;){let m=o[s++];m.widget&&(d?(u||(u=[d])).push(m):d=m)}if(d)if(u){u.sort(s0);for(let m=0;m<u.length;m++)n(u[m],c,!!a)}else n(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let m=0;m<l.length;m++)l[m].to<=i&&l.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let m=p;s<o.length&&o[s].from<m&&(m=o[s].from);for(let y=0;y<l.length;y++)l[y].to<m&&(m=l[y].to);m<p&&(a=f.cut(m-i),f=f.cut(0,m-i),p=m,h=-1)}else for(;s<o.length&&o[s].to<p;)s++;let g=f.isInline&&!f.isLeaf?l.filter(m=>!m.inline):l.slice();r(f,g,e.forChild(i,f),h),i=p}}function a0(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function c0(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<t.childCount;){let c=t.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Pl(t,e,n,r,o){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,d=l+=a.size;c>=n||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),d>n&&i.push(a.slice(n-c,a.size,r)))}return i}function ql(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(li(n)){for(a=s;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&$.isSelectable(u)&&o.parent&&!(u.isInline&&Hy(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new $(s==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=s,f=s;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);u=Math.min(u,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,s]=f==t.state.selection.anchor?[f,u]:[u,f],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=Jl(t,d,l,u)}return c}function Uu(t){return t.editable?t.hasFocus():qu(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function $t(t,e=!1){let n=t.state.selection;if(Ku(t,n),!Uu(t))return;let r=t.input.mouseDown;if(!e&&Ce&&r){let o=t.domSelectionRange(),i=t.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&vn(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)u0(t);else{let{anchor:o,head:i}=n,s,l;fu&&!(n instanceof R)&&(n.$from.parent.inlineContent||(s=hu(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=hu(t,n.to))),t.docView.setSelection(o,i,t,e),fu&&(s&&pu(s),l&&pu(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&d0(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var fu=Oe||Ce&&Iu<63;function hu(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Oe&&o&&o.contentEditable=="false")return Cl(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Cl(o);if(i)return Cl(i)}}function Cl(t){return t.contentEditable="true",Oe&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function pu(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function d0(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Uu(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function u0(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Se(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&$e&&rn<=11&&(n.disabled=!0,n.disabled=!1)}function Ku(t,e){if(e instanceof $){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(mu(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else mu(t)}function mu(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Jl(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||R.between(e,n,r)}function gu(t){return t.editable&&!t.hasFocus()?!1:qu(t)}function qu(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function f0(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return vn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function $l(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&z.findFrom(i,e)}function nn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function yu(t,e,n){let r=t.state.selection;if(r instanceof R)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return nn(t,new R(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=$l(t.state,e);return o&&o instanceof $?nn(t,o):!1}else if(!(qe&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?$.isSelectable(i)?nn(t,new $(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):Xr?nn(t,new R(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $&&r.node.isInline)return nn(t,new R(e>0?r.$to:r.$from));{let o=$l(t.state,e);return o?nn(t,o):!1}}}function ti(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _r(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function or(t,e){return e<0?h0(t):p0(t)}function h0(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Ge&&n.nodeType==1&&r<ti(n)&&_r(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(_r(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Ju(n))break;{let l=n.previousSibling;for(;l&&_r(l,-1);)o=n.parentNode,i=Se(l),l=l.previousSibling;if(l)n=l,r=ti(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Bl(t,n,r):o&&Bl(t,o,i)}function p0(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=ti(n),i,s;for(;;)if(r<o){if(n.nodeType!=1)break;let l=n.childNodes[r];if(_r(l,1))i=n,s=++r;else break}else{if(Ju(n))break;{let l=n.nextSibling;for(;l&&_r(l,1);)i=l.parentNode,s=Se(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=ti(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&Bl(t,i,s)}function Ju(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function m0(t,e){for(;t&&e==t.childNodes.length&&!Gr(t);)e=Se(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function g0(t,e){for(;t&&!e&&!Gr(t);)e=Se(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Bl(t,e,n){if(e.nodeType!=3){let i,s;(s=m0(e,n))?(e=s,n=0):(i=g0(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(li(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&$t(t)},50)}function bu(t,e){let n=t.state.doc.resolve(e);if(!(Ce||Pu)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function wu(t,e,n){let r=t.state.selection;if(r instanceof R&&!r.empty||n.indexOf("s")>-1||qe&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=$l(t.state,e);if(s&&s instanceof $)return nn(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof Ae?z.near(s,e):z.findFrom(s,e);return l?nn(t,l):!1}return!1}function xu(t,e){if(!(t.state.selection instanceof R))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function ku(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function y0(t){if(!Oe||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ku(t,r,"true"),setTimeout(()=>ku(t,r,"false"),20)}return!1}function b0(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function w0(t,e){let n=e.keyCode,r=b0(e);if(n==8||qe&&n==72&&r=="c")return xu(t,-1)||or(t,-1);if(n==46&&!e.shiftKey||qe&&n==68&&r=="c")return xu(t,1)||or(t,1);if(n==13||n==27)return!0;if(n==37||qe&&n==66&&r=="c"){let o=n==37?bu(t,t.state.selection.from)=="ltr"?-1:1:-1;return yu(t,o,r)||or(t,o)}else if(n==39||qe&&n==70&&r=="c"){let o=n==39?bu(t,t.state.selection.from)=="ltr"?1:-1:1;return yu(t,o,r)||or(t,o)}else{if(n==38||qe&&n==80&&r=="c")return wu(t,-1,r)||or(t,-1);if(n==40||qe&&n==78&&r=="c")return y0(t)||wu(t,1,r)||or(t,1);if(r==(qe?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Gl(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||yt.fromSchema(t.state.schema),l=Zu(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Qu[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
8
+
9
+ `);return{dom:a,text:f,slice:e}}function Xl(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,i||r,t)}),i)return l=new E(S.from(t.state.schema.text(e.replace(/\r\n?/g,`
10
+ `))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",f=>f(e,o,r,t));if(u)l=u;else{let f=o.marks(),{schema:h}=t.state,p=yt.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(p.serializeNode(h.text(g,f)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),s=C0(n),Xr&&v0(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ve.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!x0.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=M0(Su(l,+d[1],+d[2]),d[4]);else if(l=E.maxOpen(k0(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Su(l,u,f)}return t.someProp("transformPasted",u=>{l=u(l,t,a)}),l}var x0=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function k0(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Xu(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Yu(s[s.length-1],i.length));let d=Gu(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return S.from(s)}return t}function Gu(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,S.from(t));return t}function Xu(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=Xu(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(S.from(Gu(n,t,o+1))))}}function Yu(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Yu(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(S.empty,!0);return t.copy(n.append(r))}function zl(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),o<r-1&&(l=zl(l,e,n,r,o+1,i)),o>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(S.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Su(t,e,n){return e<t.openStart&&(t=new E(zl(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new E(zl(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Qu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Zu(){return document.implementation.createHTMLDocument("title")}var Wr=null;function S0(t){let e=window.trustedTypes;if(!e)return t;if(!Wr){if(Wr=e.defaultPolicy)try{return Wr.createHTML(t)}catch{}Wr=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Wr.createHTML(t)}function C0(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Zu(),r=n.body,o=/<([a-z][^>\s]+)/i.exec(t),i;if((i=o&&Qu[o[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=S0(t),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<n.styleSheets.length;s++){let l=n.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let d=r.querySelectorAll(c.selectorText);for(let u=0;u<d.length;u++)d[u].style.cssText+=c.style.cssText}}}return r}function v0(t){let e=t.querySelectorAll(Ce?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function M0(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;try{a.checkAttrs(r[l+1])}catch{break}o=S.from(a.create(r[l+1],o)),i++,s++}return new E(o,i,s)}var De={},Le={},T0={touchstart:!0,touchmove:!0},Hl=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function A0(t){for(let e in De){let n=De[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{O0(t,r)&&!Yl(t,r)&&(t.editable||!(r.type in Le))&&n(t,r)},T0[e]?{passive:!0}:void 0)}Oe&&t.dom.addEventListener("input",()=>null),Fl(t)}function Pt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function E0(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Fl(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Yl(t,r))})}function Yl(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function O0(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function N0(t,e){!Yl(t,e)&&De[e.type]&&(t.editable||!(e.type in Le))&&De[e.type](t,e)}Le.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!nf(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(It&&Ce&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),lr&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,yn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||w0(t,n)?n.preventDefault():Pt(t,"key")};Le.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Le.keypress=(t,e)=>{let n=e;if(nf(t)||!n.charCode||n.ctrlKey&&!n.altKey||qe&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof R)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Yr(t){return{left:t.clientX,top:t.clientY}}function R0(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ql(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Qr(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function D0(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&$.isSelectable(r)?(Qr(t,new $(n),"pointer"),!0):!1}function L0(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof $&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if($.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Qr(t,$.create(t.state.doc,o),"pointer"),!0):!1}function I0(t,e,n,r,o){return Ql(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?L0(t,n):D0(t,n))}function P0(t,e,n,r){return Ql(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function $0(t,e,n,r){return Ql(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||B0(t,n,r)}function B0(t,e,n){if(n.button!=0)return!1;let r=ef(t,e,!0),o=t.state.doc;return r?(Qr(t,r,"pointer"),r instanceof R&&o.eq(t.state.doc)&&(t.input.mouseDown=new Wl(t,r)),!0):!1}function ef(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?R.create(r,0,r.content.size):null;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return R.create(r,l+1,l+1+s.content.size);if(n&&$.isSelectable(s))return $.create(r,l)}return null}function Zl(t){return Ur(t)}var tf=qe?"metaKey":"ctrlKey";De.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Zl(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&R0(n,t.input.lastClick)&&!n[tf]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(Yr(n));s&&(i=="singleClick"?t.input.mouseDown=new Vl(t,s,n,!!r):(i=="doubleClick"?P0:$0)(t,s.pos,s.inside,n)?n.preventDefault():Pt(t,"pointer"))};var ni=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Vl=class extends ni{constructor(e,n,r,o){super(e),this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[tf],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,s=d.depth?d.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof $&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ge&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Pt(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||$t(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Yr(e))),this.updateAllowDefault(e),this.allowDefault||!n?Pt(this.view,"pointer"):I0(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Oe&&this.mightDrag&&!this.mightDrag.node.isAtom||Ce&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Qr(this.view,z.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):Pt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Pt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Wl=class extends ni{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Pt(this.view,"pointer");let n=this.view.posAtCoords(Yr(e)),r=n&&ef(this.view,n.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Qr(this.view,R.create(o,s,l),"pointer")}};De.touchstart=t=>{t.input.lastTouch=Date.now(),Zl(t),Pt(t,"pointer")};De.touchmove=t=>{t.input.lastTouch=Date.now(),Pt(t,"pointer")};De.contextmenu=t=>Zl(t);function nf(t,e){return t.composing?!0:Oe&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var z0=It?5e3:-1;Le.compositionstart=Le.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof R&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ce&&Pu&&H0(t)))t.markCursor=t.state.storedMarks||n.marks(),Ur(t,!0),t.markCursor=null;else if(Ur(t,!e.selection.empty),Ge&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}rf(t,z0)};function H0(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Le.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,rf(t,20))};function rf(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Ur(t),e))}function of(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function F0(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=By(e.focusNode,e.focusOffset),r=zy(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Ur(t,e=!1){if(!(It&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),of(t),e||t.docView&&t.docView.dirty){let n=ql(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function V0(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Kr=$e&&rn<15||lr&&Wy<604;De.copy=Le.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=Kr?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Gl(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):V0(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function W0(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function j0(t,e){if(!t.dom.parentNode)return;let n=t.input.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();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?qr(t,r.value,null,o,e):qr(t,r.textContent,r.innerHTML,o,e)},50)}function qr(t,e,n,r,o){let i=Xl(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||E.empty)))return!0;if(!i)return!1;let s=W0(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function sf(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Le.paste=(t,e)=>{let n=e;if(t.composing&&!It)return;let r=Kr?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&qr(t,sf(r),r.getData("text/html"),o,n)?n.preventDefault():j0(t,n)};var ri=class{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}},_0=qe?"altKey":"ctrlKey";function lf(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[_0]}De.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Yr(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof $?o.to-1:o.to))){if(r&&r.mightDrag)s=$.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(s=$.create(t.state.doc,u.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:d}=Gl(t,l);(!n.dataTransfer.files.length||!Ce||Iu>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Kr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Kr||n.dataTransfer.setData("text/plain",c),t.dragging=new ri(d,lf(t,n),s)};De.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Le.dragover=Le.dragenter=(t,e)=>e.preventDefault();Le.drop=(t,e)=>{try{U0(t,e,t.dragging)}finally{t.dragging=null}};function U0(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Yr(e));if(!r)return;let o=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Xl(t,sf(e.dataTransfer),Kr?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&lf(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||E.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Ko(t.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&$.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new $(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,g,m,y)=>h=y),a.setSelection(Jl(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}De.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&$t(t)},20))};De.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};De.beforeinput=(t,e)=>{if(It&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,yn(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in Le)De[t]=Le[t];function Jr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var oi=class t{constructor(e,n){this.toDOM=e,this.spec=n||Sn,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new re(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof t&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Jr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},kn=class t{constructor(e,n){this.attrs=e,this.spec=n||Sn}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new re(i,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof t&&Jr(this.attrs,e.attrs)&&Jr(this.spec,e.spec)}static is(e){return e.type instanceof t}destroy(){}},jl=class t{constructor(e,n){this.attrs=e,this.spec=n||Sn}map(e,n,r,o){let i=e.mapResult(n.from+o,1);if(i.deleted)return null;let s=e.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new re(i.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:o}=e.content.findIndex(n.from),i;return o==n.from&&!(i=e.child(r)).isText&&o+i.nodeSize==n.to}eq(e){return this==e||e instanceof t&&Jr(this.attrs,e.attrs)&&Jr(this.spec,e.spec)}destroy(){}},re=class t{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new t(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new t(e,e,new oi(n,r))}static inline(e,n,r,o){return new t(e,n,new kn(r,o))}static node(e,n,r,o){return new t(e,n,new jl(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof kn}get widget(){return this.type instanceof oi}},ir=[],Sn={},Y=class t{constructor(e,n){this.local=e.length?e:ir,this.children=n.length?n:ir}static create(e,n){return n.length?si(n,e,0,Sn):Ee}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==Ee||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Sn)}mapInner(e,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?K0(this.children,s||[],e,n,r,o,i):s?new t(s.sort(Cn),ir):Ee}add(e,n){return n.length?this==Ee?t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=cf(n,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,si(d,l,c+1,Sn)),i+=3}});let s=af(i?df(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new t(s.length?this.local.concat(s).sort(Cn):this.local,o||this.children)}remove(e){return e.length==0||this==Ee?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Ee?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new t(o,r):Ee}forChild(e,n){if(this==Ee)return this;if(n.isLeaf)return t.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof kn){let c=Math.max(i,a.from)-i,d=Math.min(s,a.to)-i;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new t(o.sort(Cn),ir);return r?new ii([l,r]):l}return r||Ee}eq(e){if(this==e)return!0;if(!(e instanceof t)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return ea(this.localsInner(e))}localsInner(e){if(this==Ee)return ir;if(e.inlineContent||!this.local.some(kn.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof kn||n.push(this.local[r]);return n}forEachSet(e){e(this)}};Y.empty=new Y([],[]);Y.removeOverlap=ea;var Ee=Y.empty,ii=class t{constructor(e){this.members=e}map(e,n){let r=this.members.map(o=>o.map(e,n,Sn));return t.from(r)}forChild(e,n){if(n.isLeaf)return Y.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,n);i!=Ee&&(i instanceof t?r=r.concat(i.members):r.push(i))}return t.from(r)}eq(e){if(!(e instanceof t)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?ea(r?n:n.sort(Cn)):ir}static from(e){switch(e.length){case 0:return Ee;case 1:return e[0];default:return new t(e.every(n=>n instanceof Y)?e:e.reduce((n,r)=>n.concat(r instanceof Y?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function K0(t,e,n,r,o,i,s){let l=t.slice();for(let c=0,d=i;c<n.maps.length;c++){let u=0;n.maps[c].forEach((f,h,p,g)=>{let m=g-p-(h-f);for(let y=0;y<l.length;y+=3){let w=l[y+1];if(w<0||f>w+d-u)continue;let x=l[y]+d-u;h>=x?l[y+1]=f<=x?-2:-1:f>=d&&m&&(l[y]+=m,l[y+1]+=m)}u+=m}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=n.map(t[c]+i),u=d-o;if(u<0||u>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-o,{index:p,offset:g}=r.content.findIndex(u),m=r.maybeChild(p);if(m&&g==u&&g+m.nodeSize==h){let y=l[c+2].mapInner(n,m,d+1,t[c]+i+1,s);y!=Ee?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=q0(l,t,e,n,o,i,s),d=si(c,r,0,s);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new Y(e.sort(Cn),l)}function af(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new re(o.from+e,o.to+e,o.type))}return n}function q0(t,e,n,r,o,i,s){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,o,c);u?n.push(u):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function cf(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let i=0,s;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function df(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function si(t,e,n,r){let o=[],i=!1;e.forEach((l,a)=>{let c=cf(t,l,a+n);if(c){i=!0;let d=si(c,l,n+a+1,r);d!=Ee&&o.push(a,a+l.nodeSize,d)}});let s=af(i?df(t):t,-n).sort(Cn);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new Y(s,o):Ee}function Cn(t,e){return t.from-e.from||t.to-e.to}function ea(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Cu(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Cu(e,o,r.copy(i.from,r.to)));break}}}return e}function Cu(t,e,n){for(;e<t.length&&Cn(n,t[e])>0;)e++;t.splice(e,0,n)}function vl(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ee&&e.push(r)}),t.cursorWrapper&&e.push(Y.create(t.state.doc,[t.cursorWrapper.deco])),ii.from(e)}var J0={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},G0=$e&&rn<=11,_l=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},Ul=class{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _l,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);$e&&rn<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Oe&&e.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),G0&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,J0)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(gu(this.view)){if(this.suppressingSelectionUpdates)return $t(this.view);if($e&&rn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&vn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=sr(i))n.add(i);for(let i=e.anchorNode;i;i=sr(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&gu(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<n.length;d++){let u=this.registerMutation(n[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(l=!0))}if(a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ce&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(Ge&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||Q0(e,u)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&li(r)&&(c=ql(e))&&c.eq(z.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$t(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),X0(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Z0(e,a)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||$t(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];n.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if($e&&rn<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==e.target?Se(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?Se(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},vu=new WeakMap,Mu=!1;function X0(t){if(!vu.has(t)&&(vu.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ge,Mu)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Mu=!0}}function Tu(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return vn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Y0(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return Tu(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Tu(t,n):null}function Q0(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Z0(t,e){var n;let{focusNode:r,focusOffset:o}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function eb(t,e,n,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d,u=c.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(d=[{node:u,offset:c.anchorOffset}],li(c)||d.push({node:c.focusNode,offset:c.focusOffset})),Ce&&t.input.lastKeyCode===8)for(let y=s;y>i;y--){let w=o.childNodes[y-1],x=w.pmViewDesc;if(w.nodeName=="BR"&&!x){s=y;break}if(!x||x.size)break}let f=t.state.doc,h=t.someProp("domParser")||Ve.fromSchema(t.state.schema),p=f.resolve(l),g=null,m=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:tb(r),context:p});if(d&&d[0].pos!=null){let y=d[0].pos,w=d[1]&&d[1].pos;w==null&&(w=y),g={anchor:y+l,head:w+l}}return{doc:m,sel:g,from:l,to:a}}var tb=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(Oe&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Oe&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},nb=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function rb(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,O=ql(t,C);if(O&&!t.state.selection.eq(O)){if(Ce&&It&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",N=>N(t,yn(13,"Enter"))))return;let P=t.state.tr.setSelection(O);C=="pointer"?P.setMeta("pointer",!0):C=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),t.dispatch(P)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=eb(t,e,n,o),d=t.state.doc,u=d.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=sb(u.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(lr&&t.input.lastIOSEnter>Date.now()-225||It)&&o.some(C=>C.nodeType==1&&!nb.test(C.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",C=>C(t,yn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof R&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let C=Au(t,t.state.doc,c.sel);if(C&&!C.eq(t.state.selection)){let O=t.state.tr.setSelection(C);i&&O.setMeta("composition",i),t.dispatch(O)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof R&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),$e&&rn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),m=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),w=g.sameParent(m)&&g.parent.inlineContent&&y.end()>=p.endA;if((lr&&t.input.lastIOSEnter>Date.now()-225&&(!w||o.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&(!g.sameParent(m)||!g.parent.inlineContent)&&g.pos<m.pos&&!/\S/.test(c.doc.textBetween(g.pos,m.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,yn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&ib(d,p.start,p.endA,g,m)&&t.someProp("handleKeyDown",C=>C(t,yn(8,"Backspace")))){It&&Ce&&t.domObserver.suppressSelectionUpdates();return}Ce&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),It&&!w&&g.start()!=m.start()&&m.parentOffset==0&&g.depth==m.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,m=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,yn(13,"Enter"))})},20));let x=p.start,b=p.endA,k=C=>{let O=C||t.state.tr.replace(x,b,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let P=Au(t,O.doc,c.sel);P&&!(Ce&&t.composing&&P.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(P.head==x||P.head==O.mapping.map(b)-1)||$e&&P.empty&&P.head==x)&&O.setSelection(P)}return i&&O.setMeta("composition",i),O.scrollIntoView()},v;if(w)if(g.pos==m.pos){$e&&rn<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>$t(t),20));let C=k(t.state.tr.delete(x,b)),O=d.resolve(p.start).marksAcross(d.resolve(p.endA));O&&C.ensureMarks(O),t.dispatch(C)}else if(p.endA==p.endB&&(v=ob(g.parent.content.cut(g.parentOffset,m.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let C=k(t.state.tr);v.type=="add"?C.addMark(x,b,v.mark):C.removeMark(x,b,v.mark),t.dispatch(C)}else if(g.parent.child(g.index()).isText&&g.index()==m.index()-(m.textOffset?0:1)){let C=g.parent.textBetween(g.parentOffset,m.parentOffset),O=()=>k(t.state.tr.insertText(C,x,b));t.someProp("handleTextInput",P=>P(t,x,b,C,O))||t.dispatch(O())}else t.dispatch(k());else t.dispatch(k())}function Au(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Jl(t,e.resolve(n.anchor),e.resolve(n.head))}function ob(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(S.from(c).eq(t))return{mark:l,type:s}}function ib(t,e,n,r,o){if(n-e<=o.pos-r.pos||Ml(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(Ml(i,!0,!0));return!s.parent.isTextblock||s.pos>n||Ml(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Ml(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function sb(t,e,n,r,o){let i=t.findDiffStart(e,n),s=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,s,l);if(o=="end"){let d=Math.max(0,i-Math.min(a,c));r-=a+d-i}if(a<i&&s<l){let d=r<=i&&r>=a?i-r:0;i-=d,c=i+(c-a),a=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var lb=Xl,ab=Ur,ar=class{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Hl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Du),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Nu(this),Ou(this),this.nodeViews=Ru(this),this.docView=du(this.state.doc,Eu(this),vl(this),this.dom,this),this.domObserver=new Ul(this,(r,o,i,s)=>rb(this,r,o,i,s)),this.domObserver.start(),A0(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Fl(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Du),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(of(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Ru(this);db(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Fl(this),this.editable=Nu(this),Ou(this);let a=vl(this),c=Eu(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Uy(this);if(s){this.domObserver.stop();let h=u&&($e||Ce)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&cb(o.selection,e.selection);if(u){let g=Ce?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=F0(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=du(e.doc,c,a,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&f0(this)&&p.delaySelUpdate())?$t(this,h):(Ku(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Ky(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof $){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&iu(this,n.getBoundingClientRect(),e)}else iu(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new ri(e.slice,e.move,o<0?void 0:$.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if($e){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&qy(this.dom),$t(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Qy(this,e)}coordsAtPos(e,n=1){return Fu(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return r0(this,n||this.state,e)}pasteHTML(e,n){return qr(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return qr(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Gl(this,e)}destroy(){this.docView&&(E0(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Py())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return N0(this,e)}domSelectionRange(){let e=this.domSelection();return e?Oe&&this.root.nodeType===11&&Fy(this.dom.ownerDocument)==this.dom&&Y0(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};ar.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Eu(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[re.node(0,t.state.doc.content.size,e)]}function Ou(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:re.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Nu(t){return!t.someProp("editable",e=>e(t.state)===!1)}function cb(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Ru(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function db(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function Du(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Bt={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:"'"},ci={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ub=typeof navigator<"u"&&/Mac/.test(navigator.platform),fb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(fe=0;fe<10;fe++)Bt[48+fe]=Bt[96+fe]=String(fe);var fe;for(fe=1;fe<=24;fe++)Bt[fe+111]="F"+fe;var fe;for(fe=65;fe<=90;fe++)Bt[fe]=String.fromCharCode(fe+32),ci[fe]=String.fromCharCode(fe);var fe;for(ai in Bt)ci.hasOwnProperty(ai)||(ci[ai]=Bt[ai]);var ai;function uf(t){var e=ub&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||fb&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ci:Bt)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var hb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pb=typeof navigator<"u"&&/Win/.test(navigator.platform);function mb(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))hb?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function gb(t){let e=Object.create(null);for(let n in t)e[mb(n)]=t[n];return e}function na(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function ff(t){return new F({props:{handleKeyDown:Zr(t)}})}function Zr(t){let e=gb(t);return function(n,r){let o=uf(r),i,s=e[na(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[na(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(pb&&r.ctrlKey&&r.altKey)&&(i=Bt[r.keyCode])&&i!=o){let l=e[na(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}function io(t){let{state:e,transaction:n}=t,{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var On=class vf{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:n,state:r}=this,{view:o}=n,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{let u=a(...d)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(f=>f===!0)),u={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...g)=>{let m=this.buildProps(c,n),y=h(...g)(m);return l.push(y),u}])),run:d};return u}static createFakeChain(){let e=new Proxy({},{get:(n,r)=>{if(r!=="then")return r==="run"?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:n,state:r}=this,o=!1,i=e||r.tr,s=this.buildProps(i,o);return{...Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,o)}}static createFallbackCan(){let e=vf.createFakeChain();return new Proxy({chain:()=>e},{get:(n,r)=>{if(r!=="then")return r==="chain"?n.chain:()=>!1}})}buildProps(e,n=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:e,editor:o,view:s,state:io({state:i,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}},yb=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var n;e.dom.blur(),(n=window)===null||n===void 0||(n=n.getSelection())===null||n===void 0||n.removeAllRanges()}}),!0),bb=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),wb=()=>({state:t,tr:e,dispatch:n})=>{let{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;let p=Rt(h);if(l.type.isTextblock){let{defaultType:g}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},xb=t=>e=>t(e),kb=()=>({state:t,dispatch:e})=>ml(t,e),Sb=(t,e)=>({editor:n,tr:r})=>{let{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new R(r.doc.resolve(Math.max(s-1,0)))),!0},Cb=()=>({tr:t,dispatch:e})=>{let{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;let o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let s=o.before(i),l=o.after(i);t.delete(s,l).scrollIntoView()}return!0}return!1};function ce(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var vb=t=>({tr:e,state:n,dispatch:r})=>{let o=ce(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let l=i.before(s),a=i.after(s);e.delete(l,a).scrollIntoView()}return!0}return!1},Mb=t=>({tr:e,dispatch:n})=>{let{from:r,to:o}=t;return n&&e.delete(r,o),!0},Tb=t=>t.content?/^text(\*|\+)/.test(t.content):!1,hf=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;let r=e.nodes[t.parent.type.name].spec;return Tb(r)?n==="left"?t.start()-1:t.end()+1:t.pos},Ab=(t,e,n)=>({from:hf(t,n,"left"),to:hf(e,n,"right")}),Eb=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){let n=t.tr,{ranges:r}=t.selection,o=n.steps.length;r.forEach(i=>{let s=n.mapping.slice(o),l=n.doc.resolve(s.map(i.$from.pos)),a=n.doc.resolve(s.map(i.$to.pos)),{from:c,to:d}=Ab(l,a,t.schema);n.deleteRange(c,d)}),n.selection.empty||n.setSelection(R.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},Ob=()=>({commands:t})=>t.keyboardShortcut("Enter"),Nb=()=>({state:t,dispatch:e})=>pl(t,e);function gi(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ro(t,e,n={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:gi(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function Mf(t,e,n={}){return t.find(r=>r.type===e&&ro(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function pf(t,e,n={}){return!!Mf(t,e,n)}function yi(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(a=>a.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(a=>a.type===e))return;if(!n){let a=r.node.marks.find(c=>c.type===e);a&&(n=a.attrs)}if(!Mf([...r.node.marks],e,n))return;let o=r.index,i=t.start()+r.offset,s=o+1,l=i+r.node.nodeSize;for(;o>0&&pf([...t.parent.child(o-1).marks],e,n);)o-=1,i-=t.parent.child(o).nodeSize;for(;s<t.parent.childCount&&pf([...t.parent.child(s).marks],e,n);)l+=t.parent.child(s).nodeSize,s+=1;return{from:i,to:l}}function xt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var Rb=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=xt(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:d}=l;if(o){let u=yi(a,i,e);if(u&&u.from<=c&&u.to>=d){let f=R.create(s,u.from,u.to);n.setSelection(f)}}return!0},Db=t=>e=>{let n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function hr(t){return t instanceof R}function wt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function hi(t,e=null){if(!e)return null;let n=z.atStart(t),r=z.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;let o=n.from,i=r.to;return e==="all"?R.create(t,wt(0,o,i),wt(t.content.size,o,i)):R.create(t,wt(e,o,i),wt(e,o,i))}function oo(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Nn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Tf(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Lb=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};let s=()=>{(Nn()||oo())&&r.dom.focus(),Tf()&&!Nn()&&!oo()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!hr(n.state.selection))return s(),!0;let l=hi(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Ib=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),Pb=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Af=t=>{let e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){let r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Af(r)}return t};function dr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");let e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Af(n)}function Ef(t){return typeof t?.nodesBetween=="function"}function Rn(t,e,n){if(Ef(t))return t;let r=typeof t=="object"&&t!==null;n={slice:!0,parseOptions:{},...n};let o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return S.fromArray(t.map(s=>e.nodeFromJSON(s)));let i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Rn("",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="",a=new Gn({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ve.fromSchema(a).parseSlice(dr(t),n.parseOptions):Ve.fromSchema(a).parse(dr(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Ve.fromSchema(e);return n.slice?i.parseSlice(dr(t),n.parseOptions).content:i.parse(dr(t),n.parseOptions)}return Rn("",e,n)}function Of(t){return!("type"in t)}function da(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof be||o instanceof ue))return;let i=t.mapping.maps[r],s=0;i.forEach((l,a,c,d)=>{s===0&&(s=d)}),t.setSelection(z.near(t.doc.resolve(s),n))}var $b=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l,a=m=>{i.emit("contentError",{editor:i,error:m,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Rn(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(m){a(m)}try{var s;l=Rn(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(m){return a(m),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0,p=Of(l)?l.content:[l];if(p.forEach(m=>{m.check(),f=f?m.isText&&m.marks.length===0:!1,h=h?m.isBlock:!1}),d===u&&h){let{parent:m}=r.doc.resolve(d);m.isTextblock&&!m.type.spec.code&&!m.childCount&&(d-=1,u+=1)}let g;if(f)Array.isArray(e)?g=e.map(m=>m.text||"").join(""):Ef(e)?g=p.map(m=>{var y;return(y=m.text)!==null&&y!==void 0?y:""}).join(""):typeof e=="object"&&e&&e.text?g=e.text:g=e,r.insertText(g,d,u);else{g=S.from(p);let m=r.doc.resolve(d),y=m.node(),w=m.parentOffset===0,x=y.isText||y.isTextblock,b=y.content.size>0;w&&x&&b&&h&&(d=Math.max(0,d-1)),r.replaceWith(d,u,p)}n.updateSelection&&da(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:g})}return!0};function pr(t){for(let e=0;e<t.edgeCount;e+=1){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Bb=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{pos:o,attrs:i,content:s,updateSelection:l=!0}=t,a;typeof o=="number"?a=e.doc.resolve(o):o?a=o:a=e.selection.$from;let c=pr(a.parent.contentMatchAt(a.index()));if(!c)return!1;let d=Object.keys(c.spec.attrs||{}),u=i?Object.fromEntries(Object.entries(i).filter(([h])=>d.includes(h))):{},f;if(s){let h=Rn(s,r.schema);f=c.createAndFill(u,h)}else f=c.createAndFill(u);return f?(n&&(e.insert(a.pos,f),l&&da(e,e.steps.length-1,-1)),!0):!1},zb=()=>({state:t,dispatch:e})=>qd(t,e),Hb=()=>({state:t,dispatch:e})=>Jd(t,e),Fb=()=>({state:t,dispatch:e})=>sl(t,e),Vb=()=>({state:t,dispatch:e})=>cl(t,e),Wb=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Zn(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},jb=()=>({state:t,dispatch:e,tr:n})=>{try{let r=Zn(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},_b=()=>({state:t,dispatch:e})=>jd(t,e),Ub=()=>({state:t,dispatch:e})=>_d(t,e);function ua(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Kb(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Nn()||ua()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var qb=t=>({editor:e,view:n,tr:r,dispatch:o})=>{let i=Kb(t).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{let d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function ct(t,e,n={}){let{from:r,to:o,empty:i}=t.selection,s=e?ce(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(d,u)=>{if(d.isText)return;let f=Math.max(r,u),h=Math.min(o,u+d.nodeSize);l.push({node:d,from:f,to:h})});let a=o-r,c=l.filter(d=>s?s.name===d.node.type.name:!0).filter(d=>ro(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,u)=>d+u.to-u.from,0)>=a}var Jb=(t,e={})=>({state:n,dispatch:r})=>ct(n,ce(t,n.schema),e)?Gd(n,r):!1,Gb=()=>({state:t,dispatch:e})=>gl(t,e),Xb=t=>({state:e,dispatch:n})=>{let r=ce(t,e.schema);return tu(r)(e,n)},Yb=()=>({state:t,dispatch:e})=>fl(t,e);function so(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ia(t,e){let n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var Qb=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=so(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=ce(t,r.schema)),l==="mark"&&(s=xt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{i&&i===d.type&&(a=!0,o&&n.setNodeMarkup(u,void 0,ia(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(f=>{s===f.type&&(a=!0,o&&n.addMark(u,u+d.nodeSize,s.create(ia(f.attrs,e))))})})}),a},Zb=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),ew=()=>({tr:t,dispatch:e})=>{if(e){let n=new Ae(t.doc);t.setSelection(n)}return!0},tw=()=>({state:t,dispatch:e})=>ll(t,e),nw=()=>({state:t,dispatch:e})=>dl(t,e),rw=()=>({state:t,dispatch:e})=>Xd(t,e),ow=()=>({state:t,dispatch:e})=>bl(t,e),iw=()=>({state:t,dispatch:e})=>yl(t,e);function pi(t,e,n={},r={}){return Rn(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var sw=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{let{doc:a}=i;if(r.preserveWhitespace!=="full"){let c=pi(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});if(s){let d=Of(c)?c.content:[c];i.replaceWith(0,a.content.size,d).setMeta("preventUpdate",!n)}return!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function fa(t,e){let n=xt(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function bi(t,e){let n=new Zt(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function mr(t,e){let n=[];return t.descendants((r,o)=>{e(r)&&n.push({node:r,pos:o})}),n}function ha(t,e,n){let r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function dt(t,e){for(let n=t.depth;n>0;n-=1){let r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Ht(t){return e=>dt(e.$from,t)}function B(t,e,n){return t.config[e]===void 0&&t.parent?B(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?B(t.parent,e,n):null}):t.config[e]}function wi(t){return t.map(e=>{let n=B(e,"addExtensions",{name:e.name,options:e.options,storage:e.storage});return n?[e,...wi(n())]:e}).flat(10)}function lo(t,e){let n=yt.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function pa(t){return typeof t=="function"}function G(t,e=void 0,...n){return pa(t)?e?t.bind(e)(...n):t(...n):t}function Nf(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Dn(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function ma(t){let e=[],{nodeExtensions:n,markExtensions:r}=Dn(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{let d=B(c,"addGlobalAttributes",{name:c.name,options:c.options,storage:c.storage,extensions:o});d&&d().forEach(u=>{let f;Array.isArray(u.types)?f=u.types:u.types==="*"?f=a:u.types==="nodes"?f=s:u.types==="marks"?f=l:f=[],f.forEach(h=>{Object.entries(u.attributes).forEach(([p,g])=>{e.push({type:h,name:p,attribute:{...i,...g}})})})})}),o.forEach(c=>{let d=B(c,"addAttributes",{name:c.name,options:c.options,storage:c.storage});if(!d)return;let u=d();Object.entries(u).forEach(([f,h])=>{let p={...i,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:c.name,name:f,attribute:p})})}),e}function lw(t){let e=[],n="",r=!1,o=!1,i=0,s=t.length;for(let l=0;l<s;l+=1){let a=t[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function mf(t){let e=[],n=lw(t||""),r=n.length;for(let o=0;o<r;o+=1){let i=n[o],s=i.indexOf(":");if(s===-1)continue;let l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function L(...t){return t.filter(e=>!!e).reduce((e,n)=>{let r={...e};return Object.entries(n).forEach(([o,i])=>{if(o==="__proto__"){Object.defineProperty(r,o,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!r[o]){r[o]=i;return}if(o==="class"){let s=i?String(i).split(" "):[],l=r[o]?r[o].split(" "):[],a=s.filter(c=>!l.includes(c));r[o]=[...l,...a].join(" ")}else if(o==="style"){let s=new Map([...mf(r[o]),...mf(i)]);r[o]=Array.from(s.entries()).map(([l,a])=>`${l}: ${a}`).join("; ")}else r[o]=i}),r},{})}function zt(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>L(n,r),{})}function Rf(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function sa(t,e){return"style"in t?t:{...t,getAttrs:n=>{let r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(n):Rf(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function gf(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Nf(n)?!1:n!=null))}function yf(t){var e,n;let r={};return!(!(t==null||(e=t.attribute)===null||e===void 0)&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),(t==null||(n=t.attribute)===null||n===void 0?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function ga(t,e){var n;let r=ma(t),{nodeExtensions:o,markExtensions:i}=Dn(t),s=(n=o.find(c=>B(c,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(o.map(c=>{let d=r.filter(m=>m.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=gf({...t.reduce((m,y)=>{let w=B(y,"extendNodeSchema",u);return{...m,...w?w(c):{}}},{}),content:G(B(c,"content",u)),marks:G(B(c,"marks",u)),group:G(B(c,"group",u)),inline:G(B(c,"inline",u)),atom:G(B(c,"atom",u)),selectable:G(B(c,"selectable",u)),draggable:G(B(c,"draggable",u)),code:G(B(c,"code",u)),whitespace:G(B(c,"whitespace",u)),linebreakReplacement:G(B(c,"linebreakReplacement",u)),defining:G(B(c,"defining",u)),isolating:G(B(c,"isolating",u)),attrs:Object.fromEntries(d.map(yf))}),h=G(B(c,"parseHTML",u));h&&(f.parseDOM=h.map(m=>sa(m,d)));let p=B(c,"renderHTML",u);p&&(f.toDOM=m=>p({node:m,HTMLAttributes:zt(m,d)}));let g=B(c,"renderText",u);return g&&(f.toText=g),[c.name,f]})),a=Object.fromEntries(i.map(c=>{let d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=gf({...t.reduce((g,m)=>{let y=B(m,"extendMarkSchema",u);return{...g,...y?y(c):{}}},{}),inclusive:G(B(c,"inclusive",u)),excludes:G(B(c,"excludes",u)),group:G(B(c,"group",u)),spanning:G(B(c,"spanning",u)),code:G(B(c,"code",u)),attrs:Object.fromEntries(d.map(yf))}),h=G(B(c,"parseHTML",u));h&&(f.parseDOM=h.map(g=>sa(g,d)));let p=B(c,"renderHTML",u);return p&&(f.toDOM=g=>p({mark:g,HTMLAttributes:zt(g,d)})),[c.name,f]}));return new Gn({topNode:s,nodes:l,marks:a})}function Df(t){let e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function ur(t){return t.sort((n,r)=>{let o=B(n,"priority")||100,i=B(r,"priority")||100;return o>i?-1:o<i?1:0})}function xi(t){let e=ur(wi(t)),n=Df(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function ki(t,e){return ga(xi(t),e)}function aw(t,e){let n=ki(e);return lo(ge.fromJSON(n,t).content,n)}function cw(t,e){let n=ki(e),r=dr(t);return Ve.fromSchema(n).parse(r).toJSON()}function ya(t,e,n){let{from:r,to:o}=e,{blockSeparator:i=`
11
+
12
+ `,textSerializers:s={}}=n||{},l="";return t.nodesBetween(r,o,(a,c,d,u)=>{a.isBlock&&c>r&&(l+=i);let f=s?.[a.type.name];if(f)return d&&(l+=f({node:a,pos:c,parent:d,index:u,range:e})),!1;if(a.isText){var h;l+=a==null||(h=a.text)===null||h===void 0?void 0:h.slice(Math.max(r,c)-c,o-c)}}),l}function ba(t,e){return ya(t,{from:0,to:t.content.size},e)}function Si(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function dw(t,e,n){let{blockSeparator:r=`
13
+
14
+ `,textSerializers:o={}}=n||{},i=ki(e);return ba(ge.fromJSON(i,t),{blockSeparator:r,textSerializers:{...Si(i),...o}})}function Lf(t,e){let n=ce(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function Ci(t,e){let n=so(typeof e=="string"?e:e.name,t.schema);return n==="node"?Lf(t,e):n==="mark"?fa(t,e):{}}function If(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function uw(t){let e=If(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Ln(t){let{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),uw(r)}function Pf(t,e=0){let n=t.type===t.type.schema.topNodeType?0:1,r=e,o=r+t.nodeSize,i=t.marks.map(a=>{let c={type:a.type.name};return Object.keys(a.attrs).length&&(c.attrs={...a.attrs}),c}),s={...t.attrs},l={type:t.type.name,from:r,to:o};return Object.keys(s).length&&(l.attrs=s),i.length&&(l.marks=i),t.content.childCount&&(l.content=[],t.forEach((a,c)=>{var d;(d=l.content)===null||d===void 0||d.push(Pf(a,e+c+n))})),t.text&&(l.text=t.text),l}function ao(t,e,n){let r=[];return t===e?n.resolve(t).marks().forEach(o=>{let i=yi(n.resolve(t),o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(t,e,(o,i)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var wa=(t,e,n,r=20)=>{let o=t.doc.resolve(n),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);l?.type.name===e?s=l:i-=1}return[s,i]},xa=t=>{let e=t.depth-1;if(e<0)return null;let n=t.index(e);return n===0?null:t.node(e).child(n-1)};function An(t,e){return e.nodes[t]||e.marks[t]||null}function no(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{let o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var $f=(t,e=500)=>{let n="",r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let d=((a=(c=o.type.spec).toText)===null||a===void 0?void 0:a.call(c,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),n};function mi(t,e,n={}){let{empty:r,ranges:o}=t.selection,i=e?xt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>ro(d.attrs,n,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:d,$to:u})=>{let f=d.pos,h=u.pos;t.doc.nodesBetween(f,h,(p,g)=>{if(i&&p.inlineContent&&!p.type.allowsMarkType(i))return!1;if(!p.isText&&!p.marks.length)return;let m=Math.max(f,g),y=Math.min(h,g+p.nodeSize),w=y-m;s+=w,l.push(...p.marks.map(x=>({mark:x,from:m,to:y})))})}),s===0)return!1;let a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>ro(d.mark.attrs,n,{strict:!1})).reduce((d,u)=>d+u.to-u.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,u)=>d+u.to-u.from,0);return(a>0?a+c:a)>=s}function vi(t,e,n={}){if(!e)return ct(t,null,n)||mi(t,null,n);let r=so(e,t.schema);return r==="node"?ct(t,e,n):r==="mark"?mi(t,e,n):!1}var ka=(t,e)=>{let{$from:n,$to:r,$anchor:o}=t.selection;if(e){let i=Ht(l=>l.type.name===e)(t.selection);if(!i)return!1;let s=t.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},Sa=t=>{let{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function la(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function fi(t,e){let{nodeExtensions:n}=Dn(e),r=n.find(i=>i.name===t);if(!r)return!1;let o=G(B(r,"group",{name:r.name,options:r.options,storage:r.storage}));return typeof o!="string"?!1:o.split(" ").includes("list")}function In(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){if(n){if(t.type.name==="hardBreak")return!0;if(t.isText){var r;return!/\S/.test((r=t.text)!==null&&r!==void 0?r:"")}}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(In(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function co(t){return t instanceof $}function fw({selection:t,pos:e,nodeSize:n,selectedOnTextSelection:r=!1}){let{from:o,to:i}=t;return!!(o<=e&&i>=e+n||r&&hr(t)&&o>e&&i<e+n)}function Ft(t){if(t===null||typeof t!="object")return!1;let e=t;return!(typeof e.apply!="function"||typeof e.getMap!="function"||typeof e.invert!="function"||typeof e.map!="function"||typeof e.merge!="function"||typeof e.toJSON!="function")}function hw(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="addMark")}function pw(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="addNodeMark")}function mw(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="attr")}function gw(t){return t===null||typeof t!="object"?!1:"forEachCell"in t&&typeof t.forEachCell=="function"}function yw(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="docAttr")}function Bf(t){if(t===null||typeof t!="object")return!1;let e=t;return!(!Array.isArray(e.content)||typeof e.size!="number"||typeof e.nodesBetween!="function"||typeof e.descendants!="function"||typeof e.textBetween!="function"||typeof e.append!="function"||typeof e.cut!="function"||typeof e.eq!="function"||typeof e.child!="function"||typeof e.forEach!="function")}function bw(t){return t===null||typeof t!="object"?!1:"node"in t&&t.node!=null}function ww(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="removeMark")}function xw(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="removeNodeMark")}function kw(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="replaceAround")}function Sw(t){if(t===null||typeof t!="object")return!1;let e=t;if(!Ft(e))return!1;let n=e.toJSON();return!(n===null||typeof n!="object"||n.stepType!=="replace")}function Cw(t){if(t===null||typeof t!="object")return!1;let e=t,n=Number.isInteger(e.openStart)&&e.openStart>=0,r=Number.isInteger(e.openEnd)&&e.openEnd>=0,o=typeof e.size=="number"&&typeof e.eq=="function"&&typeof e.toJSON=="function";if(!n||!r||!o)return!1;let i=e.content;return!(i===null||typeof i!="object"||!Bf(i))}function vw(t){if(t===null||typeof t!="object")return!1;let e=t,n=e.doc!==null&&typeof e.doc=="object"&&e.failed===null,r=typeof e.failed=="string"&&e.doc===null;return!(!n&&!r)}var Ca=class zf{constructor(e){this.position=e}static fromJSON(e){return new zf(e.position)}toJSON(){return{position:this.position}}};function Hf(t,e){let n=e.mapping.mapResult(t.position);return{position:new Ca(n.pos),mapResult:n}}function Ff(t){return new Ca(t)}function va(t,e,n){let o=t.state.doc.content.size,i=wt(e,0,o),s=wt(n,0,o),l=t.coordsAtPos(i),a=t.coordsAtPos(s,-1),c=Math.min(l.top,a.top),d=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h={top:c,bottom:d,left:u,right:f,width:f-u,height:d-c,x:u,y:c};return{...h,toJSON:()=>h}}function Vf({json:t,validMarks:e,validNodes:n,options:r,rewrittenContent:o=[]}){return t.marks&&Array.isArray(t.marks)&&(t.marks=t.marks.filter(i=>{if(i==null)return!1;let s=typeof i=="string"?i:i.type;return e.has(s)?!0:(o.push({original:JSON.parse(JSON.stringify(i)),unsupported:s}),!1)})),t.content&&Array.isArray(t.content)&&(t.content=t.content.map(i=>i==null?null:Vf({json:i,validMarks:e,validNodes:n,options:r,rewrittenContent:o}).json).filter(i=>i!=null)),t.type&&!n.has(t.type)?(o.push({original:JSON.parse(JSON.stringify(t)),unsupported:t.type}),t.content&&Array.isArray(t.content)&&r?.fallbackToParagraph!==!1?(t.type="paragraph",{json:t,rewrittenContent:o}):{json:null,rewrittenContent:o}):{json:t,rewrittenContent:o}}function Mw(t,e,n){return Vf({json:t,validNodes:new Set(Object.keys(e.nodes)),validMarks:new Set(Object.keys(e.marks)),options:n})}function Tw(t,e,n){let{selection:r}=e,o=null;if(hr(r)&&(o=r.$cursor),o){var i;let l=(i=t.storedMarks)!==null&&i!==void 0?i:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(a=>a.type.excludes(n)))}let{ranges:s}=r;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){let h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(n));c=h&&p}return!c}),c})}var Aw=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=n,{empty:s,ranges:l}=i,a=xt(t,r.schema);if(o)if(s){let c=fa(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{let p=Math.max(h,d),g=Math.min(h+f.nodeSize,u);f.marks.find(m=>m.type===a)?f.marks.forEach(m=>{a===m.type&&n.addMark(p,g,a.create({...m.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return Tw(r,n,a)},Ew=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Ow=(t,e={})=>({state:n,dispatch:r,chain:o})=>{let i=ce(t,n.schema),s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>wl(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>wl(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Nw=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,o=wt(t,0,r.content.size),i=$.create(r,o);e.setSelection(i)}return!0},Rw=(t,e)=>({tr:n,state:r,dispatch:o})=>{let{selection:i}=r,s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},Dw=t=>({tr:e,dispatch:n})=>{if(n){let{doc:r}=e,{from:o,to:i}=typeof t=="number"?{from:t,to:t}:t,s=R.atStart(r).from,l=R.atEnd(r).to,a=wt(o,s,l),c=wt(i,s,l),d=R.create(r,a,c);e.setSelection(d)}return!0},Lw=t=>({state:e,dispatch:n})=>{let r=ce(t,e.schema);return nu(r)(e,n)};function bf(t,e){let n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){let r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var Iw=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,d=no(c,l.node().type.name,l.node().attrs);if(i instanceof $&&i.node.isBlock)return!l.parentOffset||!Ke(s,l.pos)?!1:(r&&(t&&bf(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:pr(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=u&&f?[{type:f,attrs:d}]:void 0,p=Ke(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ke(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(i instanceof R&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){let g=e.mapping.map(l.before()),m=e.doc.resolve(g);l.node(-1).canReplaceWith(m.index(),m.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&bf(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},Pw=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{let s=ce(t,r.schema),{$from:l,$to:a}=r.selection,c=r.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let d=l.node(-1);if(d.type!==s)return!1;let u=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==s||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){var f;let y=S.empty,w=l.index(-1)?1:l.index(-2)?2:3;for(let O=l.depth-w;O>=l.depth-3;O-=1)y=S.from(l.node(O).copy(y));let x=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,b={...no(u,l.node().type.name,l.node().attrs),...e},k=((f=s.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(b))||void 0;y=y.append(S.from(s.createAndFill(null,k)||void 0));let v=l.before(l.depth-(w-1));n.replace(v,l.after(-x),new E(y,4-w,0));let C=-1;n.doc.nodesBetween(v,n.doc.content.size,(O,P)=>{if(C>-1)return!1;O.isTextblock&&O.content.size===0&&(C=P+1)}),C>-1&&n.setSelection(R.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}let h=a.pos===l.end()?d.contentMatchAt(0).defaultType:null,p={...no(u,d.type.name,d.attrs),...e},g={...no(u,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,a.pos);let m=h?[{type:s,attrs:p},{type:h,attrs:g}]:[{type:s,attrs:p}];if(!Ke(n.doc,l.pos,2))return!1;if(o){let{selection:y,storedMarks:w}=r,{splittableMarks:x}=i.extensionManager,b=w||y.$to.parentOffset&&y.$from.marks();if(n.split(l.pos,2,m).scrollIntoView(),!b||!o)return!0;let k=b.filter(v=>x.includes(v.type.name));n.ensureMarks(k)}return!0};function wf(t){return!t||t==="1"?null:t}function Wf(t,e){return wf(t)===wf(e)}var ra=(t,e)=>{let n=Ht(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&lt(t.doc,n.pos))||!Wf(n.node.attrs.type,o?.attrs.type)||t.join(n.pos),!0},oa=(t,e)=>{let n=Ht(i=>i.type===e)(t.selection);if(!n)return!0;let r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let o=t.doc.nodeAt(r);return!(n.node.type===o?.type&&lt(t.doc,r))||!Wf(n.node.attrs.type,o?.attrs.type)||t.join(r),!0};function $w(t){let e=t.doc,n=e.firstChild;if(!n)return null;let r=e.resolve(1),o=e.resolve(n.nodeSize-1);return R.between(r,o)}var Bw=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{let{extensions:u,splittableMarks:f}=o.extensionManager,h=ce(t,s.schema),p=ce(e,s.schema),{selection:g,storedMarks:m}=s,{$from:y,$to:w}=g,x=y.blockRange(w),b=m||g.$to.parentOffset&&g.$from.marks();if(!x)return!1;let k=Ht(q=>fi(q.type.name,u))(g),v=g.from===0&&g.to===s.doc.content.size,C=s.doc.content.content,O=C.length===1?C[0]:null,P=v&&O&&fi(O.type.name,u)?{node:O,pos:0,depth:0}:null,N=k??P,_=!!k&&x.depth>=1&&x.depth-k.depth<=1,U=!!P;if((_||U)&&N){if(N.node.type===h)return v&&U?a().command(({tr:q,dispatch:I})=>{let M=$w(q);return M?(q.setSelection(M),I&&I(q),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(fi(N.node.type.name,u)&&h.validContent(N.node.content))return a().command(()=>(i.setNodeMarkup(N.pos,h),!0)).command(()=>ra(i,h)).command(()=>oa(i,h)).run()}return!n||!b||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>ra(i,h)).command(()=>oa(i,h)).run():a().command(()=>{let q=d().wrapInList(h,r),I=b.filter(M=>f.includes(M.type.name));return i.ensureMarks(I),q?!0:c.clearNodes()}).wrapInList(h,r).command(()=>ra(i,h)).command(()=>oa(i,h)).run()},zw=(t,e={},n={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=n,s=xt(t,r.schema);return mi(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},Hw=(t,e,n={})=>({state:r,commands:o})=>{let i=ce(t,r.schema),s=ce(e,r.schema),l=ct(r,i,n),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},Fw=(t,e={})=>({state:n,commands:r})=>{let o=ce(t,n.schema);return ct(n,o,e)?r.lift(o):r.wrapIn(o,e)},Vw=()=>({state:t,dispatch:e})=>{let n=t.plugins;for(let r=0;r<n.length;r+=1){let o=n[r],i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){let s=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},Ww=(t={})=>({tr:e,dispatch:n,editor:r})=>{let{ignoreClearable:o=!1}=t,{selection:i}=e,{empty:s,ranges:l}=i;if(s)return!0;let{nonClearableMarks:a}=r.extensionManager;if(n){let c=Object.values(r.schema.marks).filter(d=>o||!a.includes(d.name));l.forEach(d=>{for(let u of c)e.removeMark(d.$from.pos,d.$to.pos,u)})}return!0},jw=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let{extendEmptyMarkRange:i=!1}=e,{selection:s}=n,l=xt(t,r.schema),{$from:a,empty:c,ranges:d}=s;if(!o)return!0;if(c&&i){var u;let{from:f,to:h}=s,p=yi(a,l,(u=a.marks().find(g=>g.type===l))===null||u===void 0?void 0:u.attrs);p&&(f=p.from,h=p.to),n.removeMark(f,h,l)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},_w=t=>({tr:e,state:n,dispatch:r})=>{let{selection:o}=n,i,s;return typeof t=="number"?(i=t,s=t):t&&"from"in t&&"to"in t?(i=t.from,s=t.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;let c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},Uw=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null,l=so(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=ce(t,r.schema)),l==="mark"&&(s=xt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{let d=c.$from.pos,u=c.$to.pos,f,h,p,g;n.selection.empty?r.doc.nodesBetween(d,u,(m,y)=>{i&&i===m.type&&(a=!0,p=Math.max(y,d),g=Math.min(y+m.nodeSize,u),f=y,h=m)}):r.doc.nodesBetween(d,u,(m,y)=>{y<d&&i&&i===m.type&&(a=!0,p=Math.max(y,d),g=Math.min(y+m.nodeSize,u),f=y,h=m),y>=d&&y<=u&&(i&&i===m.type&&(a=!0,o&&n.setNodeMarkup(y,void 0,{...m.attrs,...e})),s&&m.marks.length&&m.marks.forEach(w=>{if(s===w.type&&(a=!0,o)){let x=Math.max(y,d),b=Math.min(y+m.nodeSize,u);n.addMark(x,b,s.create({...w.attrs,...e}))}}))}),h&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(m=>{s===m.type&&o&&n.addMark(p,g,s.create({...m.attrs,...e}))}))}),a},En=new j("__tiptap_decorations__"),Kw=t=>({tr:e,dispatch:n})=>(n&&e.setMeta(En,{type:"force",name:t}),!0),qw=(t,e={})=>({state:n,dispatch:r})=>{let o=ce(t,n.schema);return Zd(o,e)(n,r)},Jw=(t,e={})=>({state:n,dispatch:r})=>{let o=ce(t,n.schema);return eu(o,e)(n,r)},jf=$o({blur:()=>yb,clearContent:()=>bb,clearNodes:()=>wb,command:()=>xb,createParagraphNear:()=>kb,cut:()=>Sb,deleteCurrentNode:()=>Cb,deleteNode:()=>vb,deleteRange:()=>Mb,deleteSelection:()=>Eb,enter:()=>Ob,exitCode:()=>Nb,extendMarkRange:()=>Rb,first:()=>Db,focus:()=>Lb,forEach:()=>Ib,insertContent:()=>Pb,insertContentAt:()=>$b,insertDefaultBlock:()=>Bb,joinBackward:()=>Fb,joinDown:()=>Hb,joinForward:()=>Vb,joinItemBackward:()=>Wb,joinItemForward:()=>jb,joinTextblockBackward:()=>_b,joinTextblockForward:()=>Ub,joinUp:()=>zb,keyboardShortcut:()=>qb,lift:()=>Jb,liftEmptyBlock:()=>Gb,liftListItem:()=>Xb,newlineInCode:()=>Yb,resetAttributes:()=>Qb,scrollIntoView:()=>Zb,selectAll:()=>ew,selectNodeBackward:()=>tw,selectNodeForward:()=>nw,selectParentNode:()=>rw,selectTextblockEnd:()=>ow,selectTextblockStart:()=>iw,setContent:()=>sw,setMark:()=>Aw,setMeta:()=>Ew,setNode:()=>Ow,setNodeSelection:()=>Nw,setTextDirection:()=>Rw,setTextSelection:()=>Dw,sinkListItem:()=>Lw,splitBlock:()=>Iw,splitListItem:()=>Pw,toggleList:()=>Bw,toggleMark:()=>zw,toggleNode:()=>Hw,toggleWrap:()=>Fw,undoInputRule:()=>Vw,unsetAllMarks:()=>Ww,unsetMark:()=>jw,unsetTextDirection:()=>_w,updateAttributes:()=>Uw,updateDecorations:()=>Kw,wrapIn:()=>qw,wrapInList:()=>Jw}),cr=new WeakMap;function Gw(t,e){var n;cr.set(t,((n=cr.get(t))!==null&&n!==void 0?n:0)+1);try{return e()}finally{var r;let o=((r=cr.get(t))!==null&&r!==void 0?r:1)-1;o>0?cr.set(t,o):cr.delete(t)}}function Xw(t){return cr.has(t)}var Yw=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){let n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){let n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){let n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},_f=typeof process<"u"&&!1;function Qw(t){return t.kind==="widget"}function Uf(t,e){let n=[],r=new Set;for(let o of t)o.kind==="widget"&&Qw(o)&&r.add(o.key),n.push(o.toPMDecoration(e));return{decorations:n,widgetKeys:r}}function Zw(t,e,n){let{decorations:r,widgetKeys:o}=Uf(e,n);return{set:Y.create(t,r),widgetKeys:o}}function Kf({position:t,from:e,to:n,docSize:r}){return t<e?!1:t<n?!0:t===n&&n===r}function ex({decorations:t,from:e,to:n,docSize:r,extensionName:o,warnedExtensions:i}){return t.filter(s=>Kf({position:s.anchor,from:e,to:n,docSize:r})?!0:(s.anchor===n||i.has(o)||(i.add(o),console.warn(`[tiptap warn]: Extension "${o}" returned a decoration outside the requested range [${e}, ${n}). It was ignored.`)),!1))}function qf(t){var e;let n=(e=t.spec)===null||e===void 0?void 0:e.key;return typeof n=="string"?n:void 0}function tx(t){let e=new Map,n=new Map;for(let s of t.find()){var r,o,i;let l=qf(s);if(!l)continue;let a=(r=s.spec.extensionName)!==null&&r!==void 0?r:"unknown",c=(o=e.get(l))!==null&&o!==void 0?o:new Set;c.add(a),e.set(l,c),n.set(l,((i=n.get(l))!==null&&i!==void 0?i:0)+1)}return Array.from(e,([s,l])=>({key:s,extensions:l})).filter(({key:s})=>{var l;return((l=n.get(s))!==null&&l!==void 0?l:0)>1})}function Jf(t){return t.jsonID==="attr"}function nx(t){let e=!1;if(t.getMap().forEach(()=>{e=!0}),e||Jf(t))return!0;let n=t;return typeof n.from=="number"&&typeof n.to=="number"}function rx(t,e){let n=null,r=0,o=0;for(let i=0;i<t.childCount&&!(o>e.to);i+=1){let s=o+t.child(i).nodeSize;s>=e.from&&(n===null&&(n=o),r=s),o=s}return n===null?null:{from:n,to:r}}function ox(t,e){if(t.steps.some(i=>!nx(i)))return{type:"full"};let n=Ln(t).map(({newRange:i})=>i);t.steps.forEach((i,s)=>{if(!Jf(i))return;let l=t.mapping.slice(s);n.push({from:l.map(i.pos,-1),to:l.map(i.pos+1)})});let r=[];for(let i of n){let s=rx(e,i);s&&r.push(s)}r.sort((i,s)=>i.from-s.from);let o=[];for(let i of r){let s=o[o.length-1];s&&i.from<=s.to?s.to=Math.max(s.to,i.to):o.push({...i})}return{type:"ranges",ranges:o}}function Gf(t,e,n,r){return t.map(e,n,{onRemove:o=>{let i=o?.key;typeof i=="string"&&r.delete(i)}})}function ix(t,e,n){var r,o;let i=(r=e.decorationSetsByExtension[t])!==null&&r!==void 0?r:Y.empty,s=new Set((o=e.widgetKeysByExtension[t])!==null&&o!==void 0?o:[]);return{set:Gf(i,n.mapping,n.doc,s),widgetKeys:s}}function xf(t,e){let n=Object.values(e).flatMap(r=>r.find());return Y.create(t,n)}function kf(t){let e=new Set;for(let n of Object.values(t))for(let r of n)e.add(r);return e}function sx(t,e){var n;switch((n=e.update)!==null&&n!==void 0?n:"document"){case"document":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case"changedRanges":if(!e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case"manual":if(e.createInRange)throw new Error(`[tiptap error]: Extension "${t}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(e.shouldUpdate)throw new Error(`[tiptap error]: Extension "${t}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw new Error(`[tiptap error]: Extension "${t}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function lx(t,e,n){return n?!0:t.update==="manual"?!1:t.shouldUpdate?t.shouldUpdate(e):e.tr.docChanged}var Xf=new Set;function Yf(t){var e,n;return(e=(n=t.extensionManager)===null||n===void 0||(n=n.decorationManager)===null||n===void 0?void 0:n.liveWidgetKeys())!==null&&e!==void 0?e:Xf}var Qf=class{constructor(t){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let n=En.getState(e);n&&this.warnDuplicateWidgetKeys(n)},this.editor=t.editor,this.entries=this.resolveEntries(t.entries),this.entries.forEach(({name:e,spec:n})=>sx(e,n)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on("beforeTransaction",this.handleBeforeTransaction)}destroy(){this.editor.off("beforeTransaction",this.handleBeforeTransaction)}liveWidgetKeys(){var t,e;return(t=(e=En.getState(this.editor.state))===null||e===void 0?void 0:e.widgetKeys)!==null&&t!==void 0?t:Xf}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(t){let e=[];for(let{name:n,addDecorations:r}of t){let o=r();o&&e.push({name:n,spec:o})}return e}createPlugin(){let{editor:t,entries:e}=this;return new F({key:En,state:{init:(n,r)=>{let o={},i={};for(let{name:l,spec:a}of e){let{set:c,widgetKeys:d}=this.buildFullSet(l,a,r);o[l]=c,i[l]=d}let s={decorationSetsByExtension:o,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(r.doc,o),widgetKeys:kf(i)};return this.warnDuplicateWidgetKeys(s),s},apply:(n,r,o,i)=>{let s=n.getMeta(En),l=s?.type==="force"&&!s.name,a=s?.type==="force"?s.name:void 0,c={},d={},u=new Set;return Gw(t,()=>{for(let{name:f,spec:h}of e){let p=l||a===f;if(lx(h,{editor:t,tr:n,oldState:o,newState:i},p))if(h.update==="changedRanges"&&n.docChanged&&!p){let g=this.applyChangedRangesRecompute(f,h,r,n,i);c[f]=g.set,d[f]=g.widgetKeys,u.add(f)}else{let{set:g,widgetKeys:m}=this.buildFullSet(f,h,i);c[f]=g,d[f]=m,u.add(f)}else{let g=ix(f,r,n);c[f]=g.set,d[f]=g.widgetKeys}}}),u.size===0&&!n.docChanged?r:{decorationSetsByExtension:c,widgetKeysByExtension:d,mergedDecorationSet:this.mergeAfterApply({entries:e,previous:r,tr:n,decorationSetsByExtension:c,recomputedNames:u}),widgetKeys:kf(d)}}},props:{decorations(n){var r,o;return(r=(o=En.getState(n))===null||o===void 0?void 0:o.mergedDecorationSet)!==null&&r!==void 0?r:Y.empty}}})}applyChangedRangesRecompute(t,e,n,r,o){let i=ox(r,o.doc);return i.type==="full"?this.buildFullSet(t,e,o):this.rebuildRanges(t,e,n,r,o,i.ranges)}rebuildRanges(t,e,n,r,o,i){var s,l;let a=(s=n.decorationSetsByExtension[t])!==null&&s!==void 0?s:Y.empty,c=new Set((l=n.widgetKeysByExtension[t])!==null&&l!==void 0?l:[]),d=Gf(a,r.mapping,r.doc,c),u=o.doc.content.size;for(let{from:f,to:h}of i){let p=d.find(f,h).filter(y=>Kf({position:y.from,from:f,to:h,docSize:u}));for(let y of p){let w=qf(y);w&&c.delete(w)}d=d.remove(p);let{decorations:g,widgetKeys:m}=Uf(ex({decorations:this.runCreate(t,"createInRange",()=>e.createInRange({editor:this.editor,state:o,view:this.mountedView,from:f,to:h})),from:f,to:h,docSize:u,extensionName:t,warnedExtensions:this.warnedOutOfRangeExtensions}),t);d=d.add(o.doc,g);for(let y of m)c.add(y)}return{set:d,widgetKeys:c}}buildFullSet(t,e,n){let r=this.runCreate(t,"create",()=>e.create({editor:this.editor,state:n,view:this.mountedView}));return Zw(n.doc,r,t)}runCreate(t,e,n){try{return n()}catch(r){return console.error(`[tiptap error]: Extension "${t}" threw in \`addDecorations().${e}()\`. Its decorations were dropped for this update.`,r),[]}}warnDuplicateWidgetKeys(t){if(!_f)return;if(t.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let e=tx(t.mergedDecorationSet),n=new Set(e.map(({key:r})=>r));for(let{key:r,extensions:o}of e){if(this.warnedWidgetKeys.has(r))continue;let i=Array.from(o).map(s=>`"${s}"`).join(", ");console.warn(`[tiptap warn]: Duplicate widget decoration key "${r}" in extension${o.size===1?"":"s"} ${i}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(t,e){let n=Object.keys(e);return n.length===1?e[n[0]]:xf(t,e)}mergeAfterApply({entries:t,previous:e,tr:n,decorationSetsByExtension:r,recomputedNames:o}){return t.length===1?r[t[0].name]:o.size===0?e.mergedDecorationSet.map(n.mapping,n.doc):xf(n.doc,r)}};function Ma(t,e){if(t===e)return!0;if(!t||!e)return!1;let n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(o=>Object.prototype.hasOwnProperty.call(e,o)&&Object.is(t[o],e[o]))}function Ta(t,e){let{selection:n}=t,{$from:r}=n;if(n instanceof $){let i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let o=r.depth;for(;o>=0;){let i=r.index(o);if(r.node(o).contentMatchAt(i).matchType(e))return!0;o-=1}return!1}function Zf(t,e,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}function Aa(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Ea(t,e){let n=t.getAttribute("style");if(!n)return null;let r=n.split(";").map(i=>i.trim()).filter(Boolean),o=e.toLowerCase();for(let i=r.length-1;i>=0;i-=1){let s=r[i],l=s.indexOf(":");if(l!==-1&&s.slice(0,l).trim().toLowerCase()===o)return s.slice(l+1).trim()}return null}function ax(t){return t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function cx(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function dx(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}function eh(t){return typeof t=="number"}function ux(t){return Object.prototype.toString.call(t).slice(8,-1)}function eo(t){return ux(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function fx(t){return typeof t=="string"}function Oa(t){return/\s/.test(t)}function hx(t){return/^[a-zA-Z]$/.test(t)}function th(t){return/^\w$/.test(t)}function aa(t,e){for(;e<t.length&&Oa(t[e]);)e+=1;return e}function fr(t,e){for(;e<t.length&&!Oa(t[e]);)e+=1;return e}function nh(t,e,n){for(;e<t.length&&(th(t[e])||n&&t[e]==="-");)e+=1;return e}function px(t,e){let n=t[e],r=e+1,o=nh(t,r,!0);return o===r?{nextIndex:fr(t,o)}:{token:{type:n==="."?"class":"id",name:t.slice(r,o)},nextIndex:fr(t,o)}}function mx(t,e){let n=t.indexOf(t[e],e+1);return{nextIndex:fr(t,n===-1?e:n+1)}}function gx(t,e,n,r){let o=r?aa(t,n):n;if(t[o]!=="=")return;o=r?aa(t,o+1):o+1;let i=t[o];if(i!=='"'&&i!=="'")return;let s=t.indexOf(i,o+1);if(s!==-1)return{token:{type:"keyValue",name:e,value:t.slice(o+1,s)},nextIndex:fr(t,s+1)}}function yx(t,e,n){let r=n==="pandoc",o=nh(t,e+1,r),i=t.slice(e,o),s=gx(t,i,o,r);if(s)return s;let l=o===t.length||Oa(t[o]);return{token:r&&l?{type:"boolean",name:i}:void 0,nextIndex:n==="shortcode"?fr(t,o):o}}function bx(t,e,n){let r=t[e];return n==="pandoc"&&(r==="."||r==="#")?px(t,e):r==='"'||r==="'"?mx(t,e):(n==="pandoc"?hx(r):th(r))?yx(t,e,n):{nextIndex:fr(t,e)}}function rh(t,e){let n=[],r=0;for(;r<t.length&&(r=aa(t,r),!(r>=t.length));){let o=bx(t,r,e);o.token&&n.push(o.token),r=o.nextIndex}return n}function wx(t){let e={},n=t.filter(o=>o.type==="class").map(o=>o.name),r=t.find(o=>o.type==="id");return n.length>0&&(e.class=n.join(" ")),r&&(e.id=r.name),t.forEach(o=>{o.type==="keyValue"&&(e[o.name]=o.value)}),t.forEach(o=>{o.type==="boolean"&&(e[o.name]=!0)}),e}function Mi(t){return t?.trim()?wx(rh(t,"pandoc")):{}}function Ti(t){if(!t||Object.keys(t).length===0)return"";let e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(n=>e.push(`.${n}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function oh(t){let{nodeName:e,name:n,parseAttributes:r=Mi,serializeAttributes:o=Ti,defaultAttributes:i={},requiredAttributes:s=[],allowedAttributes:l}=t,a=n||e,c=d=>{if(!l)return d;let u={};return l.forEach(f=>{f in d&&(u[f]=d[f])}),u};return{parseMarkdown:(d,u)=>{let f={...i,...d.attributes};return u.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;let f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=d.match(f))===null||u===void 0?void 0:u.index;return h!==void 0?h:-1},tokenize(d,u,f){let h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(h);if(!p)return;let g=p[1]||"",m=r(g);if(!s.find(y=>!(y in m)))return{type:e,raw:p[0],attributes:m}}},renderMarkdown:d=>{let u=c(d.attrs||{}),f=o(u),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function gr(t){let{nodeName:e,name:n,getContent:r,parseAttributes:o=Mi,serializeAttributes:i=Ti,defaultAttributes:s={},content:l="block",allowedAttributes:a}=t,c=n||e,d=u=>{if(!a)return u;let f={};return a.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{let h;if(r){let g=r(u);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(u.tokens||[]):h=f.parseInline(u.tokens||[]);let p={...s,...u.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var f;let h=new RegExp(`^:::${c}`,"m"),p=(f=u.match(h))===null||f===void 0?void 0:f.index;return p!==void 0?p:-1},tokenize(u,f,h){let p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(p);if(!g)return;let[m,y=""]=g,w=o(y),x=1,b=m.length,k="",v=/^:::([\w-]*)(\s.*)?/gm,C=u.slice(b);for(v.lastIndex=0;;){var O;let P=v.exec(C);if(P===null)break;let N=P.index,_=P[1];if(!(!((O=P[2])===null||O===void 0)&&O.endsWith(":::"))){if(_)x+=1;else if(x-=1,x===0){let U=C.slice(0,N);k=U.trim();let q=u.slice(0,b+N+P[0].length),I=[];if(k)if(l==="block")for(I=h.blockTokens(U),I.forEach(M=>{M.text&&(!M.tokens||M.tokens.length===0)&&(M.tokens=h.inlineTokens(M.text))});I.length>0;){let M=I[I.length-1];if(M.type==="paragraph"&&(!M.text||M.text.trim()===""))I.pop();else break}else I=h.inlineTokens(k);return{type:e,raw:q,attributes:w,content:k,tokens:I}}}}}},renderMarkdown:(u,f)=>{let h=d(u.attrs||{}),p=i(h),g=p?` {${p}}`:"",m=f.renderChildren(u.content||[],`
15
+
16
+ `);return`:::${c}${g}
17
+
18
+ ${m}
19
+
20
+ :::`}}}function xx(t){let e={};return rh(t,"shortcode").forEach(n=>{n.type==="keyValue"&&(e[n.name]=n.value)}),e}function kx(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function ih(t){let{nodeName:e,name:n,getContent:r,parseAttributes:o=xx,serializeAttributes:i=kx,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,d=f=>{if(!a)return f;let h={};return a.forEach(p=>{let g=typeof p=="string"?p:p.name,m=typeof p=="string"?void 0:p.skipIfDefault;if(g in f){let y=f[g];if(m!==void 0&&y===m)return;h[g]=y}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{let p={...s,...f.attributes};if(l)return h.createNode(e,p);let g=r?r(f):f.content||"";return g?h.createNode(e,p,[h.createTextNode(g)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){let h=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=f.match(h),g=p?.index;return g!==void 0?g:-1},tokenize(f,h,p){let g=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),m=f.match(g);if(!m)return;let y="",w="";if(l){let[,b]=m;w=b}else{let[,b,k]=m;w=b,y=k||""}let x=o(w.trim());return{type:e,raw:m[0],content:y.trim(),attributes:x}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));let p=d(f.attrs||{}),g=i(p),m=g?` ${g}`:"";return l?`[${c}${m}]`:`[${c}${m}]${h}[/${c}]`}}}function uo(t,e,n){let r=t.split(`
21
+ `),o=[],i="",s=0,l=e.baseIndentSize||2;for(;s<r.length;){let d=r[s],u=d.match(e.itemPattern);if(!u){if(o.length>0)break;if(d.trim()===""){s+=1,i=`${i}${d}
22
+ `;continue}else return}let f=e.extractItemData(u),{indentLevel:h,mainContent:p}=f;i=`${i}${d}
23
+ `;let g=[p];for(s+=1;s<r.length;){var a;let x=r[s];if(x.trim()===""){var c;let b=r.slice(s+1).findIndex(k=>k.trim()!=="");if(b===-1)break;if((((c=r[s+1+b].match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>h){g.push(x),i=`${i}${x}
24
+ `,s+=1;continue}else break}if((((a=x.match(/^(\s*)/))===null||a===void 0||(a=a[1])===null||a===void 0?void 0:a.length)||0)>h)g.push(x),i=`${i}${x}
25
+ `,s+=1;else break}let m,y=g.slice(1);if(y.length>0){let x=y.map(b=>b.slice(h+l)).join(`
26
+ `);x.trim()&&(e.customNestedParser?m=e.customNestedParser(x):m=n.blockTokens(x))}let w=e.createToken(f,m);o.push(w)}if(o.length!==0)return{items:o,raw:i}}function fo(t,e,n,r){if(!t||!Array.isArray(t.content))return"";let o=typeof n=="function"?n(r):n,[i,...s]=t.content,l=`${o}${e.renderChildren([i])}`;return s&&s.length>0&&s.forEach((a,c)=>{var d,u;let f=(d=(u=e.renderChild)===null||u===void 0?void 0:u.call(e,a,c+1))!==null&&d!==void 0?d:e.renderChildren([a]);if(f!=null){let h=f.split(`
27
+ `).map(p=>p?e.indent(p):e.indent("")).join(`
28
+ `);l+=a.type==="paragraph"?`
29
+
30
+ ${h}`:`
31
+ ${h}`}}),l}var Sx=$o({createAtomBlockMarkdownSpec:()=>oh,createBlockMarkdownSpec:()=>gr,createInlineMarkdownSpec:()=>ih,parseAttributes:()=>Mi,parseIndentedBlocks:()=>uo,renderNestedMarkdownContent:()=>fo,serializeAttributes:()=>Ti});function Sf(t){return typeof t.type=="string"?t.type:t.type.name}function Cx(t,e){if(t.length!==e.length)return!1;let n=Array.from({length:e.length},()=>!1);return t.every(r=>{let o=Sf(r),i=e.findIndex((s,l)=>!n[l]&&o===Sf(s)&&Ma(r.attrs,s.attrs));return i===-1?!1:(n[i]=!0,!0)})}function Na(t,e){let n={...t};return eo(t)&&eo(e)&&Object.keys(e).forEach(r=>{eo(e[r])&&eo(t[r])?n[r]=Na(t[r],e[r]):n[r]=e[r]}),n}function Ra(t,e,n={}){let{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{let c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize,u=null;if(l.marks.forEach(h=>{if(h!==s)return!1;u=h}),!u)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==u.attrs[h]&&(f=!0)}),f){let h=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,h)}}),i.docChanged&&e.view.dispatch(i)}var vx=class{constructor(t,e,n){this.component=t,this.editor=e.editor,this.options={...n},this.mark=e.mark,this.HTMLAttributes=e.HTMLAttributes}get dom(){return this.editor.view.dom}get contentDOM(){return null}updateAttributes(t,e){Ra(e||this.mark,this.editor,t)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Nn()||oo())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}},ln=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}},Mx=(t,e)=>{if(gi(e))return e.exec(t);let n=e(t);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function di(t){var e;let{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1,u=$f(c)+i;return s.forEach(f=>{if(d)return;let h=Mx(u,f.find);if(!h)return;let p=h[0].length-i.length;if(p>0){let k=c.parentOffset-p;if(k<0||c.parent.textBetween(k,c.parentOffset)!==h[0].slice(0,p))return}let g=a.state.tr,m=io({state:a.state,transaction:g}),y={from:r-(h[0].length-i.length),to:o},{commands:w,chain:x,can:b}=new On({editor:n,state:m});f.handler({state:m,range:y,match:h,commands:w,chain:x,can:b})===null||!g.steps.length||(f.undoable&&g.setMeta(l,{transform:g,from:r,to:o,text:i}),a.dispatch(g),d=!0)}),d}function sh(t){let{editor:e,rules:n}=t,r=new F({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:c}=a;typeof c=="string"?c=c:c=lo(S.from(c),s.schema);let{from:d}=a,u=d+c.length;di({editor:e,from:d,to:u,text:c,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return di({editor:e,from:i,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&di({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?di({editor:e,from:s.pos,to:s.pos,text:`
32
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Ai=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...G(B(this,"addOptions",{name:this.name}))}}get storage(){return{...G(B(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){let e=this.extend({...this.config,addOptions:()=>Na(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){let e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},ie=class lh extends Ai{constructor(...e){super(...e),this.type="mark"}static create(e={}){let n=typeof e=="function"?e():e;return new lh(n)}static handleExit({editor:e,mark:n}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let i=o.marks();if(!i.find(l=>l?.type.name===n.name))return!1;let s=i.find(l=>l?.type.name===n.name);return s&&r.removeStoredMark(s),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},yr=class{constructor(t){this.find=t.find,this.handler=t.handler}},Tx=(t,e,n)=>{if(gi(e))return[...t.matchAll(e)];let r=e(t,n);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function Ax(t){let{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:d}=new On({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,o,(f,h)=>{var p,g,m,y;if(!((p=f.type)===null||p===void 0||(p=p.spec)===null||p===void 0)&&p.code||!(f.isText||f.isTextblock||f.isInline))return;let w=(g=(m=(y=f.content)===null||y===void 0?void 0:y.size)!==null&&m!==void 0?m:f.nodeSize)!==null&&g!==void 0?g:0,x=Math.max(r,h),b=Math.min(o,h+w);if(x>=b)return;let k=f.isText?f.text||"":f.textBetween(x-h,b-h,void 0,"\uFFFC");Tx(k,i.find,s).forEach(v=>{if(v.index===void 0)return;let C=x+v.index+1,O=C+v[0].length,P={from:n.tr.mapping.map(C),to:n.tr.mapping.map(O)},N=i.handler({state:n,range:P,match:v,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});u.push(N)})}),u.every(f=>f!==null)}var ui=null,Ex=t=>{var e;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function ah(t){let{editor:e,rules:n}=t,r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:c,from:d,to:u,rule:f,pasteEvt:h})=>{let p=c.tr,g=io({state:c,transaction:p});if(!(!Ax({editor:e,state:g,from:Math.max(d-1,0),to:u.b-1,rule:f,pasteEvent:h,dropEvent:l})||!p.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,p}};return n.map(c=>new F({view(d){let u=h=>{var p;r=!((p=d.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?d.dom.parentElement:null,r&&(ui=e)},f=()=>{ui&&(ui=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,u)=>{if(i=r===d.dom.parentElement,l=u,!i){let f=ui;f?.isEditable&&setTimeout(()=>{let h=f.state.selection;h&&f.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(d,u)=>{var f;let h=(f=u.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return s=u,o=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(d,u,f)=>{let h=d[0],p=h.getMeta("uiEvent")==="paste"&&!o,g=h.getMeta("uiEvent")==="drop"&&!i,m=h.getMeta("applyPasteRules"),y=!!m;if(!p&&!g&&!y)return;if(y){let{text:b}=m;typeof b=="string"?b=b:b=lo(S.from(b),f.schema);let{from:k}=m,v=k+b.length,C=Ex(b);return a({rule:c,state:f,from:k,to:{b:v},pasteEvt:C})}let w=u.doc.content.findDiffStart(f.doc.content),x=u.doc.content.findDiffEnd(f.doc.content);if(!(!eh(w)||!x||w===x.b))return a({rule:c,state:f,from:w,to:x,pasteEvt:s})}}))}var Ei=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=e,this.baseExtensions=t,this.extensions=xi(t),this.schema=ga(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{let n=B(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:An(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){let{editor:t}=this,e=ur([...this.extensions].reverse()).flatMap(r=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:An(r.name,this.schema)},i=[],s=B(r,"addKeyboardShortcuts",o),l={};if(r.type==="mark"&&B(r,"exitable",o)&&(l.ArrowRight=()=>ie.handleExit({editor:t,mark:r})),s){let f=Object.fromEntries(Object.entries(s()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}let a=ff(l);i.push(a);let c=B(r,"addInputRules",o);if(la(r,t.options.enableInputRules)&&c){let f=c();if(f&&f.length){let h=sh({editor:t,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}let d=B(r,"addPasteRules",o);if(la(r,t.options.enablePasteRules)&&d){let f=d();if(f&&f.length){let h=ah({editor:t,rules:f});i.push(...h)}}let u=B(r,"addProseMirrorPlugins",o);if(u){let f=u();i.push(...f)}return i}),n=this.createDecorationPlugin();return n&&e.push(n),e}createDecorationPlugin(){var t;let{editor:e}=this;(t=this.decorationManager)===null||t===void 0||t.destroy();let n=[];return this.extensions.forEach(r=>{let o=B(r,"addDecorations",{name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:An(r.name,this.schema)});o&&n.push({name:r.name,addDecorations:o})}),this.decorationManager=new Qf({editor:e,entries:n}),this.decorationManager.plugin}get attributes(){return ma(this.extensions)}get nodeViews(){let{editor:t}=this,{nodeExtensions:e}=Dn(this.extensions);return Object.fromEntries(e.filter(n=>!!B(n,"addNodeView")).map(n=>{let r=this.attributes.filter(l=>l.type===n.name),o=B(n,"addNodeView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ce(n.name,this.schema)});if(!o)return[];let i=o();if(!i)return[];let s=(l,a,c,d,u)=>{let f=zt(l,r);return i({node:l,view:a,getPos:c,decorations:d,innerDecorations:u,editor:t,extension:n,HTMLAttributes:f})};return[n.name,s]}))}dispatchTransaction(t){let{editor:e}=this;return ur([...this.extensions].reverse()).reduceRight((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:An(r.name,this.schema)},i=B(r,"dispatchTransaction",o);return i?s=>{i.call(o,{transaction:s,next:n})}:n},t)}transformPastedHTML(t){let{editor:e}=this;return ur([...this.extensions]).reduce((n,r)=>{let o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:An(r.name,this.schema)},i=B(r,"transformPastedHTML",o);return i?(s,l)=>{let a=n(s,l);return i.call(o,a)}:n},t||(n=>n))}get markViews(){let{editor:t}=this,{markExtensions:e}=Dn(this.extensions);return Object.fromEntries(e.filter(n=>!!B(n,"addMarkView")).map(n=>{let r=this.attributes.filter(s=>s.type===n.name),o=B(n,"addMarkView",{name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:xt(n.name,this.schema)});if(!o)return[];let i=(s,l,a)=>{let c=zt(s,r);return o()({mark:s,view:l,inline:a,editor:t,extension:n,HTMLAttributes:c,updateAttributes:d=>{Ra(s,t,d)}})};return[n.name,i]}))}destroy(){var t;(t=this.decorationManager)===null||t===void 0||t.destroy(),this.extensions.forEach(e=>{let n=e;for(;n.parent;){let r=n.parent;r.child===n&&(r.child=null),n=r}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{let n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:An(e.name,this.schema)};if(e.type==="mark"){var r,o;(!((r=G(B(e,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name),!((o=G(B(e,"clearable",n)))!==null&&o!==void 0)||o||this.nonClearableMarks.push(e.name)}let i=B(e,"onBeforeCreate",n),s=B(e,"onCreate",n),l=B(e,"onUpdate",n),a=B(e,"onSelectionUpdate",n),c=B(e,"onTransaction",n),d=B(e,"onFocus",n),u=B(e,"onBlur",n),f=B(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};Ei.resolve=xi;Ei.sort=ur;Ei.flatten=wi;var Z=class ch extends Ai{constructor(...e){super(...e),this.type="extension"}static create(e={}){let n=typeof e=="function"?e():e;return new ch(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},dh=Z.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new F({key:new j("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,i=Si(n),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:i};return[...o.ranges].sort((a,c)=>a.$from.pos-c.$from.pos).map(({$from:a,$to:c})=>ya(r,{from:a.pos,to:c.pos},l)).join(s??`
33
+
34
+ `)}}})]}}),uh=Z.create({name:"commands",addCommands(){return{...jf}}}),fh=Z.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r;let o=()=>{var i,s,l;if((i=(s=this.editor.options.coreExtensionOptions)===null||s===void 0||(s=s.delete)===null||s===void 0||(l=s.filterTransaction)===null||l===void 0?void 0:l.call(s,t))!==null&&i!==void 0?i:t.getMeta("y-sync$"))return;let a=bi(t.before,[t,...e]);Ln(a).forEach(d=>{a.mapping.mapResult(d.oldRange.from).deletedAfter&&a.mapping.mapResult(d.oldRange.to).deletedBefore&&a.before.nodesBetween(d.oldRange.from,d.oldRange.to,(u,f)=>{let h=f+u.nodeSize-2,p=d.oldRange.from<=f&&h<=d.oldRange.to;this.editor.emit("delete",{type:"node",node:u,from:f,to:h,newFrom:a.mapping.map(f),newTo:a.mapping.map(h),deletedRange:d.oldRange,newRange:d.newRange,partial:!p,editor:this.editor,transaction:t,combinedTransform:a})})});let c=a.mapping;a.steps.forEach((d,u)=>{if(d instanceof Nt){var f,h;let p=c.slice(u).map(d.from,-1),g=c.slice(u).map(d.to),m=c.invert().map(p,-1),y=c.invert().map(g),w=p>0?(f=a.doc.nodeAt(p-1))===null||f===void 0?void 0:f.marks.some(b=>b.eq(d.mark)):!1,x=(h=a.doc.nodeAt(g))===null||h===void 0?void 0:h.marks.some(b=>b.eq(d.mark));this.editor.emit("delete",{type:"mark",mark:d.mark,from:d.from,to:d.to,deletedRange:{from:m,to:y},newRange:{from:p,to:g},partial:!!(x||w),editor:this.editor,transaction:t,combinedTransform:a})}})};!((n=(r=this.editor.options.coreExtensionOptions)===null||r===void 0||(r=r.delete)===null||r===void 0?void 0:r.async)!==null&&n!==void 0)||n?setTimeout(o,0):o()}}),hh=Z.create({name:"drop",addProseMirrorPlugins(){return[new F({key:new j("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),ph=Z.create({name:"editable",addProseMirrorPlugins(){return[new F({key:new j("editable"),props:{editable:()=>this.editor.options.editable}})]}}),mh=new j("focusEvents"),gh=Z.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:t}=this;return[new F({key:mh,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;let r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;let r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),yh=Z.create({name:"keymap",addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,g=p.parent.type.spec.isolating,m=u.pos-u.parentOffset,y=g&&p.parent.childCount===1?m===u.pos:z.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Nn()||ua()?i:o},addProseMirrorPlugins(){return[new F({key:new j("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(h=>h.getMeta("composition")))return;let r=t.some(h=>h.docChanged)&&!e.doc.eq(n.doc),o=t.some(h=>h.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=z.atStart(e.doc).from,c=z.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!In(n.doc))return;let d=n.tr,u=io({state:n,transaction:d}),{commands:f}=new On({editor:this.editor,state:u});if(f.clearNodes(),!!d.steps.length)return d}})]}}),bh=Z.create({name:"paste",addProseMirrorPlugins(){return[new F({key:new j("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),wh=Z.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new F({key:new j("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:"0"}}}})]}}),xh=Z.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:t}=Dn(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new F({key:new j("textDirection"),props:{attributes:()=>{let t=this.options.direction;return t?{dir:t}:{}}}})]}}),Ox=$o({ClipboardTextSerializer:()=>dh,Commands:()=>uh,Delete:()=>fh,Drop:()=>hh,Editable:()=>ph,FocusEvents:()=>gh,Keymap:()=>yh,Paste:()=>bh,Tabindex:()=>wh,TextDirection:()=>xh,focusEventsPluginKey:()=>mh}),Cf=!1;function Nx(t){if(Cf)return;Cf=!0;let e;try{e=be.fromJSON(t,{from:0,to:0}).slice.content}catch{return}e instanceof S||console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.")}var kh=class to{get name(){return this.node.type.name}constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new to(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new to(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new to(e,this.editor)}get children(){let e=[];return this.node.content.forEach((n,r)=>{let o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;let a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;let c=new to(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){let i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){let a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;let i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(l=>n[l]===s.node.attrs[l])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){let{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Rx=`.ProseMirror {
35
+ position: relative;
36
+ }
37
+
38
+ .ProseMirror {
39
+ word-wrap: break-word;
40
+ white-space: pre-wrap;
41
+ white-space: break-spaces;
42
+ -webkit-font-variant-ligatures: none;
43
+ font-variant-ligatures: none;
44
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
45
+ }
46
+
47
+ .ProseMirror [contenteditable="false"] {
48
+ white-space: normal;
49
+ }
50
+
51
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
52
+ white-space: pre-wrap;
53
+ }
54
+
55
+ .ProseMirror pre {
56
+ white-space: pre-wrap;
57
+ }
58
+
59
+ img.ProseMirror-separator {
60
+ display: inline !important;
61
+ border: none !important;
62
+ margin: 0 !important;
63
+ width: 0 !important;
64
+ height: 0 !important;
65
+ }
66
+
67
+ .ProseMirror-gapcursor {
68
+ display: none;
69
+ pointer-events: none;
70
+ position: absolute;
71
+ margin: 0;
72
+ }
73
+
74
+ .ProseMirror-gapcursor:after {
75
+ content: "";
76
+ display: block;
77
+ position: absolute;
78
+ top: -2px;
79
+ width: 20px;
80
+ border-top: 1px solid black;
81
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
82
+ }
83
+
84
+ @keyframes ProseMirror-cursor-blink {
85
+ to {
86
+ visibility: hidden;
87
+ }
88
+ }
89
+
90
+ .ProseMirror-hideselection *::selection {
91
+ background: transparent;
92
+ }
93
+
94
+ .ProseMirror-hideselection *::-moz-selection {
95
+ background: transparent;
96
+ }
97
+
98
+ .ProseMirror-hideselection * {
99
+ caret-color: transparent;
100
+ }
101
+
102
+ .ProseMirror-focused .ProseMirror-gapcursor {
103
+ display: block;
104
+ }`,Dx=class extends Yw{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Hf,createMappablePosition:Ff},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:o})=>this.options.onDrop(n,r,o)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);let e=this.createDoc();if(!this.editorState){let n=hi(e,this.options.autofocus);this.editorState=tr.create({doc:e,schema:this.schema,selection:n||void 0})}Nx(this.schema),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():On.createFakeChain()}can(){return this.commandManager?this.commandManager.can():On.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Zf(Rx,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return _f&&!this.hasWarnedStaleDecorationRead&&Xw(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){let n=pa(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;let e=this.state.plugins,n=e;if([].concat(t).forEach(o=>{let i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;let n=[...this.options.enableCoreExtensions?[ph,dh.configure({blockSeparator:(t=this.options.coreExtensionOptions)===null||t===void 0||(t=t.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),uh,gh,yh,wh.configure({value:(e=this.options.coreExtensionOptions)===null||e===void 0||(e=e.tabindex)===null||e===void 0?void 0:e.value}),hh,bh,fh,xh.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new Ei(n,this)}createCommandManager(){this.commandManager=new On({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=pi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;let n=pi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=tr.create({doc:n,schema:this.schema,selection:hi(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}createView(t){let{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new ar(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();let a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;let e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var d;return(d=this.capturedTransaction)===null||d===void 0?void 0:d.step(c)});return}let{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});let s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s?.getMeta("focus"),a=s?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Ci(this.state,t)}isActive(t,e){let n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return vi(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return lo(this.state.doc.content,this.schema)}getText(t){let{blockSeparator:e=`
105
+
106
+ `,textSerializers:n={}}=t||{};return ba(this.state.doc,{blockSeparator:e,textSerializers:{...Si(this.schema),...n}})}get isEmpty(){return In(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(t=(e=this.editorView)===null||e===void 0?void 0:e.isDestroyed)!==null&&t!==void 0?t:!0}$node(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,e))||null}$pos(t){let e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new kh(e,this,!1,n)}get $doc(){return this.$pos(0)}},ho=class{static Inline(t,e,n={},r){return new Sh(t,e,n,r)}static Node(t,e,n={},r){return new Ch(t,e,n,r)}static Widget(t,e,n){let{key:r,...o}=n;return new vh(t,e,r,o)}},Sh=class extends ho{constructor(t,e,n={},r){super(),this.kind="inline",this.from=t,this.to=e,this.attrs=n,this.spec=r}get anchor(){return this.from}toPMDecoration(t){let e=t?{...this.spec,extensionName:t}:this.spec;return re.inline(this.from,this.to,this.attrs,e)}},Ch=class extends ho{constructor(t,e,n={},r){super(),this.kind="node",this.from=t,this.to=e,this.attrs=n,this.spec=r}get anchor(){return this.from}toPMDecoration(t){let e=t?{...this.spec,extensionName:t}:this.spec;return re.node(this.from,this.to,this.attrs,e)}},vh=class extends ho{constructor(t,e,n,r){super(),this.kind="widget",this.pos=t,this.render=e,this.key=n,this.spec=r}get anchor(){return this.pos}toPMDecoration(t){let e=t?{...this.spec,key:this.key,extensionName:t}:{...this.spec,key:this.key};return re.widget(this.pos,this.render,e)}};function Lx(t,e){let n=t,r=n[e];if(!r){r={renderers:new Map,props:new Map,pendingProps:new Map,flushScheduled:!1},n[e]=r;let o=r;t.on("destroy",()=>{o.pendingProps.clear(),o.renderers.forEach(i=>i.destroy()),o.renderers.clear(),o.props.clear()})}return r}function Ix(t){t.flushScheduled=!1;for(let[e,n]of t.pendingProps){let r=t.renderers.get(e);r&&(r.updateProps(n),t.props.set(e,{...n}))}t.pendingProps.clear()}function Px(t){let{editor:e,pos:n,key:r,props:o,cacheKey:i,context:s,create:l,materialize:a,side:c,relaxedSide:d,marks:u,stopEvent:f,ignoreSelection:h,destroy:p}=t,g=Lx(e,i);if(g.renderers.has(r)){var m;let w=(m=g.pendingProps.get(r))!==null&&m!==void 0?m:g.props.get(r);(!w||!Ma(w,o))&&(g.pendingProps.set(r,o),g.flushScheduled||(g.flushScheduled=!0,queueMicrotask(()=>Ix(g))))}let y=(w,x)=>{let b={...o,...s(x)},k=g.renderers.get(r);return k?k.updateProps(b):(k=l(b),g.renderers.set(r,k),g.props.set(r,{...o})),a(k)};return ho.Widget(n,y,{key:r,side:c,relaxedSide:d,marks:u,stopEvent:f,ignoreSelection:h,destroy:w=>{if(!Yf(e).has(r))try{var x;(x=g.renderers.get(r))===null||x===void 0||x.destroy(),g.renderers.delete(r),g.props.delete(r),g.pendingProps.delete(r)}finally{p?.(w)}}})}function Ie(t){return new ln({find:t.find,handler:({state:e,range:n,match:r})=>{let o=G(t.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=n.from+l.indexOf(s),d=c+s.length;if(ao(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(h=>h===t.type&&h!==f.mark.type)).filter(f=>f.to>c).length)return null;d<n.to&&i.delete(d,n.to),c>n.from&&i.delete(n.from+a,c);let u=n.from+a+s.length;i.addMark(n.from+a,u,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function po(t){return new ln({find:t.find,handler:({state:e,range:n,match:r})=>{let o=G(t.getAttributes,void 0,r)||{},{tr:i}=e,s=n.from,l=n.to,a=t.type.create(o);if(r[1]){let c=s+r[0].lastIndexOf(r[1]);c>l?c=l:l=c+r[1].length;let d=r[0][r[0].length-1];i.insertText(d,s+r[0].length-1),i.replaceWith(c,l,a)}else if(r[0]){let c=t.type.isInline?s:s-1;i.insert(c,t.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function br(t){return new ln({find:t.find,handler:({state:e,range:n,match:r})=>{let o=e.doc.resolve(n.from),i=G(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function $x(t){return new ln({find:t.find,handler:({state:e,range:n,match:r})=>{let o=t.replace,i=n.from,s=n.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)},undoable:t.undoable})}function Vt(t){return new ln({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{let i=G(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),a=l&&Qn(l,t.type,i);if(!a)return null;if(s.wrap(l,a),t.keepMarks&&t.editor){let{selection:d,storedMarks:u}=e,{splittableMarks:f}=t.editor.extensionManager,h=u||d.$to.parentOffset&&d.$from.marks();if(h){let p=h.filter(g=>f.includes(g.type.name));s.ensureMarks(p)}}if(t.keepAttributes){let d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,i).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&lt(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)},undoable:t.undoable})}var Mh=new WeakSet,Da=new WeakSet;function Tn(t){let e=t;return Mh.add(e),e}function ca(t){return Array.isArray(t)&&Mh.has(t)}function Th(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Da.has(e)&&!ca(e)?Th(e):[e])}function Bx(t){return Da.add(t.children),t.children}function zx(t,e){if(t==="slot")return 0;if(t instanceof Function){let o=t(e);return Array.isArray(o)&&!ca(o)&&!Da.has(o)?Tn(o):o}let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(ca(n))return Tn([t,r,n]);if(n.length===0)return Tn([t,r]);let o=Th(n);return o.length===0?Tn([t,r]):Tn([t,r,...o])}return n!=null?Tn([t,r,n]):Tn([t,r])}var Hx=(t,e)=>zx(t,e),Fx=t=>"touches"in t,Oi=class{constructor(t){var e,n,r,o,i,s;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;let a=l.touches[0];if(!a)return;let c=a.clientX-this.startX,d=a.clientY-this.startY;this.handleResize(c,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;let l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,!((e=t.options)===null||e===void 0)&&e.min&&(this.minSize={...this.minSize,...t.options.min}),!((n=t.options)===null||n===void 0)&&n.max&&(this.maxSize=t.options.max),!(t==null||(r=t.options)===null||r===void 0)&&r.directions&&(this.directions=t.options.directions),!((o=t.options)===null||o===void 0)&&o.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),!((i=t.options)===null||i===void 0)&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),!((s=t.options)===null||s===void 0)&&s.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!==null&&t!==void 0?t:null}handleEditorUpdate(){let t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){let t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){let e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){let n=e.includes("top"),r=e.includes("bottom"),o=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),o&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){let t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Fx(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,o,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,o=this.startHeight,i=t.includes("right"),s=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return i?r=this.startWidth+e:s&&(r=this.startWidth-e),l?o=this.startHeight+n:a&&(o=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(o=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,o,t):{width:r,height:o}}applyConstraints(t,e,n){var r,o;if(!n){var i,s;let c=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return!((i=this.maxSize)===null||i===void 0)&&i.width&&(c=Math.min(this.maxSize.width,c)),!((s=this.maxSize)===null||s===void 0)&&s.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),!((r=this.maxSize)===null||r===void 0)&&r.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),!((o=this.maxSize)===null||o===void 0)&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){let r=n==="left"||n==="right",o=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:o?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}},Vx=Oi,W=class Ah extends Ai{constructor(...e){super(...e),this.type="node"}static create(e={}){let n=typeof e=="function"?e():e;return new Ah(n)}configure(e){return super.configure(e)}extend(e){let n=typeof e=="function"?e():e;return super.extend(n)}},Wx=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=()=>{try{return e.getPos()}catch{return}},this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n;let{view:r}=this.editor,o=t.target,i=o.nodeType===3?(e=o.parentElement)===null||e===void 0?void 0:e.closest("[data-drag-handle]"):o.closest("[data-drag-handle]");if(!this.dom||!((n=this.contentDOM)===null||n===void 0)&&n.contains(o)||!i)return;let s=0,l=0;if(this.dom!==i){var a,c,d,u;let w=this.dom.getBoundingClientRect(),x=i.getBoundingClientRect(),b=(a=t.offsetX)!==null&&a!==void 0?a:(c=t.nativeEvent)===null||c===void 0?void 0:c.offsetX,k=(d=t.offsetY)!==null&&d!==void 0?d:(u=t.nativeEvent)===null||u===void 0?void 0:u.offsetY;s=x.x-w.x+b,l=x.y-w.y+k}let f=this.dom.cloneNode(!0);try{let w=this.dom.getBoundingClientRect();f.style.width=`${Math.round(w.width)}px`,f.style.height=`${Math.round(w.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let h=null;try{var p;h=document.createElement("div"),h.style.position="absolute",h.style.top="-9999px",h.style.left="-9999px",h.style.pointerEvents="none",h.appendChild(f),document.body.appendChild(h),(p=t.dataTransfer)===null||p===void 0||p.setDragImage(f,s,l)}finally{h&&setTimeout(()=>{try{h?.remove()}catch{}},0)}let g=this.getPos();if(typeof g!="number")return;let m=$.create(r.state.doc,g),y=r.state.tr.setSelection(m);r.dispatch(y)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});let n=t.target;if(!(this.dom.contains(n)&&!(!((e=this.contentDOM)===null||e===void 0)&&e.contains(n))))return!1;let r=t.type.startsWith("drag"),o=t.type==="dragover"||t.type==="dragenter",i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!r)return!0;let{isEditable:s}=this.editor,{isDragging:l}=this,a=!!this.node.type.spec.draggable,c=$.isSelectable(this.node),d=t.type==="copy",u=t.type==="paste",f=t.type==="cut",h=t.type==="mousedown";if(!a&&c&&r&&t.target===this.dom&&t.preventDefault(),a&&r&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(a&&s&&!l&&h){let p=n.closest("[data-drag-handle]");p&&(this.dom===p||this.dom.contains(p))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||o||i||d||u||f||h&&c)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Nn()||oo())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(e=>e.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{let n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){let t=this.getPos();if(typeof t!="number")return;let e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Ne(t){return new yr({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{let i=G(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=n.to;if(l){let d=a.search(/\S/),u=n.from+a.indexOf(l),f=u+l.length;if(ao(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(p=>p===t.type&&p!==h.mark.type)).filter(h=>h.to>u).length)return null;f<n.to&&s.delete(f,n.to),u>n.from&&s.delete(n.from+d,u),c=n.from+d+l.length,s.addMark(n.from+d,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}function jx(t){return new yr({find:t.find,handler({match:e,chain:n,range:r,pasteEvent:o}){let i=G(t.getAttributes,void 0,e,o),s=G(t.getContent,void 0,i);if(i===!1||i===null)return null;let l={type:t.type.name,attrs:i};s&&(l.content=s),e.input&&n().deleteRange(r).insertContentAt(r.from,l)}})}function _x(t){return new yr({find:t.find,handler:({state:e,range:n,match:r})=>{let o=t.replace,i=n.from,s=n.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)}})}var Ux=class{constructor(t){this.transaction=t,this.currentStep=this.transaction.steps.length}map(t){let e=!1;return{position:this.transaction.steps.slice(this.currentStep).reduce((n,r)=>{let o=r.getMap().mapResult(n);return o.deleted&&(e=!0),o.pos},t),deleted:e}}};function Eh(t={}){return new F({view(e){return new La(e,t)}})}var La=class{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(n){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),g=u?p.bottom:p.top;u&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:p.left,right:p.right,top:g-m,bottom:g+m}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!i){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ko(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var pe=class t extends z{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return t.valid(r)?new t(r):z.near(r)}content(){return E.empty}eq(e){return e instanceof t&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new t(e.resolve(n.pos))}getBookmark(){return new Ia(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!Kx(e)||!qx(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&t.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(t.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!$.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(t.valid(l))return l}return null}}};pe.prototype.visible=!1;pe.findFrom=pe.findGapCursorFrom;z.jsonID("gapcursor",pe);var Ia=class t{constructor(e){this.pos=e}map(e){return new t(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return pe.valid(n)?new pe(n):z.near(n)}};function Oh(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Kx(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Oh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function qx(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Oh(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Nh(){return new F({props:{decorations:Yx,createSelectionBetween(t,e,n){return e.pos==n.pos&&pe.valid(n)?new pe(n):null},handleClick:Gx,handleKeyDown:Jx,handleDOMEvents:{beforeinput:Xx}}})}var Jx=Zr({ArrowLeft:Ri("horiz",-1),ArrowRight:Ri("horiz",1),ArrowUp:Ri("vert",-1),ArrowDown:Ri("vert",1)});function Ri(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof R){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=pe.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new pe(c))),!0):!1}}function Gx(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!pe.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&$.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new pe(r))),!0)}function Xx(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof pe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=S.empty;for(let s=r.length-1;s>=0;s--)o=S.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new E(o,0,0));return i.setSelection(R.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function Yx(t){if(!(t.selection instanceof pe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Y.create(t.doc,[re.widget(t.selection.head,e,{key:"gapcursor"})])}var Di=200,ve=function(){};ve.prototype.append=function(e){return e.length?(e=ve.from(e),!this.length&&e||e.length<Di&&this.leafAppend(e)||this.length<Di&&e.leafPrepend(this)||this.appendInner(e)):this};ve.prototype.prepend=function(e){return e.length?ve.from(e).append(this):this};ve.prototype.appendInner=function(e){return new Qx(this,e)};ve.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ve.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ve.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ve.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};ve.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};ve.from=function(e){return e instanceof ve?e:e&&e.length?new Rh(e):ve.empty};var Rh=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Di)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Di)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(ve);ve.empty=new Rh([]);var Qx=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ve),Pa=ve;var Zx=500,$n=class t{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new kt(u.map));let h=u.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new kt(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new t(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new kt(e.mapping.maps[d],u,n),h;(h=a&&a.merge(f))&&(f=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(s++,n=void 0),o||(a=f)}let c=s-r.depth;return c>tk&&(l=ek(l,c),s-=c),new t(l.append(i),s)}remapping(e,n){let r=new $r;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new t(this.items.append(e.map(n=>new kt(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),m=f.selection&&f.selection.map(i.slice(a+1,h));m&&l++,r.push(new kt(p,g,m))}else r.push(new kt(p))},o);let c=[];for(let f=n;f<s;f++)c.push(new kt(i.maps[f]));let d=this.items.slice(0,o).append(c).append(r),u=new t(d,l);return u.emptyItemCount()>Zx&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let d=s.selection&&s.selection.map(n.slice(r));d&&i++;let u=new kt(c.invert(),a,d),f,h=o.length-1;(f=o.length&&o[h].merge(u))?o[h]=f:o.push(u)}}else s.map&&r--},this.items.length,0),new t(Pa.from(o.reverse()),i)}};$n.empty=new $n(Pa.empty,0);function ek(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}var kt=class t{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new t(n.getMap().invert(),n,this.selection)}}},St=class{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},tk=20;function nk(t,e,n,r){let o=n.getMeta(Pn),i;if(o)return o.historyState;n.getMeta(ik)&&(t=new St(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Pn))return s.getMeta(Pn).redo?new St(t.done.addTransform(n,void 0,r,Li(e)),t.undone,Dh(n.mapping.maps),t.prevTime,t.prevComposition):new St(t.done,t.undone.addTransform(n,void 0,r,Li(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!rk(n,t.prevRanges)),c=s?$a(t.prevRanges,n.mapping):Dh(n.mapping.maps);return new St(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Li(e)),$n.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new St(t.done.rebased(n,i),t.undone.rebased(n,i),$a(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new St(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),$a(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function rk(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(n=!0)}),n}function Dh(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function $a(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function ok(t,e,n){let r=Li(e),o=Pn.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),a=new St(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Pn,{redo:n,historyState:a})}var Ba=!1,Lh=null;function Li(t){let e=t.plugins;if(Lh!=e){Ba=!1,Lh=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ba=!0;break}}return Ba}var Pn=new j("history"),ik=new j("closeHistory");function Ih(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new F({key:Pn,state:{init(){return new St($n.empty,$n.empty,null,0,-1)},apply(e,n,r){return nk(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?za:r=="historyRedo"?Ha:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function Ii(t,e){return(n,r)=>{let o=Pn.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=ok(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}var za=Ii(!1,!0),Ha=Ii(!0,!0),zM=Ii(!1,!1),HM=Ii(!0,!1);var GM=Z.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{let e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){let n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{let e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new F({key:new j("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;let o=this.options.limit,i=this.options.autoTrim;if(o==null||o===0||i===!1){t=!0;return}let s=this.storage.characters({node:r.doc});if(s>o){let l=s-o,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);let d=r.tr.deleteRange(a,c);return t=!0,d}t=!0},filterTransaction:(e,n)=>{let r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;let o=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||o>r&&i>r&&i<=o)return!0;if(o>r&&i>r&&i>o||!e.getMeta("paste"))return!1;let s=e.selection.$head.pos,l=s-(i-r),a=s;return e.deleteRange(l,a),!(this.storage.characters({node:e.doc})>r)}})]}}),Bh=Z.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Eh(this.options)]}}),XM=Z.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new F({key:new j("focus"),props:{decorations:({doc:t,selection:e})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,i=[];if(!n||!r)return Y.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(!a.isText){if(!(o>=c&&o<=c+a.nodeSize-1))return!1;s+=1}});let l=0;return t.descendants((a,c)=>{if(a.isText||!(o>=c&&o<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(re.node(c,c+a.nodeSize,{class:this.options.className}))}),Y.create(t,i)}}})]}}),zh=Z.create({name:"gapCursor",addProseMirrorPlugins(){return[Nh()]},extendNodeSchema(t){var e;let n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=G(B(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),Hh="placeholder",Ph=new j("tiptap__placeholder");function Fh(t){let{editor:e,placeholder:n,dataAttribute:r,pos:o,node:i,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,d=[a];return s&&d.push(c),re.node(o,o+i.nodeSize,{class:d.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:o,hasAnchor:l}):n})}function Vh(t,e){return typeof t=="function"?t(e):t}function Wh({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:i,to:s}){let{anchor:l}=o,a=[],c=t.isEmpty;return r.nodesBetween(i,s,(d,u)=>{let f=l>=u&&l<=u+d.nodeSize,h=!d.isLeaf&&In(d);return d.type.isTextblock&&(f||!e.showOnlyCurrent)&&h&&a.push(Fh({editor:t,isEmptyDoc:c,dataAttribute:n,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Vh(e.emptyNodeClass,{editor:t,node:d,pos:u,hasAnchor:f})},node:d,pos:u})),e.includeChildren}),a}function jh({editor:t,options:e,dataAttribute:n,doc:r,selection:o}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;let{anchor:i}=o,s=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){let a=r.resolve(i),c=a.depth>0?a.node(1):a.nodeAfter,d=a.depth>0?a.before(1):i;if(c&&c.type.isTextblock&&In(c)){let u=i>=d&&i<=d+c.nodeSize;s.push(Fh({editor:t,isEmptyDoc:l,dataAttribute:n,hasAnchor:u,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Vh(e.emptyNodeClass,{editor:t,node:c,pos:d,hasAnchor:u})},node:c,pos:d}))}}else s.push(...Wh({editor:t,options:e,dataAttribute:n,doc:r,selection:o,from:0,to:r.content.size}));return Y.create(r,s)}function mo(t,e){let n=t.resolve(e);if(n.depth===0){var r;let i=(r=n.nodeAfter)!==null&&r!==void 0?r:n.nodeBefore;if(!i)return{from:e,to:e};let s=n.nodeAfter?e:e-i.nodeSize;return{from:s,to:s+i.nodeSize}}let o=n.before(1);return{from:o,to:o+n.node(1).nodeSize}}function go(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function sk(t,e,n){let r=[];return t.forEach((o,i)=>{let s=i,l=s+o.nodeSize,a=s+1,c=l+1;a<n&&c>e&&r.push({from:s,to:l})}),r}function lk(t){if(t.length===0)return[];let e=[...t].sort((r,o)=>r.from-o.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){let o=n[n.length-1],i=e[r];i.from<=o.to?o.to=Math.max(o.to,i.to):n.push({...i})}return n}function ak(t,e){let n=sk(t,e.from,e.to);return n.push(go(t,mo(t,e.from))),e.to>e.from?n.push(go(t,mo(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(go(t,mo(t,Math.min(e.from+1,t.content.size)))),n}function ck(t,e,n){let r=[];if(t.docChanged){let o=Ln(t);for(let i of o)r.push(...ak(n.doc,i.newRange))}return t.selectionSet&&(r.push(go(n.doc,mo(n.doc,t.mapping.map(e.selection.anchor)))),r.push(go(n.doc,mo(n.doc,n.selection.anchor)))),lk(r)}function dk(t,e,n){let r=Math.max(0,Math.min(t,n.content.size));return{from:r,to:Math.max(r,Math.min(e,n.content.size))}}function uk({decorations:t,ranges:e,editor:n,options:r,dataAttribute:o,doc:i,selection:s}){let l=t;for(let a of e){let{from:c,to:d}=dk(a.from,a.to,i),u=l.find(c,d).filter(h=>h.from>=c&&h.to<=d);u.length&&(l=l.remove(u));let f=Wh({editor:n,options:r,dataAttribute:o,doc:i,selection:s,from:c,to:d});f.length&&(l=l.add(i,f))}return l}function fk({editor:t,options:e,dataAttribute:n}){return{init(r,o){let i=jh({editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection});return i??Y.empty},apply(r,o,i,s){return!r.docChanged&&!r.selectionSet?o:uk({decorations:o.map(r.mapping,r.doc),ranges:ck(r,i,s),editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection})}}}function hk(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function pk({editor:t,options:e}){let n=e.dataAttribute?`data-${hk(e.dataAttribute)}`:`data-${Hh}`,r=e.showOnlyCurrent&&!e.includeChildren;return new F({key:Ph,...r?{}:{state:fk({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:o,selection:i})=>jh({editor:t,options:e,dataAttribute:n,doc:o,selection:i}):o=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?Y.empty:(i=Ph.getState(o))!==null&&i!==void 0?i:Y.empty}}})}var Va=Z.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Hh,placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[pk({editor:this.editor,options:this.options})]}});function Fa(t,e){return!t.selection.empty&&!co(t.selection)&&e.isEditable}function mk(t,e){return Fa(t,e)&&!e.isFocused&&!e.view.dragging}function gk(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function yk(t){t.focus()}var YM=Z.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){let{editor:t,options:e}=this;return[new F({key:new j("selection"),props:{decorations(n){return mk(n,t)?Y.create(n.doc,[re.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Fa(n.state,t)&&gk(),!1},focus(n){return Fa(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&yk(n)}),!1}}}})]}});function $h({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var QM=Z.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;let e=new j(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new F({key:e,appendTransaction:(o,i,s)=>{let{doc:l,tr:a,schema:c}=s,d=e.getState(s),u=l.content.size,f=c.nodes[n];if(!o.some(h=>h.getMeta("skipTrailingNode"))&&d)return a.insert(u,f.create())},state:{init:(o,i)=>{let s=i.tr.doc.lastChild;return!$h({node:s,types:r})},apply:(o,i)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return i;let s=o.doc.lastChild;return!$h({node:s,types:r})}}})]}}),_h=Z.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>za(t,e),redo:()=>({state:t,dispatch:e})=>Ha(t,e)}},addProseMirrorPlugins(){return[Ih(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Uh=new WeakSet,Kh=new WeakSet;function Bn(t){let e=t;return Uh.add(e),e}function Wa(t){return Array.isArray(t)&&Uh.has(t)}function qh(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&Kh.has(e)&&!Wa(e)?qh(e):[e])}function bk(t,e){if(t==="slot")return 0;if(t instanceof Function){let o=t(e);return Array.isArray(o)&&!Wa(o)&&!Kh.has(o)?Bn(o):o}let{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");if(Array.isArray(n)){if(Wa(n))return Bn([t,r,n]);if(n.length===0)return Bn([t,r]);let o=qh(n);return o.length===0?Bn([t,r]):Bn([t,r,...o])}return n!=null?Bn([t,r,n]):Bn([t,r])}var wr=(t,e)=>bk(t,e);var wk=(t,e)=>{var n;let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0)return!1;let s=i.depth-1;if(s<0)return!1;let l=i.node(s),a=i.index(s);if(a===0)return!1;if(l.type===e)return t.commands.lift(e.name);let c=l.child(a-1);if(c.type!==e||!(!((n=c.lastChild)===null||n===void 0)&&n.isTextblock))return!1;let d=i.before()-1-1;return t.commands.command(({tr:u,dispatch:f})=>{if(!f)return!0;let h=i.parent.content,p=new E(h,0,0);return u.replace(d,i.after(),p),u.setSelection(R.create(u.doc,d+h.size)),u.scrollIntoView(),f(u),!0})},xk=/^\s*>\s$/,kk=W.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return wr("blockquote",{...L(this.options.HTMLAttributes,t),children:wr("slot",{})})},parseMarkdown:(t,e)=>{var n;let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";let n=">",r=[];return t.content.forEach((o,i)=>{var s,l;let a=((s=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,o,i))!==null&&s!==void 0?s:e.renderChildren([o])).split(`
107
+ `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(a.join(`
108
+ `))}),r.join(`
109
+ ${n}
110
+ `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>wk(this.editor,this.type)}},addInputRules(){return[Vt({find:xk,type:this.type})]}}),Jh=kk;var Sk=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ck=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,vk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Mk=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Tk=ie.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return wr("strong",{...L(this.options.HTMLAttributes,t),children:wr("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ie({find:Sk,type:this.type}),Ie({find:vk,type:this.type})]},addPasteRules(){return[Ne({find:Ck,type:this.type}),Ne({find:Mk,type:this.type})]}}),Gh=Tk;var Ak=t=>{let e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},Ek=t=>{let e=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},Ok=ie.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",L(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ie({find:Ak,type:this.type})]},addPasteRules(){return[Ne({find:Ek,type:this.type})]}}),Xh=Ok;var ja=4,Nk=/^```([a-z]+)?[\s\n]$/,Rk=/^~~~([a-z]+)?[\s\n]$/,Dk=W.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ja,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;let{languageClassPrefix:n}=this.options;if(!n)return null;let r=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return r||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",L(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)===null||n===void 0?void 0:n.startsWith("```"))===!1&&((r=t.raw)===null||r===void 0?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="",o=((n=t.attrs)===null||n===void 0?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(`
111
+ `):r=`\`\`\`${o}
112
+
113
+ \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ja,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;if(i.parent.type!==this.type)return!1;let l=" ".repeat(n);return s?t.commands.insertContent(l):t.commands.command(({tr:a})=>{let{from:c,to:d}=o,u=r.doc.textBetween(c,d,`
114
+ `,`
115
+ `).split(`
116
+ `).map(f=>l+f).join(`
117
+ `);return a.replaceWith(c,d,r.schema.text(u)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;let n=(e=this.options.tabSize)!==null&&e!==void 0?e:ja,{state:r}=t,{selection:o}=r,{$from:i,empty:s}=o;return i.parent.type!==this.type?!1:s?t.commands.command(({tr:l})=>{var a;let{pos:c}=i,d=i.start(),u=i.end(),f=r.doc.textBetween(d,u,`
118
+ `,`
119
+ `).split(`
120
+ `),h=0,p=0,g=c-d;for(let x=0;x<f.length;x+=1){if(p+f[x].length>=g){h=x;break}p+=f[x].length+1}let m=((a=f[h].match(/^ */))===null||a===void 0?void 0:a[0])||"",y=Math.min(m.length,n);if(y===0)return!0;let w=d;for(let x=0;x<h;x+=1)w+=f[x].length+1;return l.delete(w,w+y),c-w<=y&&l.setSelection(R.create(l.doc,w)),!0}):t.commands.command(({tr:l})=>{let{from:a,to:c}=o,d=r.doc.textBetween(a,c,`
121
+ `,`
122
+ `).split(`
123
+ `).map(u=>{var f;let h=((f=u.match(/^ */))===null||f===void 0?void 0:f[0])||"",p=Math.min(h.length,n);return u.slice(p)}).join(`
124
+ `);return l.replaceWith(a,c,r.schema.text(d)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(`
125
+
126
+ `);return!i||!s?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;let{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==0)return!1;let i=r.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:i}=n;if(!i||o.parent.type!==this.type||o.parentOffset!==o.parent.nodeSize-2)return!1;let s=o.after();return s===void 0?!1:r.nodeAt(s)?t.commands.command(({tr:l})=>(l.setSelection(z.near(r.resolve(s))),!0)):t.commands.exitCode()}}},addInputRules(){return[br({find:Nk,type:this.type,getAttributes:t=>({language:t[1]})}),br({find:Rk,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new F({key:new j("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o?.mode;if(!n||!i)return!1;let{tr:s,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
127
+ `));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(R.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),Yh=Dk;var Qh=W.create({name:"customBlock",group:"block",atom:!0,defining:!0,draggable:!0,selectable:!0,isolating:!0,allowGapCursor:!0,inline:!1,addNodeView(){return({editor:t,node:e,getPos:n,HTMLAttributes:r,decorations:o,extension:i})=>{let s=document.createElement("div");s.setAttribute("data-config",JSON.stringify(e.attrs.config)),s.setAttribute("data-id",e.attrs.id),s.setAttribute("data-testid","rich-editor-custom-block"),s.setAttribute("data-type","customBlock"),i.options.hasMinimalCustomBlockControls&&e.attrs.preview&&s.classList.add("fi-fo-rich-editor-custom-block-minimal");let l=document.createElement("div");if(l.className="fi-fo-rich-editor-custom-block-header fi-not-prose",s.appendChild(l),t.isEditable&&typeof e.attrs.config=="object"&&e.attrs.config!==null&&Object.keys(e.attrs.config).length>0){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-edit-btn-ctn",l.appendChild(c);let d=document.createElement("button");d.className="fi-icon-btn",d.dataset.testid="rich-editor-custom-block-edit-button",d.type="button",i.options.editCustomBlockButtonLabel&&d.setAttribute("aria-label",i.options.editCustomBlockButtonLabel),d.innerHTML=i.options.editCustomBlockButtonIconHtml,d.addEventListener("click",()=>{t.commands.setNodeSelection(n()),i.options.editCustomBlockUsing(e.attrs.id,e.attrs.config)}),c.appendChild(d)}let a=document.createElement("p");if(a.className="fi-fo-rich-editor-custom-block-heading",a.textContent=e.attrs.label,l.appendChild(a),t.isEditable){let c=document.createElement("div");c.className="fi-fo-rich-editor-custom-block-delete-btn-ctn",l.appendChild(c);let d=document.createElement("button");d.className="fi-icon-btn",d.dataset.testid="rich-editor-custom-block-delete-button",d.type="button",i.options.deleteCustomBlockButtonLabel&&d.setAttribute("aria-label",i.options.deleteCustomBlockButtonLabel),d.innerHTML=i.options.deleteCustomBlockButtonIconHtml,d.addEventListener("click",()=>t.chain().focus().setNodeSelection(n()).deleteSelection().run()),c.appendChild(d)}if(e.attrs.preview){let c=document.createElement("div"),d=["fi-fo-rich-editor-custom-block-preview"];e.attrs.shouldApplyProseStylingToPreview||d.push("fi-not-prose"),c.className=d.join(" "),c.innerHTML=new TextDecoder().decode(Uint8Array.from(atob(e.attrs.preview),u=>u.charCodeAt(0))),s.appendChild(c)}return{dom:s,stopEvent:c=>c.target instanceof Element&&l.contains(c.target.closest("button"))}}},addOptions(){return{deleteCustomBlockButtonIconHtml:null,deleteCustomBlockButtonLabel:null,editCustomBlockButtonIconHtml:null,editCustomBlockButtonLabel:null,editCustomBlockUsing:()=>{},getCustomBlockPreviewsUsing:async()=>[],hasMinimalCustomBlockControls:!1,insertCustomBlockUsing:()=>{}}},addAttributes(){return{config:{default:null,parseHTML:t=>JSON.parse(t.getAttribute("data-config")),renderHTML:t=>t.config?{"data-config":JSON.stringify(t.config)}:{}},id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:()=>null,rendered:!1},preview:{default:null,parseHTML:()=>null,rendered:!1},shouldApplyProseStylingToPreview:{default:!1,parseHTML:()=>!1,rendered:!1}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",L({"data-type":"customBlock"},t)]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({state:t})=>{let e=!1,{selection:n}=t,{empty:r,anchor:o}=n;return r?(t.doc.nodesBetween(o-1,o,i=>{if(i.type.name===this.name)return e=!0,!1}),e):!1})}},addProseMirrorPlugins(){let{getCustomBlockPreviewsUsing:t,insertCustomBlockUsing:e}=this.options,n=new Map,r=new Set,o=s=>JSON.stringify([s.attrs.id,s.attrs.config]),i=async s=>{if(this.editor.isDestroyed)return;let l=[],a=[],c=new Map;if(s.state.doc.descendants(u=>{if(u.type.name!==this.name)return;let f=o(u);if(u.attrs.preview!==null){n.set(f,{label:u.attrs.label,preview:u.attrs.preview,shouldApplyProseStylingToPreview:u.attrs.shouldApplyProseStylingToPreview});return}!u.attrs.id||r.has(f)||c.set(f,{config:u.attrs.config,id:u.attrs.id})}),c.forEach((u,f)=>{n.has(f)||(r.add(f),a.push(f),l.push({...u,key:l.length}))}),l.length){let u,f;try{u=await Promise.race([t(l),new Promise((h,p)=>{f=setTimeout(()=>p(new Error("Preview request timed out")),3e4)})])}catch(h){this.editor.isDestroyed||console.error("Failed to hydrate custom block previews",h);return}finally{clearTimeout(f),a.forEach(h=>{r.delete(h)})}if(this.editor.isDestroyed)return;a.forEach(h=>{n.set(h,null)}),u.forEach(h=>{let p=a[h.key];p!==void 0&&n.set(p,{label:h.label,preview:h.preview,shouldApplyProseStylingToPreview:h.shouldApplyProseStylingToPreview})})}let d=s.state.tr;s.state.doc.descendants((u,f)=>{if(u.type.name!==this.name||u.attrs.preview!==null)return;let h=n.get(o(u));h&&d.setNodeMarkup(f,void 0,{...u.attrs,...h})}),d.docChanged&&(d.setMeta("addToHistory",!1),s.dispatch(d))};return[new F({props:{handleDrop(s,l){if(!l||!l.dataTransfer.getData("customBlock"))return!1;l.preventDefault();let a=l.dataTransfer.getData("customBlock");return e(a,s.posAtCoords({left:l.clientX,top:l.clientY}).pos),!1}},view:s=>(setTimeout(()=>i(s)),{update:l=>queueMicrotask(()=>i(l))})})]}});var Pi=(t,e)=>{let n=e.view.domAtPos(t).node,r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return r?r.offsetParent!==null:!1},Lk=(t,e,n)=>{for(let r=t.depth;r>0;r-=1){let o=t.node(r),i=e(o),s=Pi(t.start(r),n);if(i&&s)return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:o}}},Zh=(t,e)=>{let{state:n,view:r,extensionManager:o}=t,{schema:i,selection:s}=n,{empty:l,$anchor:a}=s,c=!!o.extensions.find(m=>m.name==="gapCursor");if(!l||a.parent.type!==i.nodes.detailsSummary||!c||e==="right"&&a.parentOffset!==a.parent.nodeSize-2)return!1;let d=Ht(m=>m.type===i.nodes.details)(s);if(!d)return!1;let u=mr(d.node,m=>m.type===i.nodes.detailsContent);if(!u.length||Pi(d.start+u[0].pos+1,t))return!1;let f=n.doc.resolve(d.pos+d.node.nodeSize),h=pe.findFrom(f,1,!1);if(!h)return!1;let{tr:p}=n,g=new pe(h);return p.setSelection(g),p.scrollIntoView(),r.dispatch(p),!0},ep=W.create({name:"details",content:"detailsSummary detailsContent",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,addOptions(){return{persist:!1,openClassName:"is-open",HTMLAttributes:{},renderToggleButton:({element:t,isOpen:e})=>{t.setAttribute("aria-label",e?"Collapse details content":"Expand details content")}}},addAttributes(){return this.options.persist?{open:{default:!1,parseHTML:t=>t.hasAttribute("open"),renderHTML:({open:t})=>t?{open:""}:{}}}:[]},parseHTML(){return[{tag:"details"}]},renderHTML({HTMLAttributes:t}){return["details",L(this.options.HTMLAttributes,t),0]},...gr({nodeName:"details",content:"block"}),addNodeView(){return({editor:t,getPos:e,node:n,HTMLAttributes:r})=>{let o=document.createElement("div"),i=L(this.options.HTMLAttributes,r,{"data-type":this.name});Object.entries(i).forEach(([d,u])=>o.setAttribute(d,u));let s=document.createElement("button");s.type="button";let l=d=>{this.options.renderToggleButton({element:s,...d})};o.append(s);let a=document.createElement("div");o.append(a);let c=d=>{let{setToValue:u,node:f=n}=d||{};if(u!==void 0)if(u){if(o.classList.contains(this.options.openClassName))return;o.classList.add(this.options.openClassName)}else{if(!o.classList.contains(this.options.openClassName))return;o.classList.remove(this.options.openClassName)}else o.classList.toggle(this.options.openClassName);let h=o.classList.contains(this.options.openClassName);l({isOpen:h,node:f});let p=new Event("toggleDetailsContent"),g=a.querySelector(':scope > div[data-type="detailsContent"]');g?.dispatchEvent(p)};return l({isOpen:!!n.attrs.open,node:n}),n.attrs.open&&setTimeout(()=>c()),s.addEventListener("click",()=>{if(c(),!this.options.persist){t.commands.focus(void 0,{scrollIntoView:!1});return}if(t.isEditable&&typeof e=="function"){let{from:d,to:u}=t.state.selection;t.chain().command(({tr:f})=>{let h=e();if(typeof h!="number")return!1;let p=f.doc.nodeAt(h);return p?.type!==this.type?!1:(f.setNodeMarkup(h,void 0,{open:!p.attrs.open}),!0)}).setTextSelection({from:d,to:u}).focus(void 0,{scrollIntoView:!1}).run()}}),{dom:o,contentDOM:a,ignoreMutation(d){if(d.type==="selection")return!1;let u=d.target,f=o.contains(u);return s.contains(u)||!f||o===u},update:d=>d.type!==this.type?!1:(d.attrs.open!==void 0?c({setToValue:d.attrs.open,node:d}):l({isOpen:o.classList.contains(this.options.openClassName),node:d}),!0)}}},addCommands(){return{setDetails:()=>({state:t,chain:e})=>{var n;let{schema:r,selection:o}=t,{$from:i,$to:s}=o,l=i.blockRange(s);if(!l)return!1;let a=t.doc.slice(l.start,l.end);if(!r.nodes.detailsContent.contentMatch.matchFragment(a.content))return!1;let c=((n=a.toJSON())===null||n===void 0?void 0:n.content)||[];return e().insertContentAt({from:l.start,to:l.end},{type:this.name,content:[{type:"detailsSummary"},{type:"detailsContent",content:c}]}).setTextSelection(l.start+2).run()},unsetDetails:()=>({state:t,chain:e})=>{let{selection:n,schema:r}=t,o=Ht(g=>g.type===this.type)(n);if(!o)return!1;let i=mr(o.node,g=>g.type===r.nodes.detailsSummary),s=mr(o.node,g=>g.type===r.nodes.detailsContent);if(!i.length||!s.length)return!1;let l=i[0],a=s[0],c=o.pos,d=t.doc.resolve(c),u={from:c,to:c+o.node.nodeSize},f=a.node.content.toJSON()||[],h=d.parent.type.contentMatch.defaultType,p=[h?.create(null,l.node.content).toJSON(),...f];return e().insertContentAt(u,p).setTextSelection(c+1).run()}}},addKeyboardShortcuts(){return{Backspace:()=>{let{schema:t,selection:e}=this.editor.state,{empty:n,$anchor:r}=e;return!n||r.parent.type!==t.nodes.detailsSummary?!1:r.parentOffset!==0?this.editor.commands.command(({tr:o})=>{let i=r.pos-1,s=r.pos;return o.delete(i,s),!0}):this.editor.commands.unsetDetails()},Enter:({editor:t})=>{let{state:e,view:n}=t,{schema:r,selection:o}=e,{$head:i}=o;if(i.parent.type!==r.nodes.detailsSummary)return!1;let s=Pi(i.after()+1,t),l=s?e.doc.nodeAt(i.after()):i.node(-2);if(!l)return!1;let a=s?0:i.indexAfter(-1),c=pr(l.contentMatchAt(a));if(!c||!l.canReplaceWith(a,a,c))return!1;let d=c.createAndFill();if(!d)return!1;let u=s?i.after()+1:i.after(-1),f=e.tr.replaceWith(u,u,d),h=f.doc.resolve(u),p=z.near(h,1);return f.setSelection(p),f.scrollIntoView(),n.dispatch(f),!0},ArrowRight:({editor:t})=>Zh(t,"right"),ArrowDown:({editor:t})=>Zh(t,"down")}},addProseMirrorPlugins(){return[new F({key:new j("detailsSelection"),appendTransaction:(t,e,n)=>{let{editor:r,type:o}=this;if(r.view.composing||!t.some(u=>u.selectionSet)||!e.selection.empty||!n.selection.empty||!vi(n,o.name))return;let{$from:i}=n.selection;if(Pi(i.pos,r))return;let s=Lk(i,u=>u.type===o,r);if(!s)return;let l=mr(s.node,u=>u.type===n.schema.nodes.detailsSummary);if(!l.length)return;let a=l[0],c=(e.selection.from<n.selection.from?"forward":"backward")=="forward"?s.start+a.pos:s.pos+a.pos+a.node.nodeSize,d=R.create(n.doc,c);return n.tr.setSelection(d)}})]}}),tp=W.create({name:"detailsContent",content:"block+",defining:!0,selectable:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`div[data-type="${this.name}"]`}]},renderHTML({HTMLAttributes:t}){return["div",L(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addNodeView(){return({HTMLAttributes:t})=>{let e=document.createElement("div"),n=L(this.options.HTMLAttributes,t,{"data-type":this.name,hidden:"hidden"});return Object.entries(n).forEach(([r,o])=>e.setAttribute(r,o)),e.addEventListener("toggleDetailsContent",()=>{e.toggleAttribute("hidden")}),{dom:e,contentDOM:e,ignoreMutation(r){return r.type==="selection"?!1:!e.contains(r.target)||e===r.target},update:r=>r.type===this.type}}},addKeyboardShortcuts(){return{Enter:({editor:t})=>{let{state:e,view:n}=t,{selection:r}=e,{$from:o,empty:i}=r,s=Ht(P=>P.type===this.type)(r);if(!i||!s||!s.node.childCount)return!1;let l=o.index(s.depth),{childCount:a}=s.node;if(a!==l+1)return!1;let c=s.node.type.contentMatch.defaultType,d=c?.createAndFill();if(!d)return!1;let u=e.doc.resolve(s.pos+1),f=a-1,h=s.node.child(f),p=u.posAtIndex(f,s.depth);if(!h.eq(d))return!1;let g=o.node(-3);if(!g)return!1;let m=o.indexAfter(-3),y=pr(g.contentMatchAt(m));if(!y||!g.canReplaceWith(m,m,y))return!1;let w=y.createAndFill();if(!w)return!1;let{tr:x}=e,b=o.after(-2);x.replaceWith(b,b,w);let k=x.doc.resolve(b),v=z.near(k,1);x.setSelection(v);let C=p,O=p+h.nodeSize;return x.delete(C,O),x.scrollIntoView(),n.dispatch(x),!0}}},...gr({nodeName:"detailsContent"})}),np=W.create({name:"detailsSummary",content:"text*",defining:!0,selectable:!1,isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"summary"}]},renderHTML({HTMLAttributes:t}){return["summary",L(this.options.HTMLAttributes,t),0]},...gr({nodeName:"detailsSummary",content:"inline"})});var Ik=W.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
128
+
129
+ `):""}),rp=Ik;var Pk=12,ip=(t,e)=>{let n=dt(t.$from,o=>o.type.name===e),r=t.node?.type.name==="gridColumn"?{node:t.node,pos:t.from,depth:t.$from.depth+1}:dt(t.$from,o=>o.type.name==="gridColumn");return n&&r&&r.depth===n.depth+1?{grid:n,column:r}:null},sp=t=>Math.max(1,Number(t.attrs["data-col-span"])||1),lp=(t,e)=>e?lp(e,t%e):t,$k=t=>{let e=!0;return t.forEach(n=>{sp(n)!==1&&(e=!1)}),e},op=({tr:t,dispatch:e,editor:n,gridNodeName:r,shouldInsertAfter:o})=>{let i=ip(t.selection,r);if(!i||!$k(i.grid.node)||i.grid.node.childCount>=Pk)return!1;if(e){let s=n.schema.nodes.gridColumn.createAndFill({"data-col-span":1}),l=o?i.column.pos+i.column.node.nodeSize:i.column.pos;t.setNodeMarkup(i.grid.pos,void 0,{...i.grid.node.attrs,"data-cols":i.grid.node.childCount+1}).insert(l,s).scrollIntoView()}return!0},ap=W.create({name:"grid",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"gridColumn+",addOptions(){return{HTMLAttributes:{class:"grid-layout"}}},addAttributes(){return{"data-cols":{default:2,parseHTML:t=>t.getAttribute("data-cols")},"data-from-breakpoint":{default:"md",parseHTML:t=>t.getAttribute("data-from-breakpoint")},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>({style:`--cols: repeat(${Math.max(1,Number(t["data-cols"])||1)}, minmax(0, 1fr))`})}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("grid-layout")&&null}]},renderHTML({HTMLAttributes:t}){return["div",L(this.options.HTMLAttributes,t),0]},addCommands(){return{addGridColumnBefore:()=>({tr:t,dispatch:e,editor:n})=>op({tr:t,dispatch:e,editor:n,gridNodeName:this.name,shouldInsertAfter:!1}),addGridColumnAfter:()=>({tr:t,dispatch:e,editor:n})=>op({tr:t,dispatch:e,editor:n,gridNodeName:this.name,shouldInsertAfter:!0}),deleteGridColumn:()=>({tr:t,dispatch:e})=>{let n=ip(t.selection,this.name);if(!n||n.grid.node.childCount<=1)return!1;if(e){let r=[];n.grid.node.forEach((s,l)=>{let a=n.grid.pos+1+l;a!==n.column.pos&&r.push({column:s,position:a,span:sp(s)})});let o=r.map(s=>s.span).reduce(lp),i=r.reduce((s,l)=>s+l.span/o,0);r.forEach(({column:s,position:l,span:a})=>{t.setNodeMarkup(l,void 0,{...s.attrs,"data-col-span":a/o})}),t.setNodeMarkup(n.grid.pos,void 0,{...n.grid.node.attrs,"data-cols":i}).delete(n.column.pos,n.column.pos+n.column.node.nodeSize).setSelection(R.near(t.doc.resolve(n.column.pos))).scrollIntoView()}return!0},deleteGrid:()=>({tr:t,dispatch:e})=>{let n=dt(t.selection.$from,r=>r.type.name===this.name);if(!n)return!1;if(e){let r=[];n.node.forEach(o=>{o.forEach(i=>r.push(i))}),t.replaceWith(n.pos,n.pos+n.node.nodeSize,r).setSelection(R.near(t.doc.resolve(n.pos))).scrollIntoView()}return!0},insertGrid:({columns:t=[1,1],fromBreakpoint:e,coordinates:n=null}={})=>({tr:r,dispatch:o,editor:i})=>{let s=i.schema.nodes.gridColumn,l=Array.isArray(t)&&t.length?t:[1,1],a=[];for(let u=0;u<l.length;u+=1)a.push(s.createAndFill({"data-col-span":Number(l[u]??1)||1}));let c=l.map(u=>Number(u)||1).reduce((u,f)=>u+f,0),d=i.schema.nodes.grid.createChecked({"data-cols":c,"data-from-breakpoint":e},a);if(o){let u=r.selection.anchor+1;[null,void 0].includes(n?.from)?r.replaceSelectionWith(d).scrollIntoView().setSelection(R.near(r.doc.resolve(u))):r.replaceRangeWith(n.from,n.to,d).scrollIntoView().setSelection(R.near(r.doc.resolve(n.from)))}return!0}}}});var cp=W.create({name:"gridColumn",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"grid-layout-col"}}},addAttributes(){return{"data-col-span":{default:1,parseHTML:t=>t.getAttribute("data-col-span"),renderHTML:t=>({"data-col-span":t["data-col-span"]??1})},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>{let e=Math.max(1,Number(t["data-col-span"])||1);return{style:`--col-span: span ${e} / span ${e}`}}}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("grid-layout-col")&&null}]},renderHTML({HTMLAttributes:t}){return["div",L(this.options.HTMLAttributes,t),0]}});var Bk=W.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",L(this.options.HTMLAttributes,t)]},renderText(){return`
130
+ `},renderMarkdown:()=>`
131
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{let{selection:o,storedMarks:i}=n;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&s){let u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),dp=Bk;var zk=W.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,L(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;let r=!((n=t.attrs)===null||n===void 0)&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>br({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),up=zk;var Hk=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Fk=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Vk=ie.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||Ea(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",L(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){let r=/^(==)([^=]+)(==)/.exec(t);if(r){let o=r[2].trim(),i=n.inlineTokens(o);return{type:"highlight",raw:r[0],text:o,tokens:i}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ie({find:Hk,type:this.type})]},addPasteRules(){return[Ne({find:Fk,type:this.type})]}}),fp=Vk;var Wk=W.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",L(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Ta(e,e.schema.nodes[this.name]))return!1;let{selection:n}=e,{$to:r}=n,o=t();return co(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:i,tr:s,dispatch:l})=>{if(l){let{$to:a}=s.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?s.setSelection(R.create(s.doc,a.pos+1)):a.nodeAfter.isBlock?s.setSelection($.create(s.doc,a.pos)):s.setSelection(R.create(s.doc,a.pos));else{let d=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(s.insert(c,u),s.setSelection(R.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[po({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),hp=Wk;var jk=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,_k=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Uk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Kk=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,qk=ie.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",L(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ie({find:jk,type:this.type}),Ie({find:Uk,type:this.type})]},addPasteRules(){return[Ne({find:_k,type:this.type}),Ne({find:Kk,type:this.type})]}}),pp=qk;var Jk=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Gk=W.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",L(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,o,i,s;let l=(e=(n=t.attrs)===null||n===void 0?void 0:n.src)!==null&&e!==void 0?e:"",a=(r=(o=t.attrs)===null||o===void 0?void 0:o.alt)!==null&&r!==void 0?r:"",c=(i=(s=t.attrs)===null||s===void 0?void 0:s.title)!==null&&i!==void 0?i:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;let{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,o=new Set(["src","width","height"]);return({node:i,getPos:s,HTMLAttributes:l,editor:a})=>{let c=document.createElement("img");c.draggable=!1;let d=L(this.options.HTMLAttributes,l);Object.entries(d).forEach(([y,w])=>{if(w!=null)switch(y){case"src":case"width":case"height":break;default:c.setAttribute(y,w)}}),d.src!==null&&(c.src=d.src);let u={...l},f=y=>{if(typeof y=="string"&&y!==""){c.getAttribute("src")!==y&&(c.src=y);return}c.hasAttribute("src")&&c.removeAttribute("src"),c.src!==""&&(c.src="")};f(l.src);let h=y=>{if(y.type!==i.type)return!1;let w=a.extensionManager.attributes.filter(b=>b.type===y.type.name),x=zt(y,w);return Object.keys(u).forEach(b=>{!o.has(b)&&!(b in x)&&c.removeAttribute(b)}),Object.entries(x).forEach(([b,k])=>{o.has(b)||(k!=null?c.setAttribute(b,k):c.removeAttribute(b))}),f(x.src),u=x,!0},p=new Oi({element:c,editor:a,node:i,getPos:s,onResize:(y,w)=>{c.style.width=`${y}px`,c.style.height=`${w}px`},onCommit:(y,w)=>{let x=s();x!==void 0&&this.editor.chain().setNodeSelection(x).updateAttributes(this.name,{width:y,height:w}).run()},onUpdate:h,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),g=p.dom,m=()=>{g.style.visibility="",g.style.pointerEvents=""};return g.style.visibility="hidden",g.style.pointerEvents="none",c.complete&&c.naturalWidth>0?m():(c.onload=m,c.onerror=m),p}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[po({find:Jk,type:this.type,getAttributes:t=>{let[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),mp=Gk;var gp=t=>/^\d+(?:\.\d+)?$/.test(t)?`${t}px`:t,yp=mp.extend({addAttributes(){return{...this.parent?.(),id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},width:{default:null,parseHTML:t=>t.getAttribute("width")||t.style.width||null,renderHTML:t=>t.width?{width:t.width,style:`width: ${gp(t.width)}`}:{}},height:{default:null,parseHTML:t=>t.getAttribute("height")||t.style.height||null,renderHTML:t=>t.height?{height:t.height,style:`height: ${gp(t.height)}`}:{}}}}});var bp=W.create({name:"lead",group:"block",content:"block+",addOptions(){return{HTMLAttributes:{class:"lead"}}},parseHTML(){return[{tag:"div",getAttrs:t=>t.classList.contains("lead")}]},renderHTML({HTMLAttributes:t}){return["div",L(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleLead:()=>({commands:t})=>t.toggleWrap(this.name)}}});var Xk="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Yk="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Xa="numeric",Ya="ascii",Qa="alpha",wo="asciinumeric",bo="alphanumeric",Za="domain",vp="emoji",Qk="scheme",Zk="slashscheme",_a="whitespace";function eS(t,e){return t in e||(e[t]=[]),e[t]}function zn(t,e,n){e[Xa]&&(e[wo]=!0,e[bo]=!0),e[Ya]&&(e[wo]=!0,e[Qa]=!0),e[wo]&&(e[bo]=!0),e[Qa]&&(e[bo]=!0),e[bo]&&(e[Za]=!0),e[vp]&&(e[Za]=!0);for(let r in e){let o=eS(r,n);o.indexOf(t)<0&&o.push(t)}}function tS(t,e){let n={};for(let r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Be(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Be.groups={};Be.prototype={accepts(){return!!this.t},go(t){let e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){let o=e.jr[r][0],i=e.jr[r][1];if(i&&o.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||Be.groups;let o;return e&&e.j?o=e:(o=new Be(e),n&&r&&zn(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this,i=t.length;if(!i)return o;for(let s=0;s<i-1;s++)o=o.tt(t[s]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Be.groups;let o=this;if(e&&e.j)return o.j[t]=e,e;let i=e,s,l=o.go(t);if(l?(s=new Be,Object.assign(s.j,l.j),s.jr.push.apply(s.jr,l.jr),s.jd=l.jd,s.t=l.t):s=new Be,i){if(r)if(s.t&&typeof s.t=="string"){let a=Object.assign(tS(s.t,r),n);zn(i,a,r)}else n&&zn(i,n,r);s.t=i}return o.j[t]=s,s}};var K=(t,e,n,r,o)=>t.ta(e,n,r,o),le=(t,e,n,r,o)=>t.tr(e,n,r,o),wp=(t,e,n,r,o)=>t.ts(e,n,r,o),T=(t,e,n,r,o)=>t.tt(e,n,r,o),_t="WORD",ec="UWORD",Mp="ASCIINUMERICAL",Tp="ALPHANUMERICAL",Mo="LOCALHOST",tc="TLD",nc="UTLD",Hi="SCHEME",xr="SLASH_SCHEME",oc="NUM",rc="WS",ic="NL",xo="OPENBRACE",ko="CLOSEBRACE",Fi="OPENBRACKET",Vi="CLOSEBRACKET",Wi="OPENPAREN",ji="CLOSEPAREN",_i="OPENANGLEBRACKET",Ui="CLOSEANGLEBRACKET",Ki="FULLWIDTHLEFTPAREN",qi="FULLWIDTHRIGHTPAREN",Ji="LEFTCORNERBRACKET",Gi="RIGHTCORNERBRACKET",Xi="LEFTWHITECORNERBRACKET",Yi="RIGHTWHITECORNERBRACKET",Qi="FULLWIDTHLESSTHAN",Zi="FULLWIDTHGREATERTHAN",es="AMPERSAND",ts="APOSTROPHE",ns="ASTERISK",cn="AT",rs="BACKSLASH",is="BACKTICK",ss="CARET",Hn="COLON",sc="COMMA",ls="DOLLAR",Ct="DOT",as="EQUALS",lc="EXCLAMATION",Qe="HYPHEN",So="PERCENT",cs="PIPE",ds="PLUS",us="POUND",Co="QUERY",ac="QUOTE",Ap="FULLWIDTHMIDDLEDOT",cc="SEMI",vt="SLASH",vo="TILDE",fs="UNDERSCORE",Ep="EMOJI",hs="SYM",Op=Object.freeze({__proto__:null,ALPHANUMERICAL:Tp,AMPERSAND:es,APOSTROPHE:ts,ASCIINUMERICAL:Mp,ASTERISK:ns,AT:cn,BACKSLASH:rs,BACKTICK:is,CARET:ss,CLOSEANGLEBRACKET:Ui,CLOSEBRACE:ko,CLOSEBRACKET:Vi,CLOSEPAREN:ji,COLON:Hn,COMMA:sc,DOLLAR:ls,DOT:Ct,EMOJI:Ep,EQUALS:as,EXCLAMATION:lc,FULLWIDTHGREATERTHAN:Zi,FULLWIDTHLEFTPAREN:Ki,FULLWIDTHLESSTHAN:Qi,FULLWIDTHMIDDLEDOT:Ap,FULLWIDTHRIGHTPAREN:qi,HYPHEN:Qe,LEFTCORNERBRACKET:Ji,LEFTWHITECORNERBRACKET:Xi,LOCALHOST:Mo,NL:ic,NUM:oc,OPENANGLEBRACKET:_i,OPENBRACE:xo,OPENBRACKET:Fi,OPENPAREN:Wi,PERCENT:So,PIPE:cs,PLUS:ds,POUND:us,QUERY:Co,QUOTE:ac,RIGHTCORNERBRACKET:Gi,RIGHTWHITECORNERBRACKET:Yi,SCHEME:Hi,SEMI:cc,SLASH:vt,SLASH_SCHEME:xr,SYM:hs,TILDE:vo,TLD:tc,UNDERSCORE:fs,UTLD:nc,UWORD:ec,WORD:_t,WS:rc}),Wt=/[a-z]/,yo=/\p{L}/u,Ua=/\p{Emoji}/u;var jt=/\d/,Ka=/\s/;var xp="\r",qa=`
132
+ `,nS="\uFE0F",rS="\u200D",Ja="\uFFFC",$i=null,Bi=null;function oS(t=[]){let e={};Be.groups=e;let n=new Be;$i==null&&($i=kp(Xk)),Bi==null&&(Bi=kp(Yk)),T(n,"'",ts),T(n,"{",xo),T(n,"}",ko),T(n,"[",Fi),T(n,"]",Vi),T(n,"(",Wi),T(n,")",ji),T(n,"<",_i),T(n,">",Ui),T(n,"\uFF08",Ki),T(n,"\uFF09",qi),T(n,"\u300C",Ji),T(n,"\u300D",Gi),T(n,"\u300E",Xi),T(n,"\u300F",Yi),T(n,"\uFF1C",Qi),T(n,"\uFF1E",Zi),T(n,"&",es),T(n,"*",ns),T(n,"@",cn),T(n,"`",is),T(n,"^",ss),T(n,":",Hn),T(n,",",sc),T(n,"$",ls),T(n,".",Ct),T(n,"=",as),T(n,"!",lc),T(n,"-",Qe),T(n,"%",So),T(n,"|",cs),T(n,"+",ds),T(n,"#",us),T(n,"?",Co),T(n,'"',ac),T(n,"/",vt),T(n,";",cc),T(n,"~",vo),T(n,"_",fs),T(n,"\\",rs),T(n,"\u30FB",Ap);let r=le(n,jt,oc,{[Xa]:!0});le(r,jt,r);let o=le(r,Wt,Mp,{[wo]:!0}),i=le(r,yo,Tp,{[bo]:!0}),s=le(n,Wt,_t,{[Ya]:!0});le(s,jt,o),le(s,Wt,s),le(o,jt,o),le(o,Wt,o);let l=le(n,yo,ec,{[Qa]:!0});le(l,Wt),le(l,jt,i),le(l,yo,l),le(i,jt,i),le(i,Wt),le(i,yo,i);let a=T(n,qa,ic,{[_a]:!0}),c=T(n,xp,rc,{[_a]:!0}),d=le(n,Ka,rc,{[_a]:!0});T(n,Ja,d),T(c,qa,a),T(c,Ja,d),le(c,Ka,d),T(d,xp),T(d,qa),le(d,Ka,d),T(d,Ja,d);let u=le(n,Ua,Ep,{[vp]:!0});T(u,"#"),le(u,Ua,u),T(u,nS,u);let f=T(u,rS);T(f,"#"),le(f,Ua,u);let h=[[Wt,s],[jt,o]],p=[[Wt,null],[yo,l],[jt,i]];for(let g=0;g<$i.length;g++)an(n,$i[g],tc,_t,h);for(let g=0;g<Bi.length;g++)an(n,Bi[g],nc,ec,p);zn(tc,{tld:!0,ascii:!0},e),zn(nc,{utld:!0,alpha:!0},e),an(n,"file",Hi,_t,h),an(n,"mailto",Hi,_t,h),an(n,"http",xr,_t,h),an(n,"https",xr,_t,h),an(n,"ftp",xr,_t,h),an(n,"ftps",xr,_t,h),zn(Hi,{scheme:!0,ascii:!0},e),zn(xr,{slashscheme:!0,ascii:!0},e),t=t.sort((g,m)=>g[0]>m[0]?1:-1);for(let g=0;g<t.length;g++){let m=t[g][0],w=t[g][1]?{[Qk]:!0}:{[Zk]:!0};m.indexOf("-")>=0?w[Za]=!0:Wt.test(m)?jt.test(m)?w[wo]=!0:w[Ya]=!0:w[Xa]=!0,wp(n,m,m,w)}return wp(n,"localhost",Mo,{ascii:!0}),n.jd=new Be(hs),{start:n,tokens:Object.assign({groups:e},Op)}}function Np(t,e){let n=iS(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,o=[],i=0,s=0;for(;s<r;){let l=t,a=null,c=0,d=null,u=-1,f=-1;for(;s<r&&(a=l.go(n[s]));)l=a,l.accepts()?(u=0,f=0,d=l):u>=0&&(u+=n[s].length,f++),c+=n[s].length,i+=n[s].length,s++;i-=u,s-=f,c-=u,o.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function iS(t){let e=[],n=t.length,r=0;for(;r<n;){let o=t.charCodeAt(r),i,s=o<55296||o>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}function an(t,e,n,r,o){let i,s=e.length;for(let l=0;l<s-1;l++){let a=e[l];t.j[a]?i=t.j[a]:(i=new Be(r),i.jr=o.slice(),t.j[a]=i),t=i}return i=new Be(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function kp(t){let e=[],n=[],r=0,o="0123456789";for(;r<t.length;){let i=0;for(;o.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let s=parseInt(t.substring(r,r+i),10);s>0;s--)n.pop();r+=i}else n.push(t[r]),r++}return e}var To={defaultProtocol:"http",events:null,format:Sp,formatHref:Sp,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function dc(t,e=null){let n=Object.assign({},To);t&&(n=Object.assign(n,t instanceof dc?t.o:t));let r=n.ignoreTags,o=[];for(let i=0;i<r.length;i++)o.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}dc.prototype={o:To,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){let r=e!=null,o=this.o[t];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:To[t],typeof o=="function"&&r&&(o=o(e,n))):typeof o=="function"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){let e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Sp(t){return t}function Rp(t,e){this.t="token",this.v=t,this.tk=e}Rp.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){let e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"\u2026":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=To.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){let e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),u=t.getObj("events",n,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:o,attributes:s,content:i,eventListeners:u}}};function ps(t,e){class n extends Rp{constructor(o,i){super(o,i),this.t=t}}for(let r in e)n.prototype[r]=e[r];return n.t=t,n}var sS=ps("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Cp=ps("text"),lS=ps("nl"),zi=ps("url",{isLink:!0,toHref(t=To.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){let t=this.tk;return t.length>=2&&t[0].t!==Mo&&t[1].t===Hn}});var Ye=t=>new Be(t);function aS({groups:t}){let e=t.domain.concat([es,ns,cn,rs,is,ss,ls,as,Qe,oc,So,cs,ds,us,vt,hs,vo,fs]),n=[ts,Hn,sc,Ct,lc,So,Co,ac,cc,_i,Ui,xo,ko,Vi,Fi,Wi,ji,Ki,qi,Ji,Gi,Xi,Yi,Qi,Zi],r=[es,ts,ns,rs,is,ss,ls,as,Qe,xo,ko,So,cs,ds,us,Co,vt,hs,vo,fs],o=Ye(),i=T(o,vo);K(i,r,i),K(i,t.domain,i);let s=Ye(),l=Ye(),a=Ye();K(o,t.domain,s),K(o,t.scheme,l),K(o,t.slashscheme,a),K(s,r,i),K(s,t.domain,s);let c=T(s,cn);T(i,cn,c),T(l,cn,c),T(a,cn,c);let d=T(i,Ct);K(d,r,i),K(d,t.domain,i);let u=Ye();K(c,t.domain,u),K(u,t.domain,u);let f=T(u,Ct);K(f,t.domain,u);let h=Ye(sS);K(f,t.tld,h),K(f,t.utld,h),T(c,Mo,h);let p=T(u,Qe);T(p,Qe,p),K(p,t.domain,u),K(h,t.domain,u),T(h,Ct,f),T(h,Qe,p);let g=T(s,Qe),m=T(s,Ct);T(g,Qe,g),K(g,t.domain,s),K(m,r,i),K(m,t.domain,s);let y=Ye(zi);K(m,t.tld,y),K(m,t.utld,y),K(y,t.domain,s),K(y,r,i),T(y,Ct,m),T(y,Qe,g),T(y,cn,c);let w=T(y,Hn),x=Ye(zi);K(w,t.numeric,x);let b=Ye(zi),k=Ye();K(b,e,b),K(b,n,k),K(k,e,b),K(k,n,k),T(y,vt,b),T(x,vt,b);let v=T(l,Hn),C=T(a,Hn),O=T(C,vt),P=T(O,vt);K(l,t.domain,s),T(l,Ct,m),T(l,Qe,g),K(a,t.domain,s),T(a,Ct,m),T(a,Qe,g),K(v,t.domain,b),T(v,vt,b),T(v,Co,b),K(P,t.domain,b),K(P,e,b),T(P,vt,b);let N=[[xo,ko],[Fi,Vi],[Wi,ji],[_i,Ui],[Ki,qi],[Ji,Gi],[Xi,Yi],[Qi,Zi]];for(let _=0;_<N.length;_++){let[U,q]=N[_],I=T(b,U);T(k,U,I);let M=Ye(zi);K(I,e,M);let V=Ye();K(I,n,V),T(I,q,b),K(M,e,M),K(M,n,V),K(V,e,M),K(V,n,V),T(M,q,b),T(V,q,b)}return T(o,Mo,y),T(o,ic,lS),{start:o,tokens:Op}}function cS(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let l=t,a=null,c=null,d=0,u=null,f=-1;for(;o<r&&!(a=l.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=a||l.go(n[o].t));)a=null,l=c,l.accepts()?(f=0,u=l):f>=0&&f++,o++,d++;if(f<0)o-=d,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(Ga(Cp,e,s)),s=[]),o-=f,d-=f;let h=u.t,p=n.slice(o-d,o);i.push(Ga(h,e,p))}}return s.length>0&&i.push(Ga(Cp,e,s)),i}function Ga(t,e,n){let r=n[0].s,o=n[n.length-1].e,i=e.slice(r,o);return new t(i,n)}var dS=typeof console<"u"&&console&&console.warn||(()=>{}),uS="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",oe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Dp(){return Be.groups={},oe.scanner=null,oe.parser=null,oe.tokenQueue=[],oe.pluginQueue=[],oe.customSchemes=[],oe.initialized=!1,oe}function uc(t,e=!1){if(oe.initialized&&dS(`linkifyjs: already initialized - will not register custom scheme "${t}" ${uS}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
133
+ 1. Must only contain digits, lowercase ASCII letters or "-"
134
+ 2. Cannot start or end with "-"
135
+ 3. "-" cannot repeat`);oe.customSchemes.push([t,e])}function fS(){oe.scanner=oS(oe.customSchemes);for(let t=0;t<oe.tokenQueue.length;t++)oe.tokenQueue[t][1]({scanner:oe.scanner});oe.parser=aS(oe.scanner.tokens);for(let t=0;t<oe.pluginQueue.length;t++)oe.pluginQueue[t][1]({scanner:oe.scanner,parser:oe.parser});return oe.initialized=!0,oe}function ms(t){return oe.initialized||fS(),cS(oe.parser.start,t,Np(oe.scanner.start,t))}ms.scan=Np;function fc(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}let r=new dc(n),o=ms(t),i=[];for(let s=0;s<o.length;s++){let l=o[s];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var hc="[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]",hS=new RegExp(hc),pS=new RegExp(`${hc}$`),mS=new RegExp(hc,"g");function gS(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function yS(t){return new F({key:new j("autolink"),appendTransaction:(e,n,r)=>{let o=e.some(a=>a.docChanged)&&!n.doc.eq(r.doc),i=e.some(a=>a.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=bi(n.doc,[...e]);if(Ln(l).forEach(({newRange:a})=>{let c=ha(r.doc,a,f=>f.isTextblock),d,u;if(c.length>1)d=c[0],u=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(c.length){let f=r.doc.textBetween(a.from,a.to," "," ");if(!pS.test(f))return;d=c[0],u=r.doc.textBetween(d.pos,a.to,void 0," ")}if(d&&u){let f=u.split(hS).filter(Boolean);if(f.length<=0)return!1;let h=f[f.length-1],p=d.pos+u.lastIndexOf(h);if(!h)return!1;let g=ms(h).map(m=>m.toObject(t.defaultProtocol));if(!gS(g))return!1;g.filter(m=>m.isLink).map(m=>({...m,from:p+m.start+1,to:p+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>t.validate(m.value)).filter(m=>t.shouldAutoLink(m.value)).forEach(m=>{ao(m.from,m.to,r.doc).some(y=>y.mark.type===t.type)||s.addMark(m.from,m.to,t.type.create({href:m.href}))})}}),!!s.steps.length)return s}})}function bS(t){return new F({key:new j("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let a=r.target;if(!a)return!1;let c=t.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){var s,l;let a=Ci(e.state,t.type.name),c=(s=o.href)!==null&&s!==void 0?s:a.href,d=(l=o.target)!==null&&l!==void 0?l:a.target;c&&(window.open(c,d),i=!0)}return i}}})}var wS=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,xS=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Lp(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function kS(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&Lp(t,r)){r+=1;continue}let o=0;for(;r<e&&t[r]==="`";)o+=1,r+=1;n===0?n=o:o===n&&(n=0)}return n>0}function Ip(t,e,n){var r,o;let[,i,s]=e;return(e.index?t[e.index-1]:void 0)==="!"||Lp(t,(r=e.index)!==null&&r!==void 0?r:0)||kS(t,(o=e.index)!==null&&o!==void 0?o:0)?!1:!!i.trim()&&n(s)}function Pp(t){var e,n;let[r,o,i,,s,l,a]=t,c=(e=s??l)!==null&&e!==void 0?e:a;return{index:(n=t.index)!==null&&n!==void 0?n:0,text:r,replaceWith:o,data:{href:i,title:c||null,markdown:!0}}}function SS(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function $p(t){var e,n,r;return{href:(e=t.data)===null||e===void 0?void 0:e.href,title:(n=(r=t.data)===null||r===void 0?void 0:r.title)!==null&&n!==void 0?n:null}}function CS(t){let e=Ie({find:n=>{let r=wS.exec(n);return!r||!Ip(n,r,t.isAllowedHref)?null:Pp(r)},type:t.type,getAttributes:$p});return new ln({find:e.find,handler:n=>{let r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function vS(t){let e=Ne({find:n=>{var r,o;let i=[];for(let l of n.matchAll(xS))Ip(n,l,t.isAllowedHref)&&i.push(Pp(l));let s=((r=(o=t.findPlainUrls)===null||o===void 0?void 0:o.call(t,n))!==null&&r!==void 0?r:[]).filter(l=>!i.some(a=>SS(a,l)));return[...i,...s]},type:t.type,getAttributes:$p});return new yr({find:e.find,handler:n=>{var r;let o=e.handler(n);return o!==null&&n.state.tr.steps.length&&(!((r=n.match.data)===null||r===void 0)&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),o}})}function MS(t){return new F({key:new j("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o}=t,{state:i}=e,{selection:s}=i,{empty:l}=s;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});let c=fc(a,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Ut(t,e){let n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(mS,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var TS=ie.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){uc(t);return}uc(t.scheme,t.optionalSlashes)})},onDestroy(){Dp()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ut(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!==null&&t!==void 0?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!==null&&e!==void 0?e:null},class:{default:(n=this.options.HTMLAttributes.class)!==null&&n!==void 0?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{let e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ut(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ut(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",L(this.options.HTMLAttributes,t),0]:["a",L(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,o,i;let s=(n=(r=t.attrs)===null||r===void 0?void 0:r.href)!==null&&n!==void 0?n:"",l=(o=(i=t.attrs)===null||i===void 0?void 0:i.title)!==null&&o!==void 0?o:"",a=e.renderChildren(t);return l?`[${a}](${s} "${l}")`:`[${a}](${s})`},addCommands(){return{setLink:t=>({chain:e})=>{let{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ut(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{let{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Ut(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[CS({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!Ut(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let t=e=>{let n=[];if(e){let{protocols:r,defaultProtocol:o}=this.options;fc(e).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Ut(s,r),protocols:r,defaultProtocol:o})).forEach(i=>{this.options.shouldAutoLink(i.value)&&n.push({text:i.value,data:{href:i.href},index:i.start})})}return n};return this.options.markdownLinks?[vS({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!Ut(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[Ne({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)===null||n===void 0?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(yS({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Ut(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(bS({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(MS({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Bp=TS;var AS="listItem",zp="textStyle",Hp=/^\s*([-+*])\s$/,mc=W.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",L(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
136
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(AS,this.editor.getAttributes(zp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Vt({find:Hp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Vt({find:Hp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(zp),editor:this.editor})),[t]}}),ES=(t,e,n)=>{let{selection:r}=t;if(!r.empty)return null;let{$from:o}=r;if(!o.parent.isTextblock||o.parentOffset!==o.parent.content.size)return null;let i=-1;for(let h=o.depth;h>0;h-=1)if(o.node(h).type.name===e){i=h;break}if(i<0)return null;let s=o.node(i),l=o.index(i);if(l+1>=s.childCount)return null;let a=s.child(l+1);if(!n.includes(a.type.name))return null;let c=t.schema.nodes[e],d=!1;if(a.forEach(h=>{h.type===c&&h.childCount>1&&(d=!0)}),!d)return null;let u=t.doc.resolve(o.after()).nodeAfter;if(!u||!n.includes(u.type.name))return null;let f=[];return u.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:i,nestedList:u,nestedListPos:o.after(),insertPos:o.after(i),items:f}},OS=(t,e,n,r)=>{let o=ES(t,n,r);if(!o)return!1;let{selection:i}=t,{nestedList:s,nestedListPos:l,insertPos:a,items:c}=o,d=t.tr;d.delete(l,l+s.nodeSize);let u=d.mapping.map(a);return d.insert(u,S.from(c)),d.setSelection(i.map(d.doc,d.mapping)),e&&e(d),!0},NS=(t,e,n)=>OS(t.state,t.view.dispatch,e,n),Up=(t,e)=>Z.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>NS(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),Kp=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],gs="abcdefghijklmnopqrstuvwxyz",qp=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function bs(t){let e=t,n="";for(let[r,o]of Kp)for(;e>=r;)n+=o,e-=r;return n}function gc(t){return bs(t).toUpperCase()}function Jp(t){let e=t.toLowerCase(),n=0,r=0;for(;n<e.length;){let o=!1;for(let[i,s]of Kp)if(e.startsWith(s,n)){r+=i,n+=s.length,o=!0;break}if(!o)return 0}return r}function RS(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;let e=Jp(t);return e<=0?!1:(t===t.toLowerCase()?bs(e):gc(e))===t}function DS(t){let e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){let n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function ys(t){if(t<=26)return gs[t-1];let e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?gs[n]:gs[e]+gs[n]}function ws(t){if(!(!t||/^\d+$/.test(t))){if(RS(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function yc(t){if(/^\d+$/.test(t))return parseInt(t,10);let e=ws(t);if(e==="i"||e==="I")return Jp(t);if(e==="a"||e==="A"){let r=DS(t);return r>0?r:1}let n=parseInt(t,10);return Number.isNaN(n)?1:n}function LS(t,e){if(t==="numeric")return String(e);switch(t){case"a":return ys(e);case"A":return ys(e).toUpperCase();case"i":return bs(e);case"I":return gc(e);default:return String(e)}}function IS(t){var e;if(t.length===0)return!1;let n=(e=ws(t[0]))!==null&&e!==void 0?e:"numeric",r=yc(t[0]);if(r<1)return!1;for(let o=0;o<t.length;o++){let i=LS(n,r+o);if(t[o]!==i)return!1}return!0}function PS(t){return{type:ws(t),start:yc(t)}}function $S(t){let{type:e,start:n}=PS(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function BS(t,e,n=". "){let r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${ys(r)}${n}`;case"A":return`${ys(r).toUpperCase()}${n}`;case"i":return`${bs(r)}${n}`;case"I":return`${gc(r)}${n}`;default:return`${r}${n}`}}function zS(t){var e,n;let r=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((n=t.tokens)===null||n===void 0?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function HS(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var bc=W.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",L(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];let r=(n=e.parseBlockChildren)!==null&&n!==void 0?n:e.parseChildren,o=[];if(t.tokens&&t.tokens.length>0){if(zS(t))return{type:"listItem",content:[{type:"paragraph",content:HS(t.text||"",e)}]};if(t.tokens.some(i=>i.type==="paragraph"))o=r(t.tokens);else{let i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(o=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){let s=r(t.tokens.slice(1));o.push(...s)}}else o=r(t.tokens)}}return o.length===0&&(o=[{type:"paragraph",content:[]}]),{type:"listItem",content:o}},renderMarkdown:(t,e,n)=>fo(t,e,r=>{if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){var o,i;let s=((o=r.meta)===null||o===void 0||(o=o.parentAttrs)===null||o===void 0?void 0:o.start)||1;return BS((i=r.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.type,s-1+(r.index||0),". ")}return"- "},n),addExtensions(){return[Up(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),wc=(t,e)=>{let{$from:n}=e.selection,r=ce(t,e.schema),o=null,i=n.depth,s=n.pos,l=null;for(;i>0&&l===null;)o=n.node(i),o.type===r?l=i:(i-=1,s-=1);return l===null?null:{$pos:e.doc.resolve(s),depth:l}},Gp=(t,e)=>{let n=wc(t,e);if(!n)return!1;let[,r]=wa(e,t,n.$pos.pos+4);return r},FS=(t,e,n)=>{let{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),i=t.doc.resolve(o).node();return!(!i||!n.includes(i.type.name))},Fp=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ct(t.state,e)&&FS(t.state,e,n)){let{$anchor:i}=t.state.selection,s=t.state.doc.resolve(i.before()-1),l=[];s.node().descendants((d,u)=>{d.type.name===e&&l.push({node:d,pos:u})});let a=l.at(-1);if(!a)return!1;let c=t.state.doc.resolve(s.start()+a.pos+1);return t.chain().cut({from:i.start()-1,to:i.end()+1},c.end()).joinForward().run()}if(!ct(t.state,e)||!Sa(t.state))return!1;let{$from:r}=t.state.selection,o=r.depth-1;return r.node(o).type!==t.schema.nodes[e]||r.index(o)!==0?!1:t.chain().liftListItem(e).run()},VS=(t,e)=>{let n=Gp(t,e),r=wc(t,e);return!r||!n?!1:n>r.depth},WS=(t,e)=>{let n=Gp(t,e),r=wc(t,e);return!r||!n?!1:n<r.depth},Vp=(t,e)=>{if(!ct(t.state,e)||!ka(t.state,e))return!1;let{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:VS(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():WS(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},jS=(t,e,n)=>{let{state:r}=t,{selection:o}=r;if(!o.empty)return!1;let{$from:i}=o;if(i.parentOffset!==0||!i.parent.isTextblock||ct(r,e))return!1;let s=xa(i);if(!s||!n.includes(s.type.name))return!1;let l=s.lastChild;if(!l||l.type.name!==e)return!1;let a=i.parent;if(!l.canReplace(l.childCount,l.childCount,S.from(a)))return!1;let c=i.before(),d=i.after(),u=c-2;return t.commands.command(({tr:f,dispatch:h})=>(h&&(f.delete(c,d).insert(u,S.from(a)),f.setSelection(R.create(f.doc,u+1)),f.scrollIntoView()),!0))};var _S=Z.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Vp(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Vp(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Fp(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Fp(t,n,r)&&(e=!0)}),e},Tab:({editor:t})=>{for(let{itemName:e,wrapperNames:n}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&jS(t,e,n))return!0;return!1}}}}),pc=new RegExp(`^(\\s*)(${qp})([.)])\\s+(.*)$`),US=/^\s/,kr={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function KS(t){return pc.test(t.trimStart())}function qS(t){let e=t.trimStart();return kr.bulletItem.test(e)||KS(e)||kr.heading.test(e)||kr.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||kr.codeFence.test(e)||kr.blockMath.test(e)}function JS(t){return Object.values(kr).some(e=>e.test(t))}function GS(t){let e=[],n=[],r=!1;return t.forEach(o=>{if(r){n.push(o);return}if(o.trim()===""){r=!0,n.push(o);return}if(e.length>0&&qS(o)){r=!0,n.push(o);return}e.push(o)}),{paragraphLines:e,blockLines:n}}function XS(t){let e=[],n=0,r=0;for(;n<t.length;){let o=t[n],i=o.match(pc);if(!i)break;let[,s,l,a,c]=i,d=s.length,u=parseInt(l,10),f=isNaN(u)?ws(l):void 0,h=isNaN(u)?yc(l):u,p=[c],g=n+1,m=[o],y=!1;for(;g<t.length;){let w=t[g];if(w.match(pc))break;if(w.trim()==="")m.push(w),p.push(""),y=!0,g+=1;else if(w.match(US)){let x=w.length-w.trimStart().length,b=d+l.length+1;m.push(w),p.push(w.slice(Math.min(x,b))),g+=1}else{if(y||JS(w))break;m.push(w),p.push(w),g+=1}}e.push({indent:d,number:h,type:f,content:p.join(`
137
+ `).trim(),contentLines:p,raw:m.join(`
138
+ `)}),r=g,n=g}return[e,r]}var YS=new RegExp(`^(${qp})([.)])\\s+(.+)$`);function QS(t){let e=t.split(`
139
+ `).filter(r=>r.trim().length>0);if(e.length===0)return null;let n=[];for(let r of e){let o=r.trim().match(YS);if(!o)return null;n.push({marker:o[1],content:o[3]})}return IS(n.map(r=>r.marker))?{type:"orderedList",attrs:$S(n[0].marker),content:n.map(r=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:r.content}]}]}))}:null}function Xp(t,e,n){let r=[],o=0;for(;o<t.length;){let i=t[o];if(i.indent===e){let{paragraphLines:s,blockLines:l}=GS(i.contentLines),a=s.join(`
140
+ `).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});let d=l.join(`
141
+ `).trim();if(d){let h=n.blockTokens(d);c.push(...h)}let u=o+1,f=[];for(;u<t.length&&t[u].indent>e;)f.push(t[u]),u+=1;if(f.length>0){let h=Xp(f,Math.min(...f.map(p=>p.indent)),n);c.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:h,raw:f.map(p=>p.raw).join(`
142
+ `)})}r.push({type:"list_item",raw:i.raw,tokens:c}),o=u}else o+=1}return r}function ZS(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];let r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){let i=e.parseChildren([o]);r.push({type:"paragraph",content:i})}else{let i=e.parseChildren([o]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var e1="listItem",Wp="textStyle",jp=/^(\d+)\.\s$/;function _p(t){let e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var xc=W.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{let e=t.getAttribute("type");if(e)return e;let n=t.getAttribute("style");if(n){let o=_p(n);if(o)return o}let r=t.querySelector("li");if(r){let o=r.getAttribute("style");if(o){let i=_p(o);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){let{start:e,type:n,...r}=t,o=L(this.options.HTMLAttributes,r);return e!==1&&(o.start=e),n&&n!=="1"&&(o.type=n),["ol",o,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];let n=t.start||1,r=t.typeMarker,o=t.items?ZS(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:o}:{type:"orderedList",content:o}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
143
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,o;let i=t.split(`
144
+ `),[s,l]=XS(i);if(s.length===0)return;let a=Xp(s,s[0].indent,n);if(a.length!==0)return{type:"list",ordered:!0,start:((r=s[0])===null||r===void 0?void 0:r.number)||1,typeMarker:(o=s[0])===null||o===void 0?void 0:o.type,items:a,raw:i.slice(0,l).join(`
145
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(e1,this.editor.getAttributes(Wp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new F({props:{handlePaste:(t,e)=>{var n,r;let o=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/html");if(o?.trim())return!1;let i=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/plain");if(!i)return!1;let s=QS(i);if(!s)return!1;try{let l=t.state.schema.nodeFromJSON(s),a=t.state.tr.replaceSelectionWith(l);return t.dispatch(a),!0}catch{return!1}}}})]},addInputRules(){let t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1],e=Vt({find:jp,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Vt({find:jp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(Wp)}),joinPredicate:t,editor:this.editor})),[e]}}),t1=/^\s*(\[([( |x])?\])\s$/,n1="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",r1=(t,e,n)=>{var r;return(n==null||(r=n.checkboxLabel)===null||r===void 0?void 0:r.call(n,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},o1=W.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{let e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",L(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{let n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){let r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;let r=`- [${!((n=t.attrs)===null||n===void 0)&&n.checked?"x":" "}] `;return fo(t,e,r)},addExtensions(){return this.options.nested?[Up(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{let o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");s.style.cssText=n1;let c=u=>{let f=r1(u,u.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),s.textContent=f};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}let{checked:f}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{let p=n();if(typeof p!="number")return!1;let g=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{o.setAttribute(u,f)}),o.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,s),o.append(i,a),Object.entries(e).forEach(([u,f])=>{o.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:o,contentDOM:a,update:u=>{if(u.type!==this.type)return!1;o.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u);let f=r.extensionManager.attributes,h=zt(u,f),p=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return d.forEach(m=>{p.has(m)||(m in g?o.setAttribute(m,g[m]):o.removeAttribute(m))}),Object.entries(h).forEach(([m,y])=>{y==null?m in g?o.setAttribute(m,g[m]):o.removeAttribute(m):o.setAttribute(m,y)}),d=p,!0}}}},addInputRules(){return[Vt({find:t1,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),i1=W.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",L(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
146
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;let n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))===null||e===void 0?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){let r=i=>{let s=uo(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);if(s){let l={type:"taskList",raw:s.raw,items:s.items},a=i.slice(s.raw.length);return a.trim()?[l,...n.blockTokens(a)]:[l]}return n.blockTokens(i)},o=uo(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,s)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:s}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),nA=Z.create({name:"listKit",addExtensions(){let t=[];return this.options.bulletList!==!1&&t.push(mc.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(bc.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(_S.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(xc.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(o1.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(i1.configure(this.options.taskList)),t}});var Yp=(t,e,n={})=>{t?.dispatchEvent(new CustomEvent(e,{composed:!0,cancelable:!0,detail:n}))},kc=({files:t,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:r,maxSizeValidationMessage:o})=>{for(let i of t){if(e&&!e.includes(i.type))return n;if(r&&i.size>+r*1024)return o}return null},s1=()=>("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16)),l1=({editor:t,acceptedTypes:e,acceptedTypesValidationMessage:n,get$WireUsing:r,getFileAttachmentUrlUsing:o,key:i,maxSize:s,maxSizeValidationMessage:l,statePath:a,uploadingMessage:c})=>{let d=new Set,u,f=!1;t.on("destroy",()=>{f=!0,d.forEach(m=>m())});let h=m=>{let y=m.dom.closest("form");d.size||(u=t.isEditable);let w=()=>{d.delete(w)&&(!f&&!d.size&&(t.setEditable(u),m.dom.dispatchEvent(new CustomEvent("rich-editor-uploaded-file",{bubbles:!0,detail:{key:i,livewireId:r().id}}))),Yp(y,"form-processing-finished"))};return d.add(w),t.setEditable(!1),Yp(y,"form-processing-started",{message:c}),m.dom.dispatchEvent(new CustomEvent("rich-editor-uploading-file",{bubbles:!0,detail:{key:i,livewireId:r().id}})),{finish:w,isCurrent:()=>!f&&d.has(w)}},p=(m,y)=>new Promise(w=>{let x=s1();r().upload(`componentFileAttachments.${a}.${x}`,m,async()=>{if(!y.isCurrent()){w(null);return}try{let b=await o(x);w(b?{id:x,src:b}:null)}catch{w(null)}},()=>w(null),()=>{},()=>w(null))}).catch(()=>null),g=async(m,y,w)=>{let x=h(m);try{(await Promise.allSettled(y.map(async k=>{let v=await p(k,x);!v||!x.isCurrent()||t.chain().insertContentAt(w(),{type:"image",attrs:v}).run()}))).forEach(k=>{k.status==="rejected"&&console.error("Failed to insert uploaded file attachment",k.reason)})}finally{x.finish()}};return new F({key:new j("localFiles"),props:{handleDrop(m,y,w,x){if(x||!y.dataTransfer?.files.length)return!1;let b=Array.from(y.dataTransfer.files),k=kc({files:b,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:s,maxSizeValidationMessage:l});if(k)return m.dom.dispatchEvent(new CustomEvent("rich-editor-file-validation-message",{bubbles:!0,detail:{key:i,livewireId:r().id,validationMessage:k}})),!1;if(!b.length)return!1;y.preventDefault(),y.stopPropagation();let v=m.posAtCoords({left:y.clientX,top:y.clientY});return g(m,b,()=>v?.pos??0),!0},handlePaste(m,y){let w=y.clipboardData?.files?.length?Array.from(y.clipboardData.files):[],x=y.clipboardData?.getData("text")?.length>0,b=y.clipboardData?.getData("text/html")||"";if(w.length&&!x){let k=kc({files:w,acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:s,maxSizeValidationMessage:l});return k?(m.dom.dispatchEvent(new CustomEvent("rich-editor-file-validation-message",{bubbles:!0,detail:{key:i,livewireId:r().id,validationMessage:k}})),!1):(y.preventDefault(),y.stopPropagation(),g(m,w,()=>t.state.selection.anchor),!0)}if(b){let v=new DOMParser().parseFromString(b,"text/html"),C=v.querySelectorAll("img[src]");if(C.length){y.stopPropagation();let{from:O,to:P}=t.state.selection,N=h(m);return(async()=>{try{for(let I of C){if(!N.isCurrent())return;let M=I.getAttribute("src");if(!M.startsWith("data:image/"))continue;let V;try{let[Gt,nt]=M.split(","),rt=Gt.match(/:(.*?);/)[1],ot=atob(nt),A=new Uint8Array(ot.length);for(let H=0;H<ot.length;H++)A[H]=ot.charCodeAt(H);V=new Blob([A],{type:rt})}catch{continue}let X=V.type.split("/")[1]?.split("+")[0]||"png",se=new File([V],`image.${X}`,{type:V.type});if(kc({files:[se],acceptedTypes:e,acceptedTypesValidationMessage:n,maxSize:s,maxSizeValidationMessage:l}))continue;let Pe=await p(se,N);Pe&&(I.setAttribute("src",Pe.src),I.setAttribute("data-id",Pe.id))}if(!N.isCurrent())return;for(let I of Array.from(v.querySelectorAll("img[src]"))){let M=v.createElement("p");I.replaceWith(M),M.appendChild(I)}let _=v.body.innerHTML;t.view.someProp("transformPastedHTML",I=>{_=I(_)});let U=document.createElement("div");U.innerHTML=_;let q=Ve.fromSchema(t.state.schema).parseSlice(U,{preserveWhitespace:!1});t.view.dispatch(t.state.tr.replaceRange(O,P,q))}finally{N.finish()}})(),!0}}return!1}}})},Qp=Z.create({name:"localFiles",addOptions(){return{acceptedTypes:[],acceptedTypesValidationMessage:null,key:null,maxSize:null,maxSizeValidationMessage:null,statePath:null,uploadingMessage:null,get$WireUsing:null,getFileAttachmentUrlUsing:null}},addProseMirrorPlugins(){return[l1({editor:this.editor,...this.options})]}});var Sc=["top","right","bottom","left"],Zp=["start","end"],Cc=Sc.reduce((t,e)=>t.concat(e,e+"-"+Zp[0],e+"-"+Zp[1]),[]),We=Math.min,we=Math.max,Oo=Math.round,No=Math.floor,ut=t=>({x:t,y:t}),a1={left:"right",right:"left",bottom:"top",top:"bottom"};function xs(t,e,n){return we(t,We(e,n))}function Mt(t,e){return typeof t=="function"?t(e):t}function je(t){return t.split("-")[0]}function Ze(t){return t.split("-")[1]}function vc(t){return t==="x"?"y":"x"}function ks(t){return t==="y"?"height":"width"}function ft(t){let e=t[0];return e==="t"||e==="b"?"y":"x"}function Ss(t){return vc(ft(t))}function Mc(t,e,n){n===void 0&&(n=!1);let r=Ze(t),o=Ss(t),i=ks(o),s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Eo(s)),[s,Eo(s)]}function nm(t){let e=Eo(t);return[Ao(t),e,Ao(e)]}function Ao(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}var em=["left","right"],tm=["right","left"],c1=["top","bottom"],d1=["bottom","top"];function u1(t,e,n){switch(t){case"top":case"bottom":return n?e?tm:em:e?em:tm;case"left":case"right":return e?c1:d1;default:return[]}}function rm(t,e,n,r){let o=Ze(t),i=u1(je(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(Ao)))),i}function Eo(t){let e=je(t);return a1[e]+t.slice(e.length)}function f1(t){return{top:0,right:0,bottom:0,left:0,...t}}function Cs(t){return typeof t!="number"?f1(t):{top:t,right:t,bottom:t,left:t}}function Kt(t){let{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function om(t,e,n){let{reference:r,floating:o}=t,i=ft(e),s=Ss(e),l=ks(s),a=je(e),c=i==="y",d=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,f=r[l]/2-o[l]/2,h;switch(a){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-o.width,y:u};break;default:h={x:r.x,y:r.y}}switch(Ze(e)){case"start":h[s]-=f*(n&&c?-1:1);break;case"end":h[s]+=f*(n&&c?-1:1);break}return h}async function lm(t,e){var n;e===void 0&&(e={});let{x:r,y:o,platform:i,rects:s,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:h=0}=Mt(e,t),p=Cs(h),m=l[f?u==="floating"?"reference":"floating":u],y=Kt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(m)))==null||n?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),w=u==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),b=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},k=Kt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:x,strategy:a}):w);return{top:(y.top-k.top+p.top)/b.y,bottom:(k.bottom-y.bottom+p.bottom)/b.y,left:(y.left-k.left+p.left)/b.x,right:(k.right-y.right+p.right)/b.x}}var h1=50,am=async(t,e,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=s.detectOverflow?s:{...s,detectOverflow:lm},a=await(s.isRTL==null?void 0:s.isRTL(e)),c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:u}=om(c,r,a),f=r,h=0,p={};for(let g=0;g<i.length;g++){let m=i[g];if(!m)continue;let{name:y,fn:w}=m,{x,y:b,data:k,reset:v}=await w({x:d,y:u,initialPlacement:r,placement:f,strategy:o,middlewareData:p,rects:c,platform:l,elements:{reference:t,floating:e}});d=x??d,u=b??u,p[y]={...p[y],...k},v&&h<h1&&(h++,typeof v=="object"&&(v.placement&&(f=v.placement),v.rects&&(c=v.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):v.rects),{x:d,y:u}=om(c,f,a)),g=-1)}return{x:d,y:u,placement:f,strategy:o,middlewareData:p}},cm=t=>({name:"arrow",options:t,async fn(e){let{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:a}=e,{element:c,padding:d=0}=Mt(t,e)||{};if(c==null)return{};let u=Cs(d),f={x:n,y:r},h=Ss(o),p=ks(h),g=await s.getDimensions(c),m=h==="y",y=m?"top":"left",w=m?"bottom":"right",x=m?"clientHeight":"clientWidth",b=i.reference[p]+i.reference[h]-f[h]-i.floating[p],k=f[h]-i.reference[h],v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c)),C=v?v[x]:0;(!C||!await(s.isElement==null?void 0:s.isElement(v)))&&(C=l.floating[x]||i.floating[p]);let O=b/2-k/2,P=C/2-g[p]/2-1,N=We(u[y],P),_=We(u[w],P),U=N,q=C-g[p]-_,I=C/2-g[p]/2+O,M=xs(U,I,q),V=!a.arrow&&Ze(o)!=null&&I!==M&&i.reference[p]/2-(I<U?N:_)-g[p]/2<0,X=V?I<U?I-U:I-q:0;return{[h]:f[h]+X,data:{[h]:M,centerOffset:I-M-X,...V&&{alignmentOffset:X}},reset:V}}});function p1(t,e,n){return(t?[...n.filter(o=>Ze(o)===t),...n.filter(o=>Ze(o)!==t)]:n.filter(o=>je(o)===o)).filter(o=>t?Ze(o)===t||(e?Ao(o)!==o:!1):!0)}var dm=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,o;let{rects:i,middlewareData:s,placement:l,platform:a,elements:c}=e,{crossAxis:d=!1,alignment:u,allowedPlacements:f=Cc,autoAlignment:h=!0,...p}=Mt(t,e),g=u!==void 0||f===Cc?p1(u||null,h,f):f,m=await a.detectOverflow(e,p),y=((n=s.autoPlacement)==null?void 0:n.index)||0,w=g[y];if(w==null)return{};let x=Mc(w,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==w)return{reset:{placement:g[0]}};let b=[m[je(w)],m[x[0]],m[x[1]]],k=[...((r=s.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:b}],v=g[y+1];if(v)return{data:{index:y+1,overflows:k},reset:{placement:v}};let C=k.map(N=>{let _=Ze(N.placement);return[N.placement,_&&d?N.overflows.slice(0,2).reduce((U,q)=>U+q,0):N.overflows[0],N.overflows]}).sort((N,_)=>N[1]-_[1]),P=((o=C.filter(N=>N[2].slice(0,Ze(N[0])?2:3).every(_=>_<=0))[0])==null?void 0:o[0])||C[0][0];return P!==l?{data:{index:y+1,overflows:k},reset:{placement:P}}:{}}}},um=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;let{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...m}=Mt(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let y=je(o),w=ft(l),x=je(l)===l,b=await(a.isRTL==null?void 0:a.isRTL(c.floating)),k=f||(x||!g?[Eo(l)]:nm(l)),v=p!=="none";!f&&v&&k.push(...rm(l,g,p,b));let C=[l,...k],O=await a.detectOverflow(e,m),P=[],N=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&P.push(O[y]),u){let I=Mc(o,s,b);P.push(O[I[0]],O[I[1]])}if(N=[...N,{placement:o,overflows:P}],!P.every(I=>I<=0)){var _,U;let I=(((_=i.flip)==null?void 0:_.index)||0)+1,M=C[I];if(M&&(!(u==="alignment"?w!==ft(M):!1)||N.every(se=>ft(se.placement)===w?se.overflows[0]>0:!0)))return{data:{index:I,overflows:N},reset:{placement:M}};let V=(U=N.filter(X=>X.overflows[0]<=0).sort((X,se)=>X.overflows[1]-se.overflows[1])[0])==null?void 0:U.placement;if(!V)switch(h){case"bestFit":{var q;let X=(q=N.filter(se=>{if(v){let xe=ft(se.placement);return xe===w||xe==="y"}return!0}).map(se=>[se.placement,se.overflows.filter(xe=>xe>0).reduce((xe,Pe)=>xe+Pe,0)]).sort((se,xe)=>se[1]-xe[1])[0])==null?void 0:q[0];X&&(V=X);break}case"initialPlacement":V=l;break}if(o!==V)return{reset:{placement:V}}}return{}}}};function im(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function sm(t){return Sc.some(e=>t[e]>=0)}var fm=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){let{rects:n,platform:r}=e,{strategy:o="referenceHidden",...i}=Mt(t,e);switch(o){case"referenceHidden":{let s=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=im(s,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:sm(l)}}}case"escaped":{let s=await r.detectOverflow(e,{...i,altBoundary:!0}),l=im(s,n.floating);return{data:{escapedOffsets:l,escaped:sm(l)}}}default:return{}}}}};function hm(t){let e=We(...t.map(i=>i.left)),n=We(...t.map(i=>i.top)),r=we(...t.map(i=>i.right)),o=we(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:o-n}}function m1(t){let e=t.slice().sort((o,i)=>o.y-i.y),n=[],r=null;for(let o=0;o<e.length;o++){let i=e[o];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(o=>Kt(hm(o)))}var pm=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){let{placement:n,elements:r,rects:o,platform:i,strategy:s}=e,{padding:l=2,x:a,y:c}=Mt(t,e),d=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),u=m1(d),f=Kt(hm(d)),h=Cs(l);function p(){if(u.length===2&&u[0].left>u[1].right&&a!=null&&c!=null)return u.find(m=>a>m.left-h.left&&a<m.right+h.right&&c>m.top-h.top&&c<m.bottom+h.bottom)||f;if(u.length>=2){if(ft(n)==="y"){let N=u[0],_=u[u.length-1],U=je(n)==="top",q=N.top,I=_.bottom,M=U?N.left:_.left,V=U?N.right:_.right,X=V-M,se=I-q;return{top:q,bottom:I,left:M,right:V,width:X,height:se,x:M,y:q}}let m=je(n)==="left",y=we(...u.map(N=>N.right)),w=We(...u.map(N=>N.left)),x=u.filter(N=>m?N.left===w:N.right===y),b=x[0].top,k=x[x.length-1].bottom,v=w,C=y,O=C-v,P=k-b;return{top:b,bottom:k,left:v,right:C,width:O,height:P,x:v,y:b}}return f}let g=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:s});return o.reference.x!==g.reference.x||o.reference.y!==g.reference.y||o.reference.width!==g.reference.width||o.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},g1=new Set(["left","top"]);async function y1(t,e){let{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=je(n),l=Ze(n),a=ft(n)==="y",c=g1.has(s)?-1:1,d=i&&a?-1:1,u=Mt(e,t),{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*d,y:f*c}:{x:f*c,y:h*d}}var mm=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;let{x:o,y:i,placement:s,middlewareData:l}=e,a=await y1(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},gm=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:r,placement:o,platform:i}=e,{mainAxis:s=!0,crossAxis:l=!1,limiter:a={fn:y=>{let{x:w,y:x}=y;return{x:w,y:x}}},...c}=Mt(t,e),d={x:n,y:r},u=await i.detectOverflow(e,c),f=ft(je(o)),h=vc(f),p=d[h],g=d[f];if(s){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",x=p+u[y],b=p-u[w];p=xs(x,p,b)}if(l){let y=f==="y"?"top":"left",w=f==="y"?"bottom":"right",x=g+u[y],b=g-u[w];g=xs(x,g,b)}let m=a.fn({...e,[h]:p,[f]:g});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:s,[f]:l}}}}}};var ym=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;let{placement:o,rects:i,platform:s,elements:l}=e,{apply:a=()=>{},...c}=Mt(t,e),d=await s.detectOverflow(e,c),u=je(o),f=Ze(o),h=ft(o)==="y",{width:p,height:g}=i.floating,m,y;u==="top"||u==="bottom"?(m=u,y=f===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(y=u,m=f==="end"?"top":"bottom");let w=g-d.top-d.bottom,x=p-d.left-d.right,b=We(g-d[m],w),k=We(p-d[y],x),v=!e.middlewareData.shift,C=b,O=k;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=x),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(C=w),v&&!f){let N=we(d.left,0),_=we(d.right,0),U=we(d.top,0),q=we(d.bottom,0);h?O=p-2*(N!==0||_!==0?N+_:we(d.left,d.right)):C=g-2*(U!==0||q!==0?U+q:we(d.top,d.bottom))}await a({...e,availableWidth:O,availableHeight:C});let P=await s.getDimensions(l.floating);return p!==P.width||g!==P.height?{reset:{rects:!0}}:{}}}};function vs(){return typeof window<"u"}function Vn(t){return wm(t)?(t.nodeName||"").toLowerCase():"#document"}function ze(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ht(t){var e;return(e=(wm(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function wm(t){return vs()?t instanceof Node||t instanceof ze(t).Node:!1}function et(t){return vs()?t instanceof Element||t instanceof ze(t).Element:!1}function Tt(t){return vs()?t instanceof HTMLElement||t instanceof ze(t).HTMLElement:!1}function bm(t){return!vs()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ze(t).ShadowRoot}function Cr(t){let{overflow:e,overflowX:n,overflowY:r,display:o}=tt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&o!=="inline"&&o!=="contents"}function xm(t){return/^(table|td|th)$/.test(Vn(t))}function Ro(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}var b1=/transform|translate|scale|rotate|perspective|filter/,w1=/paint|layout|strict|content/,Fn=t=>!!t&&t!=="none",Tc;function Ms(t){let e=et(t)?tt(t):t;return Fn(e.transform)||Fn(e.translate)||Fn(e.scale)||Fn(e.rotate)||Fn(e.perspective)||!Ts()&&(Fn(e.backdropFilter)||Fn(e.filter))||b1.test(e.willChange||"")||w1.test(e.contain||"")}function km(t){let e=qt(t);for(;Tt(e)&&!Wn(e);){if(Ms(e))return e;if(Ro(e))return null;e=qt(e)}return null}function Ts(){return Tc==null&&(Tc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Tc}function Wn(t){return/^(html|body|#document)$/.test(Vn(t))}function tt(t){return ze(t).getComputedStyle(t)}function Do(t){return et(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function qt(t){if(Vn(t)==="html")return t;let e=t.assignedSlot||t.parentNode||bm(t)&&t.host||ht(t);return bm(e)?e.host:e}function Sm(t){let e=qt(t);return Wn(e)?t.ownerDocument?t.ownerDocument.body:t.body:Tt(e)&&Cr(e)?e:Sm(e)}function Sr(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=Sm(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=ze(o);if(i){let l=As(s);return e.concat(s,s.visualViewport||[],Cr(o)?o:[],l&&n?Sr(l):[])}else return e.concat(o,Sr(o,[],n))}function As(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Tm(t){let e=tt(t),n=parseFloat(e.width)||0,r=parseFloat(e.height)||0,o=Tt(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=Oo(n)!==i||Oo(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Ec(t){return et(t)?t:t.contextElement}function vr(t){let e=Ec(t);if(!Tt(e))return ut(1);let n=e.getBoundingClientRect(),{width:r,height:o,$:i}=Tm(e),s=(i?Oo(n.width):n.width)/r,l=(i?Oo(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}var x1=ut(0);function Am(t){let e=ze(t);return!Ts()||!e.visualViewport?x1:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function k1(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ze(t)?!1:e}function jn(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),i=Ec(t),s=ut(1);e&&(r?et(r)&&(s=vr(r)):s=vr(t));let l=k1(i,n,r)?Am(i):ut(0),a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,d=o.width/s.x,u=o.height/s.y;if(i){let f=ze(i),h=r&&et(r)?ze(r):r,p=f,g=As(p);for(;g&&r&&h!==p;){let m=vr(g),y=g.getBoundingClientRect(),w=tt(g),x=y.left+(g.clientLeft+parseFloat(w.paddingLeft))*m.x,b=y.top+(g.clientTop+parseFloat(w.paddingTop))*m.y;a*=m.x,c*=m.y,d*=m.x,u*=m.y,a+=x,c+=b,p=ze(g),g=As(p)}}return Kt({width:d,height:u,x:a,y:c})}function Es(t,e){let n=Do(t).scrollLeft;return e?e.left+n:jn(ht(t)).left+n}function Em(t,e){let n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Es(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function S1(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t,i=o==="fixed",s=ht(r),l=e?Ro(e.floating):!1;if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=ut(1),d=ut(0),u=Tt(r);if((u||!u&&!i)&&((Vn(r)!=="body"||Cr(s))&&(a=Do(r)),u)){let h=jn(r);c=vr(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}let f=s&&!u&&!i?Em(s,a):ut(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+d.x+f.x,y:n.y*c.y-a.scrollTop*c.y+d.y+f.y}}function C1(t){return Array.from(t.getClientRects())}function v1(t){let e=ht(t),n=Do(t),r=t.ownerDocument.body,o=we(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=we(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight),s=-n.scrollLeft+Es(t),l=-n.scrollTop;return tt(r).direction==="rtl"&&(s+=we(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}var Cm=25;function M1(t,e){let n=ze(t),r=ht(t),o=n.visualViewport,i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;let d=Ts();(!d||d&&e==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}let c=Es(r);if(c<=0){let d=r.ownerDocument,u=d.body,f=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-h);p<=Cm&&(i-=p)}else c<=Cm&&(i+=c);return{width:i,height:s,x:l,y:a}}function T1(t,e){let n=jn(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=Tt(t)?vr(t):ut(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,a=o*i.x,c=r*i.y;return{width:s,height:l,x:a,y:c}}function vm(t,e,n){let r;if(e==="viewport")r=M1(t,n);else if(e==="document")r=v1(ht(t));else if(et(e))r=T1(e,n);else{let o=Am(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Kt(r)}function Om(t,e){let n=qt(t);return n===e||!et(n)||Wn(n)?!1:tt(n).position==="fixed"||Om(n,e)}function A1(t,e){let n=e.get(t);if(n)return n;let r=Sr(t,[],!1).filter(l=>et(l)&&Vn(l)!=="body"),o=null,i=tt(t).position==="fixed",s=i?qt(t):t;for(;et(s)&&!Wn(s);){let l=tt(s),a=Ms(s);!a&&l.position==="fixed"&&(o=null),(i?!a&&!o:!a&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Cr(s)&&!a&&Om(t,s))?r=r.filter(d=>d!==s):o=l,s=qt(s)}return e.set(t,r),r}function E1(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t,s=[...n==="clippingAncestors"?Ro(e)?[]:A1(e,this._c):[].concat(n),r],l=vm(e,s[0],o),a=l.top,c=l.right,d=l.bottom,u=l.left;for(let f=1;f<s.length;f++){let h=vm(e,s[f],o);a=we(h.top,a),c=We(h.right,c),d=We(h.bottom,d),u=we(h.left,u)}return{width:c-u,height:d-a,x:u,y:a}}function O1(t){let{width:e,height:n}=Tm(t);return{width:e,height:n}}function N1(t,e,n){let r=Tt(e),o=ht(e),i=n==="fixed",s=jn(t,!0,i,e),l={scrollLeft:0,scrollTop:0},a=ut(0);function c(){a.x=Es(o)}if(r||!r&&!i)if((Vn(e)!=="body"||Cr(o))&&(l=Do(e)),r){let h=jn(e,!0,i,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else o&&c();i&&!r&&o&&c();let d=o&&!r&&!i?Em(o,l):ut(0),u=s.left+l.scrollLeft-a.x-d.x,f=s.top+l.scrollTop-a.y-d.y;return{x:u,y:f,width:s.width,height:s.height}}function Ac(t){return tt(t).position==="static"}function Mm(t,e){if(!Tt(t)||tt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ht(t)===n&&(n=n.ownerDocument.body),n}function Nm(t,e){let n=ze(t);if(Ro(t))return n;if(!Tt(t)){let o=qt(t);for(;o&&!Wn(o);){if(et(o)&&!Ac(o))return o;o=qt(o)}return n}let r=Mm(t,e);for(;r&&xm(r)&&Ac(r);)r=Mm(r,e);return r&&Wn(r)&&Ac(r)&&!Ms(r)?n:r||km(t)||n}var R1=async function(t){let e=this.getOffsetParent||Nm,n=this.getDimensions,r=await n(t.floating);return{reference:N1(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function D1(t){return tt(t).direction==="rtl"}var L1={convertOffsetParentRelativeRectToViewportRelativeRect:S1,getDocumentElement:ht,getClippingRect:E1,getOffsetParent:Nm,getElementRects:R1,getClientRects:C1,getDimensions:O1,getScale:vr,isElement:et,isRTL:D1};function Rm(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function I1(t,e){let n=null,r,o=ht(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function s(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();let c=t.getBoundingClientRect(),{left:d,top:u,width:f,height:h}=c;if(l||e(),!f||!h)return;let p=No(u),g=No(o.clientWidth-(d+f)),m=No(o.clientHeight-(u+h)),y=No(d),x={rootMargin:-p+"px "+-g+"px "+-m+"px "+-y+"px",threshold:we(0,We(1,a))||1},b=!0;function k(v){let C=v[0].intersectionRatio;if(C!==a){if(!b)return s();C?s(!1,C):r=setTimeout(()=>{s(!1,1e-7)},1e3)}C===1&&!Rm(c,t.getBoundingClientRect())&&s(),b=!1}try{n=new IntersectionObserver(k,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,x)}n.observe(t)}return s(!0),i}function Dm(t,e,n,r){r===void 0&&(r={});let{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=Ec(t),d=o||i?[...c?Sr(c):[],...e?Sr(e):[]]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});let u=c&&l?I1(c,n):null,f=-1,h=null;s&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&h&&e&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),n()}),c&&!a&&h.observe(c),e&&h.observe(e));let p,g=a?jn(t):null;a&&m();function m(){let y=jn(t);g&&!Rm(g,y)&&n(),g=y,p=requestAnimationFrame(m)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),u?.(),(y=h)==null||y.disconnect(),h=null,a&&cancelAnimationFrame(p)}}var Os=mm,Lm=dm,Ns=gm,Mr=um,Im=ym,Pm=fm,$m=cm,Bm=pm;var Tr=(t,e,n)=>{let r=new Map,o={platform:L1,...n},i={...o.platform,_c:r};return am(t,e,{...o,platform:i})};function P1(t){var e;let{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:l}=t,a=r&&!o,c=Aa(n),d=new RegExp(`\\s${c}$`),u=s?"^":"",f=o?"":c,h=a?new RegExp(`${u}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=l.nodeBefore)===null||e===void 0?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;let g=l.pos-p.length,m=Array.from(p.matchAll(h)).pop();if(!m||m.input===void 0||m.index===void 0)return null;let y=m.input.slice(Math.max(0,m.index-1),m.index),w=new RegExp(`^[${i?.join("")}\0]?$`).test(y);if(i!==null&&!w)return null;let x=g+m.index,b=x+m[0].length;return a&&d.test(p.slice(b-1,b+1))&&(m[0]+=" ",b+=1),x<l.pos&&b>=l.pos?{range:{from:x,to:b},query:m[0].slice(n.length),text:m[0]}:null}function $1(t){return t.docChanged?t.steps.some(e=>{let n=e.slice;if(!n?.content)return!1;let r=n.content.textBetween(0,n.content.size,`
147
+ `);return/\s/.test(r)}):!1}function B1(t){return()=>{let e=t.state.selection.$anchor.pos,{top:n,right:r,bottom:o,left:i}=t.view.coordsAtPos(e);try{return new DOMRect(i,n,r-i,o-n)}catch{return null}}}function z1(t,e,n,r){return n?()=>{let o=r.getState(t.state),i=o?.decorationId,s=e.dom.querySelector(`[data-decoration-id="${i}"]`);return s?.getBoundingClientRect()||null}:B1(t)}function H1({match:t,dismissedRange:e,state:n,transaction:r,editor:o,shouldResetDismissed:i,effectiveAllowSpaces:s}){return i?.({editor:o,state:n,range:e,match:t,transaction:r,allowSpaces:s})?!1:s?t.range.from===e.from:t.range.from===e.from&&!$1(r)}function F1({view:t,pluginKeyRef:e}){let n=t.state.tr.setMeta(e,{exit:!0});t.dispatch(n)}function V1({pluginKey:t,decorationTag:e,decorationClass:n,decorationContent:r,decorationEmptyClass:o,renderer:i,dispatchExit:s}){return{handleKeyDown(l,a){var c;let d=t.getState(l.state);if(!d.active)return!1;if(a.key==="Escape"||a.key==="Esc"){var u;return i==null||(u=i.onKeyDown)===null||u===void 0||u.call(i,{view:l,event:a,range:d.range}),s(l),!0}return(i==null||(c=i.onKeyDown)===null||c===void 0?void 0:c.call(i,{view:l,event:a,range:d.range}))||!1},decorations(l){let{active:a,range:c,decorationId:d,query:u}=t.getState(l);if(!a)return null;let f=!u?.length,h=[n];return f&&h.push(o),Y.create(l.doc,[re.inline(c.from,c.to,{nodeName:e,class:h.join(" "),"data-decoration-id":d||void 0,"data-decoration-content":r})])}}}function W1({editor:t,char:e,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:i,findSuggestionMatch:s,allow:l,shouldShow:a,shouldKeepDismissed:c,pluginKey:d}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(u,f,h,p){let{isEditable:g}=t,{composing:m}=t.view,{selection:y}=u,{empty:w,from:x}=y,b={...f},k=u.getMeta(d);if(k&&k.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=m,u.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:u.mapping.map(b.dismissedRange.from),to:u.mapping.map(b.dismissedRange.to)}),g&&(w||t.view.composing)){(x<f.range.from||x>f.range.to)&&!m&&!f.composing&&(b.active=!1);let v=s({char:e,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:o,startOfLine:i,$position:y.$from}),C=`id_${Math.floor(Math.random()*4294967295)}`;v&&l({editor:t,state:p,range:v.range,isActive:f.active})&&(!a||a({editor:t,range:v.range,query:v.query,text:v.text,transaction:u}))?(b.dismissedRange!==null&&!c({match:v,dismissedRange:b.dismissedRange,state:p,transaction:u})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||C,b.range=v.range,b.query=v.query,b.text=v.text):b.active=!1):(v||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function j1({editor:t,items:e}){let n=null,r=null,o=null,i=()=>{r!==null&&(clearTimeout(r),r=null),o?.(),o=null},s=c=>new Promise(d=>{o=d,r=setTimeout(()=>{r=null;let u=o;o=null,u?.()},c)}),l=()=>{n?.abort(),i(),n=null};return{abort:l,fetch:async(c,d)=>{l(),n=new AbortController;let u=n;if(d>0&&await s(d),n!==u||u.signal.aborted)return{status:"aborted"};try{let f=await e({editor:t,query:c,signal:u.signal});return n!==u||u.signal.aborted?{status:"aborted"}:{status:"resolved",items:f}}catch{return n!==u||u.signal.aborted?{status:"aborted"}:{status:"error"}}}}}function _1({placement:t,offset:e,flip:n,floatingUi:r}){var o,i,s,l;let a=[Os({mainAxis:(o=e.mainAxis)!==null&&o!==void 0?o:4,crossAxis:(i=e.crossAxis)!==null&&i!==void 0?i:0})];return n&&a.push(Mr()),!(r==null||(s=r.middleware)===null||s===void 0)&&s.length&&a.push(...r.middleware),{placement:t,strategy:(l=r?.strategy)!==null&&l!==void 0?l:"absolute",middleware:a}}function U1(t){if(t instanceof HTMLElement)return t;if(typeof t=="string")try{let e=document.querySelector(t);if(e)return e}catch{return document.body}return document.body}function K1({getReferenceRect:t,contextElement:e,config:n,container:r,dismissOnOutsideClick:o,dismiss:i}){return(s,l={})=>{let a={getBoundingClientRect:()=>{var p;return(p=t())!==null&&p!==void 0?p:new DOMRect},contextElement:e},c=!1,d=!s.isConnected;d&&U1(r).appendChild(s),l.onPosition||(s.style.visibility="hidden",s.style.width="max-content");let f=Dm(a,s,()=>{Tr(a,s,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:p,y:g,placement:m,strategy:y})=>{if(l.onPosition){l.onPosition({x:p,y:g,placement:m,strategy:y});return}Object.assign(s.style,{position:y,left:`${p}px`,top:`${g}px`}),c||(c=!0,s.style.visibility="")})},l.autoUpdate),h;return o&&(h=p=>{let g=p.target;!(g instanceof Node)||s.contains(g)||e.contains(g)||i()},document.addEventListener("pointerdown",h,!0)),()=>{f(),h&&document.removeEventListener("pointerdown",h,!0),d&&s.remove()}}}function q1({editor:t,pluginKey:e,items:n,renderer:r,minQueryLength:o,debounce:i,initialItems:s,placement:l,offset:a,container:c,flip:d,floatingUi:u,dismissOnOutsideClick:f,command:h,clientRectFor:p,dispatchExit:g}){let m,y=j1({editor:t,items:n}),w=_1({placement:l,offset:a,flip:d,floatingUi:u});function x(b,k){switch(b){case"started":var v;r==null||(v=r.onStart)===null||v===void 0||v.call(r,k);break;case"updated":var C;r==null||(C=r.onUpdate)===null||C===void 0||C.call(r,k);break;case"stopped":var O;r==null||(O=r.onExit)===null||O===void 0||O.call(r,k)}}return{update:async(b,k)=>{var v,C;let O=e.getState(k),P=e.getState(b.state);if(!O||!P)return;let N=null,_=O.query!==P.query,U=O.text!==P.text,q=O.range.from!==P.range.from||O.range.to!==P.range.to,I=_||U||q;if(!O.active&&P.active)N="started";else if(O.active&&!P.active)N="stopped";else if(P.active&&I)N="updated";else return;let M=N==="stopped"?O:P,V=b.dom.querySelector(`[data-decoration-id="${M.decorationId}"]`),X=p(b,V),se=o===0||(M.query?M.query.length>=o:!1),xe=(N==="started"||N==="updated")&&se;if(m={editor:t,range:M.range,query:M.query||"",text:M.text||"",items:s??[],command:nt=>h({editor:t,range:M.range,props:nt}),decorationNode:V,clientRect:X,loading:xe,placement:l,offset:{mainAxis:(v=a.mainAxis)!==null&&v!==void 0?v:4,crossAxis:(C=a.crossAxis)!==null&&C!==void 0?C:0},container:c,flip:d,floatingUi:w,mount:K1({getReferenceRect:X,contextElement:b.dom,config:w,container:c,dismissOnOutsideClick:f,dismiss:()=>g(t.view)})},N==="started"){var Pe;r==null||(Pe=r.onBeforeStart)===null||Pe===void 0||Pe.call(r,m)}if(N==="updated"){var Gt;r==null||(Gt=r.onBeforeUpdate)===null||Gt===void 0||Gt.call(r,m)}if(N==="started"&&x(N,m),N==="started"||N==="updated")if(!xe)y.abort(),m={...m,items:s??[],loading:!1};else{m={...m,items:s??[],loading:!0},N="updated",x(N,m);let nt=await y.fetch(M.query||"",i);if(nt.status==="aborted")return;let rt=e.getState(b.state);if(!rt?.active){y.abort();return}m=nt.status==="resolved"?{...m,items:nt.items,loading:!1}:{...m,loading:!1}}if(N==="stopped"){y.abort(),x(N,m),m=void 0;return}N==="updated"&&x(N,m)},destroy:()=>{var b;y.abort(),m&&(r==null||(b=r.onExit)===null||b===void 0||b.call(r,m))}}}var J1=new j("suggestion");function G1({pluginKey:t=J1,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:f=()=>[],minQueryLength:h=0,debounce:p=0,initialItems:g,placement:m="bottom-start",offset:y={},container:w,flip:x=!0,floatingUi:b,dismissOnOutsideClick:k=!0,render:v=()=>({}),allow:C=()=>!0,findSuggestionMatch:O=P1,shouldShow:P,shouldResetDismissed:N}){let _=v?.(),U=r&&!o,q=(V,X)=>z1(e,V,X,t);function I(V){return H1({...V,editor:e,shouldResetDismissed:N,effectiveAllowSpaces:U})}let M=V=>F1({view:V,pluginKeyRef:t});return new F({key:t,view:()=>q1({editor:e,pluginKey:t,items:f,renderer:_,minQueryLength:h,debounce:p,initialItems:g,placement:m,offset:y,container:w,flip:x,floatingUi:b,dismissOnOutsideClick:k,command:u,clientRectFor:q,dispatchExit:M}),state:W1({editor:e,char:n,effectiveAllowSpaces:U,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,findSuggestionMatch:O,allow:C,shouldShow:P,shouldKeepDismissed:I,pluginKey:t}),props:V1({pluginKey:t,decorationTag:l,decorationClass:a,decorationContent:c,decorationEmptyClass:d,renderer:_,dispatchExit:M})})}var Rs=G1;var X1=function({editor:t,overrideSuggestionOptions:e,extensionName:n}){let r=new j;return{editor:t,char:"{{",pluginKey:r,command:({editor:o,range:i,props:s})=>{o.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:n,attrs:{...s}},{type:"text",text:" "}]).run(),o.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:o,range:i})=>{let s=o.doc.resolve(i.from),l=o.schema.nodes[n];return!!s.parent.type.contentMatch.matchType(l)},...e}},zm=W.create({name:"mergeTag",priority:101,addStorage(){return{mergeTags:[],suggestions:[],getSuggestionFromTriggerCharacter:()=>null}},addOptions(){return{HTMLAttributes:{},renderText({node:t}){return`{{ ${this.mergeTags[t.attrs.id]} }}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e}){return["span",L(this.HTMLAttributes,t.HTMLAttributes),`${this.mergeTags[e.attrs.id]}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){let n=this.editor?.extensionStorage?.[this.name]?.getSuggestionFromTriggerCharacter("{{"),r={...this.options};r.HTMLAttributes=L({"data-type":this.name},this.options.HTMLAttributes,e);let o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",L({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){let e={options:this.options,node:t,suggestion:this.editor?.extensionStorage?.[this.name]?.getSuggestionFromTriggerCharacter("{{")};return this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ge,l=0;return e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":"{{",l,l+s.nodeSize),n})}},addProseMirrorPlugins(){return[...this.storage.suggestions.map(Rs),new F({props:{handleDrop(t,e){if(!e||(e.preventDefault(),!e.dataTransfer.getData("mergeTag")))return!1;let n=e.dataTransfer.getData("mergeTag");return t.dispatch(t.state.tr.insert(t.posAtCoords({left:e.clientX,top:e.clientY}).pos,t.state.schema.nodes.mergeTag.create({id:n}))),!1}}})]},onBeforeCreate(){this.storage.suggestions=(this.options.suggestions.length?this.options.suggestions:[this.options.suggestion]).map(t=>X1({editor:this.editor,overrideSuggestionOptions:t,extensionName:this.name})),this.storage.getSuggestionFromTriggerCharacter=t=>{let e=this.storage.suggestions.find(n=>n.char===t);return e||(this.storage.suggestions.length?this.storage.suggestions[0]:null)}}});function _n(t,e){Tr({getBoundingClientRect:()=>{let{from:r,to:o}=t.state.selection,i=t.view.coordsAtPos(r),s=t.view.coordsAtPos(o);return{top:Math.min(i.top,s.top),bottom:Math.max(i.bottom,s.bottom),left:Math.min(i.left,s.left),right:Math.max(i.right,s.right),width:Math.abs(s.right-i.left),height:Math.abs(s.bottom-i.top),x:Math.min(i.left,s.left),y:Math.min(i.top,s.top)}}},e,{placement:"bottom-start",strategy:"absolute",middleware:[Ns(),Mr()]}).then(({x:r,y:o,strategy:i})=>{e.style.width="max-content",e.style.position=i,e.style.left=`${r}px`,e.style.top=`${o}px`})}function He(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}var Hm=({items:t=[],noOptionsMessage:e=null,noSearchResultsMessage:n=null,searchPrompt:r=null,searchingMessage:o=null,isSearchable:i=!1})=>({items:async({query:s})=>{if(typeof t=="function")try{let a=t({query:s});return Array.isArray(a)?a:await a}catch{return[]}if(!s)return t;let l=He(String(s));return t.filter(a=>{let c=typeof a=="string"?a:a?.label??a?.name??"";return He(String(c)).includes(l)})},render:()=>{let s,l=0,a=null,c=()=>{let y=document.createElement("div");return y.className="fi-dropdown-panel fi-dropdown-list fi-scrollable",y.style.maxHeight="15rem",y.style.minWidth="12rem",y},d=()=>{if(!s||!a)return;let y=Array.isArray(a.items)?a.items:[],w=a.query??"";if(s.innerHTML="",i&&a.loading){let x=o??"Searching...",b=document.createElement("div");b.className="fi-dropdown-header";let k=document.createElement("span");k.style.whiteSpace="normal",k.textContent=x,b.appendChild(k),s.appendChild(b);return}if(y.length)y.forEach((x,b)=>{let k=typeof x=="string"?x:x?.label??x?.name??String(x?.id??""),v=typeof x=="object"?x?.id??k:k,C=document.createElement("button");C.className=`fi-dropdown-list-item ${b===l?"fi-selected":""}`,C.type="button",C.addEventListener("click",()=>f(v,k));let O=document.createElement("span");O.className="fi-dropdown-list-item-label",O.textContent=k,C.appendChild(O),s.appendChild(C)});else{let x=u(w);if(x){let b=document.createElement("div");b.className="fi-dropdown-header";let k=document.createElement("span");k.style.whiteSpace="normal",k.textContent=x,b.appendChild(k),s.appendChild(b)}}},u=y=>y?n:i?r:e,f=(y,w)=>{a&&a.command({id:y,label:w})},h=()=>{if(!s||!a||(a.items||[]).length===0)return;let w=s.children[l];if(w){let x=w.getBoundingClientRect(),b=s.getBoundingClientRect();(x.top<b.top||x.bottom>b.bottom)&&w.scrollIntoView({block:"nearest"})}},p=()=>{if(!a)return;let y=Array.isArray(a.items)?a.items:[];y.length!==0&&(l=(l+y.length-1)%y.length,d(),h())},g=()=>{if(!a)return;let y=a.items||[];y.length!==0&&(l=(l+1)%y.length,d(),h())},m=()=>{let y=a?.items||[];if(y.length===0)return;let w=y[l],x=typeof w=="string"?w:w?.label??w?.name??String(w?.id??""),b=typeof w=="object"?w?.id??x:x;f(b,x)};return{onStart:y=>{a=y,l=0,s=c(),s.style.position="absolute",s.style.zIndex="50",d(),document.body.appendChild(s),y.clientRect&&_n(y.editor,s)},onUpdate:y=>{a=y,l=0,d(),h(),y.clientRect&&_n(y.editor,s)},onKeyDown:y=>y.event.key==="Escape"?(s&&s.parentNode&&s.parentNode.removeChild(s),!0):y.event.key==="ArrowUp"?(p(),!0):y.event.key==="ArrowDown"?(g(),!0):y.event.key==="Enter"?(m(),!0):!1,onExit:()=>{s&&s.parentNode&&s.parentNode.removeChild(s)}}}});var Y1=function({editor:t,overrideSuggestionOptions:e,extensionName:n}){let r=new j,o=e?.triggerCharacter??"@",i=e?.extraAttributes??{};return{editor:t,char:o,pluginKey:r,command:({editor:s,range:l,props:a})=>{s.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(l.to+=1);let u={...a,char:o,extra:i};s.chain().focus().insertContentAt(l,[{type:n,attrs:u},{type:"text",text:" "}]).run(),s.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:s,range:l})=>{let a=s.doc.resolve(l.from),c=s.schema.nodes[n];return!!a.parent.type.contentMatch.matchType(c)},...e}},Fm=W.create({name:"mention",priority:101,addStorage(){return{suggestions:[],getSuggestionFromTriggerCharacter:()=>null}},addOptions(){return{HTMLAttributes:{},renderText({node:t}){return`${t.attrs.char??"@"}`},deleteTriggerWithBackspace:!0,renderHTML({options:t,node:e}){return["span",L(this.HTMLAttributes,t.HTMLAttributes),`${e.attrs.char??"@"}${e.attrs.label??""}`]},suggestions:[],suggestion:{},getMentionLabelsUsing:null}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,keepOnSplit:!1,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},char:{default:"@",parseHTML:t=>t.getAttribute("data-char")??"@",renderHTML:t=>t.char?{"data-char":t.char}:{}},extra:{default:null,renderHTML:t=>{let e=t?.extra;return!e||typeof e!="object"?{}:e}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){let n=this.editor?.extensionStorage?.[this.name]?.getSuggestionFromTriggerCharacter(t?.attrs?.char??"@"),r={...this.options};r.HTMLAttributes=L({"data-type":this.name},this.options.HTMLAttributes,e);let o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",L({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){let e={options:this.options,node:t,suggestion:this.editor?.extensionStorage?.[this.name]?.getSuggestionFromTriggerCharacter(t?.attrs?.char??"@")};return this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1,{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;let s=new ge,l=0;if(e.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return n=!0,s=a,l=c,!1}),n){let a=s?.attrs?.char??"@";t.insertText(this.options.deleteTriggerWithBackspace?"":a,l,l+s.nodeSize)}return n})}},addProseMirrorPlugins(){let t=async e=>{if(this.editor.isDestroyed)return;let{state:n,dispatch:r}=e,o=[];if(n.doc.descendants(s=>{if(s.type.name!==this.name||s.attrs?.label)return;let l=s.attrs?.id,a=s.attrs?.char??"@";l&&o.push({id:l,triggerCharacter:a})}),o.length===0)return;let i=this.options.getMentionLabelsUsing;if(typeof i=="function")try{let s=await i(o);if(this.editor.isDestroyed)return;let l=e.state.tr;e.state.doc.descendants((a,c)=>{if(a.type.name!==this.name||a.attrs.label||!o.some(({id:u,triggerCharacter:f})=>u===a.attrs.id&&f===(a.attrs.char??"@")))return;let d=s[a.attrs.char??"@"]?.[a.attrs.id];d&&l.setNodeMarkup(c,void 0,{...a.attrs,label:d})}),l.docChanged&&r(l)}catch{}};return[...this.storage.suggestions.map(Rs),new F({view:e=>(setTimeout(()=>t(e),0),{update:n=>t(n)})})]},onBeforeCreate(){let t=n=>Array.isArray(n)?n:n&&typeof n=="object"?Object.entries(n).map(([r,o])=>({id:r,label:o})):[],e=this.options.suggestions.length?this.options.suggestions:[this.options.suggestion];this.storage.suggestions=e.map(n=>{let r=n?.triggerCharacter??"@",o=n?.items??[],i=n?.noOptionsMessage??null,s=n?.noSearchResultsMessage??null,l=n?.isSearchable??!1,a=this.options.getMentionSearchResultsUsing,c;if(typeof n?.items=="function"){let d=n.items;c={...n,items:async u=>{if(u?.query&&typeof a=="function")try{let f=await a(u?.query,r);return t(f)}catch{}return await d(u)}}}else{let d=n?.extraAttributes,u=n?.searchPrompt??null,f=n?.searchingMessage??null;c={...Hm({items:async({query:h})=>{if(!(Array.isArray(o)?o.length>0:o&&typeof o=="object"&&Object.keys(o).length>0)&&!h)return[];let g=t(o);if(h&&l&&typeof a=="function")try{let y=await a(h,r);return t(y)}catch{}if(!h)return g;let m=He(String(h));return g.filter(y=>{let w=typeof y=="string"?y:y?.label??y?.name??"";return He(String(w)).includes(m)})},isSearchable:l,noOptionsMessage:i,noSearchResultsMessage:s,searchPrompt:u,searchingMessage:f}),triggerCharacter:r,...d?{extraAttributes:d}:{}}}return Y1({editor:this.editor,overrideSuggestionOptions:c,extensionName:this.name})}),this.storage.getSuggestionFromTriggerCharacter=n=>this.storage.suggestions.find(r=>r.char===n)??this.storage.suggestions[0]??null}});var Ds="&nbsp;",Oc="\xA0",Q1=W.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",L(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{let n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);let r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Ds||n[0].text===Ds||n[0].raw===Oc||n[0].text===Oc)&&r.length===1&&r[0].type==="text"&&(r[0].text===Ds||r[0].text===Oc)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{if(!t)return"";let r=Array.isArray(t.content)?t.content:[];if(r.length===0){var o,i;let s=Array.isArray(n==null||(o=n.previousNode)===null||o===void 0?void 0:o.content)?n.previousNode.content:[];return(n==null||(i=n.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&s.length===0?Ds:""}return e.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Vm=Q1;var Nc=Va;var Wm=ie.create({name:"small",parseHTML(){return[{tag:"small"}]},renderHTML({HTMLAttributes:t}){return["small",t,0]},addCommands(){return{setSmall:()=>({commands:t})=>t.setMark(this.name),toggleSmall:()=>({commands:t})=>t.toggleMark(this.name),unsetSmall:()=>({commands:t})=>t.unsetMark(this.name)}}});var jm=ie.create({name:"textColor",addOptions(){return{textColors:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.classList?.contains("color")}]},renderHTML({HTMLAttributes:t}){let e={...t},n=t.class;e.class=["color",n].filter(Boolean).join(" ");let r=t["data-color"],i=(this.options.textColors||{})[r],s=typeof r=="string"&&r.length>0,l=i?`--color: ${i.color}; --dark-color: ${i.darkColor}`:s?`--color: ${r}; --dark-color: ${r}`:null;if(l){let a=typeof t.style=="string"?t.style:"";e.style=a?`${l}; ${a}`:l}return["span",e,0]},addAttributes(){return{"data-color":{default:null,parseHTML:t=>t.getAttribute("data-color"),renderHTML:t=>t["data-color"]?{"data-color":t["data-color"]}:{}}}},addCommands(){return{setTextColor:({color:t})=>({commands:e})=>e.setMark(this.name,{"data-color":t}),unsetTextColor:()=>({commands:t})=>t.unsetMark(this.name)}}});var Z1=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,eC=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,tC=ie.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",L(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ie({find:Z1,type:this.type})]},addPasteRules(){return[Ne({find:eC,type:this.type})]}}),_m=tC;var nC=ie.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",L(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Um=nC;var rC=ie.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",L(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),Km=rC;var Dc,Lc;if(typeof WeakMap<"u"){let t=new WeakMap;Dc=e=>t.get(e),Lc=(e,n)=>(t.set(e,n),n)}else{let t=[],n=0;Dc=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Lc=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var ae=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){let n=this.map[e];if(n!=t)continue;let r=e%this.width,o=e/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){let{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){let{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){let e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){let i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){let i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width,l=(t+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(t){return Dc(t)||Lc(t,oC(t))}};function oC(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=iC(t),n=t.childCount,r=[],o=0,i=null,s=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){let u=t.child(c);d++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==u.childCount)break;let g=u.child(p),{colspan:m,rowspan:y,colwidth:w}=g.attrs;for(let x=0;x<y;x++){if(x+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-x});break}let b=o+x*e;for(let k=0;k<m;k++){r[b+k]==0?r[b+k]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:m-k});let v=w&&w[k];if(v){let C=(b+k)%e*2,O=s[C];O==null||O!=v&&s[C+1]==1?(s[C]=v,s[C+1]=1):O==v&&s[C+1]++}}}o+=m,d+=g.nodeSize}let f=(c+1)*e,h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new ae(e,n,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&sC(l,s,t),l}function iC(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let o=t.child(r),i=0;if(n)for(let s=0;s<r;s++){let l=t.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function sC(t,e,n){t.problems||(t.problems=[]);let r={};for(let o=0;o<t.map.length;o++){let i=t.map[o];if(r[i])continue;r[i]=!0;let s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let d=e[(o+c)%t.width*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=lC(a)))[c]=d)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function lC(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Re(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var dn=new j("selectingCells");function Un(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function aC(t){for(let e=t.depth;e>0;e--){let n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function pt(t){let e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function zs(t){let e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let n=Un(e.$head)||cC(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function cC(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Ic(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function dC(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Bc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function ng(t,e,n){let r=t.node(-1),o=ae.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Kn(t,e,n=1){let r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function rg(t,e,n=1){let r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function uC(t,e,n){let r=Re(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var te=class Jt extends z{constructor(e,n=e){let r=e.node(-1),o=ae.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(d=>d!=n.pos-i);a.unshift(n.pos-i);let c=a.map(d=>{let u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);let f=i+d+1;return new gn(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(Ic(r)&&Ic(o)&&Bc(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Jt.rowSelection(r,o):i&&this.isColSelection()?Jt.colSelection(r,o):new Jt(r,o)}return R.between(r,o)}content(){let e=this.$anchorCell.node(-1),n=ae.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let d=a*n.width+o.left,u=o.left;u<o.right;u++,d++){let f=n.map[d];if(i[f])continue;i[f]=!0;let h=n.findCell(f),p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);let g=o.left-h.left,m=h.right-o.right;if(g>0||m>0){let y=p.attrs;if(g>0&&(y=Kn(y,0,g)),m>0&&(y=Kn(y,y.colspan-m,m)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){let y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(S.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new E(S.from(l),1,1)}replace(e,n=E.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?E.empty:n)}let i=z.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new E(S.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=ae.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=e.node(-1),o=ae.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Jt(e,n)}isRowSelection(){let e=this.$anchorCell.node(-1),n=ae.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof Jt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=e.node(-1),o=ae.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new Jt(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Jt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Jt(e.resolve(n),e.resolve(r))}getBookmark(){return new fC(this.$anchorCell.pos,this.$headCell.pos)}};te.prototype.visible=!1;z.jsonID("cell",te);var fC=class og{constructor(e,n){this.anchor=e,this.head=n}map(e){return new og(e.map(this.anchor),e.map(this.head))}resolve(e){let n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Bc(n,r)?new te(n,r):z.near(r,1)}};function hC(t){if(!(t.selection instanceof te))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(re.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Y.create(t.doc,e)}function pC({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function mC({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){let i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function gC(t,e,n){let r=(e||t).selection,o=(e||t).doc,i,s;if(r instanceof $&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=te.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=te.rowSelection(l,l)}else if(!n){let l=ae.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=te.create(o,a+1,c)}}else r instanceof R&&pC(r)?i=R.create(o,r.from):r instanceof R&&mC(r)&&(i=R.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var yC=new j("fix-tables");function ig(t,e,n,r){let o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,d=Math.min(o,s+3);c<d;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&t.child(l).sameMarkup(a)?ig(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function zc(t,e){let n,r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=bC(t,o,i,n))};return e?e.doc!=t.doc&&ig(e.doc,t.doc,0,r):t.doc.descendants(r),n}function bC(t,e,n,r){let o=ae.get(e);if(!o.problems)return r;r||(r=t.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let d=e.nodeAt(c.pos);if(!d)continue;let u=d.attrs;for(let f=0;f<u.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Kn(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<o.height;a++){let d=e.child(a),u=c+d.nodeSize,f=i[a];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);let p=[];for(let m=0;m<f;m++){let y=Re(t.schema)[h].createAndFill();y&&p.push(y)}let g=(a==0||s==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(g),p)}c=u}return r.setMeta(yC,{fixTables:!0})}function At(t){let e=t.selection,n=zs(t),r=n.node(-1),o=n.start(-1),i=ae.get(r);return{...e instanceof te?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function sg(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;uC(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,rg(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?Re(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function lg(t,e){if(!pt(t))return!1;if(e){let n=At(t);e(sg(t.tr,n,n.left))}return!0}function ag(t,e){if(!pt(t))return!1;if(e){let n=At(t);e(sg(t.tr,n,n.right))}return!0}function wC(t,{map:e,table:n,tableStart:r},o){let i=t.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Kn(d,o-e.colCount(a)));else{let u=t.mapping.slice(i).map(r+a);t.delete(u,u+c.nodeSize)}s+=d.rowspan}}function cg(t,e){if(!pt(t))return!1;if(e){let n=At(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;wC(r,n,o),o!=n.left;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ae.get(i)}e(r)}return!0}function xC(t,e,n){var r;let o=Re(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function dg(t,{map:e,tableStart:n,table:r},o){let i=n;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;xC(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c<e.width;c++,d++)if(o>0&&o<e.height&&e.map[d]==e.map[d-e.width]){let u=e.map[d],f=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let u=l==null?Re(r.type.schema).cell:(a=r.nodeAt(e.map[d+l*e.width]))===null||a===void 0?void 0:a.type,f=u?.createAndFill();f&&s.push(f)}return t.insert(i,Re(r.type.schema).row.create(null,s)),t}function ug(t,e){if(!pt(t))return!1;if(e){let n=At(t);e(dg(t.tr,n,n.top))}return!0}function fg(t,e){if(!pt(t))return!1;if(e){let n=At(t);e(dg(t.tr,n,n.bottom))}return!0}function kC(t,{map:e,table:n,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=n.child(c).nodeSize;let s=i+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(i+r,s+r);let a=new Set;for(let c=0,d=o*e.width;c<e.width;c++,d++){let u=e.map[d];if(!a.has(u)){if(a.add(u),o>0&&u==e.map[d-e.width]){let f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&u==e.map[d+e.width]){let f=n.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=h.colspan-1}}}}function hg(t,e){if(!pt(t))return!1;if(e){let n=At(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;kC(r,n,o),o!=n.top;o--){let i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=ae.get(n.table)}e(r)}return!0}function qm(t){let e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function SC({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function Hc(t,e){let n=t.selection;if(!(n instanceof te)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=At(t),{map:o}=r;if(SC(o,r))return!1;if(e){let i=t.tr,s={},l=S.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){let f=o.map[d*o.width+u],h=r.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,a==null)a=f,c=h;else{qm(h)||(l=l.append(h.content));let p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...rg(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let d=a+1+c.content.size,u=qm(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new te(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Fc(t,e){let n=Re(t.schema);return CC(({node:r})=>n[r.type.spec.tableRole])(t,e)}function CC(t){return(e,n)=>{let r=e.selection,o,i;if(r instanceof te){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=aC(r.$from),!o)return!1;i=(s=Un(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let d=At(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=o.nodeSize);for(let g=d.left,m=0;g<d.right;g++,m++)g==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),t({node:o,row:h,col:g}).createAndFill(a[m]))}u.setNodeMarkup(i,t({node:o,row:d.top,col:d.left}),a[0]),r instanceof te&&u.setSelection(new te(u.doc.resolve(r.$anchorCell.pos),f?u.doc.resolve(f):void 0)),n(u)}return!0}}function pg(t,e){return function(n,r){if(!pt(n))return!1;let o=zs(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){let i=n.tr;n.selection instanceof te?n.selection.forEachCell((s,l)=>{s.attrs[t]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function vC(t){return function(e,n){if(!pt(e))return!1;if(n){let r=Re(e.schema),o=At(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Jm(t,e,n){let r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){let i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Ar(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?vC(t):function(n,r){if(!pt(n))return!1;if(r){let o=Re(n.schema),i=At(n),s=n.tr,l=Jm("row",i,o),a=Jm("column",i,o),c=(t==="column"?l:t==="row"&&a)?1:0,d=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,u=t=="column"?a?o.cell:o.header_cell:t=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(d).forEach(f=>{let h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),r(s)}return!0}}var sE=Ar("row",{useDeprecatedLogic:!0}),lE=Ar("column",{useDeprecatedLogic:!0}),mg=Ar("cell",{useDeprecatedLogic:!0});function MC(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){let i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){let i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function Vc(t){return function(e,n){if(!pt(e))return!1;let r=MC(zs(e),t);if(r==null)return!1;if(n){let o=e.doc.resolve(r);n(e.tr.setSelection(R.between(o,dC(o))).scrollIntoView())}return!0}}function gg(t,e){let n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Ls(t,e){let n=t.selection;if(!(n instanceof te))return!1;if(e){let r=t.tr,o=Re(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new E(o,0,0))}),r.docChanged&&e(r)}return!0}function TC(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,d=a?0:Math.max(0,n-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=Pc(Re(s).row,new E(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Pc(Re(s).row,new E(e,n,r)).content:e);else return null;return AC(s,l)}function AC(t,e){let n=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(S.empty),n[o]<r){let i=Re(t).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);e[o]=e[o].append(S.from(s))}return{height:e.length,width:r,rows:e}}function Pc(t,e){let n=t.createAndFill();return new Zt(n).replace(0,n.content.size,e).doc}function EC({width:t,height:e,rows:n},r,o){if(t!=r){let i=[],s=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let f=a.child(u%a.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(Kn(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(S.from(c))}n=s,t=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=n[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);s+u.attrs.rowspan>o&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),a.push(u)}i.push(S.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function OC(t,e,n,r,o,i,s){let l=t.doc.type.schema,a=Re(l),c,d;if(o>e.width)for(let u=0,f=0;u<e.height;u++){let h=n.child(u);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=d||(d=a.header_cell.createAndFill());for(let m=e.width;m<o;m++)p.push(g);t.insert(t.mapping.slice(s).map(f-1+r),p)}if(i>e.height){let u=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,o);p++){let m=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;u.push(m?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,S.from(u)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),h)}return!!(c||d)}function Gm(t,e,n,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let d=s*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;let f=n.nodeAt(u),{top:h,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function Xm(t,e,n,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let d=c*e.width+s,u=e.map[d];if(e.map[d-1]==u){a=!0;let f=n.nodeAt(u),h=e.colCount(u),p=t.mapping.slice(l).map(u+r);t.setNodeMarkup(p,null,Kn(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Kn(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function Ym(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=ae.get(i),{top:l,left:a}=r,c=a+o.width,d=l+o.height,u=t.tr,f=0;function h(){if(i=n?u.doc.nodeAt(n-1):u.doc,!i)throw new Error("No table found");s=ae.get(i),f=u.mapping.maps.length}OC(u,s,i,n,c,d,f)&&h(),Gm(u,s,i,n,a,c,l,f)&&h(),Gm(u,s,i,n,a,c,d,f)&&h(),Xm(u,s,i,n,l,d,a,f)&&h(),Xm(u,s,i,n,l,d,c,f)&&h();for(let p=l;p<d;p++){let g=s.positionAt(p,a,i),m=s.positionAt(p,c,i);u.replace(u.mapping.slice(f).map(g+n),u.mapping.slice(f).map(m+n),new E(o.rows[p-l],0,0))}h(),u.setSelection(new te(u.doc.resolve(n+s.positionAt(l,a,i)),u.doc.resolve(n+s.positionAt(d-1,c-1,i)))),e(u)}var NC=Zr({ArrowLeft:Is("horiz",-1),ArrowRight:Is("horiz",1),ArrowUp:Is("vert",-1),ArrowDown:Is("vert",1),"Shift-ArrowLeft":Ps("horiz",-1),"Shift-ArrowRight":Ps("horiz",1),"Shift-ArrowUp":Ps("vert",-1),"Shift-ArrowDown":Ps("vert",1),Backspace:Ls,"Mod-Backspace":Ls,Delete:Ls,"Mod-Delete":Ls});function $s(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Is(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection;if(i instanceof te)return $s(n,r,z.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;let s=yg(o,t,e);if(s==null)return!1;if(t=="horiz")return $s(n,r,z.near(n.doc.resolve(i.head+e),e));{let l=n.doc.resolve(s),a=ng(l,t,e),c;return a?c=z.near(a,1):e<0?c=z.near(n.doc.resolve(l.before(-1)),-1):c=z.near(n.doc.resolve(l.after(-1)),1),$s(n,r,c)}}}function Ps(t,e){return(n,r,o)=>{if(!o)return!1;let i=n.selection,s;if(i instanceof te)s=i;else{let a=yg(o,t,e);if(a==null)return!1;s=new te(n.doc.resolve(a))}let l=ng(s.$headCell,t,e);return l?$s(n,r,new te(s.$anchorCell,l)):!1}}function RC(t,e){let n=t.state.doc,r=Un(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new te(r))),!0):!1}function DC(t,e,n){if(!pt(t.state))return!1;let r=TC(n),o=t.state.selection;if(o instanceof te){r||(r={width:1,height:1,rows:[S.from(Pc(Re(t.state.schema).cell,n))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ae.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=EC(r,l.right-l.left,l.bottom-l.top),Ym(t.state,t.dispatch,s,l,r),!0}else if(r){let i=zs(t.state),s=i.start(-1);return Ym(t.state,t.dispatch,s,ae.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function LC(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Qm(t,e.target),o;if(e.shiftKey&&t.state.selection instanceof te)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Un(t.state.selection.$anchor))!=null&&((n=Rc(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Rc(t,c),u=dn.getState(t.state)==null;if(!d||!Bc(a,d))if(u)d=a;else return;let f=new te(a,d);if(u||!t.state.selection.eq(f)){let h=t.state.tr.setSelection(f);u&&h.setMeta(dn,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),dn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(dn,-1))}function l(a){let c=a,d=dn.getState(t.state),u;if(d!=null)u=t.state.doc.resolve(d);else if(Qm(t,c.target)!=r&&(u=Rc(t,e),!u))return s();u&&i(u,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function yg(t,e,n){if(!(t.state.selection instanceof R))return null;let{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function Qm(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Rc(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&Un(t.state.doc.resolve(r))||Un(t.state.doc.resolve(o))}var IC=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),$c(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,$c(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function $c(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c){for(let u=0,f=0;u<c.childCount;u++){let{colspan:h,colwidth:p}=c.child(u).attrs;for(let g=0;g<h;g++,f++){let m=o==f?i:p&&p[g],y=m?m+"px":"";if(s+=m||r,m||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{let w=document.createElement("col");w.style.width=y,e.appendChild(w)}}}for(;a;){var d;let u=a.nextSibling;(d=a.parentNode)===null||d===void 0||d.removeChild(a),a=u}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}var _e=new j("tableColumnResizing");function bg({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=IC,lastColumnResizable:o=!0}={}){let i=new F({key:_e,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,d=Re(l.schema).table.name;return r&&c&&(c[d]=(u,f)=>new r(u,n,f)),new PC(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=_e.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{$C(s,l,t,o)},mouseleave:s=>{BC(s)},mousedown:(s,l)=>{zC(s,l,e,n)}},decorations:s=>{let l=_e.getState(s);if(l&&l.activeHandle>-1)return jC(s,l.activeHandle)},nodeViews:{}}});return i}var PC=class Bs{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(_e);if(r&&r.setHandle!=null)return new Bs(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Bs(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return Ic(e.doc.resolve(o))||(o=-1),new Bs(o,n.dragging)}return n}};function $C(t,e,n,r){if(!t.editable)return;let o=_e.getState(t.state);if(o&&!o.dragging){let i=FC(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=Zm(t,e,"left",n):a-e.clientX<=n&&(s=Zm(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=t.state.doc.resolve(s),a=l.node(-1),c=ae.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}wg(t,s)}}}function BC(t){if(!t.editable)return;let e=_e.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&wg(t,-1)}function zC(t,e,n,r){var o;if(!t.editable)return!1;let i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=_e.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=t.state.doc.nodeAt(s.activeHandle),a=HC(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(_e,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);let f=_e.getState(t.state);f?.dragging&&(VC(t,f.activeHandle,eg(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(_e,{setDragging:null})))}function d(u){if(!u.which)return c(u);let f=_e.getState(t.state);if(f&&f.dragging){let h=eg(f.dragging,u,n);tg(t,f.activeHandle,h,r)}}return tg(t,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function HC(t,e,{colspan:n,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=t.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function FC(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Zm(t,e,n,r){let o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=Un(t.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;let a=ae.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function eg(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function wg(t,e){t.dispatch(t.state.tr.setMeta(_e,{setHandle:e}))}function VC(t,e,n){let r=t.state.doc.resolve(e),o=r.node(-1),i=ae.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){let d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;let u=i.map[d],f=o.nodeAt(u).attrs,h=f.colspan==1?0:l-i.colCount(u);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():WC(f.colspan);p[h]=n,a.setNodeMarkup(s+u,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function tg(t,e,n,r){let o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=ae.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=t.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&$c(i,a.firstChild,a,r,l,n)}function WC(t){return Array(t).fill(0)}function jC(t,e){let n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Y.empty;let i=ae.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let d=l+c*i.width;if((l==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){var a;let u=i.map[d],f=s+u+o.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=_e.getState(t))===null||a===void 0)&&a.dragging&&n.push(re.node(s+u,s+u+o.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),n.push(re.widget(f,h))}}return Y.create(t.doc,n)}function xg({allowTableNodeSelection:t=!1}={}){return new F({key:dn,state:{init(){return null},apply(e,n){let r=e.getMeta(dn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:hC,handleDOMEvents:{mousedown:LC},createSelectionBetween(e){return dn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:RC,handleKeyDown:NC,handlePaste:DC},appendTransaction(e,n,r){return gC(r,zc(r,n),t)}})}function Fs(t){return t==="left"||t==="right"||t==="center"?t:null}function _C(t){let e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return Fs(e||n)}function UC(t){return Fs(t?.align)}function vg(){return{default:null,parseHTML:t=>_C(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}function KC(t){var e;let n=t.parentElement,r=t.closest("table");if(!n||!r)return null;let o=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll("colgroup > col")[o])===null||e===void 0?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function Mg(t){let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):KC(t)}var qC=/[ \t\r\n\f]+/g;function Tg(t){var e;return t.children.length>0?!1:((e=t.textContent)!==null&&e!==void 0?e:"").replace(qC,"")===""}function Ag(t){let e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}var JC=W.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Mg},align:vg()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>Tg(t)?{}:!1,getContent:(t,e)=>Ag(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",L(this.options.HTMLAttributes,t),0]}}),GC=W.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:Mg},align:vg()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>Tg(t)?{}:!1,getContent:(t,e)=>Ag(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",L(this.options.HTMLAttributes,t),0]}}),XC=W.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",L(this.options.HTMLAttributes,t),0]}});function Wc(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function kg(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild,c=t.firstChild;if(c!==null)for(let f=0,h=0;f<c.childCount;f+=1){let{colspan:p,colwidth:g}=c.child(f).attrs;for(let m=0;m<p;m+=1,h+=1){let y=o===h?i:g&&g[m],w=y?`${y}px`:"";if(s+=y||r,y||(l=!1),a){if(a.style.width!==w){let[x,b]=Wc(r,y);a.style.setProperty(x,b)}a=a.nextSibling}else{let x=document.createElement("col"),[b,k]=Wc(r,y);x.style.setProperty(b,k),e.appendChild(x)}}}for(;a;){var d;let f=a.nextSibling;(d=a.parentNode)===null||d===void 0||d.removeChild(a),a=f}let u=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);l&&!u?(n.style.width=`${s}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${s}px`)}var YC=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(let[o,i]of Object.entries(r))i!=null&&(o==="style"?this.table.style.cssText=String(i):this.table.setAttribute(o,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),kg(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,kg(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){let e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function QC(t,e,n,r){let o=0,i=!0,s=[],l=t.firstChild;if(!l)return{};for(let d=0,u=0;d<l.childCount;d+=1){let{colspan:f,colwidth:h}=l.child(d).attrs;for(let p=0;p<f;p+=1,u+=1){let g=n===u?r:h&&h[p];o+=g||e,g||(i=!1);let[m,y]=Wc(e,g);s.push(["col",{style:`${m}: ${y}`}])}}let a=i?`${o}px`:"",c=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:a,tableMinWidth:c}}function Sg(t,e){return e?t.createChecked(null,e):t.createAndFill()}function ZC(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;let e={};return Object.keys(t.nodes).forEach(n=>{let r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function ev(t,e,n,r,o){let i=ZC(t),s=[],l=[];for(let c=0;c<n;c+=1){let d=Sg(i.cell,o);if(d&&l.push(d),r){let u=Sg(i.header_cell,o);u&&s.push(u)}}let a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?s:l));return i.table.createChecked(null,a)}function tv(t){return t instanceof te}var Hs=({editor:t})=>{let{selection:e}=t.state;if(!tv(e))return!1;let n=0,r=dt(e.ranges[0].$from,o=>o.type.name==="table");return r?.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n!==e.ranges.length?!1:(t.commands.deleteTable(),!0)};function Cg(t,e){let n=t.mapping.map(e),r=dt(t.selection.$from,s=>s.type.name==="table");if(r?.pos===n)return;let o=t.doc.nodeAt(n);if(!o)return;let i=n+o.nodeSize-1;t.setSelection(R.near(t.doc.resolve(i),-1))}function nv(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!=="`"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]==="`";)r+=1;let o=n+r,i=!1;for(;o<t.length;){if(t[o]!=="`"){o+=1;continue}let s=0;for(;o+s<t.length&&t[o+s]==="`";)s+=1;if(s===r){let l=t.slice(n+r,o);e+=t.slice(n,n+r)+l.replace(/\\\||\|/g,a=>a==="|"?"\\|":a)+t.slice(o,o+r),n=o+r,i=!0;break}o+=s}i||(e+=t.slice(n,n+r),n+=r)}return e}function rv(t){return t.split(`
148
+ `).map(e=>!e.includes("|")||!e.includes("`")?e:nv(e)).join(`
149
+ `)}function ov(t){return(t||"").replace(/\s+/g," ").trim()}function iv(t,e,n={}){var r;let o=(r=n.cellLineSeparator)!==null&&r!==void 0?r:"";if(!t||!t.content||t.content.length===0)return"";let i=[];t.content.forEach(p=>{let g=[];p.content&&p.content.forEach(m=>{let y="";m.content&&Array.isArray(m.content)&&m.content.length>1?y=m.content.map(k=>e.renderChildren(k)).join(o):y=m.content?e.renderChildren(m.content):"";let w=ov(y.split(o).join(`
150
+ `).replace(/[ \t]*\r?\n[ \t]*/g,"<br>")),x=m.type==="tableHeader",b=UC(m.attrs);g.push({text:w,isHeader:x,align:b})}),i.push(g)});let s=i.reduce((p,g)=>Math.max(p,g.length),0);if(s===0)return"";let l=Array.from({length:s}).fill(0);i.forEach(p=>{for(let m=0;m<s;m+=1){var g;let y=(((g=p[m])===null||g===void 0?void 0:g.text)||"").length;y>l[m]&&(l[m]=y),l[m]<3&&(l[m]=3)}});let a=(p,g)=>p+" ".repeat(Math.max(0,g-p.length)),c=i[0],d=c.some(p=>p.isHeader),u=Array.from({length:s}).fill(null);i.forEach(p=>{for(let m=0;m<s;m+=1){var g;!u[m]&&(!((g=p[m])===null||g===void 0)&&g.align)&&(u[m]=p[m].align)}});let f=`
151
+ `,h=Array.from({length:s}).map((p,g)=>d&&c[g]&&c[g].text||"");return f+=`| ${h.map((p,g)=>a(p,l[g])).join(" | ")} |
152
+ `,f+=`| ${l.map((p,g)=>{let m=Math.max(3,p),y=u[g];return y==="left"?`:${"-".repeat(m)}`:y==="right"?`${"-".repeat(m)}:`:y==="center"?`:${"-".repeat(m)}:`:"-".repeat(m)}).join(" | ")} |
153
+ `,(d?i.slice(1):i).forEach(p=>{f+=`| ${Array.from({length:s}).fill(0).map((g,m)=>a(p[m]&&p[m].text||"",l[m])).join(" | ")} |
154
+ `}),f}var sv=W.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:YC,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let{colgroup:n,tableWidth:r,tableMinWidth:o}=QC(t,this.options.cellMinWidth),i=e.style;function s(){return i||(r?`width: ${r}`:`min-width: ${o}`)}let l=["table",L(this.options.HTMLAttributes,e,{style:s()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{let n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){let o=[];t.header.forEach((i,s)=>{var l;let a=Fs((l=r[s])!==null&&l!==void 0?l:i.align),c=a?{align:a}:{};o.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},o))}return t.rows&&t.rows.forEach(o=>{let i=[];o.forEach((s,l)=>{var a;let c=Fs((a=r[l])!==null&&a!==void 0?a:s.align),d=c?{align:c}:{};i.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>iv(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{let e=t.split(`
155
+ `);if(e.length<2)return-1;let n=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(t,e,n){let r=t.indexOf(`
156
+
157
+ `),o=r>=0?t.slice(0,r):t,i=o.split(`
158
+ `);if(i.length<2)return;let s=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(s)||!s.includes("|"))return;let l=rv(o);if(l===o)return;let a=n.blockTokens(l)[0];if(a?.type!=="table"||!a.raw)return;let c=a.raw.split(`
159
+ `).length,d=t.split(`
160
+ `).slice(0,c).join(`
161
+ `);return{...a,raw:d}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=ev(i.schema,t,e,n);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(R.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>lg(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>ag(t,e),deleteColumn:()=>({state:t,dispatch:e})=>{let n=dt(t.selection.$from,r=>r.type.name==="table");return cg(t,e&&(r=>{n&&Cg(r,n.pos),e(r)}))},addRowBefore:()=>({state:t,dispatch:e})=>ug(t,e),addRowAfter:()=>({state:t,dispatch:e})=>fg(t,e),deleteRow:()=>({state:t,dispatch:e})=>{let n=dt(t.selection.$from,r=>r.type.name==="table");return hg(t,e&&(r=>{n&&Cg(r,n.pos),e(r)}))},deleteTable:()=>({state:t,dispatch:e})=>gg(t,e),mergeCells:()=>({state:t,dispatch:e})=>Hc(t,e),splitCell:()=>({state:t,dispatch:e})=>Fc(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Ar("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Ar("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>mg(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Hc(t,e)?!0:Fc(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>pg(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Vc(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Vc(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&zc(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){let r=te.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Hs,"Mod-Backspace":Hs,Delete:Hs,"Mod-Delete":Hs}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[bg({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],xg({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){let t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r,HTMLAttributes:o})=>{let i=L(this.options.HTMLAttributes,o);return new e(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(t){let e={name:t.name,options:t.options,storage:t.storage};return{tableRole:G(B(t,"tableRole",e))}}}),Eg=Z.create({name:"tableKit",addExtensions(){let t=[];return this.options.table!==!1&&t.push(sv.configure(this.options.table)),this.options.tableCell!==!1&&t.push(JC.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(GC.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(XC.configure(this.options.tableRow)),t}});var lv=W.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Og=lv;var av=Z.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{let e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Ng=av;var cv=ie.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",L(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;let o=r[2].trim();return{type:"underline",raw:r[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Rg=cv;var Dg=({mergeTags:t,noMergeTagSearchResultsMessage:e})=>({items:({query:n})=>{let r=He(n);return Object.entries(t).filter(([o,i])=>He(o).replace(/\s/g,"").includes(r)||He(i).replace(/\s/g,"").includes(r)).map(([o,i])=>({id:o,label:i}))},render:()=>{let n,r=0,o=null,i=()=>{let f=document.createElement("div");return f.className="fi-dropdown-panel fi-dropdown-list",f.style.minWidth="12rem",f},s=()=>{if(!n||!o)return;let f=o.items||[];if(n.innerHTML="",f.length)f.forEach((h,p)=>{let g=document.createElement("button");g.className=`fi-dropdown-list-item fi-dropdown-list-item-label ${p===r?"fi-selected":""}`,g.textContent=h.label,g.type="button",g.addEventListener("click",()=>l(p)),n.appendChild(g)});else{let h=document.createElement("div");h.className="fi-dropdown-header";let p=document.createElement("span");p.style.whiteSpace="normal",p.textContent=e,h.appendChild(p),n.appendChild(h)}},l=f=>{if(!o)return;let p=(o.items||[])[f];p&&o.command({id:p.id})},a=()=>{if(!n||!o||o.items.length===0)return;let f=n.children[r];if(f){let h=f.getBoundingClientRect(),p=n.getBoundingClientRect();(h.top<p.top||h.bottom>p.bottom)&&f.scrollIntoView({block:"nearest"})}},c=()=>{if(!o)return;let f=o.items||[];f.length!==0&&(r=(r+f.length-1)%f.length,s(),a())},d=()=>{if(!o)return;let f=o.items||[];f.length!==0&&(r=(r+1)%f.length,s(),a())},u=()=>{l(r)};return{onStart:f=>{o=f,r=0,n=i(),n.style.position="absolute",n.style.zIndex="50",s(),document.body.appendChild(n),f.clientRect&&_n(f.editor,n)},onUpdate:f=>{o=f,r=0,s(),a(),f.clientRect&&_n(f.editor,n)},onKeyDown:f=>f.event.key==="Escape"?(n&&n.parentNode&&n.parentNode.removeChild(n),!0):f.event.key==="ArrowUp"?(c(),!0):f.event.key==="ArrowDown"?(d(),!0):f.event.key==="Enter"?(u(),!0):!1,onExit:()=>{n&&n.parentNode&&n.parentNode.removeChild(n)}}}});var Lg=async({$wire:t,acceptedFileTypes:e,acceptedFileTypesValidationMessage:n,canAttachFiles:r,customExtensionUrls:o,deleteCustomBlockButtonIconHtml:i,deleteCustomBlockButtonLabel:s,editCustomBlockButtonIconHtml:l,editCustomBlockButtonLabel:a,editCustomBlockUsing:c,getCustomBlockPreviewsUsing:d,getFileAttachmentUrlUsing:u,getMentionLabelsUsing:f,getMentionSearchResultsUsing:h,hasResizableImages:p,hasMinimalCustomBlockControls:g=!1,insertCustomBlockUsing:m,key:y,linkProtocols:w,maxFileSize:x,maxFileSizeValidationMessage:b,mentions:k,mergeTags:v,noMergeTagSearchResultsMessage:C,placeholder:O,statePath:P,textColors:N,uploadingFileMessage:_})=>{let U=[Jh,Gh,mc,Xh,Yh,Qh.configure({deleteCustomBlockButtonIconHtml:i,deleteCustomBlockButtonLabel:s,editCustomBlockButtonIconHtml:l,editCustomBlockButtonLabel:a,editCustomBlockUsing:c,getCustomBlockPreviewsUsing:d,hasMinimalCustomBlockControls:g,insertCustomBlockUsing:m}),ep,np,tp,rp,Bh.configure({class:"fi-not-prose"}),zh,ap,cp,dp,up,fp,hp,pp,yp.configure({inline:!0,resize:{enabled:p,alwaysPreserveAspectRatio:!0,allowBase64:!0}}),bp,Bp.configure({autolink:!0,HTMLAttributes:{target:null,rel:null},openOnClick:!1,protocols:w}),bc,...r?[Qp.configure({acceptedTypes:e,acceptedTypesValidationMessage:n,get$WireUsing:()=>t,getFileAttachmentUrlUsing:u,key:y,maxSize:x,maxSizeValidationMessage:b,statePath:P,uploadingMessage:_})]:[],...Object.keys(v).length?[zm.configure({deleteTriggerWithBackspace:!0,suggestion:Dg({mergeTags:v,noMergeTagSearchResultsMessage:C}),mergeTags:v})]:[],...k.length?[Fm.configure({HTMLAttributes:{class:"fi-fo-rich-editor-mention"},suggestions:k,getMentionSearchResultsUsing:h,getMentionLabelsUsing:f})]:[],xc,Vm,Nc.configure({placeholder:O,showOnlyWhenEditable:!1}),jm.configure({textColors:N}),Wm,_m,Um,Km,Eg.configure({table:{resizable:!0}}),Og,Ng.configure({types:["heading","paragraph"],alignments:["start","center","end","justify"],defaultAlignment:"start"}),Rg,_h],q=await Promise.all(o.map(async I=>{new RegExp("^(?:[a-z+]+:)?//","i").test(I)||(I=new URL(I,document.baseURI).href);try{let V=(await import(I)).default;return typeof V=="function"?V():V}catch(V){return console.error(`Failed to load rich editor custom extension from [${I}]:`,V),null}}));for(let I of q){if(!I||!I.name)continue;let M=U.findIndex(V=>V.name===I.name);I.name==="placeholder"&&I.parent===null&&(I=Nc.configure(I.options)),M!==-1?U[M]=I:U.push(I)}return U};function Lo(t,e){if(!t||!Array.isArray(t.content)&&t.type!=="listItem")return t;let n=(t.content??[]).map(r=>Lo(r,e));if(t.type==="listItem"&&e.nodes.listItem.spec.content==="paragraph block*"){let r=[],o=null;for(let i of n){let s=e.nodes[i.type];if(!s)throw new Error(`Unknown rich editor node [${i.type}].`);if(!s.isInline){r.push(i),o=null;continue}o||(o={type:"paragraph",content:[]},r.push(o)),o.content.push(i)}r[0]?.type!=="paragraph"&&r.unshift({type:"paragraph",content:[]}),n=r}return{...t,content:n}}function dv(t,e){let n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),o=Math.min(t.left,e.left),i=Math.max(t.right,e.right)-o,s=r-n;return new DOMRect(o,n,i,s)}var uv=class{get middlewares(){let t=[];return this.floatingUIOptions.flip&&t.push(Mr(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(Ns(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(Os(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push($m(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(Im(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(Lm(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(Pm(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(Bm(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}get virtualElement(){var t,e;let{selection:n}=this.editor.state,r=(t=this.getReferencedVirtualElement)===null||t===void 0?void 0:t.call(this);if(r)return r;if(!(!((e=this.view)===null||e===void 0||(e=e.dom)===null||e===void 0)&&e.parentNode))return;let o=va(this.view,n.from,n.to),i={getBoundingClientRect:()=>o,getClientRects:()=>[o]};if(n instanceof $){let s=this.view.nodeDOM(n.from),l=s.dataset.nodeViewWrapper?s:s.querySelector("[data-node-view-wrapper]");l&&(s=l),s&&(i={getBoundingClientRect:()=>s.getBoundingClientRect(),getClientRects:()=>[s.getBoundingClientRect()]})}if(n instanceof te){let{$anchorCell:s,$headCell:l}=n,a=s?s.pos:l.pos,c=l?l.pos:s.pos,d=this.view.nodeDOM(a),u=this.view.nodeDOM(c);if(!d||!u)return;let f=d===u?d.getBoundingClientRect():dv(d.getBoundingClientRect(),u.getBoundingClientRect());i={getBoundingClientRect:()=>f,getClientRects:()=>[f]}}return i}constructor({editor:t,element:e,view:n,pluginKey:r="bubbleMenu",updateDelay:o=250,resizeDelay:i=60,shouldShow:s,appendTo:l,getReferencedVirtualElement:a,options:c}){var d;this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:f,from:h,to:p})=>{let{doc:g,selection:m}=f,{empty:y}=m,w=!g.textBetween(h,p).length&&hr(f.selection),x=this.element.contains(document.activeElement);return!(!(u.hasFocus()||x)||y||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var f;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u?.relatedTarget&&(!((f=this.element.parentNode)===null||f===void 0)&&f.contains(u.relatedTarget))||u?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,f)=>{let h=!f?.selection.eq(u.state.selection),p=!f?.doc.eq(u.state.doc);!h&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,h,p,f)},this.updateDelay))},this.updateHandler=(u,f,h,p)=>{let{composing:g}=u;if(!(g||!f&&!h)){if(!this.getShouldShow(p)){this.hide();return}this.show(),this.updatePosition()}},this.transactionHandler=({transaction:u})=>{let f=u.getMeta(this.pluginKey);f==="updatePosition"?this.updatePosition():f&&typeof f=="object"&&f.type==="updateOptions"?this.updateOptions(f.options):f==="hide"?this.hide():f==="show"&&(this.updatePosition(),this.show())},this.editor=t,this.element=e,this.view=n,this.pluginKey=r,this.updateDelay=o,this.resizeDelay=i,this.appendTo=l,this.scrollTarget=(d=c?.scrollTarget)!==null&&d!==void 0?d:window,this.getReferencedVirtualElement=a,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}updatePosition(){if(!this.isVisible)return;let t=this.virtualElement;t&&Tr(t,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:n,strategy:r,middlewareData:o})=>{var i,s;if(!(!this.isVisible||this.editor.isDestroyed||!this.element.isConnected)){if(!((i=o.hide)===null||i===void 0)&&i.referenceHidden||!((s=o.hide)===null||s===void 0)&&s.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=r,this.element.style.left=`${e}px`,this.element.style.top=`${n}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()}})}update(t,e){let{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}let o=!e?.selection.eq(t.state.selection),i=!e?.doc.eq(t.state.doc);this.updateHandler(t,o,i,e)}getShouldShow(t){var e;let{state:n}=this.view,{selection:r}=n,{ranges:o}=r,i=Math.min(...o.map(l=>l.$from.pos)),s=Math.max(...o.map(l=>l.$to.pos));return((e=this.shouldShow)===null||e===void 0?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:i,to:s}))||!1}show(){var t;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";let e=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(t=e??this.view.dom.parentElement)===null||t===void 0||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(t){if(t.updateDelay!==void 0&&(this.updateDelay=t.updateDelay),t.resizeDelay!==void 0&&(this.resizeDelay=t.resizeDelay),t.appendTo!==void 0&&(this.appendTo=t.appendTo),t.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=t.getReferencedVirtualElement),t.shouldShow!==void 0&&t.shouldShow&&(this.shouldShow=t.shouldShow),t.options!==void 0){var e;let n=(e=t.options.scrollTarget)!==null&&e!==void 0?e:window;n!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=n,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...t.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},jc=t=>new F({key:typeof t.pluginKey=="string"?new j(t.pluginKey):t.pluginKey,view:e=>new uv({view:e,...t})}),hO=Z.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[jc({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}});function Ig(t,e){let n=t.previousElementSibling;if(!n?.hasAttribute("data-field-accessibility"))return null;let r=()=>e({"aria-describedby":n.getAttribute("aria-describedby"),"aria-invalid":n.getAttribute("aria-invalid")},n);r();let o=new MutationObserver(r);return o.observe(n,{attributes:!0,attributeFilter:["aria-describedby","aria-invalid","data-preserve-filepond-description"]}),o}var{Editor:fv}=Ni,{Selection:hv}=Xo;window.FilamentRichEditor=window.FilamentRichEditor||{};window.FilamentRichEditor.tiptap={core:Ni,pmState:Xo,pmView:ta,pmModel:kl};function pv({acceptedFileTypes:t,acceptedFileTypesValidationMessage:e,activePanel:n,canAttachFiles:r,deleteCustomBlockButtonIconHtml:o,deleteCustomBlockButtonLabel:i,editCustomBlockButtonIconHtml:s,editCustomBlockButtonLabel:l,extensions:a,floatingToolbars:c,hasResizableImages:d,hasMinimalCustomBlockControls:u=!1,hasStickyToolbar:f=!1,isDisabled:h,isLiveDebounced:p,isLiveOnBlur:g,key:m,label:y,linkProtocols:w,liveDebounce:x,livewireId:b,maxFileSize:k,maxFileSizeValidationMessage:v,mergeTags:C,mentions:O,noMergeTagSearchResultsMessage:P,placeholder:N,state:_,statePath:U,textColors:q,uploadingFileMessage:I}){let M,V=[],X=!1,se,xe,Pe,Gt,nt,rt=new Map,ot=new Map;return{state:_,activePanel:n,customBlockSearch:"",editorSelection:{type:"text",anchor:1,head:1},isUploadingFile:!1,fileValidationMessage:null,shouldUpdateState:!0,editorUpdatedAt:Date.now(),async init(){let A=await Lg({acceptedFileTypes:t,acceptedFileTypesValidationMessage:e,canAttachFiles:r,customExtensionUrls:a,deleteCustomBlockButtonIconHtml:o,deleteCustomBlockButtonLabel:i,editCustomBlockButtonIconHtml:s,editCustomBlockButtonLabel:l,editCustomBlockUsing:(D,ee)=>this.$wire.mountAction("customBlock",{editorSelection:this.editorSelection,id:D,config:ee,mode:"edit"},{schemaComponent:m}),floatingToolbars:c,getCustomBlockPreviewsUsing:D=>this.$getCustomBlockPreviewsForJs({customBlocks:D}),getFileAttachmentUrlUsing:D=>this.$callSchemaComponentMethod("getUploadedFileAttachmentTemporaryUrl",{attachment:D},{async:!0}),hasResizableImages:d,hasMinimalCustomBlockControls:u,insertCustomBlockUsing:(D,ee=null)=>this.$wire.mountAction("customBlock",{id:D,dragPosition:ee,mode:"insert"},{schemaComponent:m}),key:m,linkProtocols:w,maxFileSize:k,maxFileSizeValidationMessage:v,mergeTags:C,mentions:O,getMentionSearchResultsUsing:(D,ee)=>this.$getMentionSearchResultsForJs({search:D,triggerCharacter:ee}),getMentionLabelsUsing:D=>this.$getMentionLabelsForJs({mentions:D}),noMergeTagSearchResultsMessage:P,placeholder:N,statePath:U,textColors:q,uploadingFileMessage:I,$wire:this.$wire});if(X)return;this.$refs.toolbar&&(se=new ResizeObserver(([D])=>{X||(f&&this.$el.style.setProperty("--rich-editor-toolbar-height",`${D.borderBoxSize[0].blockSize}px`),this.syncToolbarTools())}),se.observe(this.$refs.toolbar,{box:"border-box"}));let H=this.$el.closest(".fi-modal"),J=!!this.$el.querySelector(".fi-fo-rich-editor-sticky-panels");if(H&&(f||J)){let D=H.querySelector(":scope > .fi-modal-window-ctn > .fi-modal-window"),ee,he,me,fn=()=>{let mt=H.matches(".fi-modal-has-sticky-header")?D.querySelector(":scope > .fi-modal-header"):null,de=J&&H.matches(".fi-modal-has-sticky-footer")?D.querySelector(":scope > .fi-modal-footer"):null,Ue=J?D.parentElement:null;for(let[Me,gt,Io,Pg]of[[ee,mt,"--rich-editor-modal-header-height","border-box"],[he,de,"--rich-editor-modal-footer-height","border-box"],[me,Ue,"--rich-editor-modal-viewport-height","content-box"]])Me!==gt&&(Me&&xe.unobserve(Me),this.$el.style.removeProperty(Io),gt&&xe.observe(gt,{box:Pg}));ee=mt,he=de,me=Ue};xe=new ResizeObserver(mt=>{for(let de of mt){let Ue=de.target===ee?"--rich-editor-modal-header-height":de.target===he?"--rich-editor-modal-footer-height":"--rich-editor-modal-viewport-height",Me=de.target===me?de.contentBoxSize[0].blockSize:de.borderBoxSize[0].blockSize;this.$el.style.setProperty(Ue,`${Me}px`)}}),fn(),Pe=new MutationObserver(fn),Pe.observe(H,{attributes:!0,attributeFilter:["class"]}),Pe.observe(D,{childList:!0})}let ne;M=new fv({editable:!h,element:this.$refs.editor,editorProps:{attributes:{role:"textbox",...y?{"aria-label":y}:{},"aria-multiline":"true","data-testid":"rich-editor-content"}},extensions:A,content:this.state,onBeforeCreate:({editor:D})=>{ne=Lo(D.options.content,D.schema),D.setOptions({content:ne})}}),JSON.stringify(ne)!==JSON.stringify(this.state)&&(this.state=ne),Gt=Ig(this.$el,D=>{let ee={...M.options.editorProps.attributes};for(let[he,me]of Object.entries(D))me===null?delete ee[he]:ee[he]=me;M.setOptions({editorProps:{...M.options.editorProps,attributes:ee}})}),Object.keys(c).forEach(D=>{let ee=this.$refs[`floatingToolbar::${D}`];if(!ee){console.warn(`Floating toolbar [${D}] not found.`);return}ot.set(D,ee),M.registerPlugin(jc({editor:M,element:ee,pluginKey:`floatingToolbar::${D}`,getReferencedVirtualElement:D==="grid"?()=>{let{node:he}=M.view.domAtPos(M.state.selection.from);return(he.nodeType===Node.TEXT_NODE?he.parentElement:he)?.closest(".grid-layout")}:void 0,shouldShow:()=>!X&&this.isFloatingToolbarEligible(D)&&(M.isFocused||ee.contains(document.activeElement)),options:{placement:D==="grid"?"top-end":"bottom",offset:15,...D==="grid"?{flip:{fallbackPlacements:["bottom-end"]}}:{}}})),ee.tabIndex=-1}),nt=new MutationObserver(()=>{X||this.syncToolbarTools()});for(let D of[this.$refs.toolbar,...ot.values()])D&&nt.observe(D,{attributes:!0,attributeFilter:["disabled","aria-disabled","hidden","style","class"],childList:!0,subtree:!0});this.syncToolbarTools(),M.on("create",()=>{this.editorUpdatedAt=Date.now()});let it=Alpine.debounce(()=>{X||this.$wire.commit()},x??300);M.on("update",({editor:D})=>this.$nextTick(()=>{if(X)return;this.editorUpdatedAt=Date.now();let ee=D.getJSON();JSON.stringify(ee)!==JSON.stringify(this.state)&&(this.shouldUpdateState=!1,this.state=ee),this.fileValidationMessage=null,p&&it()})),M.on("selectionUpdate",({transaction:D})=>{X||(this.editorUpdatedAt=Date.now(),this.editorSelection=D.selection.toJSON())}),M.on("transaction",()=>{X||(this.editorUpdatedAt=Date.now())}),g&&M.on("blur",()=>{X||this.$wire.commit()}),this.$watch("state",()=>{if(X)return;if(!this.shouldUpdateState){this.shouldUpdateState=!0;return}let D=Lo(this.state,M.schema);M.commands.setContent(D);let ee=M.getJSON();JSON.stringify(ee)!==JSON.stringify(this.state)&&(this.shouldUpdateState=!1,this.state=ee)});let Xt=D=>{D.detail.livewireId===b&&D.detail.key===m&&this.runEditorCommands(D.detail)};window.addEventListener("run-rich-editor-commands",Xt),V.push(["run-rich-editor-commands",Xt]);let Fe=D=>{D.detail.livewireId===b&&D.detail.key===m&&(this.isUploadingFile=!0,this.fileValidationMessage=null,D.stopPropagation())};window.addEventListener("rich-editor-uploading-file",Fe),V.push(["rich-editor-uploading-file",Fe]);let un=D=>{D.detail.livewireId===b&&D.detail.key===m&&(this.isUploadingFile=!1,D.stopPropagation())};window.addEventListener("rich-editor-uploaded-file",un),V.push(["rich-editor-uploaded-file",un]);let st=D=>{D.detail.livewireId===b&&D.detail.key===m&&(this.isUploadingFile=!1,this.fileValidationMessage=D.detail.validationMessage,D.stopPropagation())};window.addEventListener("rich-editor-file-validation-message",st),V.push(["rich-editor-file-validation-message",st]),window.dispatchEvent(new CustomEvent(`schema-component-${b}-${m}-loaded`))},getEditor(){return M},$getEditor(){return this.getEditor()},isFloatingToolbarEligible(A){if(!M?.isEditable||!M.isActive(A))return!1;let H=M.isActive("paragraph")&&!M.state.selection.empty;return A==="paragraph"?H:!("paragraph"in c&&H)},getToolbarTools(A){return A?Array.from(A.querySelectorAll("[data-rich-editor-tool]")).filter(H=>H.closest("[data-rich-editor-toolbar]")===A&&!H.closest('[role="menu"]')&&!H.disabled&&H.getAttribute("aria-disabled")!=="true"&&H.getClientRects().length&&getComputedStyle(H).visibility!=="hidden"):[]},syncToolbarTools(){for(let A of[this.$refs.toolbar,...ot.values()]){if(!A)continue;let H=this.getToolbarTools(A),J=rt.get(A),ne=H.includes(J?.tool)?J.tool:H[Math.min(J?.index??0,H.length-1)];A.querySelectorAll("[data-rich-editor-tool]").forEach(it=>{it.tabIndex=A===this.$refs.toolbar&&it===ne?0:-1}),rt.set(A,{tool:ne,index:ne?H.indexOf(ne):J?.index??0}),J?.tool&&J.tool!==ne&&(document.activeElement===J.tool||!J.tool.isConnected&&document.activeElement===document.body)&&(ne?ne.focus():A.isConnected&&this.focusEditor())}},handleToolbarFocusin(A){let H=A.target.closest("[data-rich-editor-toolbar]");if(!H)return;let J=this.getToolbarTools(H);J.includes(A.target)&&(rt.set(H,{tool:A.target,index:J.indexOf(A.target)}),this.syncToolbarTools())},handleToolbarFocusout(A){let H=A.target.closest("[data-rich-editor-toolbar]");!H||H.contains(A.relatedTarget)||this.$nextTick(()=>{if(!(X||H.contains(document.activeElement)))for(let[J,ne]of ot)ne===H&&!M.isFocused&&M.view.dispatch(M.state.tr.setMeta(`floatingToolbar::${J}`,"hide"))})},handleToolbarKeydown(A){if(X||!M||A.defaultPrevented)return;let H=A.target.closest("[data-rich-editor-toolbar]"),J=A.target===M.view.dom;if(A.key==="F10"&&A.altKey&&!A.ctrlKey&&!A.metaKey&&!A.shiftKey&&(J||H&&!A.target.closest('[role="menu"]'))){let st=Array.from(ot).filter(([D])=>this.isFloatingToolbarEligible(D)).map(([,D])=>D);if(this.$refs.toolbar&&this.getToolbarTools(this.$refs.toolbar).length&&st.push(this.$refs.toolbar),!st.length)return;for(let D=1;D<=st.length;D++){let ee=st[(st.indexOf(H)+D)%st.length],he=Array.from(ot).find(([,fn])=>fn===ee)?.[0];he&&(M.view.dispatch(M.state.tr.setMeta(`floatingToolbar::${he}`,"show")),M.view.dispatch(M.state.tr.setMeta(`floatingToolbar::${he}`,"updatePosition"))),this.syncToolbarTools();let me=rt.get(ee)?.tool;if(me){A.preventDefault(),me.focus();return}he&&M.view.dispatch(M.state.tr.setMeta(`floatingToolbar::${he}`,"hide"))}return}if(!H||A.target.closest('[role="menu"]')||A.altKey||A.ctrlKey||A.metaKey||A.shiftKey)return;let ne=this.getToolbarTools(H),it=ne.indexOf(A.target);if(it===-1)return;if(A.key==="Escape"){A.preventDefault(),A.stopPropagation(),this.focusEditor();return}if(!["ArrowLeft","ArrowRight","Home","End"].includes(A.key))return;A.preventDefault();let Xt=getComputedStyle(H).direction==="rtl",Fe=A.key==="ArrowRight"!==Xt?1:-1,un=A.key==="Home"?0:A.key==="End"?ne.length-1:(it+Fe+ne.length)%ne.length;ne[un].focus()},handleToolbarMenuKeydown(A){let H=A.currentTarget;if(X||A.defaultPrevented||H.getAttribute("aria-orientation")!=="horizontal"||A.target.closest('[role="menu"]')!==H||A.altKey||A.ctrlKey||A.metaKey||A.shiftKey||!["ArrowLeft","ArrowRight","Home","End"].includes(A.key))return;let J=Alpine.$data(H.closest(".fi-dropdown")).getMenuItems(),ne=J.indexOf(A.target);if(ne===-1)return;A.preventDefault(),A.stopImmediatePropagation();let it=getComputedStyle(H).direction==="rtl",Xt=A.key==="ArrowRight"!==it?1:-1,Fe=A.key==="Home"?0:A.key==="End"?J.length-1:(ne+Xt+J.length)%J.length;J[Fe].focus()},focusEditor(){M?.commands.focus(null,{scrollIntoView:!1})},async mountToolAction(A,H={},J=document.activeElement){let ne=M,it=JSON.stringify(M.getJSON()),Xt=M.state.selection.toJSON(),Fe=J.closest('[role="menu"]')?Alpine.$data(J.closest(".fi-dropdown")).getTrigger():J;for(let me of[J,Fe])me._tippy?.clearDelayTimeouts(),me._tippy?.hide();let un=Fe.closest("[data-rich-editor-toolbar]"),st=Fe.dataset.richEditorTool,D=un===this.$refs.toolbar,ee=D?Array.from(un.querySelectorAll("[data-rich-editor-tool]")).indexOf(Fe):-1;D||M.view.focus();let he={id:b,createFocusTarget:me=>{let fn=!1;return window.addEventListener("run-rich-editor-commands",mt=>{mt.detail.livewireId===b&&mt.detail.key===m&&(fn=!0)},{signal:me}),async()=>{let mt=()=>{let Ue=Livewire.find(b)?.$el?.querySelectorAll("[data-rich-editor-key]"),Me=Array.from(Ue??[]).find(gt=>gt.dataset.richEditorKey===m&&gt.closest("[wire\\:id]")?.getAttribute("wire:id")===b);return Me?Alpine.$data(Me):null},de=mt();if(!de)return null;if(!de.getEditor()){let Ue=!1,Me;if(await new Promise(gt=>{Me=Io=>{Io.target===document.body||!Io.target.isConnected||(Ue=!0,gt())},window.addEventListener("focusin",Me,{signal:me}),window.addEventListener(`schema-component-${b}-${m}-loaded`,gt,{once:!0,signal:me}),me.addEventListener("abort",gt,{once:!0})}),window.removeEventListener("focusin",Me),Ue)return null;de=mt()}if(me.aborted||!de?.getEditor())return null;if(de.getEditor()!==ne&&!fn&&JSON.stringify(de.getEditor().getJSON())===it&&de.setEditorSelection(Xt),D){let Ue=de.getToolbarTools(de.$refs.toolbar),Me=Ue.includes(Fe)?Fe:de.$refs.toolbar?.querySelectorAll("[data-rich-editor-tool]")[ee];if(Ue.includes(Me)&&Me.dataset.richEditorTool===st){Me.focus({preventScroll:!0});return}}de.getEditor().view.focus()}}};window.dispatchEvent(new CustomEvent("action-modal-focus-target",{detail:he}));try{return await this.$wire.mountAction(A,H,{schemaComponent:m})}finally{window.dispatchEvent(new CustomEvent("action-modal-focus-target-finished",{detail:he}))}},setEditorSelection(A){A&&(this.editorSelection=A,M.chain().command(({tr:H})=>(H.setSelection(hv.fromJSON(M.state.doc,this.editorSelection)),!0)).run())},runEditorCommands({commands:A,editorSelection:H}){this.setEditorSelection(H);let J=M.chain();A.forEach(ne=>J=J[ne.name](...ne.arguments??[])),J.run()},matchesCustomBlockSearch(A){let H=He(this.customBlockSearch.trim().toLocaleLowerCase());return!H||A.some(J=>He(J.toLocaleLowerCase()).includes(H))},togglePanel(A=null){if(this.isPanelActive(A)){this.activePanel=null;return}this.activePanel=A},isPanelActive(A=null){return A===null?this.activePanel!==null:this.activePanel===A},insertMergeTag(A){M.chain().focus().insertContent([{type:"mergeTag",attrs:{id:A}},{type:"text",text:" "}]).run()},destroy(){X=!0,Gt?.disconnect(),se?.disconnect(),xe?.disconnect(),Pe?.disconnect(),nt?.disconnect(),rt.clear(),ot.clear(),V.forEach(([A,H])=>{window.removeEventListener(A,H)}),V=[],M&&(M.destroy(),M=null),this.shouldUpdateState=!0}}}export{pv as default};