@notectl/core 2.3.1 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/README.md +1 -1
  2. package/THIRD-PARTY-NOTICES.md +129 -0
  3. package/dist/chunks/{AlignmentPlugin--xAFlRqE.mjs → AlignmentPlugin-C9Rr_R-g.mjs} +2 -2
  4. package/dist/chunks/{AlignmentPlugin--xAFlRqE.mjs.map → AlignmentPlugin-C9Rr_R-g.mjs.map} +1 -1
  5. package/dist/chunks/{AttributedMarkCommands-bagbH8Qt.mjs → AttributedMarkCommands-BCvmqeFZ.mjs} +2 -2
  6. package/dist/chunks/{AttributedMarkCommands-bagbH8Qt.mjs.map → AttributedMarkCommands-BCvmqeFZ.mjs.map} +1 -1
  7. package/dist/chunks/{BidiIsolationPlugin-DBXyXpgm.mjs → BidiIsolationPlugin-Cw2KMk-H.mjs} +2 -2
  8. package/dist/chunks/{BidiIsolationPlugin-DBXyXpgm.mjs.map → BidiIsolationPlugin-Cw2KMk-H.mjs.map} +1 -1
  9. package/dist/chunks/{BlockInsertion-CJusvrDL.mjs → BlockInsertion-CYH2gRkY.mjs} +2 -2
  10. package/dist/chunks/{BlockInsertion-CJusvrDL.mjs.map → BlockInsertion-CYH2gRkY.mjs.map} +1 -1
  11. package/dist/chunks/{BlockquotePlugin-Bz2glHwX.mjs → BlockquotePlugin-0bZSbkyo.mjs} +2 -2
  12. package/dist/chunks/{BlockquotePlugin-Bz2glHwX.mjs.map → BlockquotePlugin-0bZSbkyo.mjs.map} +1 -1
  13. package/dist/chunks/CaretNavigationPlugin-BPZ9b6XR.mjs +2 -0
  14. package/dist/chunks/CaretNavigationPlugin-BPZ9b6XR.mjs.map +1 -0
  15. package/dist/chunks/CodeBlockPlugin-BCJ3faXx.mjs +2 -0
  16. package/dist/chunks/{CodeBlockPlugin-C1hrdbSZ.mjs.map → CodeBlockPlugin-BCJ3faXx.mjs.map} +1 -1
  17. package/dist/chunks/{ColorGrid-C9RQoEWF.mjs → ColorGrid-DQEkJ-0y.mjs} +2 -2
  18. package/dist/chunks/{ColorGrid-C9RQoEWF.mjs.map → ColorGrid-DQEkJ-0y.mjs.map} +1 -1
  19. package/dist/chunks/ColorPickerPopup-CyF26zIU.mjs +2 -0
  20. package/dist/chunks/{ColorPickerPopup-DiA68Pzz.mjs.map → ColorPickerPopup-CyF26zIU.mjs.map} +1 -1
  21. package/dist/chunks/Commands-D5ND50PQ.mjs +2 -0
  22. package/dist/chunks/{Commands-1dFFldi7.mjs.map → Commands-D5ND50PQ.mjs.map} +1 -1
  23. package/dist/chunks/{Decoration-BpoEOANl.mjs → Decoration-BOP1TAUd.mjs} +2 -2
  24. package/dist/chunks/{Decoration-BpoEOANl.mjs.map → Decoration-BOP1TAUd.mjs.map} +1 -1
  25. package/dist/chunks/{FontPlugin-By-TGrQo.mjs → FontPlugin-D041tiLe.mjs} +2 -2
  26. package/dist/chunks/{FontPlugin-By-TGrQo.mjs.map → FontPlugin-D041tiLe.mjs.map} +1 -1
  27. package/dist/chunks/{FontSizePlugin-Dln-tYXV.mjs → FontSizePlugin-8CAvj1RD.mjs} +2 -2
  28. package/dist/chunks/{FontSizePlugin-Dln-tYXV.mjs.map → FontSizePlugin-8CAvj1RD.mjs.map} +1 -1
  29. package/dist/chunks/{FormulaPlugin-By1befrR.mjs → FormulaPlugin-DJ39BtqV.mjs} +2 -2
  30. package/dist/chunks/FormulaPlugin-DJ39BtqV.mjs.map +1 -0
  31. package/dist/chunks/GapCursorNavigation-DCWOmopl.mjs +2 -0
  32. package/dist/chunks/{GapCursorNavigation-BuXngVu-.mjs.map → GapCursorNavigation-DCWOmopl.mjs.map} +1 -1
  33. package/dist/chunks/GapCursorPlugin-2iR6506y.mjs +2 -0
  34. package/dist/chunks/{GapCursorPlugin-DAxVzXRs.mjs.map → GapCursorPlugin-2iR6506y.mjs.map} +1 -1
  35. package/dist/chunks/{HardBreakPlugin-DlbSlrdq.mjs → HardBreakPlugin-vniSvTgq.mjs} +2 -2
  36. package/dist/chunks/{HardBreakPlugin-DlbSlrdq.mjs.map → HardBreakPlugin-vniSvTgq.mjs.map} +1 -1
  37. package/dist/chunks/{HeadingPlugin-uMAjPOk5.mjs → HeadingPlugin-DUKsLuMd.mjs} +2 -2
  38. package/dist/chunks/{HeadingPlugin-uMAjPOk5.mjs.map → HeadingPlugin-DUKsLuMd.mjs.map} +1 -1
  39. package/dist/chunks/{HighlightPlugin-Bj7FPkIQ.mjs → HighlightPlugin-DRTAE1N5.mjs} +2 -2
  40. package/dist/chunks/{HighlightPlugin-Bj7FPkIQ.mjs.map → HighlightPlugin-DRTAE1N5.mjs.map} +1 -1
  41. package/dist/chunks/HorizontalRulePlugin-B9OvwrKB.mjs +2 -0
  42. package/dist/chunks/{HorizontalRulePlugin-DUVmTQpX.mjs.map → HorizontalRulePlugin-B9OvwrKB.mjs.map} +1 -1
  43. package/dist/chunks/{ImagePlugin-FToCOjd5.mjs → ImagePlugin-CwxTRr6d.mjs} +2 -2
  44. package/dist/chunks/{ImagePlugin-FToCOjd5.mjs.map → ImagePlugin-CwxTRr6d.mjs.map} +1 -1
  45. package/dist/chunks/{InlineCodePlugin-pISIoGQE.mjs → InlineCodePlugin-uxgMUX_E.mjs} +2 -2
  46. package/dist/chunks/{InlineCodePlugin-pISIoGQE.mjs.map → InlineCodePlugin-uxgMUX_E.mjs.map} +1 -1
  47. package/dist/chunks/{LinkPlugin-Ct5Z180S.mjs → LinkPlugin-CvWHbSkb.mjs} +2 -2
  48. package/dist/chunks/{LinkPlugin-Ct5Z180S.mjs.map → LinkPlugin-CvWHbSkb.mjs.map} +1 -1
  49. package/dist/chunks/{ListPlugin-DAY5ezNs.mjs → ListPlugin-BchSFWVn.mjs} +2 -2
  50. package/dist/chunks/{ListPlugin-DAY5ezNs.mjs.map → ListPlugin-BchSFWVn.mjs.map} +1 -1
  51. package/dist/chunks/{MarkdownHTMLRegistry-CKEx7LkR.mjs → MarkdownHTMLRegistry-Q7l0d6Ma.mjs} +2 -2
  52. package/dist/chunks/{MarkdownHTMLRegistry-CKEx7LkR.mjs.map → MarkdownHTMLRegistry-Q7l0d6Ma.mjs.map} +1 -1
  53. package/dist/chunks/{MarkdownParser-CWt3M6jR.mjs → MarkdownParser-Dp62mfUq.mjs} +2 -2
  54. package/dist/chunks/{MarkdownParser-CWt3M6jR.mjs.map → MarkdownParser-Dp62mfUq.mjs.map} +1 -1
  55. package/dist/chunks/{MarkdownSerializer-J-i28out.mjs → MarkdownSerializer-DBELFAeo.mjs} +2 -2
  56. package/dist/chunks/{MarkdownSerializer-J-i28out.mjs.map → MarkdownSerializer-DBELFAeo.mjs.map} +1 -1
  57. package/dist/chunks/MathFont-BS8IwYh2.mjs +2 -0
  58. package/dist/chunks/MathFont-BS8IwYh2.mjs.map +1 -0
  59. package/dist/chunks/NodeSelectionCommands-WH5snxr_.mjs +2 -0
  60. package/dist/chunks/{NodeSelectionCommands-1PjwUDTJ.mjs.map → NodeSelectionCommands-WH5snxr_.mjs.map} +1 -1
  61. package/dist/chunks/PluginHelpers-KDuTlmXm.mjs +2 -0
  62. package/dist/chunks/{PluginHelpers-Dx_0hfDe.mjs.map → PluginHelpers-KDuTlmXm.mjs.map} +1 -1
  63. package/dist/chunks/{PopupManager-CT-fMZJn.mjs → PopupManager-Cj86uDEB.mjs} +2 -2
  64. package/dist/chunks/{PopupManager-CT-fMZJn.mjs.map → PopupManager-Cj86uDEB.mjs.map} +1 -1
  65. package/dist/chunks/PrintPlugin-D2javl_d.mjs +2 -0
  66. package/dist/chunks/{PrintPlugin-7zz9mhhU.mjs.map → PrintPlugin-D2javl_d.mjs.map} +1 -1
  67. package/dist/chunks/SimpleMark-gTQaSJcO.mjs +2 -0
  68. package/dist/chunks/{SimpleMark-7CQcA4RK.mjs.map → SimpleMark-gTQaSJcO.mjs.map} +1 -1
  69. package/dist/chunks/SmartPastePlugin-BvJQ-fOz.mjs +2 -0
  70. package/dist/chunks/SmartPastePlugin-BvJQ-fOz.mjs.map +1 -0
  71. package/dist/chunks/StarterFonts-BDQPg-cu.mjs +2 -0
  72. package/dist/chunks/StarterFonts-BDQPg-cu.mjs.map +1 -0
  73. package/dist/chunks/{StrikethroughPlugin-C2oWvGc3.mjs → StrikethroughPlugin-BdrG1TTY.mjs} +2 -2
  74. package/dist/chunks/{StrikethroughPlugin-C2oWvGc3.mjs.map → StrikethroughPlugin-BdrG1TTY.mjs.map} +1 -1
  75. package/dist/chunks/{SuperSubPlugin-D1xaKrSu.mjs → SuperSubPlugin-DTZB0Y3D.mjs} +2 -2
  76. package/dist/chunks/{SuperSubPlugin-D1xaKrSu.mjs.map → SuperSubPlugin-DTZB0Y3D.mjs.map} +1 -1
  77. package/dist/chunks/{TablePlugin-PJe3zwr-.mjs → TablePlugin-CPvg9YZS.mjs} +2 -2
  78. package/dist/chunks/{TablePlugin-PJe3zwr-.mjs.map → TablePlugin-CPvg9YZS.mjs.map} +1 -1
  79. package/dist/chunks/{TextColorPlugin-CTd9tfeG.mjs → TextColorPlugin-Ckg3KWvb.mjs} +2 -2
  80. package/dist/chunks/{TextColorPlugin-CTd9tfeG.mjs.map → TextColorPlugin-Ckg3KWvb.mjs.map} +1 -1
  81. package/dist/chunks/{TextDirectionAutoPlugin-CPnKVVuI.mjs → TextDirectionAutoPlugin-DRGbgTlx.mjs} +2 -2
  82. package/dist/chunks/{TextDirectionAutoPlugin-CPnKVVuI.mjs.map → TextDirectionAutoPlugin-DRGbgTlx.mjs.map} +1 -1
  83. package/dist/chunks/TextDirectionPlugin-BCeYyJHo.mjs +2 -0
  84. package/dist/chunks/{TextDirectionPlugin-Bns_03vL.mjs.map → TextDirectionPlugin-BCeYyJHo.mjs.map} +1 -1
  85. package/dist/chunks/TextDirectionService-OFOU6r_s.mjs +2 -0
  86. package/dist/chunks/{TextDirectionService-BcX07mw2.mjs.map → TextDirectionService-OFOU6r_s.mjs.map} +1 -1
  87. package/dist/chunks/TextFormattingPlugin-BhRxSC8q.mjs +2 -0
  88. package/dist/chunks/{TextFormattingPlugin-DBVlePqj.mjs.map → TextFormattingPlugin-BhRxSC8q.mjs.map} +1 -1
  89. package/dist/chunks/ThemeEngine-BUVo_zaT.mjs +3 -0
  90. package/dist/chunks/ThemeEngine-BUVo_zaT.mjs.map +1 -0
  91. package/dist/chunks/ToolbarPlugin-dmTj1jIz.mjs +2 -0
  92. package/dist/chunks/{ToolbarPlugin-DtfGTO_V.mjs.map → ToolbarPlugin-dmTj1jIz.mjs.map} +1 -1
  93. package/dist/chunks/{VideoPlugin-BrR8g6Rz.mjs → VideoPlugin-BugkI7-m.mjs} +2 -2
  94. package/dist/chunks/{VideoPlugin-BrR8g6Rz.mjs.map → VideoPlugin-BugkI7-m.mjs.map} +1 -1
  95. package/dist/chunks/XmlSupport-DIXH5on9.mjs +2 -0
  96. package/dist/chunks/XmlSupport-DIXH5on9.mjs.map +1 -0
  97. package/dist/chunks/full-JM0-SwWy.mjs +2 -0
  98. package/dist/chunks/{full-DSWM4cKQ.mjs.map → full-JM0-SwWy.mjs.map} +1 -1
  99. package/dist/chunks/minimal-DSlR2A27.mjs +2 -0
  100. package/dist/chunks/{minimal-CFkkPXef.mjs.map → minimal-DSlR2A27.mjs.map} +1 -1
  101. package/dist/chunks/register-BjsdJ3Aq.mjs +2 -0
  102. package/dist/chunks/register-BjsdJ3Aq.mjs.map +1 -0
  103. package/dist/chunks/src-5GKFQ2mQ.mjs +2 -0
  104. package/dist/chunks/src-5GKFQ2mQ.mjs.map +1 -0
  105. package/dist/chunks/xml-BsV44TrJ.mjs +2 -0
  106. package/dist/chunks/xml-BsV44TrJ.mjs.map +1 -0
  107. package/dist/editor/NotectlEditor.d.ts.map +1 -1
  108. package/dist/fonts/math.d.ts +3 -0
  109. package/dist/fonts/math.d.ts.map +1 -0
  110. package/dist/fonts/math.mjs +1 -0
  111. package/dist/fonts/starter.d.ts +3 -0
  112. package/dist/fonts/starter.d.ts.map +1 -0
  113. package/dist/fonts/starter.mjs +1 -0
  114. package/dist/fonts.d.ts +4 -4
  115. package/dist/fonts.mjs +1 -1
  116. package/dist/full.d.ts +1 -1
  117. package/dist/full.mjs +1 -1
  118. package/dist/index.d.ts +2 -1
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/markdown.mjs +1 -1
  121. package/dist/notectl-core.mjs +1 -1
  122. package/dist/notectl-core.umd.js +1 -1
  123. package/dist/notectl-core.umd.js.map +1 -1
  124. package/dist/plugins/alignment.mjs +1 -1
  125. package/dist/plugins/bidi-isolation.mjs +1 -1
  126. package/dist/plugins/blockquote.mjs +1 -1
  127. package/dist/plugins/caret-navigation.mjs +1 -1
  128. package/dist/plugins/code-block/CodeBlockHighlighting.d.ts.map +1 -1
  129. package/dist/plugins/code-block.mjs +1 -1
  130. package/dist/plugins/font-size.mjs +1 -1
  131. package/dist/plugins/font.mjs +1 -1
  132. package/dist/plugins/formula/FormulaTypes.d.ts +1 -1
  133. package/dist/plugins/formula.mjs +1 -1
  134. package/dist/plugins/gap-cursor.mjs +1 -1
  135. package/dist/plugins/hard-break.mjs +1 -1
  136. package/dist/plugins/heading.mjs +1 -1
  137. package/dist/plugins/highlight.mjs +1 -1
  138. package/dist/plugins/horizontal-rule.mjs +1 -1
  139. package/dist/plugins/image.mjs +1 -1
  140. package/dist/plugins/inline-code.mjs +1 -1
  141. package/dist/plugins/language.mjs +1 -1
  142. package/dist/plugins/link.mjs +1 -1
  143. package/dist/plugins/list.mjs +1 -1
  144. package/dist/plugins/print.mjs +1 -1
  145. package/dist/plugins/shared.mjs +1 -1
  146. package/dist/plugins/smart-paste/SmartPastePlugin.d.ts.map +1 -1
  147. package/dist/plugins/smart-paste.mjs +1 -1
  148. package/dist/plugins/strikethrough.mjs +1 -1
  149. package/dist/plugins/super-sub.mjs +1 -1
  150. package/dist/plugins/table.mjs +1 -1
  151. package/dist/plugins/text-color.mjs +1 -1
  152. package/dist/plugins/text-direction-auto.mjs +1 -1
  153. package/dist/plugins/text-direction.mjs +1 -1
  154. package/dist/plugins/text-formatting.mjs +1 -1
  155. package/dist/plugins/toolbar.mjs +1 -1
  156. package/dist/plugins/video.mjs +1 -1
  157. package/dist/presets/full.d.ts +1 -1
  158. package/dist/presets/full.mjs +1 -1
  159. package/dist/presets/minimal.d.ts +1 -1
  160. package/dist/presets/minimal.mjs +1 -1
  161. package/dist/presets.d.ts +1 -1
  162. package/dist/presets.mjs +1 -1
  163. package/dist/register.d.ts +3 -0
  164. package/dist/register.d.ts.map +1 -0
  165. package/dist/register.mjs +1 -0
  166. package/package.json +24 -223
  167. package/dist/chunks/CaretNavigationPlugin-CNsT0eb4.mjs +0 -2
  168. package/dist/chunks/CaretNavigationPlugin-CNsT0eb4.mjs.map +0 -1
  169. package/dist/chunks/CodeBlockPlugin-C1hrdbSZ.mjs +0 -2
  170. package/dist/chunks/ColorPickerPopup-DiA68Pzz.mjs +0 -2
  171. package/dist/chunks/Commands-1dFFldi7.mjs +0 -2
  172. package/dist/chunks/FormulaPlugin-By1befrR.mjs.map +0 -1
  173. package/dist/chunks/GapCursorNavigation-BuXngVu-.mjs +0 -2
  174. package/dist/chunks/GapCursorPlugin-DAxVzXRs.mjs +0 -2
  175. package/dist/chunks/HorizontalRulePlugin-DUVmTQpX.mjs +0 -2
  176. package/dist/chunks/NodeSelectionCommands-1PjwUDTJ.mjs +0 -2
  177. package/dist/chunks/PluginHelpers-Dx_0hfDe.mjs +0 -2
  178. package/dist/chunks/PrintPlugin-7zz9mhhU.mjs +0 -2
  179. package/dist/chunks/PrintTypes-CxU69qu3.mjs +0 -3
  180. package/dist/chunks/PrintTypes-CxU69qu3.mjs.map +0 -1
  181. package/dist/chunks/SimpleMark-7CQcA4RK.mjs +0 -2
  182. package/dist/chunks/SmartPastePlugin-CYa_nD9v.mjs +0 -2
  183. package/dist/chunks/SmartPastePlugin-CYa_nD9v.mjs.map +0 -1
  184. package/dist/chunks/TextDirectionPlugin-Bns_03vL.mjs +0 -2
  185. package/dist/chunks/TextDirectionService-BcX07mw2.mjs +0 -2
  186. package/dist/chunks/TextFormattingPlugin-DBVlePqj.mjs +0 -2
  187. package/dist/chunks/ToolbarPlugin-DtfGTO_V.mjs +0 -2
  188. package/dist/chunks/XmlDetector-D7TQpw-e.mjs +0 -2
  189. package/dist/chunks/XmlDetector-D7TQpw-e.mjs.map +0 -1
  190. package/dist/chunks/XmlSupport-BYiRwlkK.mjs +0 -2
  191. package/dist/chunks/XmlSupport-BYiRwlkK.mjs.map +0 -1
  192. package/dist/chunks/fonts-DQC6Uj4r.mjs +0 -2
  193. package/dist/chunks/fonts-DQC6Uj4r.mjs.map +0 -1
  194. package/dist/chunks/full-DSWM4cKQ.mjs +0 -2
  195. package/dist/chunks/minimal-CFkkPXef.mjs +0 -2
  196. package/dist/chunks/src-DiAOfuOT.mjs +0 -2
  197. package/dist/chunks/src-DiAOfuOT.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import{A as t,D as e,N as o,T as n,_ as r,a as s,b as c,g as d,h as l,j as f,k as i,m as u,o as a,r as p,t as m,u as k,v as I,w as h}from"./Document-827l3P80.mjs";import{i as b}from"./Selection-HYoVFpAx.mjs";import{a as y}from"./TypeBrands-Ch9856Gb.mjs";import{n as g,o as x,s as B}from"./NodeResolver-Dleih-8R.mjs";var v={type:"identity"};function P(t){const e=/* @__PURE__ */new Set,o=t=>{e.add(t.id);for(const e of t.children)h(e)&&o(e)};return o(t),e}function w(t,e,o=-1){switch(e.type){case"identity":case"childIndexShift":case"moveNode":return{pos:t,deleted:!1};case"shift":return function(t,e,o){if(t.blockId!==e.blockId)return{pos:t,deleted:!1};const n=e.newLen-(e.to-e.from),r=t.offset;if(r<e.from)return{pos:t,deleted:!1};if(r===e.from){if(e.from===e.to){const n=1===o?e.from+e.newLen:e.from;return n===r?{pos:t,deleted:!1}:{pos:N(t,n),deleted:!1}}return{pos:t,deleted:!1}}if(r<e.to)return{pos:N(t,1===o?e.from+e.newLen:e.from),deleted:!0};const s=r+n;return s===r?{pos:t,deleted:!1}:{pos:N(t,s),deleted:!1}}(t,e,o);case"split":return function(t,e,o){return t.blockId!==e.blockId||t.offset<e.offset?{pos:t,deleted:!1}:t.offset>e.offset?{pos:b(e.newBlockId,t.offset-e.offset),deleted:!1}:1===o?{pos:b(e.newBlockId,0),deleted:!1}:{pos:t,deleted:!1}}(t,e,o);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?{pos:t,deleted:!1}:{pos:b(e.targetBlockId,t.offset+e.targetLengthBefore),deleted:!1}}(t,e);case"blockRemoval":return function(t,e){return e.removedBlockIds.has(t.blockId)?{pos:t,deleted:!0}:{pos:t,deleted:!1}}(t,e)}}function N(t,e){return b(t.blockId,e,t.path)}var M=class t{static empty=new t([]);maps;constructor(t){this.maps=t}static from(e){const o=[];for(const t of e)"identity"!==t.type&&o.push(t);return 0===o.length?t.empty:new t(o)}appendMap(e){return"identity"===e.type?this:new t([...this.maps,e])}appendMapping(e){return 0===e.maps.length?this:0===this.maps.length?e:new t([...this.maps,...e.maps])}get isEmpty(){return 0===this.maps.length}map(t,e=-1){return this.mapResult(t,e).pos}mapResult(t,e=-1){let o=t,n=!1,r=!1;for(const s of this.maps){const t=w(o,s,e);o=t.pos,t.deleted?"blockRemoval"===s.type?r=!0:n=!0:"childIndexShift"===s.type&&s.insertedBlockIds?.has(o.blockId)&&(r=!1)}return{pos:o,deleted:n||r}}mapRange(t,e=-1,o=1){const n=this.mapResult(t.from,e),r=this.mapResult(t.to,o);return n.deleted&&r.deleted&&n.pos.blockId===r.pos.blockId&&n.pos.offset>=r.pos.offset?null:{from:n.pos,to:r.pos}}};function T(t,e,o,n,r=1,s=-1){if(n.isEmpty)return{blockId:t,from:e,to:o};const c=b(t,e),d=b(t,o),l=n.mapResult(c,r),f=n.mapResult(d,s);return l.deleted&&f.deleted||l.pos.blockId!==f.pos.blockId||l.pos.offset>f.pos.offset?null:{blockId:l.pos.blockId,from:l.pos.offset,to:f.pos.offset}}function L(t,e,o,n=-1){if(o.isEmpty)return{blockId:t,from:e,to:e};const r=b(t,e),s=o.mapResult(r,n);return s.deleted?null:{blockId:s.pos.blockId,from:s.pos.offset,to:s.pos.offset}}function A(t,e,o){return S(t,e,o,"existing")}function R(t,e,o){return S(t,e,o,"insertion")}function S(t,e,o,n){if(o.isEmpty)return e;let r=e;for(const s of o.maps){const e=E(t,r,s,n);if(null===e)return null;r=e}return r}function E(t,e,o,n){switch(o.type){case"identity":case"shift":case"split":case"merge":return e;case"blockRemoval":return H(t,o.parentPath)?e===o.index?"existing"===n?null:e:e>o.index?e-1:e:e;case"childIndexShift":return H(t,o.parentPath)&&e>=o.fromIndex?e+o.delta:e;case"moveNode":return function(t,e,o,n){const r=H(o.fromParentPath,o.toParentPath);if(r&&o.fromIndex===o.destinationIndex)return e;if("existing"===n&&r&&H(t,o.fromParentPath)&&e===o.fromIndex)return o.destinationIndex;let s=e;if(H(t,o.fromParentPath))if(s===o.fromIndex){if("existing"===n)return null}else s>o.fromIndex&&s--;return H(t,o.toParentPath)&&s>=o.destinationIndex&&s++,s}(t,e,o,n)}}function H(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function z(t){switch(t.type){case"identity":return v;case"shift":return{type:"shift",blockId:t.blockId,from:t.from,to:t.from+t.newLen,newLen:t.to-t.from};case"split":return{type:"merge",targetBlockId:t.blockId,sourceBlockId:t.newBlockId,targetLengthBefore:t.offset};case"merge":return{type:"split",blockId:t.targetBlockId,offset:t.targetLengthBefore,newBlockId:t.sourceBlockId};case"blockRemoval":return{type:"childIndexShift",parentPath:t.parentPath,fromIndex:t.index,delta:1,insertedBlockIds:t.removedBlockIds};case"childIndexShift":return 1===t.delta&&t.insertedBlockIds?{type:"blockRemoval",removedBlockIds:t.insertedBlockIds,parentPath:t.parentPath,index:t.fromIndex}:v;case"moveNode":return{type:"moveNode",movedNodeId:t.movedNodeId,fromParentPath:t.toParentPath,fromIndex:t.destinationIndex,toParentPath:t.fromParentPath,destinationIndex:t.fromIndex}}}function j(t,e){if(t.type!==e.type)return!1;switch(t.type){case"identity":return!0;case"shift":{const o=e;return t.blockId===o.blockId&&t.from===o.from&&t.to===o.to&&t.newLen===o.newLen}case"split":{const o=e;return t.blockId===o.blockId&&t.offset===o.offset&&t.newBlockId===o.newBlockId}case"merge":{const o=e;return t.targetBlockId===o.targetBlockId&&t.sourceBlockId===o.sourceBlockId&&t.targetLengthBefore===o.targetLengthBefore}case"blockRemoval":{const o=e;if(t.index!==o.index)return!1;if(!H(t.parentPath,o.parentPath))return!1;if(t.removedBlockIds.size!==o.removedBlockIds.size)return!1;for(const e of t.removedBlockIds)if(!o.removedBlockIds.has(e))return!1;return!0}case"childIndexShift":{const o=e;return t.fromIndex===o.fromIndex&&t.delta===o.delta&&H(t.parentPath,o.parentPath)&&function(t,e){if(t===e)return!0;if(!t||!e||t.size!==e.size)return!1;for(const o of t)if(!e.has(o))return!1;return!0}(t.insertedBlockIds,o.insertedBlockIds)}case"moveNode":return"moveNode"===e.type&&t.movedNodeId===e.movedNodeId&&t.fromIndex===e.fromIndex&&t.destinationIndex===e.destinationIndex&&H(t.fromParentPath,e.fromParentPath)&&H(t.toParentPath,e.toParentPath)}}function D(t,e,o){return{children:O(t.children,e,o)}}function O(t,e,o){let n=!1;const r=t.map(t=>{if(!h(t))return t;if(t.id===e)return n=!0,o(t);const r=O(t.children,e,o);return r===t.children?t:(n=!0,{...t,children:r})});return n?r:t}function _(t,e,o){if(0===e.length)return t;const n=e[0];return n?{children:t.children.map(t=>h(t)&&t.id===n?1===e.length?o(t):q(t,e,1,o):t)}:t}function q(t,e,o,n){const r=e[o];if(!r)return t;const s=t.children.map(t=>h(t)&&t.id===r?o===e.length-1?n(t):q(t,e,o+1,n):t);return{...t,children:s}}function C(t,e,o){if(e(t))return o(t);let n=!1;const r=t.map(t=>{if(!h(t))return t;const r=C(t.children,e,o);return r?(n=!0,{...t,children:r}):t});return n?r:null}function W(t,e,o){const r=[];let s=0,c=!1;for(const d of t){if(n(d)){c||e!==s||(r.push(...o()),c=!0),r.push(d),s+=1;continue}const t=s+d.text.length;if(!c&&e>=s&&e<=t){const t=e-s,n=d.text.slice(0,t),l=d.text.slice(t);n&&r.push(k(n,d.marks)),r.push(...o()),l&&r.push(k(l,d.marks)),c=!0}else r.push(d);s=t}return c||r.push(...o()),r}function F(t,e,o){const r=[];let s=0;for(const c of t){if(n(c)){const t=s+1;t>e&&s<o&&r.push(c),s=t;continue}const t=s+c.text.length;if(t<=e||s>=o);else{const t=Math.max(0,e-s),n=Math.min(c.text.length,o-s),d=c.text.slice(t,n);d.length>0&&r.push(k(d,c.marks))}s=t}return 0===r.length&&r.push(k("")),r}function G(t,e,o,r,s){const c=[];let d=0;for(const l of t){if(n(l)){c.push(l),d+=1;continue}const t=d+l.text.length;if(t<=e||d>=o)c.push(l);else if(d>=e&&t<=o){const t=s?m(l.marks,r):f(l.marks,r.type);c.push(k(l.text,t))}else{const t=Math.max(0,e-d),n=Math.min(l.text.length,o-d),i=l.text.slice(0,t),u=l.text.slice(t,n),a=l.text.slice(n);if(i&&c.push(k(i,l.marks)),u){const t=s?m(l.marks,r):f(l.marks,r.type);c.push(k(u,t))}a&&c.push(k(a,l.marks))}d=t}return c}function J(t,e,o,r){const s=[];if(e>=o)return s;let c=null,d=0;const l=()=>{c&&(s.push(c),c=null)};for(const f of t){const t=d+(n(f)?1:f.text.length);if(t<=e||d>=o){d=t;continue}const s=Math.max(d,e),i=Math.min(t,o);n(f)?c&&(c.to=i):f.marks.some(t=>t.type===r)?l():c?c.to=i:c={from:s,to:i},d=t}return l(),s}function K(t,e,o,r){const s=[];if(e>=o)return s;let c=null,d=0;const l=()=>{c&&(s.push(c),c=null)};for(const f of t){const t=d+(n(f)?1:f.text.length);if(t<=e||d>=o){d=t;continue}const s=Math.max(d,e),u=Math.min(t,o);if(n(f))c&&(c.to=u);else{const t=f.marks.find(t=>t.type===r);t?c&&i(c.mark,t)?c.to=u:(l(),c={from:s,to:u,mark:t}):l()}d=t}return l(),s}function Q(t,o){if(t.every(t=>e(t)||n(t)))return o;const r=t.filter(t=>!e(t)&&!n(t));return[...o,...r]}function U(t){return t.reduce((t,e)=>t+("inline"===e.kind?1:e.text.length),0)}function V(t){return{blocks:t.split(/\r?\n/).map(t=>({type:y("paragraph"),segments:[o(t)]}))}}function X(t){return $(t.fromParentPath,t.toParentPath)&&t.toIndex>t.fromIndex?t.toIndex-1:t.toIndex}function Y(t){return $(t.fromParentPath,t.toParentPath)&&X(t)===t.fromIndex}function Z(t,e){const o=x(t,e.fromParentPath,e.fromIndex);if(!o||o.id!==e.movedNode.id)return null;if(e.toParentPath.includes(o.id))return null;const n=0===e.toParentPath.length?t.children.length:B(t,e.toParentPath)?.children.length??null;if(null===n||!Number.isInteger(e.toIndex)||e.toIndex<0||e.toIndex>n)return null;const r=$(e.fromParentPath,e.toParentPath),s=X(e);return s<0||s>n-(r?1:0)?null:{movedNode:o,destinationIndex:s}}function $(t,e){return t.length===e.length&&t.every((t,o)=>t===e[o])}function tt(t){return t.segments?U(t.segments):t.text.length}function et(e,o,n,r=!0){return D(e,o,e=>{const o=n(c(e));return{...e,children:Q(e.children,r?t(o):o)}})}function ot(t,e){if(0===e.parentPath.length){const o=[...t.children];return o.splice(e.index,0,e.node),{children:o}}return _(t,e.parentPath,t=>{const o=[...t.children];return o.splice(e.index,0,e.node),{...t,children:o}})}function nt(t,e){if(0===e.parentPath.length){const o=[...t.children];return o.splice(e.index,1),{children:o}}return _(t,e.parentPath,t=>{const o=[...t.children];return o.splice(e.index,1),{...t,children:o}})}function rt(t){return t.path?{path:t.path}:{}}function st(t){for(const e of t.steps)if("setStoredMarks"===e.type)return e.previousMarks;return t.storedMarksAfter}function ct(t,e,o){return o?t!==e?{}:{path:o}:{}}function dt(t,e,o){if(0===t.length)return!0;for(const n of t){const t=e.mapResult({blockId:n,offset:0},-1);if(t.deleted)return!1;if(t.pos.blockId!==n)return!1}return void 0!==B(o,t)}function lt(t,e){return e.blockId===t.blockId&&e.from===t.from&&e.to===t.to}var ft={insertText:{apply:function(t,e){return et(t,e.blockId,t=>{return e.segments?(o=t,n=e.offset,r=e.segments,W(o,n,()=>r.map(s))):function(t,e,o,n){return W(t,e,()=>[k(o,n)])}(t,e.offset,e.text,e.marks);var o,n,r})},invert:function(t){return{type:"deleteText",blockId:t.blockId,from:t.offset,to:t.offset+tt(t),deletedText:t.text,deletedMarks:t.marks,deletedSegments:t.segments??[o(t.text,[...t.marks])],...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset,newLen:tt(e)}},map:function(t,e,o){const n=L(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"insertText",blockId:n.blockId,offset:n.from,text:t.text,marks:t.marks,...t.segments?{segments:t.segments}:{},...ct(t.blockId,n.blockId,t.path)}:null}},deleteText:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e,o){const r=[];let s=0;for(const c of t){if(n(c)){const t=s+1;(t<=e||s>=o)&&r.push(c),s=t;continue}const t=s+c.text.length;if(t<=e||s>=o)r.push(c);else{const t=Math.max(0,e-s),n=Math.min(c.text.length,o-s),d=c.text.slice(0,t)+c.text.slice(n);d.length>0&&r.push(k(d,c.marks))}s=t}return r}(t,e.from,e.to))},invert:function(t){return{type:"insertText",blockId:t.blockId,offset:t.from,text:t.deletedText,marks:t.deletedMarks,segments:t.deletedSegments,...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.from,to:e.to,newLen:0}},map:function(t,e,o){const n=T(t.blockId,t.from,t.to,e);if(!n)return null;if(lt({blockId:t.blockId,from:t.from,to:t.to},n))return t;const s=g(o,n.blockId);if(!s)return null;const c=r(s).slice(n.from,n.to),l=d(s,n.from),f=u(s,n.from,n.to);return{type:"deleteText",blockId:n.blockId,from:n.from,to:n.to,deletedText:c,deletedMarks:l,deletedSegments:f,...ct(t.blockId,n.blockId,t.path)}}},splitBlock:{apply:function(e,o){const n=C(e.children,t=>t.some(t=>h(t)&&t.id===o.blockId),e=>{const n=e.findIndex(t=>h(t)&&t.id===o.blockId);if(-1===n)return e;const r=e[n],s=c(r),d=l(r),f=F(s,0,o.offset),i=F(s,o.offset,d),u={...r,children:t(f)},p=void 0!==o.newBlockType,m=o.newBlockType??r.type,k=p?o.newBlockAttrs:r.attrs,I=a(m,t(i),o.newBlockId,k,o.newBlockHTMLId),b=[...e];return b.splice(n,1,u,I),b});return n?{children:n}:e},invert:function(t){return{type:"mergeBlocks",targetBlockId:t.blockId,sourceBlockId:t.newBlockId,targetLengthBefore:t.offset,...void 0!==t.newBlockType?{sourceType:t.newBlockType}:{},...t.newBlockAttrs?{sourceAttrs:t.newBlockAttrs}:{},...void 0!==t.newBlockHTMLId?{sourceHTMLId:t.newBlockHTMLId}:{},...rt(t)}},getMap:function(t,e){return{type:"split",blockId:e.blockId,offset:e.offset,newBlockId:e.newBlockId}},map:function(t,e,o){const n=L(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"splitBlock",blockId:n.blockId,offset:n.from,newBlockId:t.newBlockId,...void 0!==t.newBlockType?{newBlockType:t.newBlockType}:{},...t.newBlockAttrs?{newBlockAttrs:t.newBlockAttrs}:{},...void 0!==t.newBlockHTMLId?{newBlockHTMLId:t.newBlockHTMLId}:{},...ct(t.blockId,n.blockId,t.path)}:null}},mergeBlocks:{apply:function(e,o){const n=C(e.children,t=>t.some(t=>h(t)&&t.id===o.targetBlockId)&&t.some(t=>h(t)&&t.id===o.sourceBlockId),e=>{const n=e.findIndex(t=>h(t)&&t.id===o.targetBlockId),r=e.findIndex(t=>h(t)&&t.id===o.sourceBlockId);if(-1===n||-1===r)return e;const s=e[n],d=e[r],l=c(s),f=c(d),i=t([...l,...f]),u={...s,children:i};return e.filter(t=>!h(t)||t.id!==o.sourceBlockId).map(t=>h(t)&&t.id===o.targetBlockId?u:t)});return n?{children:n}:e},invert:function(t){return{type:"splitBlock",blockId:t.targetBlockId,offset:t.targetLengthBefore,newBlockId:t.sourceBlockId,...void 0!==t.sourceType?{newBlockType:t.sourceType}:{},...t.sourceAttrs?{newBlockAttrs:t.sourceAttrs}:{},...void 0!==t.sourceHTMLId?{newBlockHTMLId:t.sourceHTMLId}:{},...rt(t)}},getMap:function(t,e){return{type:"merge",targetBlockId:e.targetBlockId,sourceBlockId:e.sourceBlockId,targetLengthBefore:e.targetLengthBefore}},map:function(t,e,o){if(e.isEmpty)return t;const n=e.mapResult({blockId:t.targetBlockId,offset:0},-1),r=e.mapResult({blockId:t.sourceBlockId,offset:0},-1);if(n.deleted||r.deleted)return null;const s=n.pos.blockId,c=r.pos.blockId;if(s===c)return null;const d=g(o,s);if(!d)return null;const f=l(d);return s===t.targetBlockId&&c===t.sourceBlockId&&f===t.targetLengthBefore?t:{type:"mergeBlocks",targetBlockId:s,sourceBlockId:c,targetLengthBefore:f,...void 0!==t.sourceType?{sourceType:t.sourceType}:{},...t.sourceAttrs?{sourceAttrs:t.sourceAttrs}:{},...void 0!==t.sourceHTMLId?{sourceHTMLId:t.sourceHTMLId}:{},...ct(t.targetBlockId,s,t.path)}}},addMark:{apply:function(t,e){return et(t,e.blockId,t=>G(t,e.from,e.to,e.mark,!0))},invert:function(t){return{type:"removeMark",blockId:t.blockId,from:t.from,to:t.to,mark:t.mark,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){const n=T(t.blockId,t.from,t.to,e);return n?lt({blockId:t.blockId,from:t.from,to:t.to},n)?t:{type:"addMark",blockId:n.blockId,from:n.from,to:n.to,mark:t.mark,...ct(t.blockId,n.blockId,t.path)}:null}},removeMark:{apply:function(t,e){return et(t,e.blockId,t=>G(t,e.from,e.to,e.mark,!1))},invert:function(t){return{type:"addMark",blockId:t.blockId,from:t.from,to:t.to,mark:t.mark,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){const n=T(t.blockId,t.from,t.to,e);return n?lt({blockId:t.blockId,from:t.from,to:t.to},n)?t:{type:"removeMark",blockId:n.blockId,from:n.from,to:n.to,mark:t.mark,...ct(t.blockId,n.blockId,t.path)}:null}},setStoredMarks:{apply:function(t){return t},invert:function(t){return{type:"setStoredMarks",marks:t.previousMarks,previousMarks:t.marks}},getMap:function(t,e){return v},map:function(t,e,o){return t}},setBlockType:{apply:function(t,e){return D(t,e.blockId,t=>{const{attrs:o,...n}=t;return{...n,type:e.nodeType,...e.attrs?{attrs:e.attrs}:{}}})},invert:function(t){return{type:"setBlockType",blockId:t.blockId,nodeType:t.previousNodeType,attrs:t.previousAttrs,previousNodeType:t.nodeType,previousAttrs:t.attrs,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){if(e.isEmpty)return t;const n=e.mapResult({blockId:t.blockId,offset:0},-1);if(n.deleted)return null;const r=n.pos.blockId,s=g(o,r);return s?r===t.blockId&&s.type===t.previousNodeType&&p(s.attrs,t.previousAttrs)?t:{type:"setBlockType",blockId:r,nodeType:t.nodeType,...t.attrs?{attrs:t.attrs}:{},previousNodeType:s.type,...s.attrs?{previousAttrs:s.attrs}:{},...ct(t.blockId,r,t.path)}:null}},insertNode:{apply:ot,invert:function(t){return{type:"removeNode",parentPath:t.parentPath,index:t.index,removedNode:t.node}},getMap:function(t,e){return{type:"childIndexShift",parentPath:e.parentPath,fromIndex:e.index,delta:1,insertedBlockIds:P(e.node)}},map:function(t,e,o){if(!dt(t.parentPath,e,o))return null;const n=R(t.parentPath,t.index,e);return n===t.index?t:{type:"insertNode",parentPath:t.parentPath,index:n,node:t.node}}},removeNode:{apply:nt,invert:function(t){return{type:"insertNode",parentPath:t.parentPath,index:t.index,node:t.removedNode}},getMap:function(t,e){return{type:"blockRemoval",removedBlockIds:P(e.removedNode),parentPath:e.parentPath,index:e.index}},map:function(t,e,o){if(!dt(t.parentPath,e,o))return null;const n=e.mapResult({blockId:t.removedNode.id,offset:0},-1);if(n.deleted)return null;if(n.pos.blockId!==t.removedNode.id)return null;const r=A(t.parentPath,t.index,e);if(null===r)return null;const s=x(o,t.parentPath,r);return s?s.id!==t.removedNode.id?null:r===t.index&&s===t.removedNode?t:{type:"removeNode",parentPath:t.parentPath,index:r,removedNode:s}:null}},moveNode:{apply:function(t,e){const o=Z(t,e);return!o||Y(e)?t:ot(nt(t,{type:"removeNode",parentPath:e.fromParentPath,index:e.fromIndex,removedNode:o.movedNode}),{type:"insertNode",parentPath:e.toParentPath,index:o.destinationIndex,node:o.movedNode})},invert:function(t){const e=X(t),o=t.fromParentPath.length===t.toParentPath.length&&t.fromParentPath.every((e,o)=>e===t.toParentPath[o])&&t.fromIndex>e?t.fromIndex+1:t.fromIndex;return{type:"moveNode",fromParentPath:t.toParentPath,fromIndex:e,toParentPath:t.fromParentPath,toIndex:o,movedNode:t.movedNode}},getMap:function(t,e){const o=Z(t,e);return!o||Y(e)?v:{type:"moveNode",movedNodeId:e.movedNode.id,fromParentPath:e.fromParentPath,fromIndex:e.fromIndex,toParentPath:e.toParentPath,destinationIndex:o.destinationIndex}},map:function(t,e,o){if(!dt(t.fromParentPath,e,o))return null;if(!dt(t.toParentPath,e,o))return null;const n=e.mapResult({blockId:t.movedNode.id,offset:0},-1);if(n.deleted||n.pos.blockId!==t.movedNode.id)return null;const r=A(t.fromParentPath,t.fromIndex,e);if(null===r)return null;const s=R(t.toParentPath,t.toIndex,e),c=x(o,t.fromParentPath,r);if(!c||c.id!==t.movedNode.id)return null;const d={type:"moveNode",fromParentPath:t.fromParentPath,fromIndex:r,toParentPath:t.toParentPath,toIndex:s,movedNode:c};return Z(o,d)?r===t.fromIndex&&s===t.toIndex&&c===t.movedNode?t:d:null}},setNodeAttr:{apply:function(t,e){const o=e.path[e.path.length-1];return o?D(t,o,t=>({...t,attrs:e.attrs})):t},invert:function(t){return{type:"setNodeAttr",path:t.path,attrs:t.previousAttrs,previousAttrs:t.attrs}},getMap:function(t,e){return v},map:function(t,e,o){if(e.isEmpty)return t;if(!dt(t.path,e,o))return null;const n=B(o,t.path);return n?{type:"setNodeAttr",path:t.path,attrs:t.attrs,...n.attrs?{previousAttrs:n.attrs}:{}}:null}},insertInlineNode:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e,o){const r=[];let s=0,c=!1;for(const d of t){if(n(d)){c||e!==s||(r.push(o),c=!0),r.push(d),s+=1;continue}const t=s+d.text.length;if(!c&&e>=s&&e<=t){const t=e-s,n=d.text.slice(0,t),l=d.text.slice(t);n&&r.push(k(n,d.marks)),r.push(o),l&&r.push(k(l,d.marks)),c=!0}else r.push(d);s=t}return c||r.push(o),r}(t,e.offset,e.node))},invert:function(t){return{type:"removeInlineNode",blockId:t.blockId,offset:t.offset,removedNode:t.node,...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset,newLen:1}},map:function(t,e,o){const n=L(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"insertInlineNode",blockId:n.blockId,offset:n.from,node:t.node,...ct(t.blockId,n.blockId,t.path)}:null}},removeInlineNode:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e){const o=[];let r=0;for(const s of t)n(s)?(r!==e&&o.push(s),r+=1):(o.push(s),r+=s.text.length);return o}(t,e.offset))},invert:function(t){return{type:"insertInlineNode",blockId:t.blockId,offset:t.offset,node:t.removedNode,...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset+1,newLen:0}},map:function(t,e,o){const r=T(t.blockId,t.offset,t.offset+1,e,1,1);if(!r)return null;if(r.to-r.from!==1)return null;const s=g(o,r.blockId);if(!s)return null;const c=I(s,r.from);return c&&"inline"===c.kind&&n(c.node)?(d=t.removedNode)===(l=c.node)||d.inlineType===l.inlineType&&p(d.attrs,l.attrs)?r.blockId===t.blockId&&r.from===t.offset?t:{type:"removeInlineNode",blockId:r.blockId,offset:r.from,removedNode:c.node,...ct(t.blockId,r.blockId,t.path)}:null:null;var d,l}},setInlineNodeAttr:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e,o){const r=[];let s=0;for(const c of t)n(c)?(s===e?r.push({...c,attrs:o}):r.push(c),s+=1):(r.push(c),s+=c.text.length);return r}(t,e.offset,e.attrs),!1)},invert:function(t){return{type:"setInlineNodeAttr",blockId:t.blockId,offset:t.offset,attrs:t.previousAttrs,previousAttrs:t.attrs,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){const r=T(t.blockId,t.offset,t.offset+1,e,1,1);if(!r)return null;if(r.to-r.from!==1)return null;if(r.blockId===t.blockId&&r.from===t.offset)return t;const s=g(o,r.blockId);if(!s)return null;const c=I(s,r.from);return c&&"inline"===c.kind&&n(c.node)?{type:"setInlineNodeAttr",blockId:r.blockId,offset:r.from,attrs:t.attrs,previousAttrs:c.node.attrs,...ct(t.blockId,r.blockId,t.path)}:null}}};function it(t){return ft[t.type]}function ut(t,e){return it(e).apply(t,e)}function at(t){return it(t).invert(t)}function pt(t,e){return it(e).getMap(t,e)}function mt(t,e,o){return e.isEmpty?t:it(t).map(t,e,o)}function kt(t){const e=t.steps.map(at).reverse();return{steps:e,selectionBefore:t.selectionAfter,selectionAfter:t.selectionBefore,storedMarksAfter:st(t),mapping:M.empty,forwardStepMaps:e.map(()=>v),metadata:{origin:"history",timestamp:Date.now()}}}function It(t,e){switch(t.type){case"inline":return function(t,e){switch(e.type){case"identity":case"childIndexShift":case"moveNode":return t;case"shift":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(b(t.blockId,t.from),e,-1).pos,n=w(b(t.blockId,t.to),e,1).pos;return o.offset>=n.offset?null:o.offset===t.from&&n.offset===t.to?t:{...t,from:o.offset,to:n.offset}}(t,e);case"split":return function(t,e){return t.blockId!==e.blockId||t.to<=e.offset?t:t.from>=e.offset?{...t,blockId:e.newBlockId,from:t.from-e.offset,to:t.to-e.offset}:[{...t,to:e.offset},{...t,blockId:e.newBlockId,from:0,to:t.to-e.offset}]}(t,e);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?t:{...t,blockId:e.targetBlockId,from:t.from+e.targetLengthBefore,to:t.to+e.targetLengthBefore}}(t,e);case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e);case"widget":return function(t,e){switch(e.type){case"identity":case"childIndexShift":case"moveNode":return t;case"shift":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(b(t.blockId,t.offset),e,t.side);return o.deleted?null:o.pos.offset===t.offset?t:{...t,offset:o.pos.offset}}(t,e);case"split":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(b(t.blockId,t.offset),e,t.side);return o.pos.blockId===t.blockId&&o.pos.offset===t.offset?t:{...t,blockId:o.pos.blockId,offset:o.pos.offset}}(t,e);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?t:{...t,blockId:e.targetBlockId,offset:t.offset+e.targetLengthBefore}}(t,e);case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e);case"node":return function(t,e){switch(e.type){case"identity":case"shift":case"split":case"childIndexShift":case"moveNode":return t;case"merge":return t.blockId===e.sourceBlockId?null:t;case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e)}}function ht(t,e,o,n){return{type:"inline",blockId:t,from:e,to:o,attrs:n}}function bt(t,e){return{type:"node",blockId:t,attrs:e}}function yt(t,e,o,n){return{type:"widget",blockId:t,offset:e,toDOM:o,side:n?.side??-1,key:n?.key}}var gt=class t{byBlock;static empty=new t(/* @__PURE__ */new Map);constructor(t){this.byBlock=t}static create(e){if(0===e.length)return t.empty;const o=/* @__PURE__ */new Map;for(const t of e){const e=o.get(t.blockId);e?e.push(t):o.set(t.blockId,[t])}return new t(o)}find(t){return this.byBlock.get(t)??[]}findInline(t){const e=this.byBlock.get(t);return e?e.filter(t=>"inline"===t.type):[]}findNode(t){const e=this.byBlock.get(t);return e?e.filter(t=>"node"===t.type):[]}findWidget(t){const e=this.byBlock.get(t);return e?e.filter(t=>"widget"===t.type):[]}add(e){if(0===e.length)return this;if(this.isEmpty)return t.create(e);const o=/* @__PURE__ */new Map;for(const[t,n]of this.byBlock)o.set(t,[...n]);for(const t of e){const e=o.get(t.blockId);e?e.push(t):o.set(t.blockId,[t])}return new t(o)}remove(e){const o=/* @__PURE__ */new Map;let n=!1;for(const[t,r]of this.byBlock){const s=r.filter(t=>!e(t));s.length!==r.length&&(n=!0),s.length>0&&o.set(t,s)}return n?0===o.size?t.empty:new t(o):this}merge(e){if(e.isEmpty)return this;if(this.isEmpty)return e;const o=/* @__PURE__ */new Map;for(const[t,n]of this.byBlock)o.set(t,[...n]);for(const[t,n]of e.byBlock){const e=o.get(t);e?e.push(...n):o.set(t,[...n])}return new t(o)}equals(t){if(this===t)return!0;if(this.byBlock.size!==t.byBlock.size)return!1;for(const[e,o]of this.byBlock){const n=t.byBlock.get(e);if(!n)return!1;if(!xt(o,n))return!1}return!0}get isEmpty(){return 0===this.byBlock.size}map(e){if(this.isEmpty||e.mapping.isEmpty)return this;let o=[];for(const t of this.byBlock.values())for(const e of t)o.push(e);for(const t of e.mapping.maps){const e=[];for(const n of o){const o=It(n,t);if(null!==o)if(Array.isArray(o))for(const t of o)e.push(t);else e.push(o)}o=e}return 0===o.length?t.empty:t.create(o)}};function xt(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++){const n=t[o],r=e[o];if(!n||!r||!Bt(n,r))return!1}return!0}function Bt(t,e){if(t.type!==e.type)return!1;if(t.blockId!==e.blockId)return!1;switch(t.type){case"inline":{const o=e;return t.from===o.from&&t.to===o.to&&vt(t.attrs,o.attrs)}case"node":{const o=e;return vt(t.attrs,o.attrs)}case"widget":{const o=e;return t.offset===o.offset&&t.side===o.side&&t.key===o.key&&t.toDOM===o.toDOM}}}function vt(t,e){if(t===e)return!0;const o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(const r of o)if(t[r]!==e[r])return!1;return!0}export{w as C,R as S,v as _,yt as a,z as b,at as c,st as d,Y as f,K as g,J as h,bt as i,kt as l,U as m,xt as n,ut as o,V as p,ht as r,pt as s,gt as t,mt as u,M as v,j as w,A as x,P as y};
2
- //# sourceMappingURL=Decoration-BpoEOANl.mjs.map
1
+ import{A as t,D as e,N as o,T as n,_ as r,a as s,b as c,g as d,h as l,j as f,k as i,m as u,o as a,r as p,t as m,u as k,v as I,w as h}from"./Document-827l3P80.mjs";import{n as b,o as y,s as g}from"./NodeResolver-Dleih-8R.mjs";import{i as x}from"./Selection-HYoVFpAx.mjs";import{a as B}from"./TypeBrands-Ch9856Gb.mjs";var v={type:"identity"};function P(t){const e=/* @__PURE__ */new Set,o=t=>{e.add(t.id);for(const e of t.children)h(e)&&o(e)};return o(t),e}function w(t,e,o=-1){switch(e.type){case"identity":case"childIndexShift":case"moveNode":return{pos:t,deleted:!1};case"shift":return function(t,e,o){if(t.blockId!==e.blockId)return{pos:t,deleted:!1};const n=e.newLen-(e.to-e.from),r=t.offset;if(r<e.from)return{pos:t,deleted:!1};if(r===e.from){if(e.from===e.to){const n=1===o?e.from+e.newLen:e.from;return n===r?{pos:t,deleted:!1}:{pos:N(t,n),deleted:!1}}return{pos:t,deleted:!1}}if(r<e.to)return{pos:N(t,1===o?e.from+e.newLen:e.from),deleted:!0};const s=r+n;return s===r?{pos:t,deleted:!1}:{pos:N(t,s),deleted:!1}}(t,e,o);case"split":return function(t,e,o){return t.blockId!==e.blockId||t.offset<e.offset?{pos:t,deleted:!1}:t.offset>e.offset?{pos:x(e.newBlockId,t.offset-e.offset),deleted:!1}:1===o?{pos:x(e.newBlockId,0),deleted:!1}:{pos:t,deleted:!1}}(t,e,o);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?{pos:t,deleted:!1}:{pos:x(e.targetBlockId,t.offset+e.targetLengthBefore),deleted:!1}}(t,e);case"blockRemoval":return function(t,e){return e.removedBlockIds.has(t.blockId)?{pos:t,deleted:!0}:{pos:t,deleted:!1}}(t,e)}}function N(t,e){return x(t.blockId,e,t.path)}var M=class t{static empty=new t([]);maps;constructor(t){this.maps=t}static from(e){const o=[];for(const t of e)"identity"!==t.type&&o.push(t);return 0===o.length?t.empty:new t(o)}appendMap(e){return"identity"===e.type?this:new t([...this.maps,e])}appendMapping(e){return 0===e.maps.length?this:0===this.maps.length?e:new t([...this.maps,...e.maps])}get isEmpty(){return 0===this.maps.length}map(t,e=-1){return this.mapResult(t,e).pos}mapResult(t,e=-1){let o=t,n=!1,r=!1;for(const s of this.maps){const t=w(o,s,e);o=t.pos,t.deleted?"blockRemoval"===s.type?r=!0:n=!0:"childIndexShift"===s.type&&s.insertedBlockIds?.has(o.blockId)&&(r=!1)}return{pos:o,deleted:n||r}}mapRange(t,e=-1,o=1){const n=this.mapResult(t.from,e),r=this.mapResult(t.to,o);return n.deleted&&r.deleted&&n.pos.blockId===r.pos.blockId&&n.pos.offset>=r.pos.offset?null:{from:n.pos,to:r.pos}}};function T(t,e,o,n,r=1,s=-1){if(n.isEmpty)return{blockId:t,from:e,to:o};const c=x(t,e),d=x(t,o),l=n.mapResult(c,r),f=n.mapResult(d,s);return l.deleted&&f.deleted||l.pos.blockId!==f.pos.blockId||l.pos.offset>f.pos.offset?null:{blockId:l.pos.blockId,from:l.pos.offset,to:f.pos.offset}}function L(t,e,o,n=-1){if(o.isEmpty)return{blockId:t,from:e,to:e};const r=x(t,e),s=o.mapResult(r,n);return s.deleted?null:{blockId:s.pos.blockId,from:s.pos.offset,to:s.pos.offset}}function A(t,e,o){return S(t,e,o,"existing")}function R(t,e,o){return S(t,e,o,"insertion")}function S(t,e,o,n){if(o.isEmpty)return e;let r=e;for(const s of o.maps){const e=E(t,r,s,n);if(null===e)return null;r=e}return r}function E(t,e,o,n){switch(o.type){case"identity":case"shift":case"split":case"merge":return e;case"blockRemoval":return H(t,o.parentPath)?e===o.index?"existing"===n?null:e:e>o.index?e-1:e:e;case"childIndexShift":return H(t,o.parentPath)&&e>=o.fromIndex?e+o.delta:e;case"moveNode":return function(t,e,o,n){const r=H(o.fromParentPath,o.toParentPath);if(r&&o.fromIndex===o.destinationIndex)return e;if("existing"===n&&r&&H(t,o.fromParentPath)&&e===o.fromIndex)return o.destinationIndex;let s=e;if(H(t,o.fromParentPath))if(s===o.fromIndex){if("existing"===n)return null}else s>o.fromIndex&&s--;return H(t,o.toParentPath)&&s>=o.destinationIndex&&s++,s}(t,e,o,n)}}function H(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function z(t){switch(t.type){case"identity":return v;case"shift":return{type:"shift",blockId:t.blockId,from:t.from,to:t.from+t.newLen,newLen:t.to-t.from};case"split":return{type:"merge",targetBlockId:t.blockId,sourceBlockId:t.newBlockId,targetLengthBefore:t.offset};case"merge":return{type:"split",blockId:t.targetBlockId,offset:t.targetLengthBefore,newBlockId:t.sourceBlockId};case"blockRemoval":return{type:"childIndexShift",parentPath:t.parentPath,fromIndex:t.index,delta:1,insertedBlockIds:t.removedBlockIds};case"childIndexShift":return 1===t.delta&&t.insertedBlockIds?{type:"blockRemoval",removedBlockIds:t.insertedBlockIds,parentPath:t.parentPath,index:t.fromIndex}:v;case"moveNode":return{type:"moveNode",movedNodeId:t.movedNodeId,fromParentPath:t.toParentPath,fromIndex:t.destinationIndex,toParentPath:t.fromParentPath,destinationIndex:t.fromIndex}}}function j(t,e){if(t.type!==e.type)return!1;switch(t.type){case"identity":return!0;case"shift":{const o=e;return t.blockId===o.blockId&&t.from===o.from&&t.to===o.to&&t.newLen===o.newLen}case"split":{const o=e;return t.blockId===o.blockId&&t.offset===o.offset&&t.newBlockId===o.newBlockId}case"merge":{const o=e;return t.targetBlockId===o.targetBlockId&&t.sourceBlockId===o.sourceBlockId&&t.targetLengthBefore===o.targetLengthBefore}case"blockRemoval":{const o=e;if(t.index!==o.index)return!1;if(!H(t.parentPath,o.parentPath))return!1;if(t.removedBlockIds.size!==o.removedBlockIds.size)return!1;for(const e of t.removedBlockIds)if(!o.removedBlockIds.has(e))return!1;return!0}case"childIndexShift":{const o=e;return t.fromIndex===o.fromIndex&&t.delta===o.delta&&H(t.parentPath,o.parentPath)&&function(t,e){if(t===e)return!0;if(!t||!e||t.size!==e.size)return!1;for(const o of t)if(!e.has(o))return!1;return!0}(t.insertedBlockIds,o.insertedBlockIds)}case"moveNode":return"moveNode"===e.type&&t.movedNodeId===e.movedNodeId&&t.fromIndex===e.fromIndex&&t.destinationIndex===e.destinationIndex&&H(t.fromParentPath,e.fromParentPath)&&H(t.toParentPath,e.toParentPath)}}function D(t,e,o){return{children:O(t.children,e,o)}}function O(t,e,o){let n=!1;const r=t.map(t=>{if(!h(t))return t;if(t.id===e)return n=!0,o(t);const r=O(t.children,e,o);return r===t.children?t:(n=!0,{...t,children:r})});return n?r:t}function _(t,e,o){if(0===e.length)return t;const n=e[0];return n?{children:t.children.map(t=>h(t)&&t.id===n?1===e.length?o(t):q(t,e,1,o):t)}:t}function q(t,e,o,n){const r=e[o];if(!r)return t;const s=t.children.map(t=>h(t)&&t.id===r?o===e.length-1?n(t):q(t,e,o+1,n):t);return{...t,children:s}}function C(t,e,o){if(e(t))return o(t);let n=!1;const r=t.map(t=>{if(!h(t))return t;const r=C(t.children,e,o);return r?(n=!0,{...t,children:r}):t});return n?r:null}function W(t,e,o){const r=[];let s=0,c=!1;for(const d of t){if(n(d)){c||e!==s||(r.push(...o()),c=!0),r.push(d),s+=1;continue}const t=s+d.text.length;if(!c&&e>=s&&e<=t){const t=e-s,n=d.text.slice(0,t),l=d.text.slice(t);n&&r.push(k(n,d.marks)),r.push(...o()),l&&r.push(k(l,d.marks)),c=!0}else r.push(d);s=t}return c||r.push(...o()),r}function F(t,e,o){const r=[];let s=0;for(const c of t){if(n(c)){const t=s+1;t>e&&s<o&&r.push(c),s=t;continue}const t=s+c.text.length;if(t<=e||s>=o);else{const t=Math.max(0,e-s),n=Math.min(c.text.length,o-s),d=c.text.slice(t,n);d.length>0&&r.push(k(d,c.marks))}s=t}return 0===r.length&&r.push(k("")),r}function G(t,e,o,r,s){const c=[];let d=0;for(const l of t){if(n(l)){c.push(l),d+=1;continue}const t=d+l.text.length;if(t<=e||d>=o)c.push(l);else if(d>=e&&t<=o){const t=s?m(l.marks,r):f(l.marks,r.type);c.push(k(l.text,t))}else{const t=Math.max(0,e-d),n=Math.min(l.text.length,o-d),i=l.text.slice(0,t),u=l.text.slice(t,n),a=l.text.slice(n);if(i&&c.push(k(i,l.marks)),u){const t=s?m(l.marks,r):f(l.marks,r.type);c.push(k(u,t))}a&&c.push(k(a,l.marks))}d=t}return c}function J(t,e,o,r){const s=[];if(e>=o)return s;let c=null,d=0;const l=()=>{c&&(s.push(c),c=null)};for(const f of t){const t=d+(n(f)?1:f.text.length);if(t<=e||d>=o){d=t;continue}const s=Math.max(d,e),i=Math.min(t,o);n(f)?c&&(c.to=i):f.marks.some(t=>t.type===r)?l():c?c.to=i:c={from:s,to:i},d=t}return l(),s}function K(t,e,o,r){const s=[];if(e>=o)return s;let c=null,d=0;const l=()=>{c&&(s.push(c),c=null)};for(const f of t){const t=d+(n(f)?1:f.text.length);if(t<=e||d>=o){d=t;continue}const s=Math.max(d,e),u=Math.min(t,o);if(n(f))c&&(c.to=u);else{const t=f.marks.find(t=>t.type===r);t?c&&i(c.mark,t)?c.to=u:(l(),c={from:s,to:u,mark:t}):l()}d=t}return l(),s}function Q(t,o){if(t.every(t=>e(t)||n(t)))return o;const r=t.filter(t=>!e(t)&&!n(t));return[...o,...r]}function U(t){return t.reduce((t,e)=>t+("inline"===e.kind?1:e.text.length),0)}function V(t){return{blocks:t.split(/\r?\n/).map(t=>({type:B("paragraph"),segments:[o(t)]}))}}function X(t){return $(t.fromParentPath,t.toParentPath)&&t.toIndex>t.fromIndex?t.toIndex-1:t.toIndex}function Y(t){return $(t.fromParentPath,t.toParentPath)&&X(t)===t.fromIndex}function Z(t,e){const o=y(t,e.fromParentPath,e.fromIndex);if(!o||o.id!==e.movedNode.id)return null;if(e.toParentPath.includes(o.id))return null;const n=0===e.toParentPath.length?t.children.length:g(t,e.toParentPath)?.children.length??null;if(null===n||!Number.isInteger(e.toIndex)||e.toIndex<0||e.toIndex>n)return null;const r=$(e.fromParentPath,e.toParentPath),s=X(e);return s<0||s>n-(r?1:0)?null:{movedNode:o,destinationIndex:s}}function $(t,e){return t.length===e.length&&t.every((t,o)=>t===e[o])}function tt(t){return t.segments?U(t.segments):t.text.length}function et(e,o,n,r=!0){return D(e,o,e=>{const o=n(c(e));return{...e,children:Q(e.children,r?t(o):o)}})}function ot(t,e){if(0===e.parentPath.length){const o=[...t.children];return o.splice(e.index,0,e.node),{children:o}}return _(t,e.parentPath,t=>{const o=[...t.children];return o.splice(e.index,0,e.node),{...t,children:o}})}function nt(t,e){if(0===e.parentPath.length){const o=[...t.children];return o.splice(e.index,1),{children:o}}return _(t,e.parentPath,t=>{const o=[...t.children];return o.splice(e.index,1),{...t,children:o}})}function rt(t){return t.path?{path:t.path}:{}}function st(t){for(const e of t.steps)if("setStoredMarks"===e.type)return e.previousMarks;return t.storedMarksAfter}function ct(t,e,o){return o?t!==e?{}:{path:o}:{}}function dt(t,e,o){if(0===t.length)return!0;for(const n of t){const t=e.mapResult({blockId:n,offset:0},-1);if(t.deleted)return!1;if(t.pos.blockId!==n)return!1}return void 0!==g(o,t)}function lt(t,e){return e.blockId===t.blockId&&e.from===t.from&&e.to===t.to}var ft={insertText:{apply:function(t,e){return et(t,e.blockId,t=>{return e.segments?(o=t,n=e.offset,r=e.segments,W(o,n,()=>r.map(s))):function(t,e,o,n){return W(t,e,()=>[k(o,n)])}(t,e.offset,e.text,e.marks);var o,n,r})},invert:function(t){return{type:"deleteText",blockId:t.blockId,from:t.offset,to:t.offset+tt(t),deletedText:t.text,deletedMarks:t.marks,deletedSegments:t.segments??[o(t.text,[...t.marks])],...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset,newLen:tt(e)}},map:function(t,e,o){const n=L(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"insertText",blockId:n.blockId,offset:n.from,text:t.text,marks:t.marks,...t.segments?{segments:t.segments}:{},...ct(t.blockId,n.blockId,t.path)}:null}},deleteText:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e,o){const r=[];let s=0;for(const c of t){if(n(c)){const t=s+1;(t<=e||s>=o)&&r.push(c),s=t;continue}const t=s+c.text.length;if(t<=e||s>=o)r.push(c);else{const t=Math.max(0,e-s),n=Math.min(c.text.length,o-s),d=c.text.slice(0,t)+c.text.slice(n);d.length>0&&r.push(k(d,c.marks))}s=t}return r}(t,e.from,e.to))},invert:function(t){return{type:"insertText",blockId:t.blockId,offset:t.from,text:t.deletedText,marks:t.deletedMarks,segments:t.deletedSegments,...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.from,to:e.to,newLen:0}},map:function(t,e,o){const n=T(t.blockId,t.from,t.to,e);if(!n)return null;if(lt({blockId:t.blockId,from:t.from,to:t.to},n))return t;const s=b(o,n.blockId);if(!s)return null;const c=r(s).slice(n.from,n.to),l=d(s,n.from),f=u(s,n.from,n.to);return{type:"deleteText",blockId:n.blockId,from:n.from,to:n.to,deletedText:c,deletedMarks:l,deletedSegments:f,...ct(t.blockId,n.blockId,t.path)}}},splitBlock:{apply:function(e,o){const n=C(e.children,t=>t.some(t=>h(t)&&t.id===o.blockId),e=>{const n=e.findIndex(t=>h(t)&&t.id===o.blockId);if(-1===n)return e;const r=e[n],s=c(r),d=l(r),f=F(s,0,o.offset),i=F(s,o.offset,d),u={...r,children:t(f)},p=void 0!==o.newBlockType,m=o.newBlockType??r.type,k=p?o.newBlockAttrs:r.attrs,I=a(m,t(i),o.newBlockId,k,o.newBlockHTMLId),b=[...e];return b.splice(n,1,u,I),b});return n?{children:n}:e},invert:function(t){return{type:"mergeBlocks",targetBlockId:t.blockId,sourceBlockId:t.newBlockId,targetLengthBefore:t.offset,...void 0!==t.newBlockType?{sourceType:t.newBlockType}:{},...t.newBlockAttrs?{sourceAttrs:t.newBlockAttrs}:{},...void 0!==t.newBlockHTMLId?{sourceHTMLId:t.newBlockHTMLId}:{},...rt(t)}},getMap:function(t,e){return{type:"split",blockId:e.blockId,offset:e.offset,newBlockId:e.newBlockId}},map:function(t,e,o){const n=L(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"splitBlock",blockId:n.blockId,offset:n.from,newBlockId:t.newBlockId,...void 0!==t.newBlockType?{newBlockType:t.newBlockType}:{},...t.newBlockAttrs?{newBlockAttrs:t.newBlockAttrs}:{},...void 0!==t.newBlockHTMLId?{newBlockHTMLId:t.newBlockHTMLId}:{},...ct(t.blockId,n.blockId,t.path)}:null}},mergeBlocks:{apply:function(e,o){const n=C(e.children,t=>t.some(t=>h(t)&&t.id===o.targetBlockId)&&t.some(t=>h(t)&&t.id===o.sourceBlockId),e=>{const n=e.findIndex(t=>h(t)&&t.id===o.targetBlockId),r=e.findIndex(t=>h(t)&&t.id===o.sourceBlockId);if(-1===n||-1===r)return e;const s=e[n],d=e[r],l=c(s),f=c(d),i=t([...l,...f]),u={...s,children:i};return e.filter(t=>!h(t)||t.id!==o.sourceBlockId).map(t=>h(t)&&t.id===o.targetBlockId?u:t)});return n?{children:n}:e},invert:function(t){return{type:"splitBlock",blockId:t.targetBlockId,offset:t.targetLengthBefore,newBlockId:t.sourceBlockId,...void 0!==t.sourceType?{newBlockType:t.sourceType}:{},...t.sourceAttrs?{newBlockAttrs:t.sourceAttrs}:{},...void 0!==t.sourceHTMLId?{newBlockHTMLId:t.sourceHTMLId}:{},...rt(t)}},getMap:function(t,e){return{type:"merge",targetBlockId:e.targetBlockId,sourceBlockId:e.sourceBlockId,targetLengthBefore:e.targetLengthBefore}},map:function(t,e,o){if(e.isEmpty)return t;const n=e.mapResult({blockId:t.targetBlockId,offset:0},-1),r=e.mapResult({blockId:t.sourceBlockId,offset:0},-1);if(n.deleted||r.deleted)return null;const s=n.pos.blockId,c=r.pos.blockId;if(s===c)return null;const d=b(o,s);if(!d)return null;const f=l(d);return s===t.targetBlockId&&c===t.sourceBlockId&&f===t.targetLengthBefore?t:{type:"mergeBlocks",targetBlockId:s,sourceBlockId:c,targetLengthBefore:f,...void 0!==t.sourceType?{sourceType:t.sourceType}:{},...t.sourceAttrs?{sourceAttrs:t.sourceAttrs}:{},...void 0!==t.sourceHTMLId?{sourceHTMLId:t.sourceHTMLId}:{},...ct(t.targetBlockId,s,t.path)}}},addMark:{apply:function(t,e){return et(t,e.blockId,t=>G(t,e.from,e.to,e.mark,!0))},invert:function(t){return{type:"removeMark",blockId:t.blockId,from:t.from,to:t.to,mark:t.mark,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){const n=T(t.blockId,t.from,t.to,e);return n?lt({blockId:t.blockId,from:t.from,to:t.to},n)?t:{type:"addMark",blockId:n.blockId,from:n.from,to:n.to,mark:t.mark,...ct(t.blockId,n.blockId,t.path)}:null}},removeMark:{apply:function(t,e){return et(t,e.blockId,t=>G(t,e.from,e.to,e.mark,!1))},invert:function(t){return{type:"addMark",blockId:t.blockId,from:t.from,to:t.to,mark:t.mark,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){const n=T(t.blockId,t.from,t.to,e);return n?lt({blockId:t.blockId,from:t.from,to:t.to},n)?t:{type:"removeMark",blockId:n.blockId,from:n.from,to:n.to,mark:t.mark,...ct(t.blockId,n.blockId,t.path)}:null}},setStoredMarks:{apply:function(t){return t},invert:function(t){return{type:"setStoredMarks",marks:t.previousMarks,previousMarks:t.marks}},getMap:function(t,e){return v},map:function(t,e,o){return t}},setBlockType:{apply:function(t,e){return D(t,e.blockId,t=>{const{attrs:o,...n}=t;return{...n,type:e.nodeType,...e.attrs?{attrs:e.attrs}:{}}})},invert:function(t){return{type:"setBlockType",blockId:t.blockId,nodeType:t.previousNodeType,attrs:t.previousAttrs,previousNodeType:t.nodeType,previousAttrs:t.attrs,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){if(e.isEmpty)return t;const n=e.mapResult({blockId:t.blockId,offset:0},-1);if(n.deleted)return null;const r=n.pos.blockId,s=b(o,r);return s?r===t.blockId&&s.type===t.previousNodeType&&p(s.attrs,t.previousAttrs)?t:{type:"setBlockType",blockId:r,nodeType:t.nodeType,...t.attrs?{attrs:t.attrs}:{},previousNodeType:s.type,...s.attrs?{previousAttrs:s.attrs}:{},...ct(t.blockId,r,t.path)}:null}},insertNode:{apply:ot,invert:function(t){return{type:"removeNode",parentPath:t.parentPath,index:t.index,removedNode:t.node}},getMap:function(t,e){return{type:"childIndexShift",parentPath:e.parentPath,fromIndex:e.index,delta:1,insertedBlockIds:P(e.node)}},map:function(t,e,o){if(!dt(t.parentPath,e,o))return null;const n=R(t.parentPath,t.index,e);return n===t.index?t:{type:"insertNode",parentPath:t.parentPath,index:n,node:t.node}}},removeNode:{apply:nt,invert:function(t){return{type:"insertNode",parentPath:t.parentPath,index:t.index,node:t.removedNode}},getMap:function(t,e){return{type:"blockRemoval",removedBlockIds:P(e.removedNode),parentPath:e.parentPath,index:e.index}},map:function(t,e,o){if(!dt(t.parentPath,e,o))return null;const n=e.mapResult({blockId:t.removedNode.id,offset:0},-1);if(n.deleted)return null;if(n.pos.blockId!==t.removedNode.id)return null;const r=A(t.parentPath,t.index,e);if(null===r)return null;const s=y(o,t.parentPath,r);return s?s.id!==t.removedNode.id?null:r===t.index&&s===t.removedNode?t:{type:"removeNode",parentPath:t.parentPath,index:r,removedNode:s}:null}},moveNode:{apply:function(t,e){const o=Z(t,e);return!o||Y(e)?t:ot(nt(t,{type:"removeNode",parentPath:e.fromParentPath,index:e.fromIndex,removedNode:o.movedNode}),{type:"insertNode",parentPath:e.toParentPath,index:o.destinationIndex,node:o.movedNode})},invert:function(t){const e=X(t),o=t.fromParentPath.length===t.toParentPath.length&&t.fromParentPath.every((e,o)=>e===t.toParentPath[o])&&t.fromIndex>e?t.fromIndex+1:t.fromIndex;return{type:"moveNode",fromParentPath:t.toParentPath,fromIndex:e,toParentPath:t.fromParentPath,toIndex:o,movedNode:t.movedNode}},getMap:function(t,e){const o=Z(t,e);return!o||Y(e)?v:{type:"moveNode",movedNodeId:e.movedNode.id,fromParentPath:e.fromParentPath,fromIndex:e.fromIndex,toParentPath:e.toParentPath,destinationIndex:o.destinationIndex}},map:function(t,e,o){if(!dt(t.fromParentPath,e,o))return null;if(!dt(t.toParentPath,e,o))return null;const n=e.mapResult({blockId:t.movedNode.id,offset:0},-1);if(n.deleted||n.pos.blockId!==t.movedNode.id)return null;const r=A(t.fromParentPath,t.fromIndex,e);if(null===r)return null;const s=R(t.toParentPath,t.toIndex,e),c=y(o,t.fromParentPath,r);if(!c||c.id!==t.movedNode.id)return null;const d={type:"moveNode",fromParentPath:t.fromParentPath,fromIndex:r,toParentPath:t.toParentPath,toIndex:s,movedNode:c};return Z(o,d)?r===t.fromIndex&&s===t.toIndex&&c===t.movedNode?t:d:null}},setNodeAttr:{apply:function(t,e){const o=e.path[e.path.length-1];return o?D(t,o,t=>({...t,attrs:e.attrs})):t},invert:function(t){return{type:"setNodeAttr",path:t.path,attrs:t.previousAttrs,previousAttrs:t.attrs}},getMap:function(t,e){return v},map:function(t,e,o){if(e.isEmpty)return t;if(!dt(t.path,e,o))return null;const n=g(o,t.path);return n?{type:"setNodeAttr",path:t.path,attrs:t.attrs,...n.attrs?{previousAttrs:n.attrs}:{}}:null}},insertInlineNode:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e,o){const r=[];let s=0,c=!1;for(const d of t){if(n(d)){c||e!==s||(r.push(o),c=!0),r.push(d),s+=1;continue}const t=s+d.text.length;if(!c&&e>=s&&e<=t){const t=e-s,n=d.text.slice(0,t),l=d.text.slice(t);n&&r.push(k(n,d.marks)),r.push(o),l&&r.push(k(l,d.marks)),c=!0}else r.push(d);s=t}return c||r.push(o),r}(t,e.offset,e.node))},invert:function(t){return{type:"removeInlineNode",blockId:t.blockId,offset:t.offset,removedNode:t.node,...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset,newLen:1}},map:function(t,e,o){const n=L(t.blockId,t.offset,e,-1);return n?n.blockId===t.blockId&&n.from===t.offset?t:{type:"insertInlineNode",blockId:n.blockId,offset:n.from,node:t.node,...ct(t.blockId,n.blockId,t.path)}:null}},removeInlineNode:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e){const o=[];let r=0;for(const s of t)n(s)?(r!==e&&o.push(s),r+=1):(o.push(s),r+=s.text.length);return o}(t,e.offset))},invert:function(t){return{type:"insertInlineNode",blockId:t.blockId,offset:t.offset,node:t.removedNode,...rt(t)}},getMap:function(t,e){return{type:"shift",blockId:e.blockId,from:e.offset,to:e.offset+1,newLen:0}},map:function(t,e,o){const r=T(t.blockId,t.offset,t.offset+1,e,1,1);if(!r)return null;if(r.to-r.from!==1)return null;const s=b(o,r.blockId);if(!s)return null;const c=I(s,r.from);return c&&"inline"===c.kind&&n(c.node)?(d=t.removedNode)===(l=c.node)||d.inlineType===l.inlineType&&p(d.attrs,l.attrs)?r.blockId===t.blockId&&r.from===t.offset?t:{type:"removeInlineNode",blockId:r.blockId,offset:r.from,removedNode:c.node,...ct(t.blockId,r.blockId,t.path)}:null:null;var d,l}},setInlineNodeAttr:{apply:function(t,e){return et(t,e.blockId,t=>function(t,e,o){const r=[];let s=0;for(const c of t)n(c)?(s===e?r.push({...c,attrs:o}):r.push(c),s+=1):(r.push(c),s+=c.text.length);return r}(t,e.offset,e.attrs),!1)},invert:function(t){return{type:"setInlineNodeAttr",blockId:t.blockId,offset:t.offset,attrs:t.previousAttrs,previousAttrs:t.attrs,...rt(t)}},getMap:function(t,e){return v},map:function(t,e,o){const r=T(t.blockId,t.offset,t.offset+1,e,1,1);if(!r)return null;if(r.to-r.from!==1)return null;if(r.blockId===t.blockId&&r.from===t.offset)return t;const s=b(o,r.blockId);if(!s)return null;const c=I(s,r.from);return c&&"inline"===c.kind&&n(c.node)?{type:"setInlineNodeAttr",blockId:r.blockId,offset:r.from,attrs:t.attrs,previousAttrs:c.node.attrs,...ct(t.blockId,r.blockId,t.path)}:null}}};function it(t){return ft[t.type]}function ut(t,e){return it(e).apply(t,e)}function at(t){return it(t).invert(t)}function pt(t,e){return it(e).getMap(t,e)}function mt(t,e,o){return e.isEmpty?t:it(t).map(t,e,o)}function kt(t){const e=t.steps.map(at).reverse();return{steps:e,selectionBefore:t.selectionAfter,selectionAfter:t.selectionBefore,storedMarksAfter:st(t),mapping:M.empty,forwardStepMaps:e.map(()=>v),metadata:{origin:"history",timestamp:Date.now()}}}function It(t,e){switch(t.type){case"inline":return function(t,e){switch(e.type){case"identity":case"childIndexShift":case"moveNode":return t;case"shift":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(x(t.blockId,t.from),e,-1).pos,n=w(x(t.blockId,t.to),e,1).pos;return o.offset>=n.offset?null:o.offset===t.from&&n.offset===t.to?t:{...t,from:o.offset,to:n.offset}}(t,e);case"split":return function(t,e){return t.blockId!==e.blockId||t.to<=e.offset?t:t.from>=e.offset?{...t,blockId:e.newBlockId,from:t.from-e.offset,to:t.to-e.offset}:[{...t,to:e.offset},{...t,blockId:e.newBlockId,from:0,to:t.to-e.offset}]}(t,e);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?t:{...t,blockId:e.targetBlockId,from:t.from+e.targetLengthBefore,to:t.to+e.targetLengthBefore}}(t,e);case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e);case"widget":return function(t,e){switch(e.type){case"identity":case"childIndexShift":case"moveNode":return t;case"shift":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(x(t.blockId,t.offset),e,t.side);return o.deleted?null:o.pos.offset===t.offset?t:{...t,offset:o.pos.offset}}(t,e);case"split":return function(t,e){if(t.blockId!==e.blockId)return t;const o=w(x(t.blockId,t.offset),e,t.side);return o.pos.blockId===t.blockId&&o.pos.offset===t.offset?t:{...t,blockId:o.pos.blockId,offset:o.pos.offset}}(t,e);case"merge":return function(t,e){return t.blockId!==e.sourceBlockId?t:{...t,blockId:e.targetBlockId,offset:t.offset+e.targetLengthBefore}}(t,e);case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e);case"node":return function(t,e){switch(e.type){case"identity":case"shift":case"split":case"childIndexShift":case"moveNode":return t;case"merge":return t.blockId===e.sourceBlockId?null:t;case"blockRemoval":return e.removedBlockIds.has(t.blockId)?null:t}}(t,e)}}function ht(t,e,o,n){return{type:"inline",blockId:t,from:e,to:o,attrs:n}}function bt(t,e){return{type:"node",blockId:t,attrs:e}}function yt(t,e,o,n){return{type:"widget",blockId:t,offset:e,toDOM:o,side:n?.side??-1,key:n?.key}}var gt=class t{byBlock;static empty=new t(/* @__PURE__ */new Map);constructor(t){this.byBlock=t}static create(e){if(0===e.length)return t.empty;const o=/* @__PURE__ */new Map;for(const t of e){const e=o.get(t.blockId);e?e.push(t):o.set(t.blockId,[t])}return new t(o)}find(t){return this.byBlock.get(t)??[]}findInline(t){const e=this.byBlock.get(t);return e?e.filter(t=>"inline"===t.type):[]}findNode(t){const e=this.byBlock.get(t);return e?e.filter(t=>"node"===t.type):[]}findWidget(t){const e=this.byBlock.get(t);return e?e.filter(t=>"widget"===t.type):[]}add(e){if(0===e.length)return this;if(this.isEmpty)return t.create(e);const o=/* @__PURE__ */new Map;for(const[t,n]of this.byBlock)o.set(t,[...n]);for(const t of e){const e=o.get(t.blockId);e?e.push(t):o.set(t.blockId,[t])}return new t(o)}remove(e){const o=/* @__PURE__ */new Map;let n=!1;for(const[t,r]of this.byBlock){const s=r.filter(t=>!e(t));s.length!==r.length&&(n=!0),s.length>0&&o.set(t,s)}return n?0===o.size?t.empty:new t(o):this}merge(e){if(e.isEmpty)return this;if(this.isEmpty)return e;const o=/* @__PURE__ */new Map;for(const[t,n]of this.byBlock)o.set(t,[...n]);for(const[t,n]of e.byBlock){const e=o.get(t);e?e.push(...n):o.set(t,[...n])}return new t(o)}equals(t){if(this===t)return!0;if(this.byBlock.size!==t.byBlock.size)return!1;for(const[e,o]of this.byBlock){const n=t.byBlock.get(e);if(!n)return!1;if(!xt(o,n))return!1}return!0}get isEmpty(){return 0===this.byBlock.size}map(e){if(this.isEmpty||e.mapping.isEmpty)return this;let o=[];for(const t of this.byBlock.values())for(const e of t)o.push(e);for(const t of e.mapping.maps){const e=[];for(const n of o){const o=It(n,t);if(null!==o)if(Array.isArray(o))for(const t of o)e.push(t);else e.push(o)}o=e}return 0===o.length?t.empty:t.create(o)}};function xt(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++){const n=t[o],r=e[o];if(!n||!r||!Bt(n,r))return!1}return!0}function Bt(t,e){if(t.type!==e.type)return!1;if(t.blockId!==e.blockId)return!1;switch(t.type){case"inline":{const o=e;return t.from===o.from&&t.to===o.to&&vt(t.attrs,o.attrs)}case"node":{const o=e;return vt(t.attrs,o.attrs)}case"widget":{const o=e;return t.offset===o.offset&&t.side===o.side&&t.key===o.key&&t.toDOM===o.toDOM}}}function vt(t,e){if(t===e)return!0;const o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(const r of o)if(t[r]!==e[r])return!1;return!0}export{w as C,R as S,v as _,yt as a,z as b,at as c,st as d,Y as f,K as g,J as h,bt as i,kt as l,U as m,xt as n,ut as o,V as p,ht as r,pt as s,gt as t,mt as u,M as v,j as w,A as x,P as y};
2
+ //# sourceMappingURL=Decoration-BOP1TAUd.mjs.map