@ncino/web-components 9.0.0-preview.6 → 9.0.0-preview.9

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 (424) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +1 -1
  2. package/dist/_virtual/index.js +1 -1
  3. package/dist/assets/node_modules/.pnpm/ckeditor5@47.3.0/node_modules/ckeditor5/dist/ckeditor5.css +1 -0
  4. package/dist/components/input/gator/input-phone/input-phone.gator.js +1 -1
  5. package/dist/components/input-rich-text/ckeditor-config.js +1 -1
  6. package/dist/components/input-rich-text/input-rich-text.slds.js +2 -2
  7. package/dist/components/panel/gator/panel.storybook-test.js +1 -1
  8. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-alignment@46.1.1 → @ckeditor_ckeditor5-alignment@47.3.0}/node_modules/@ckeditor/ckeditor5-alignment/dist/index.js +1 -1
  9. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-autoformat@46.1.1 → @ckeditor_ckeditor5-autoformat@47.3.0}/node_modules/@ckeditor/ckeditor5-autoformat/dist/index.js +1 -1
  10. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-autosave@46.1.1 → @ckeditor_ckeditor5-autosave@47.3.0}/node_modules/@ckeditor/ckeditor5-autosave/dist/index.js +1 -1
  11. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-basic-styles@46.1.1 → @ckeditor_ckeditor5-basic-styles@47.3.0}/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js +1 -1
  12. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-block-quote@46.1.1 → @ckeditor_ckeditor5-block-quote@47.3.0}/node_modules/@ckeditor/ckeditor5-block-quote/dist/index.js +1 -1
  13. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-clipboard@47.3.0/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +8 -0
  14. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-cloud-services@46.1.1 → @ckeditor_ckeditor5-cloud-services@47.3.0}/node_modules/@ckeditor/ckeditor5-cloud-services/dist/index.js +1 -1
  15. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-code-block@46.1.1 → @ckeditor_ckeditor5-code-block@47.3.0}/node_modules/@ckeditor/ckeditor5-code-block/dist/index.js +1 -1
  16. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-core@47.3.0/node_modules/@ckeditor/ckeditor5-core/dist/index.js +1 -0
  17. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-editor-classic@46.1.1 → @ckeditor_ckeditor5-editor-classic@47.3.0}/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js +1 -1
  18. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-engine@47.3.0/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +3 -0
  19. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-enter@46.1.1 → @ckeditor_ckeditor5-enter@47.3.0}/node_modules/@ckeditor/ckeditor5-enter/dist/index.js +1 -1
  20. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-essentials@46.1.1 → @ckeditor_ckeditor5-essentials@47.3.0}/node_modules/@ckeditor/ckeditor5-essentials/dist/index.js +1 -1
  21. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-find-and-replace@46.1.1 → @ckeditor_ckeditor5-find-and-replace@47.3.0}/node_modules/@ckeditor/ckeditor5-find-and-replace/dist/index.js +2 -2
  22. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-font@46.1.1 → @ckeditor_ckeditor5-font@47.3.0}/node_modules/@ckeditor/ckeditor5-font/dist/index.js +1 -1
  23. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-heading@46.1.1 → @ckeditor_ckeditor5-heading@47.3.0}/node_modules/@ckeditor/ckeditor5-heading/dist/index.js +1 -1
  24. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-highlight@46.1.1 → @ckeditor_ckeditor5-highlight@47.3.0}/node_modules/@ckeditor/ckeditor5-highlight/dist/index.js +1 -1
  25. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-horizontal-line@46.1.1 → @ckeditor_ckeditor5-horizontal-line@47.3.0}/node_modules/@ckeditor/ckeditor5-horizontal-line/dist/index.js +1 -1
  26. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-embed@47.3.0/node_modules/@ckeditor/ckeditor5-html-embed/dist/index.js +1 -0
  27. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@47.3.0/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +3 -0
  28. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-icons@46.1.1 → @ckeditor_ckeditor5-icons@47.3.0}/node_modules/@ckeditor/ckeditor5-icons/dist/index.js +1 -1
  29. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-image@47.3.0/node_modules/@ckeditor/ckeditor5-image/dist/index.js +1 -0
  30. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-indent@46.1.1 → @ckeditor_ckeditor5-indent@47.3.0}/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +1 -1
  31. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-language@46.1.1 → @ckeditor_ckeditor5-language@47.3.0}/node_modules/@ckeditor/ckeditor5-language/dist/index.js +1 -1
  32. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@47.3.0/node_modules/@ckeditor/ckeditor5-link/dist/index.js +1 -0
  33. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@47.3.0/node_modules/@ckeditor/ckeditor5-list/dist/index.js +1 -0
  34. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-markdown-gfm@46.1.1 → @ckeditor_ckeditor5-markdown-gfm@47.3.0}/node_modules/@ckeditor/ckeditor5-markdown-gfm/dist/index.js +1 -1
  35. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-media-embed@46.1.1 → @ckeditor_ckeditor5-media-embed@47.3.0}/node_modules/@ckeditor/ckeditor5-media-embed/dist/index.js +1 -1
  36. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-mention@46.1.1 → @ckeditor_ckeditor5-mention@47.3.0}/node_modules/@ckeditor/ckeditor5-mention/dist/index.js +1 -1
  37. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-page-break@47.3.0/node_modules/@ckeditor/ckeditor5-page-break/dist/index.js +1 -0
  38. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-paragraph@46.1.1 → @ckeditor_ckeditor5-paragraph@47.3.0}/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +1 -1
  39. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@47.3.0/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +1 -0
  40. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-remove-format@46.1.1 → @ckeditor_ckeditor5-remove-format@47.3.0}/node_modules/@ckeditor/ckeditor5-remove-format/dist/index.js +1 -1
  41. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-select-all@46.1.1 → @ckeditor_ckeditor5-select-all@47.3.0}/node_modules/@ckeditor/ckeditor5-select-all/dist/index.js +1 -1
  42. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-show-blocks@46.1.1 → @ckeditor_ckeditor5-show-blocks@47.3.0}/node_modules/@ckeditor/ckeditor5-show-blocks/dist/index.js +1 -1
  43. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-source-editing@46.1.1 → @ckeditor_ckeditor5-source-editing@47.3.0}/node_modules/@ckeditor/ckeditor5-source-editing/dist/index.js +1 -1
  44. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-special-characters@47.3.0/node_modules/@ckeditor/ckeditor5-special-characters/dist/index.js +1 -0
  45. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-style@46.1.1 → @ckeditor_ckeditor5-style@47.3.0}/node_modules/@ckeditor/ckeditor5-style/dist/index.js +1 -1
  46. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@47.3.0/node_modules/@ckeditor/ckeditor5-table/dist/index.js +1 -0
  47. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-typing@46.1.1 → @ckeditor_ckeditor5-typing@47.3.0}/node_modules/@ckeditor/ckeditor5-typing/dist/index.js +1 -1
  48. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-ui@47.3.0/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +1 -0
  49. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-undo@46.1.1 → @ckeditor_ckeditor5-undo@47.3.0}/node_modules/@ckeditor/ckeditor5-undo/dist/index.js +1 -1
  50. package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-upload@46.1.1 → @ckeditor_ckeditor5-upload@47.3.0}/node_modules/@ckeditor/ckeditor5-upload/dist/index.js +1 -1
  51. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@47.3.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +8 -0
  52. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-widget@47.3.0/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +1 -0
  53. package/dist/node_modules/.pnpm/@vitest_expect@4.0.15/node_modules/@vitest/expect/dist/index.js +58 -0
  54. package/dist/node_modules/.pnpm/@vitest_pretty-format@4.0.15/node_modules/@vitest/pretty-format/dist/index.js +5 -0
  55. package/dist/node_modules/.pnpm/@vitest_runner@4.0.15/node_modules/@vitest/runner/dist/chunk-tasks.js +2 -0
  56. package/dist/node_modules/.pnpm/@vitest_runner@4.0.15/node_modules/@vitest/runner/dist/index.js +4 -0
  57. package/dist/node_modules/.pnpm/@vitest_snapshot@4.0.15/node_modules/@vitest/snapshot/dist/index.js +21 -0
  58. package/dist/node_modules/.pnpm/@vitest_spy@4.0.15/node_modules/@vitest/spy/dist/index.js +1 -0
  59. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +1 -0
  60. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +1 -0
  61. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/diff.js +42 -0
  62. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/display.js +2 -0
  63. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/error.js +2 -0
  64. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/helpers.js +1 -0
  65. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/serialize.js +1 -0
  66. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/source-map.js +1 -0
  67. package/dist/node_modules/.pnpm/@vitest_utils@4.0.15/node_modules/@vitest/utils/dist/timers.js +1 -0
  68. package/dist/node_modules/.pnpm/chai@6.2.1/node_modules/chai/index.js +2 -0
  69. package/dist/node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js +1 -0
  70. package/dist/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js +1 -1
  71. package/dist/node_modules/.pnpm/vitest@4.0.15_@types_node@24.10.1_@vitest_browser-playwright@4.0.15_@vitest_ui@4.0.15_j_0c91d94893276de308eb5b07cced5df8/node_modules/vitest/browser/context.js +1 -0
  72. package/dist/node_modules/.pnpm/vitest@4.0.15_@types_node@24.10.1_@vitest_browser-playwright@4.0.15_@vitest_ui@4.0.15_j_0c91d94893276de308eb5b07cced5df8/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +1 -0
  73. package/dist/node_modules/.pnpm/vitest@4.0.15_@types_node@24.10.1_@vitest_browser-playwright@4.0.15_@vitest_ui@4.0.15_j_0c91d94893276de308eb5b07cced5df8/node_modules/vitest/dist/chunks/utils.DvEY5TfP.js +8 -0
  74. package/dist/node_modules/.pnpm/vitest@4.0.15_@types_node@24.10.1_@vitest_browser-playwright@4.0.15_@vitest_ui@4.0.15_j_0c91d94893276de308eb5b07cced5df8/node_modules/vitest/dist/chunks/vi.2VT5v0um.js +11 -0
  75. package/dist/utils/vitest-a11y-utils.js +1 -1
  76. package/package.json +22 -21
  77. package/web-types.json +1 -1
  78. package/dist/_virtual/___vite-browser-external.js +0 -1
  79. package/dist/_virtual/__vite-browser-external.js +0 -1
  80. package/dist/_virtual/api-request.js +0 -1
  81. package/dist/_virtual/constants.js +0 -1
  82. package/dist/_virtual/events.js +0 -1
  83. package/dist/_virtual/external.js +0 -1
  84. package/dist/_virtual/external2.js +0 -1
  85. package/dist/_virtual/external3.js +0 -1
  86. package/dist/_virtual/external_types.js +0 -1
  87. package/dist/_virtual/fetch.js +0 -1
  88. package/dist/_virtual/figma_client.js +0 -1
  89. package/dist/_virtual/figma_rest_api.js +0 -1
  90. package/dist/_virtual/helpers.js +0 -1
  91. package/dist/_virtual/index10.js +0 -1
  92. package/dist/_virtual/index11.js +0 -1
  93. package/dist/_virtual/index12.js +0 -1
  94. package/dist/_virtual/index2.js +0 -1
  95. package/dist/_virtual/index3.js +0 -1
  96. package/dist/_virtual/index4.js +0 -1
  97. package/dist/_virtual/index5.js +0 -1
  98. package/dist/_virtual/index6.js +0 -1
  99. package/dist/_virtual/index7.js +0 -1
  100. package/dist/_virtual/index8.js +0 -1
  101. package/dist/_virtual/index9.js +0 -1
  102. package/dist/_virtual/index_common.js +0 -1
  103. package/dist/_virtual/index_html.js +0 -1
  104. package/dist/_virtual/index_html2.js +0 -1
  105. package/dist/_virtual/index_react.js +0 -1
  106. package/dist/_virtual/index_react2.js +0 -1
  107. package/dist/_virtual/inherits_browser.js +0 -1
  108. package/dist/_virtual/logging.js +0 -1
  109. package/dist/_virtual/main.js +0 -1
  110. package/dist/_virtual/main2.js +0 -1
  111. package/dist/_virtual/mock-interceptor.js +0 -1
  112. package/dist/_virtual/react.production.js +0 -1
  113. package/dist/_virtual/string_decoder.js +0 -1
  114. package/dist/_virtual/template_literal.js +0 -1
  115. package/dist/_virtual/types.js +0 -1
  116. package/dist/_virtual/updates.js +0 -1
  117. package/dist/_virtual/util.js +0 -1
  118. package/dist/_virtual/utils.js +0 -1
  119. package/dist/assets/node_modules/.pnpm/ckeditor5@46.1.1/node_modules/ckeditor5/dist/ckeditor5.css +0 -1
  120. package/dist/components/accordion/gator/base/accordion.gator.figma.js +0 -10
  121. package/dist/components/accordion/gator/group/accordion-group.gator.figma.js +0 -3
  122. package/dist/components/alert/alert.gator.figma.js +0 -7
  123. package/dist/components/avatar/gator/avatar.gator.figma.js +0 -9
  124. package/dist/components/banner/gator/banner.gator.figma.js +0 -8
  125. package/dist/components/boolean/boolean.gator.figma.js +0 -11
  126. package/dist/components/breadcrumbs/gator/breadcrumb/breadcrumb.gator.figma.js +0 -3
  127. package/dist/components/breadcrumbs/gator/container/breadcrumbs.gator.figma.js +0 -5
  128. package/dist/components/button/gator/button.gator.figma.js +0 -12
  129. package/dist/components/button-group/gator/button-group.gator.figma.js +0 -7
  130. package/dist/components/icon/gator/icon.gator.figma.js +0 -7
  131. package/dist/components/icon/gator/icons.gator.figma.js +0 -1
  132. package/dist/components/text-detail/gator/text-detail.gator.figma.js +0 -30
  133. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-clipboard@46.1.1/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +0 -8
  134. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-core@46.1.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js +0 -1
  135. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-engine@46.1.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +0 -3
  136. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-embed@46.1.1/node_modules/@ckeditor/ckeditor5-html-embed/dist/index.js +0 -1
  137. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@46.1.1/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +0 -3
  138. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-image@46.1.1/node_modules/@ckeditor/ckeditor5-image/dist/index.js +0 -1
  139. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@46.1.1/node_modules/@ckeditor/ckeditor5-link/dist/index.js +0 -1
  140. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@46.1.1/node_modules/@ckeditor/ckeditor5-list/dist/index.js +0 -1
  141. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-page-break@46.1.1/node_modules/@ckeditor/ckeditor5-page-break/dist/index.js +0 -1
  142. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@46.1.1/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +0 -1
  143. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-special-characters@46.1.1/node_modules/@ckeditor/ckeditor5-special-characters/dist/index.js +0 -1
  144. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@46.1.1/node_modules/@ckeditor/ckeditor5-table/dist/index.js +0 -1
  145. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-ui@46.1.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +0 -1
  146. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@46.1.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +0 -8
  147. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-widget@46.1.1/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +0 -1
  148. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js +0 -3
  149. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js +0 -3
  150. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js +0 -1
  151. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js +0 -1
  152. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/main.js +0 -1
  153. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/types/multipart.js +0 -1
  154. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/types/urlencoded.js +0 -1
  155. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/Decoder.js +0 -1
  156. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/basename.js +0 -1
  157. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/decodeText.js +0 -1
  158. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/getLimit.js +0 -1
  159. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/parseParams.js +0 -3
  160. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/client/external.js +0 -1
  161. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/client/figma_client.js +0 -1
  162. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/common/fetch.js +0 -1
  163. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/common/logging.js +0 -1
  164. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/common/updates.js +0 -4
  165. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/connect/external_types.js +0 -1
  166. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/connect/figma_rest_api.js +0 -1
  167. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/connect/helpers.js +0 -1
  168. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/connect/index_common.js +0 -1
  169. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/html/external.js +0 -1
  170. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/html/index_html.js +0 -1
  171. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/html/template_literal.js +0 -1
  172. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/react/external.js +0 -1
  173. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/dist/react/index_react.js +0 -1
  174. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.9/node_modules/@figma/code-connect/package.json.js +0 -1
  175. package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.10.1_typescript@5.9.3__playwright@1.57.0_4c7b68e67853c98910921d3bcdc3c508/node_modules/@vitest/browser/context.js +0 -1
  176. package/dist/node_modules/.pnpm/@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.js +0 -58
  177. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.js +0 -5
  178. package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js +0 -5
  179. package/dist/node_modules/.pnpm/@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js +0 -21
  180. package/dist/node_modules/.pnpm/@vitest_spy@3.2.4/node_modules/@vitest/spy/dist/index.js +0 -1
  181. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +0 -1
  182. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/diff.js +0 -42
  183. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.js +0 -2
  184. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/helpers.js +0 -1
  185. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/index.js +0 -1
  186. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/source-map.js +0 -1
  187. package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +0 -1
  188. package/dist/node_modules/.pnpm/available-typed-arrays@1.0.7/node_modules/available-typed-arrays/index.js +0 -1
  189. package/dist/node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js +0 -1
  190. package/dist/node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js +0 -1
  191. package/dist/node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js +0 -1
  192. package/dist/node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/applyBind.js +0 -1
  193. package/dist/node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js +0 -1
  194. package/dist/node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionCall.js +0 -1
  195. package/dist/node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js +0 -1
  196. package/dist/node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/reflectApply.js +0 -1
  197. package/dist/node_modules/.pnpm/call-bind@1.0.8/node_modules/call-bind/index.js +0 -1
  198. package/dist/node_modules/.pnpm/call-bound@1.0.4/node_modules/call-bound/index.js +0 -1
  199. package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js +0 -2
  200. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +0 -2
  201. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +0 -2
  202. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +0 -4
  203. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +0 -1
  204. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +0 -1
  205. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +0 -1
  206. package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +0 -1
  207. package/dist/node_modules/.pnpm/compare-versions@6.1.1/node_modules/compare-versions/lib/esm/compare.js +0 -1
  208. package/dist/node_modules/.pnpm/compare-versions@6.1.1/node_modules/compare-versions/lib/esm/compareVersions.js +0 -1
  209. package/dist/node_modules/.pnpm/compare-versions@6.1.1/node_modules/compare-versions/lib/esm/index.js +0 -1
  210. package/dist/node_modules/.pnpm/compare-versions@6.1.1/node_modules/compare-versions/lib/esm/satisfies.js +0 -1
  211. package/dist/node_modules/.pnpm/compare-versions@6.1.1/node_modules/compare-versions/lib/esm/utils.js +0 -1
  212. package/dist/node_modules/.pnpm/compare-versions@6.1.1/node_modules/compare-versions/lib/esm/validate.js +0 -1
  213. package/dist/node_modules/.pnpm/define-data-property@1.1.4/node_modules/define-data-property/index.js +0 -1
  214. package/dist/node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js +0 -3
  215. package/dist/node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/package.json.js +0 -1
  216. package/dist/node_modules/.pnpm/dunder-proto@1.0.1/node_modules/dunder-proto/get.js +0 -1
  217. package/dist/node_modules/.pnpm/es-define-property@1.0.1/node_modules/es-define-property/index.js +0 -1
  218. package/dist/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.js +0 -1
  219. package/dist/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.js +0 -1
  220. package/dist/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.js +0 -1
  221. package/dist/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.js +0 -1
  222. package/dist/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.js +0 -1
  223. package/dist/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.js +0 -1
  224. package/dist/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.js +0 -1
  225. package/dist/node_modules/.pnpm/es-object-atoms@1.1.1/node_modules/es-object-atoms/index.js +0 -1
  226. package/dist/node_modules/.pnpm/events@3.3.0/node_modules/events/events.js +0 -1
  227. package/dist/node_modules/.pnpm/for-each@0.3.5/node_modules/for-each/index.js +0 -1
  228. package/dist/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js +0 -1
  229. package/dist/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js +0 -1
  230. package/dist/node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js +0 -1
  231. package/dist/node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js +0 -1
  232. package/dist/node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js +0 -1
  233. package/dist/node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/index.js +0 -1
  234. package/dist/node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/gOPD.js +0 -1
  235. package/dist/node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/index.js +0 -1
  236. package/dist/node_modules/.pnpm/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.js +0 -1
  237. package/dist/node_modules/.pnpm/has-symbols@1.1.0/node_modules/has-symbols/index.js +0 -1
  238. package/dist/node_modules/.pnpm/has-symbols@1.1.0/node_modules/has-symbols/shams.js +0 -1
  239. package/dist/node_modules/.pnpm/has-tostringtag@1.0.2/node_modules/has-tostringtag/shams.js +0 -1
  240. package/dist/node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.js +0 -1
  241. package/dist/node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js +0 -1
  242. package/dist/node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js +0 -1
  243. package/dist/node_modules/.pnpm/is-arguments@1.2.0/node_modules/is-arguments/index.js +0 -1
  244. package/dist/node_modules/.pnpm/is-callable@1.2.7/node_modules/is-callable/index.js +0 -1
  245. package/dist/node_modules/.pnpm/is-generator-function@1.1.0/node_modules/is-generator-function/index.js +0 -1
  246. package/dist/node_modules/.pnpm/is-regex@1.2.1/node_modules/is-regex/index.js +0 -1
  247. package/dist/node_modules/.pnpm/is-typed-array@1.1.15/node_modules/is-typed-array/index.js +0 -1
  248. package/dist/node_modules/.pnpm/js-tokens@9.0.1/node_modules/js-tokens/index.js +0 -1
  249. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +0 -1
  250. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +0 -1
  251. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +0 -1
  252. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +0 -1
  253. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +0 -1
  254. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +0 -1
  255. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +0 -1
  256. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +0 -1
  257. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +0 -2
  258. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +0 -1
  259. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +0 -1
  260. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +0 -1
  261. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +0 -1
  262. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +0 -1
  263. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +0 -1
  264. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +0 -1
  265. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +0 -1
  266. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +0 -1
  267. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +0 -1
  268. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js +0 -1
  269. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js +0 -1
  270. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/isNaN.js +0 -1
  271. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js +0 -1
  272. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js +0 -1
  273. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js +0 -1
  274. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js +0 -1
  275. package/dist/node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js +0 -1
  276. package/dist/node_modules/.pnpm/possible-typed-array-names@1.1.0/node_modules/possible-typed-array-names/index.js +0 -1
  277. package/dist/node_modules/.pnpm/react@19.2.0/node_modules/react/cjs/react.production.js +0 -1
  278. package/dist/node_modules/.pnpm/react@19.2.0/node_modules/react/index.js +0 -1
  279. package/dist/node_modules/.pnpm/safe-buffer@5.1.2/node_modules/safe-buffer/index.js +0 -1
  280. package/dist/node_modules/.pnpm/safe-regex-test@1.1.0/node_modules/safe-regex-test/index.js +0 -1
  281. package/dist/node_modules/.pnpm/set-function-length@1.2.2/node_modules/set-function-length/index.js +0 -1
  282. package/dist/node_modules/.pnpm/string_decoder@1.1.1/node_modules/string_decoder/lib/string_decoder.js +0 -1
  283. package/dist/node_modules/.pnpm/strip-literal@3.1.0/node_modules/strip-literal/dist/index.js +0 -1
  284. package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/browser.js +0 -1
  285. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/browser.js +0 -1
  286. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +0 -1
  287. package/dist/node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js +0 -1
  288. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/index.js +0 -1
  289. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/agent.js +0 -1
  290. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/abort-signal.js +0 -1
  291. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/api-connect.js +0 -1
  292. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/api-pipeline.js +0 -1
  293. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/api-request.js +0 -1
  294. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/api-stream.js +0 -1
  295. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/api-upgrade.js +0 -1
  296. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/index.js +0 -1
  297. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/readable.js +0 -1
  298. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/api/util.js +0 -1
  299. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/balanced-pool.js +0 -1
  300. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cache.js +0 -1
  301. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cachestorage.js +0 -1
  302. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/symbols.js +0 -1
  303. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/util.js +0 -1
  304. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/client.js +0 -26
  305. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/compat/dispatcher-weakref.js +0 -1
  306. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cookies/constants.js +0 -1
  307. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cookies/index.js +0 -1
  308. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cookies/parse.js +0 -1
  309. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cookies/util.js +0 -1
  310. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/core/connect.js +0 -1
  311. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/core/constants.js +0 -1
  312. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/core/errors.js +0 -1
  313. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/core/request.js +0 -5
  314. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/core/symbols.js +0 -1
  315. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/core/util.js +0 -1
  316. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/dispatcher-base.js +0 -1
  317. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/dispatcher.js +0 -1
  318. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/body.js +0 -9
  319. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/constants.js +0 -1
  320. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/dataURL.js +0 -3
  321. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/file.js +0 -3
  322. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/formdata.js +0 -1
  323. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/global.js +0 -1
  324. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/headers.js +0 -1
  325. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/index.js +0 -1
  326. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/request.js +0 -1
  327. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/response.js +0 -1
  328. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/symbols.js +0 -1
  329. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/util.js +0 -2
  330. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/webidl.js +0 -1
  331. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fileapi/encoding.js +0 -1
  332. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fileapi/filereader.js +0 -1
  333. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fileapi/progressevent.js +0 -1
  334. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fileapi/symbols.js +0 -1
  335. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fileapi/util.js +0 -1
  336. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/global.js +0 -1
  337. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/handler/DecoratorHandler.js +0 -1
  338. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/handler/RedirectHandler.js +0 -1
  339. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/handler/RetryHandler.js +0 -1
  340. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/interceptor/redirectInterceptor.js +0 -1
  341. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/llhttp/constants.js +0 -1
  342. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/llhttp/llhttp-wasm.js +0 -1
  343. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +0 -1
  344. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/llhttp/utils.js +0 -1
  345. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/mock-agent.js +0 -5
  346. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/mock-client.js +0 -1
  347. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/mock-errors.js +0 -1
  348. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/mock-interceptor.js +0 -1
  349. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/mock-pool.js +0 -1
  350. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/mock-symbols.js +0 -1
  351. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/mock-utils.js +0 -1
  352. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/pending-interceptors-formatter.js +0 -1
  353. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/mock/pluralizer.js +0 -1
  354. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/node/fixed-queue.js +0 -1
  355. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/pool-base.js +0 -1
  356. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/pool-stats.js +0 -1
  357. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/pool.js +0 -1
  358. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/proxy-agent.js +0 -1
  359. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/timers.js +0 -1
  360. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/connection.js +0 -1
  361. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/constants.js +0 -1
  362. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/events.js +0 -1
  363. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/frame.js +0 -1
  364. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/receiver.js +0 -1
  365. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/symbols.js +0 -1
  366. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/util.js +0 -1
  367. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/websocket.js +0 -1
  368. package/dist/node_modules/.pnpm/util@0.12.5/node_modules/util/support/isBufferBrowser.js +0 -1
  369. package/dist/node_modules/.pnpm/util@0.12.5/node_modules/util/support/types.js +0 -1
  370. package/dist/node_modules/.pnpm/util@0.12.5/node_modules/util/util.js +0 -10
  371. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.10.1_@vitest_browser@3.2.4_@vitest_ui@3_6e27007ba0535c26eedf5a22febb1842/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +0 -1
  372. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.10.1_@vitest_browser@3.2.4_@vitest_ui@3_6e27007ba0535c26eedf5a22febb1842/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +0 -1
  373. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.10.1_@vitest_browser@3.2.4_@vitest_ui@3_6e27007ba0535c26eedf5a22febb1842/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +0 -8
  374. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.10.1_@vitest_browser@3.2.4_@vitest_ui@3_6e27007ba0535c26eedf5a22febb1842/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +0 -12
  375. package/dist/node_modules/.pnpm/which-typed-array@1.1.19/node_modules/which-typed-array/index.js +0 -1
  376. /package/dist/node_modules/.pnpm/{@ckeditor_ckeditor5-watchdog@46.1.1 → @ckeditor_ckeditor5-watchdog@47.3.0}/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js +0 -0
  377. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/ParseError.js +0 -0
  378. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/PhoneNumber.js +0 -0
  379. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/constants.js +0 -0
  380. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/format.js +0 -0
  381. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/RFC3966.js +0 -0
  382. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js +0 -0
  383. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js +0 -0
  384. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js +0 -0
  385. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js +0 -0
  386. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js +0 -0
  387. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js +0 -0
  388. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js +0 -0
  389. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js +0 -0
  390. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +0 -0
  391. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js +0 -0
  392. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js +0 -0
  393. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js +0 -0
  394. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js +0 -0
  395. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js +0 -0
  396. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/getNumberType.js +0 -0
  397. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js +0 -0
  398. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/isObject.js +0 -0
  399. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js +0 -0
  400. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js +0 -0
  401. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/parseDigits.js +0 -0
  402. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js +0 -0
  403. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/isPossible.js +0 -0
  404. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/isValid.js +0 -0
  405. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/metadata.js +0 -0
  406. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/normalizeArguments.js +0 -0
  407. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/parse.js +0 -0
  408. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js +0 -0
  409. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/parsePhoneNumber.js +0 -0
  410. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js +0 -0
  411. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js +0 -0
  412. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/es6/tools/semver-compare.js +0 -0
  413. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/metadata.min.json.js +0 -0
  414. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/min/exports/parsePhoneNumber.js +0 -0
  415. /package/dist/node_modules/.pnpm/{libphonenumber-js@1.12.30 → libphonenumber-js@1.12.31}/node_modules/libphonenumber-js/min/exports/withMetadataArgument.js +0 -0
  416. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/_browser-chunks/chunk-A242L54C.js +0 -0
  417. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/_browser-chunks/chunk-EZSQOHRI.js +0 -0
  418. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/_browser-chunks/chunk-JP7NCOJX.js +0 -0
  419. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/_browser-chunks/chunk-RP5RXKFU.js +0 -0
  420. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/_browser-chunks/chunk-ZUWEVLDX.js +0 -0
  421. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/client-logger/index.js +0 -0
  422. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/core-events/index.js +0 -0
  423. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/instrumenter/index.js +0 -0
  424. /package/dist/node_modules/.pnpm/{storybook@10.1.2_@testing-library_dom@10.4.1_prettier@3.6.2_react-dom@19.2.0_react@19.2.0__react@19.2.0 → storybook@10.1.4_@testing-library_dom@10.4.1_prettier@3.7.4_react-dom@19.2.0_react@19.2.0__react@19.2.0}/node_modules/storybook/dist/test/index.js +0 -0
@@ -0,0 +1,3 @@
1
+ import{global as ne,EmitterMixin as x,CKEditorError as d,compareArrays as F,toMap as ge,ObservableMixin as z,count as Yt,isIterable as oe,toArray as ie,Collection as Bt,uid as Fs,spliceArray as Qt,logWarning as J,EventInfo as Rt,DomEmitterMixin as Ds,isValidAttributeName as Bs,first as Vt,isText as E,indexOf as ke,getAncestors as Vs,isComment as Be,env as N,scrollViewportToShowTarget as Ls,isInsideSurrogatePair as Wn,isInsideCombinedSymbol as qn,remove as Zt,insertAt as zn,diff as mt,fastDiff as $s,keyCodes as fe,isArrowKeyCode as Ws,priorities as gt,isInsideEmojiSequence as qs,isNode as it,getCode as zs}from"../../../../../@ckeditor_ckeditor5-utils@47.3.0/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{isEqual as en}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/predicate/isEqual.js";import{isObject as ot}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isObject.js";import{get as at}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/get.js";import{merge as Jn}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/merge.js";import{set as Js}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/set.js";import{isPlainObject as Lt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js";import{assignIn as Us}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/assignIn.js";import{clone as js}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/clone.js";import{cloneDeep as ae}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/object/cloneDeep.js";import{isEqualWith as Gs}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js";import{debounce as Tt}from"../../../../../es-toolkit@1.39.5/node_modules/es-toolkit/dist/compat/function/debounce.js";const Te=new WeakMap;let tn=!1;function hl({view:s,element:e,text:t,isDirectHost:n=!0,keepOnFocus:r=!1}){const i=s.document;Te.has(i)||(Te.set(i,new Map),i.registerPostFixer(a=>pt(Te.get(i),a)),i.on("change:isComposing",()=>{s.change(a=>pt(Te.get(i),a))},{priority:"high"})),e.is("editableElement")&&e.on("change:placeholder",(a,l,c)=>o(c)),e.placeholder?o(e.placeholder):t&&o(t),t&&Qs();function o(a){const l={text:a,isDirectHost:n,keepOnFocus:r,hostElement:n?e:null};Te.get(i).set(e,l),s.change(c=>pt([[e,l]],c))}}function Hs(s,e){return e.hasClass("ck-placeholder")?!1:(s.addClass("ck-placeholder",e),!0)}function Un(s,e){return e.hasClass("ck-placeholder")?(s.removeClass("ck-placeholder",e),!0):!1}function Ks(s,e){if(!s.isAttached()||Xs(s))return!1;const t=s.document,r=t.selection.anchor;return t.isComposing&&r&&r.parent===s?!1:e||!t.isFocused?!0:!!r&&r.parent!==s}function Xs(s){for(const e of s.getChildren())if(!e.is("uiElement"))return!0;return!1}function pt(s,e){const t=[];let n=!1;for(const[r,i]of s)i.isDirectHost&&(t.push(r),nn(e,r,i)&&(n=!0));for(const[r,i]of s){if(i.isDirectHost)continue;const o=Ys(r);o!==i.hostElement&&i.hostElement&&(e.removeAttribute("data-placeholder",i.hostElement),Un(e,i.hostElement),i.hostElement=null,n=!0),o&&(t.includes(o)||(i.hostElement=o,nn(e,r,i)&&(n=!0)))}return n}function nn(s,e,t){const{text:n,isDirectHost:r,hostElement:i}=t;let o=!1;return i.getAttribute("data-placeholder")!==n&&(s.setAttribute("data-placeholder",n,i),o=!0),(r||e.childCount==1)&&Ks(i,t.keepOnFocus)?Hs(s,i)&&(o=!0):Un(s,i)&&(o=!0),o}function Ys(s){if(s.childCount){const e=s.getChild(0);if(e.is("element")&&!e.is("uiElement")&&!e.is("attributeElement"))return e}return null}function Qs(){tn||J("enableViewPlaceholder-deprecated-text-option"),tn=!0}class _e{is(){throw new Error("is() method is abstract")}}class we extends x(_e){document;parent;constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if((e=this.parent.getChildIndex(this))==-1)throw new d("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),r=e.getAncestors(t);let i=0;for(;n[i]==r[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),r=F(t,n);switch(r){case"prefix":return!0;case"extension":return!1;default:return t[r]<n[r]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t,n){this.fire(`change:${e}`,t,n),this.parent&&this.parent._fireChange(e,t,n)}toJSON(){const e={path:this.getPath(),type:"Node"};return this!==this.root&&this.root.is("rootElement")&&(e.root=this.root.toJSON()),e}}we.prototype.is=function(s){return s==="node"||s==="view:node"};class R extends we{_textData;constructor(e,t){super(e),this._textData=t}get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(e){return e instanceof R?this===e||this.data===e.data:!1}toJSON(){const e=super.toJSON();return e.type="Text",e.data=this.data,e}_clone(){return new R(this.document,this.data)}}R.prototype.is=function(s){return s==="$text"||s==="view:$text"||s==="text"||s==="view:text"||s==="node"||s==="view:node"};class Z extends _e{textNode;data;offsetInText;constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.data.length)throw new d("view-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.data.length)throw new d("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let n=e.includeSelf?this.textNode:this.parent;for(;n!==null;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}}Z.prototype.is=function(s){return s==="$textProxy"||s==="view:$textProxy"||s==="textProxy"||s==="view:textProxy"};class lt{_consumables=new Map;add(e,t){let n;if(e.is("$text")||e.is("documentFragment")){this._consumables.set(e,!0);return}this._consumables.has(e)?n=this._consumables.get(e):(n=new Zs(e),this._consumables.set(e,n)),n.add(t?Fe(t):e._getConsumables())}test(e,t){const n=this._consumables.get(e);return n===void 0?null:e.is("$text")||e.is("documentFragment")?n:n.test(Fe(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return this.test(e,t)?(this._consumables.set(e,!1),!0):!1;const n=this._consumables.get(e);return n===void 0?!1:n.consume(Fe(t))}revert(e,t){const n=this._consumables.get(e);n!==void 0&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):n.revert(Fe(t)))}static createFrom(e,t){if(t||(t=new lt),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const n of e.getChildren())lt.createFrom(n,t)}return t}}class Zs{element;_canConsumeName=null;_attributes=new Map;constructor(e){this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,n]of e.attributes)if(n){let r=this._attributes.get(t);(!r||typeof r=="boolean")&&(r=new Map,this._attributes.set(t,r)),r.set(n,!0)}else{if(t=="style"||t=="class")throw new d("viewconsumable-invalid-attribute",this);this._attributes.set(t,!0)}}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const[t,n]of e.attributes){const r=this._attributes.get(t);if(r===void 0)return null;if(r===!1)return!1;if(r!==!0){if(n){const i=r.get(n);if(i===void 0)return null;if(!i)return!1}else for(const i of r.values())if(!i)return!1}}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(const[t,n]of e.attributes){const r=this._attributes.get(t);if(typeof r=="boolean")for(const[i]of this.element._getConsumables(t,n).attributes)this._attributes.set(i,!1);else if(n)for(const[,i]of this.element._getConsumables(t,n).attributes)r.set(i,!1);else for(const i of r.keys())r.set(i,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,n]of e.attributes){const r=this._attributes.get(t);if(r===!1){this._attributes.set(t,!0);continue}if(!(r===void 0||r===!0))if(n)r.get(n)===!1&&r.set(n,!0);else for(const i of r.keys())r.set(i,!0)}}}function Fe(s){const e=[];return"attributes"in s&&s.attributes&&_t(e,s.attributes),"classes"in s&&s.classes&&_t(e,s.classes,"class"),"styles"in s&&s.styles&&_t(e,s.styles,"style"),{name:s.name||!1,attributes:e}}function _t(s,e,t){if(typeof e=="string"){s.push(t?[t,e]:[e]);return}for(const n of e)Array.isArray(n)?s.push(n):s.push(t?[t,n]:[n])}class ze{_patterns=[];constructor(...e){this.add(...e)}add(...e){for(let t of e)(typeof t=="string"||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const n of this._patterns){const r=this._isElementMatching(t,n);if(r)return{element:t,pattern:n,match:r}}return null}matchAll(...e){const t=[];for(const n of e)for(const r of this._patterns){const i=this._isElementMatching(n,r);i&&t.push({element:n,pattern:r,match:i})}return t.length>0?t:null}getElementName(){if(this._patterns.length!==1)return null;const e=this._patterns[0],t=e.name;return typeof e!="function"&&t&&!(t instanceof RegExp)?t:null}_isElementMatching(e,t){if(typeof t=="function"){const i=t(e);return!i||typeof i!="object"?i:Fe(i)}const n={};if(t.name&&(n.name=er(t.name,e.name),!n.name))return null;const r=[];return t.attributes&&!tr(t.attributes,e,r)||t.classes&&!nr(t.classes,e,r)||t.styles&&!sr(t.styles,e,r)?null:(r.length&&(n.attributes=r),n)}}function ct(s,e){return s===!0||s===e||s instanceof RegExp&&!!String(e).match(s)}function er(s,e){return s instanceof RegExp?!!e.match(s):s===e}function $t(s,e){if(Array.isArray(s))return s.map(n=>typeof n!="object"||n instanceof RegExp?e?[e,n,!0]:[n,!0]:((n.key===void 0||n.value===void 0)&&J("matcher-pattern-missing-key-or-value",n),e?[e,n.key,n.value]:[n.key,n.value]));if(typeof s!="object"||s instanceof RegExp)return[e?[e,s,!0]:[s,!0]];const t=[];for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&t.push(e?[e,n,s[n]]:[n,s[n]]);return t}function tr(s,e,t){let n;return typeof s=="object"&&!(s instanceof RegExp)&&!Array.isArray(s)?(s.style!==void 0&&J("matcher-pattern-deprecated-attributes-style-key",s),s.class!==void 0&&J("matcher-pattern-deprecated-attributes-class-key",s)):n=["class","style"],e._collectAttributesMatch($t(s),t,n)}function nr(s,e,t){return e._collectAttributesMatch($t(s,"class"),t)}function sr(s,e,t){return e._collectAttributesMatch($t(s,"style"),t)}class Ve{_styles;_cachedStyleNames=null;_cachedExpandedStyleNames=null;_styleProcessor;constructor(e){this._styles={},this._styleProcessor=e}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=rr(e);for(const[n,r]of t)this._styleProcessor.toNormalizedForm(n,r,this._styles);return this}has(e){if(this.isEmpty)return!1;const n=this._styleProcessor.getReducedForm(e,this._styles).find(([r])=>r===e);return Array.isArray(n)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,ot(e))for(const[n,r]of Object.entries(e))this._styleProcessor.toNormalizedForm(n,r,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t={};for(const n of ie(e)){const r=Mt(n),i=at(this._styles,r);if(i)rt(t,r,i);else{const o=this.getAsString(n);o!==void 0&&this._styleProcessor.toNormalizedForm(n,o,t)}}Object.keys(t).length&&(jn(this._styles,t),this._cachedStyleNames=null,this._cachedExpandedStyleNames=null)}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map(e=>e.join(":")).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!ot(this._styles[e]))return this._styles[e];const n=this._styleProcessor.getReducedForm(e,this._styles).find(([r])=>r===e);if(Array.isArray(n))return n[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||=this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames||=this.getStylesEntries().map(([t])=>t),this._cachedStyleNames)}keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_clone(){const e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){const n=[];for(const r of this.getStyleNames(!0))if(ct(e,r)){if(t===!0){n.push(r);continue}const i=this.getAsString(r);ct(t,i)&&n.push(r)}return n.length?n:void 0}_getConsumables(e){const t=[];if(e){t.push(e);for(const n of this._styleProcessor.getRelatedStyles(e))t.push(n)}else for(const n of this.getStyleNames()){for(const r of this._styleProcessor.getRelatedStyles(n))t.push(r);t.push(n)}return t}_canMergeFrom(e){for(const t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(const t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(const t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}}class ul{_normalizers;_extractors;_reducers;_consumables;constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(ot(t)){rt(n,Mt(e),t);return}if(this._normalizers.has(e)){const r=this._normalizers.get(e),{path:i,value:o}=r(t);rt(n,i,o)}else rt(n,e,t)}getNormalized(e,t){if(!e)return Jn({},t);if(t[e]!==void 0)return t[e];if(this._extractors.has(e)){const n=this._extractors.get(e);if(typeof n=="string")return at(t,n);const r=n(e,t);if(r)return r}return at(t,Mt(e))}getReducedForm(e,t){const n=this.getNormalized(e,t);return n===void 0?[]:this._reducers.has(e)?this._reducers.get(e)(n):[[e,n]]}getStyleNames(e){const t=new Set;for(const n of this._consumables.keys()){const r=this.getNormalized(n,e);r&&(typeof r!="object"||Object.keys(r).length)&&t.add(n)}for(const n of Object.keys(e))t.add(n);return Array.from(t)}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function rr(s){let e=null,t=0,n=0,r=null;const i=new Map;if(s==="")return i;s.charAt(s.length-1)!=";"&&(s=s+";");for(let o=0;o<s.length;o++){const a=s.charAt(o);if(e===null)switch(a){case":":r||(r=s.substr(t,o-t),n=o+1);break;case'"':case"'":e=a;break;case";":{const l=s.substr(n,o-n);r&&i.set(r.trim(),l.trim()),r=null,t=o+1;break}}else a===e&&(e=null)}return i}function Mt(s){return s.replace("-",".")}function rt(s,e,t){let n=t;ot(t)&&(n=Jn({},at(s,e),t)),Js(s,e,n)}function jn(s,e){for(const t of Object.keys(e))s[t]!==null&&!Array.isArray(s[t])&&typeof s[t]=="object"&&typeof e[t]=="object"?(jn(s[t],e[t]),Object.keys(s[t]).length||delete s[t]):delete s[t]}class wt{_set=new Set;get isEmpty(){return this._set.size==0}get size(){return this._set.size}has(e){return this._set.has(e)}keys(){return Array.from(this._set.keys())}setTo(e){this.clear();for(const t of e.split(/\s+/))t&&this._set.add(t);return this}set(e){for(const t of ie(e))t&&this._set.add(t)}remove(e){for(const t of ie(e))this._set.delete(t)}clear(){this._set.clear()}toString(){return Array.from(this._set).join(" ")}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.keys())if(!e.has(t))return!1;return!0}_clone(){const e=new this.constructor;return e._set=new Set(this._set),e}_getTokensMatch(e){const t=[];if(e===!0){for(const n of this._set.keys())t.push(n);return t}if(typeof e=="string"){for(const n of e.split(/\s+/))if(this._set.has(n))t.push(n);else return;return t}for(const n of this._set.keys())n.match(e)&&t.push(n);return t.length?t:void 0}_getConsumables(e){return e?[e]:this.keys()}_canMergeFrom(){return!0}_mergeFrom(e){for(const t of e._set.keys())this._set.has(t)||this._set.add(t)}_isMatching(e){for(const t of e._set.keys())if(!this._set.has(t))return!1;return!0}}class H extends we{name;_unsafeAttributesToRender=[];_attrs;_children;_customProperties=new Map;get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}constructor(e,t,n,r){super(e),this.name=t,this._attrs=this._parseAttributes(n),this._children=[],r&&this._insertChild(0,r)}get childCount(){return this._children.length}get isEmpty(){return this._children.length===0}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes&&(yield"class"),this._styles&&(yield"style");for(const e of this._attrs.keys())e!="class"&&e!="style"&&(yield e)}*getAttributes(){for(const[e,t]of this._attrs.entries())yield[e,String(t)]}getAttribute(e){return this._attrs.has(e)?String(this._attrs.get(e)):void 0}hasAttribute(e,t){return this._attrs.has(e)?t!==void 0?ye(this.name,e)||Me(this.name,e)?this._attrs.get(e).has(t):this._attrs.get(e)===t:!0:!1}isSimilar(e){if(!(e instanceof H))return!1;if(this===e)return!0;if(this.name!=e.name||this._attrs.size!==e._attrs.size)return!1;for(const[t,n]of this._attrs){const r=e._attrs.get(t);if(r===void 0)return!1;if(typeof n=="string"||typeof r=="string"){if(r!==n)return!1}else if(!n.isSimilar(r))return!1}return!0}hasClass(...e){for(const t of e)if(!this._classes||!this._classes.has(t))return!1;return!0}getClassNames(){const e=this._classes?this._classes.keys():[],t=e[Symbol.iterator]();return Object.assign(e,{next:t.next.bind(t)})}getStyle(e){return this._styles&&this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles&&this._styles.getNormalized(e)}getStyleNames(e){return this._styles?this._styles.getStyleNames(e):[]}hasStyle(...e){for(const t of e)if(!this._styles||!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new ze(...e);let n=this.parent;for(;n&&!n.is("documentFragment");){if(t.match(n))return n;n=n.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=this._classes?this._classes.keys().sort().join(","):"",t=this._styles&&String(this._styles),n=Array.from(this._attrs).filter(([r])=>r!="style"&&r!="class").map(r=>`${r[0]}="${r[1]}"`).sort().join(" ");return this.name+(e==""?"":` class="${e}"`)+(t?` style="${t}"`:"")+(n==""?"":` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}toJSON(){const e=super.toJSON();if(e.name=this.name,e.type="Element",this._attrs.size&&(e.attributes=Object.fromEntries(this.getAttributes())),this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=[];if(e)for(const r of this.getChildren())t.push(r._clone(e));const n=new this.constructor(this.document,this.name,this._attrs,t);return n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._unsafeAttributesToRender=this._unsafeAttributesToRender,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let n=0;const r=ir(this.document,t);for(const i of r)i.parent!==null&&i._remove(),i.parent=this,i.document=this.document,this._children.splice(e,0,i),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_setAttribute(e,t,n=!0){if(this._fireChange("attributes",this),ye(this.name,e)||Me(this.name,e)){let r=this._attrs.get(e);r||(r=ye(this.name,e)?new Ve(this.document.stylesProcessor):new wt,this._attrs.set(e,r)),n?r.setTo(String(t)):ye(this.name,e)?Array.isArray(t)?r.set(t[0],t[1]):r.set(t):r.set(typeof t=="string"?t.split(/\s+/):t)}else this._attrs.set(e,String(t))}_removeAttribute(e,t){if(this._fireChange("attributes",this),t!==void 0&&(ye(this.name,e)||Me(this.name,e))){const n=this._attrs.get(e);return n?(Me(this.name,e)&&typeof t=="string"&&(t=t.split(/\s+/)),n.remove(t),n.isEmpty?this._attrs.delete(e):!1):!1}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,t){typeof e!="string"?this._setAttribute("style",e,!1):this._setAttribute("style",[e,t],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,t,n){for(const[r,i,o]of e){let a=!1,l=!1;for(const[c,h]of this._attrs)if(!(n&&n.includes(c)||!ct(r,c)))if(a=!0,typeof h=="string"){if(ct(i,h))t.push([c]),l=!0;else if(!(r instanceof RegExp))return!1}else{const f=h._getTokensMatch(i,o||!0);if(f){l=!0;for(const p of f)t.push([c,p])}else if(!(r instanceof RegExp))return!1}if(!a||!l)return!1}return!0}_getConsumables(e,t){const n=[];if(e){const r=this._attrs.get(e);if(r!==void 0)if(typeof r=="string")n.push([e]);else for(const i of r._getConsumables(t))n.push([e,i])}else for(const[r,i]of this._attrs)if(typeof i=="string")n.push([r]);else for(const o of i._getConsumables())n.push([r,o]);return{name:!e,attributes:n}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(const[t,n]of e._attrs){const r=this._attrs.get(t);if(r!==void 0){if(typeof r=="string"||typeof n=="string"){if(r!==n)return!1}else if(!r._canMergeFrom(n))return!1}}return!0}_mergeAttributesFrom(e){this._fireChange("attributes",this);for(const[t,n]of e._attrs){const r=this._attrs.get(t);r===void 0||typeof r=="string"||typeof n=="string"?this._setAttribute(t,n):r._mergeFrom(n)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(const[t,n]of e._attrs){const r=this._attrs.get(t);if(r===void 0)return!1;if(typeof r=="string"||typeof n=="string"){if(r!==n)return!1}else if(!r._isMatching(n))return!1}return!0}_subtractAttributesOf(e){this._fireChange("attributes",this);for(const[t,n]of e._attrs){const r=this._attrs.get(t);typeof r=="string"||typeof n=="string"?this._attrs.delete(t):(r.remove(n.keys()),r.isEmpty&&this._attrs.delete(t))}}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){const t=ge(e);for(const[n,r]of t)if(r===null)t.delete(n);else if(ye(this.name,n)){const i=r instanceof Ve?r._clone():new Ve(this.document.stylesProcessor).setTo(String(r));t.set(n,i)}else if(Me(this.name,n)){const i=r instanceof wt?r._clone():new wt().setTo(String(r));t.set(n,i)}else typeof r!="string"&&t.set(n,String(r));return t}}H.prototype.is=function(s,e){return e?e===this.name&&(s==="element"||s==="view:element"):s==="element"||s==="view:element"||s==="node"||s==="view:node"};function ir(s,e){if(typeof e=="string")return[new R(s,e)];oe(e)||(e=[e]);const t=[];for(const n of e)typeof n=="string"?t.push(new R(s,n)):n instanceof Z?t.push(new R(s,n.data)):t.push(n);return t}function Me(s,e){return e=="class"||s=="a"&&e=="rel"}function ye(s,e){return e=="style"}class Je extends H{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=or}toJSON(){const e=super.toJSON();return e.type="ContainerElement",e}}Je.prototype.is=function(s,e){return e?e===this.name&&(s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function or(){const s=[...this.getChildren()],e=s[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const t of s)if(!t.is("uiElement"))return null;return this.childCount}class ft extends z(Je){constructor(e,t,n,r){super(e,t,n,r),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",i=>i&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}toJSON(){const e=super.toJSON();return e.type="EditableElement",e.isReadOnly=this.isReadOnly,e.isFocused=this.isFocused,e}}ft.prototype.is=function(s,e){return e?e===this.name&&(s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};const sn=Symbol("rootName");class Gn extends ft{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(sn)}set rootName(e){this._setCustomProperty(sn,e)}toJSON(){return this.rootName}set _name(e){this.name=e}}Gn.prototype.is=function(s,e){return e?e===this.name&&(s==="rootElement"||s==="view:rootElement"||s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="rootElement"||s==="view:rootElement"||s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};class de{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new d("view-tree-walker-no-start-position",null);if(e.direction&&e.direction!="forward"&&e.direction!="backward")throw new d("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=g._createAt(e.startPosition):this._position=g._createAt(e.boundaries[e.direction=="backward"?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,n;do n=this.position,t=this.next();while(!t.done&&e(t.value));t.done||(this._position=n)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone()}next(){return this.direction=="forward"?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,n=e.parent;if(n.parent===null&&e.offset===n.childCount)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let r;if(n&&n.is("view:$text")){if(e.isAtEnd)return this._position=g._createAfter(n),this._next();r=n.data[e.offset]}else r=n.getChild(e.offset);if(typeof r=="string"){let i;this.singleCharacters?i=1:i=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset;const o=new Z(n,e.offset,i);return e.offset+=i,this._position=e,this._formatReturnValue("text",o,t,e,i)}if(r&&r.is("view:element")){if(!this.shallow)e=new g(r,0);else{if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}return this._position=e,this._formatReturnValue("elementStart",r,t,e,1)}if(r&&r.is("view:$text")){if(this.singleCharacters)return e=new g(r,0),this._position=e,this._next();let i=r.data.length,o;return r==this._boundaryEndParent?(i=this.boundaries.end.offset,o=new Z(r,0,i),e=g._createAfter(o)):(o=new Z(r,0,r.data.length),e.offset++),this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=g._createAfter(n),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,t,e)}_previous(){let e=this.position.clone();const t=this.position,n=e.parent;if(n.parent===null&&e.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let r;if(n.is("view:$text")){if(e.isAtStart)return this._position=g._createBefore(n),this._previous();r=n.data[e.offset-1]}else r=n.getChild(e.offset-1);if(typeof r=="string"){let i;if(this.singleCharacters)i=1;else{const a=n===this._boundaryStartParent?this.boundaries.start.offset:0;i=e.offset-a}e.offset-=i;const o=new Z(n,e.offset,i);return this._position=e,this._formatReturnValue("text",o,t,e,i)}if(r&&r.is("view:element"))return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",r,t,e,1)):(e=new g(r,r.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",r,t,e));if(r&&r.is("view:$text")){if(this.singleCharacters)return e=new g(r,r.data.length),this._position=e,this._previous();let i=r.data.length,o;if(r==this._boundaryStartParent){const a=this.boundaries.start.offset;o=new Z(r,a,r.data.length-a),i=o.data.length,e=g._createBefore(o)}else o=new Z(r,0,r.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=g._createBefore(n),this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}_formatReturnValue(e,t,n,r,i){return t.is("view:$textProxy")&&(t.offsetInText+t.data.length==t.textNode.data.length&&(this.direction=="forward"&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(r=g._createAfter(t.textNode),this._position=r):n=g._createAfter(t.textNode)),t.offsetInText===0&&(this.direction=="backward"&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(r=g._createBefore(t.textNode),this._position=r):n=g._createBefore(t.textNode))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:r,length:i}}}}class g extends _e{parent;offset;constructor(e,t){super(),this.parent=e,this.offset=t}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return this.offset===0}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof ft);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(e){const t=g._createAt(this),n=t.offset+e;return t.offset=n<0?0:n,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new de(t);return n.skip(e),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let r=0;for(;t[r]==n[r]&&t[r];)r++;return r===0?null:t[r-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return this.compareWith(e)=="before"}isAfter(e){return this.compareWith(e)=="after"}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],n=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),n.push(e.offset);const r=F(t,n);switch(r){case"prefix":return"before";case"extension":return"after";default:return t[r]<n[r]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new de(e)}clone(){return new g(this.parent,this.offset)}toJSON(){return{parent:this.parent.toJSON(),offset:this.offset}}static _createAt(e,t){if(e instanceof g)return new this(e.parent,e.offset);{const n=e;if(t=="end")t=n.is("$text")?n.data.length:n.childCount;else{if(t=="before")return this._createBefore(n);if(t=="after")return this._createAfter(n);if(t!==0&&!t)throw new d("view-createpositionat-offset-required",n)}return new g(n,t)}}static _createAfter(e){if(e.is("$textProxy"))return new g(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new d("view-position-after-root",e,{root:e});return new g(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new g(e.textNode,e.offsetInText);if(!e.parent)throw new d("view-position-before-root",e,{root:e});return new g(e.parent,e.index)}}g.prototype.is=function(s){return s==="position"||s==="view:position"};class w extends _e{start;end;constructor(e,t=null){super(),this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new de({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return this.start.parent===this.end.parent}get root(){return this.start.root}getEnlarged(){let e=this.start.getLastMatchingPosition(Ye,{direction:"backward"}),t=this.end.getLastMatchingPosition(Ye);return e.parent.is("$text")&&e.isAtStart&&(e=g._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=g._createAfter(t.parent)),new w(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(Ye);if(e.isAfter(this.end)||e.isEqual(this.end))return new w(e,e);let t=this.end.getLastMatchingPosition(Ye,{direction:"backward"});const n=e.nodeAfter,r=t.nodeBefore;return n&&n.is("$text")&&(e=new g(n,0)),r&&r.is("$text")&&(t=new g(r,r.data.length)),new w(e,t)}isEqual(e){return this==e||this.start.isEqual(e.start)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const n=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),r=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&r}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new w(this.start,e.start)),this.containsPosition(e.end)&&t.push(new w(e.end,this.end))):t.push(this.clone()),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,n=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(n=e.end),new w(t,n)}return null}getWalker(e={}){return e.boundaries=this,new de(e)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,t=this.end.nodeBefore;return this.start.parent.is("$text")&&this.start.isAtEnd&&this.start.parent.nextSibling&&(e=this.start.parent.nextSibling),this.end.parent.is("$text")&&this.end.isAtStart&&this.end.parent.previousSibling&&(t=this.end.parent.previousSibling),e&&e.is("element")&&e===t?e:null}clone(){return new w(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new de(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new de(e);yield t.position;for(const n of t)yield n.nextPosition}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static _createFromParentsAndOffsets(e,t,n,r){return new this(new g(e,t),new g(n,r))}static _createFromPositionAndShift(e,t){const n=e,r=e.getShiftedBy(t);return t>0?new this(n,r):new this(r,n)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(g._createBefore(e),t)}}w.prototype.is=function(s){return s==="range"||s==="view:range"};function Ye(s){return!!(s.item.is("attributeElement")||s.item.is("uiElement"))}class G extends x(_e){_ranges;_lastRangeBackward;_isFake;_fakeSelectionLabel;constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return this.rangeCount===1&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake||this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel||this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const r of e._ranges)if(t.isEqual(r)){n=!0;break}if(!n)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Yt(this.getRanges()),n=Yt(e.getRanges());if(t!=n)return!1;if(t==0)return!0;for(let r of this.getRanges()){r=r.getTrimmed();let i=!1;for(let o of e.getRanges())if(o=o.getTrimmed(),r.start.isEqual(o.start)&&r.end.isEqual(o.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,n,r]=e;if(typeof n=="object"&&(r=n,n=void 0),t===null)this._setRanges([]),this._setFakeOptions(r);else if(t instanceof G||t instanceof Wt)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof w)this._setRanges([t],r&&r.backward),this._setFakeOptions(r);else if(t instanceof g)this._setRanges([new w(t)]),this._setFakeOptions(r);else if(t instanceof we){const i=!!r&&!!r.backward;let o;if(n===void 0)throw new d("view-selection-setto-required-second-parameter",this);n=="in"?o=w._createIn(t):n=="on"?o=w._createOn(t):o=new w(g._createAt(t,n)),this._setRanges([o],i),this._setFakeOptions(r)}else if(oe(t))this._setRanges(t,r&&r.backward),this._setFakeOptions(r);else throw new d("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,t){if(this.anchor===null)throw new d("view-selection-setfocus-no-ranges",this);const n=g._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const r=this.anchor;this._ranges.pop(),n.compareWith(r)=="before"?this._addRange(new w(n,r),!0):this._addRange(new w(r,n)),this.fire("change")}toJSON(){const e={ranges:Array.from(this.getRanges()).map(t=>t.toJSON())};return this.isBackward&&(e.isBackward=!0),this.isFake&&(e.isFake=!0),e}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const n of e)this._addRange(n);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof w))throw new d("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(const t of this._ranges)if(e.isIntersecting(t))throw new d("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new w(e.start,e.end))}}G.prototype.is=function(s){return s==="selection"||s==="view:selection"};class Wt extends x(_e){_selection;constructor(...e){super(),this._selection=new G,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}toJSON(){return this._selection.toJSON()}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}}Wt.prototype.is=function(s){return s==="selection"||s=="documentSelection"||s=="view:selection"||s=="view:documentSelection"};class qt extends Rt{startRange;_eventPhase;_currentTarget;constructor(e,t,n){super(e,t),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const bt=Symbol("bubblingEmitter"),yt=Symbol("bubblingCallbacks"),vt=Symbol("bubblingContexts");function ar(s){class e extends s{fire(n,...r){try{const i=n instanceof Rt?n:new Rt(this,n),o=Pt(this),a=on(this);if(Ne(i,"capturing",this),Qe(o,"$capture",i,...r))return i.return;const l=i.startRange||this.selection.getFirstRange(),c=l?l.getContainedElement():null,h=c?cr(a,c):!1;let f=c||hr(l);if(Ne(i,"atTarget",f),!h){if(Qe(o,"$text",i,...r))return i.return;Ne(i,"bubbling",f)}for(;f;){if(f.is("element")&&Qe(o,f,i,...r))return i.return;f=f.parent,Ne(i,"bubbling",f)}return Ne(i,"bubbling",this),Qe(o,"$document",i,...r),i.return}catch(i){d.rethrowUnexpectedError(i,this)}}_addEventListener(n,r,i){const o=ie(i.context||"$document"),a=Pt(this),l=rn(this);for(const h of o)typeof h=="function"&&on(this).add(h);const c=lr(this,o,r);l.set(r,c),this.listenTo(a,n,c,i)}_removeEventListener(n,r){const i=Pt(this),o=rn(this),a=o.get(r);a&&(o.delete(r),this.stopListening(i,n,a))}}return e}function Ne(s,e,t){s instanceof qt&&(s._eventPhase=e,s._currentTarget=t)}function Qe(s,e,t,...n){return s.fire(t,{currentTarget:e,eventArgs:n}),!!t.stop.called}function lr(s,e,t){return function(n,r){const{currentTarget:i,eventArgs:o}=r;if(typeof i=="string"){e.includes(i)&&t.call(s,n,...o);return}if(i.is("rootElement")&&e.includes("$root")){t.call(s,n,...o);return}if(e.includes(i.name)){t.call(s,n,...o);return}for(const a of e)if(typeof a=="function"&&a(i)){t.call(s,n,...o);return}}}function Pt(s){return s[bt]||(s[bt]=new(x())),s[bt]}function rn(s){return s[yt]||(s[yt]=new Map),s[yt]}function on(s){return s[vt]||(s[vt]=new Set),s[vt]}function cr(s,e){for(const t of s)if(t(e))return!0;return!1}function hr(s){if(!s)return null;const e=s.start.parent,t=s.end.parent,n=e.getPath(),r=t.getPath();return n.length>r.length?e:t}class Hn extends ar(z()){selection;roots;stylesProcessor;_postFixers=new Set;constructor(e){super(),this.selection=new Wt,this.roots=new Bt({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do for(const n of this._postFixers)if(t=n(e),t)break;while(t)}}const an=10;class Ee extends H{static DEFAULT_PRIORITY=an;_priority=an;_id=null;_clonesGroup=null;constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=ur}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new d("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return this.id!==null||e.id!==null?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}toJSON(){const e=super.toJSON();return e.type="AttributeElement",e}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canSubtractAttributesOf(e)}}Ee.prototype.is=function(s,e){return e?e===this.name&&(s==="attributeElement"||s==="view:attributeElement"||s==="element"||s==="view:element"):s==="attributeElement"||s==="view:attributeElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function ur(){if(Ct(this))return null;let s=this.parent;for(;s&&s.is("attributeElement");){if(Ct(s)>1)return null;s=s.parent}return!s||Ct(s)>1?null:this.childCount}function Ct(s){return Array.from(s.getChildren()).filter(e=>!e.is("uiElement")).length}class zt extends H{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=fr}toJSON(){const e=super.toJSON();return e.type="EmptyElement",e}_insertChild(e,t){if(t&&(t instanceof we||Array.from(t).length>0))throw new d("view-emptyelement-cannot-add",[this,t]);return 0}}zt.prototype.is=function(s,e){return e?e===this.name&&(s==="emptyElement"||s==="view:emptyElement"||s==="element"||s==="view:element"):s==="emptyElement"||s==="view:emptyElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function fr(){return null}class dt extends H{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=mr}_insertChild(e,t){if(t&&(t instanceof we||Array.from(t).length>0))throw new d("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const n of this.getAttributeKeys())t.setAttribute(n,this.getAttribute(n));return t}toJSON(){const e=super.toJSON();return e.type="UIElement",e}}dt.prototype.is=function(s,e){return e?e===this.name&&(s==="uiElement"||s==="view:uiElement"||s==="element"||s==="view:element"):s==="uiElement"||s==="view:uiElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function dr(s){s.document.on("arrowKey",(e,t)=>gr(e,t,s.domConverter),{priority:"low"})}function mr(){return null}function gr(s,e,t){if(e.keyCode==fe.arrowright){const n=e.domTarget.ownerDocument.defaultView.getSelection(),r=n.rangeCount==1&&n.getRangeAt(0).collapsed;if(r||e.shiftKey){const i=n.focusNode,o=n.focusOffset,a=t.domPositionToView(i,o);if(a===null)return;let l=!1;const c=a.getLastMatchingPosition(h=>(h.item.is("uiElement")&&(l=!0),!!(h.item.is("uiElement")||h.item.is("attributeElement"))));if(l){const h=t.viewPositionToDom(c);r?n.collapse(h.parent,h.offset):n.extend(h.parent,h.offset)}}}}class Jt extends H{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=pr}toJSON(){const e=super.toJSON();return e.type="RawElement",e}_insertChild(e,t){if(t&&(t instanceof we||Array.from(t).length>0))throw new d("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}Jt.prototype.is=function(s,e){return e?e===this.name&&(s==="rawElement"||s==="view:rawElement"||s==="element"||s==="view:element"):s==="rawElement"||s==="view:rawElement"||s===this.name||s==="view:"+this.name||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function pr(){return null}class me extends x(_e){document;_children=[];_customProperties=new Map;constructor(e,t){super(),this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return this.childCount===0}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this,{index:e});let n=0;const r=_r(this.document,t);for(const i of r)i.parent!==null&&i._remove(),i.parent=this,this._children.splice(e,0,i),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_fireChange(e,t,n){this.fire(`change:${e}`,t,n)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}me.prototype.is=function(s){return s==="documentFragment"||s==="view:documentFragment"};function _r(s,e){return typeof e=="string"?[new R(s,e)]:(oe(e)||(e=[e]),Array.from(e).map(t=>typeof t=="string"?new R(s,t):t instanceof Z?new R(s,t.data):t))}class Kn{document;_cloneGroups=new Map;_slotFactory=null;constructor(e){this.document=e}setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new me(this.document,e)}createText(e){return new R(this.document,e)}createAttributeElement(e,t,n={}){const r=new Ee(this.document,e,t);return typeof n.priority=="number"&&(r._priority=n.priority),n.id&&(r._id=n.id),n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createContainerElement(e,t,n={},r={}){let i;vr(n)?r=n:i=n;const o=new Je(this.document,e,t,i);return r.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),o}createEditableElement(e,t,n={}){const r=new ft(this.document,e,t);return n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createEmptyElement(e,t,n={}){const r=new zt(this.document,e,t);return n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createUIElement(e,t,n){const r=new dt(this.document,e,t);return n&&(r.render=n),r}createRawElement(e,t,n,r={}){const i=new Jt(this.document,e,t);return n&&(i.render=n),r.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),i}setAttribute(e,t,n,r){r!==void 0?r._setAttribute(e,t,n):n._setAttribute(e,t)}removeAttribute(e,t,n){n!==void 0?n._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){Lt(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof g?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new d("view-writer-break-non-container-element",this.document);if(!t.parent)throw new d("view-writer-break-root",this.document);if(e.isAtStart)return g._createBefore(t);if(!e.isAtEnd){const n=t._clone(!1);this.insert(g._createAfter(t),n);const r=new w(e,g._createAt(t,"end")),i=new g(n,0);this.move(r,i)}return g._createAfter(t)}mergeAttributes(e){const t=e.offset,n=e.parent;if(n.is("$text"))return e;if(n.is("attributeElement")&&n.childCount===0){const o=n.parent,a=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new g(o,a))}const r=n.getChild(t-1),i=n.getChild(t);if(!r||!i)return e;if(r.is("$text")&&i.is("$text"))return cn(r,i);if(r.is("attributeElement")&&i.is("attributeElement")&&r.isSimilar(i)){const o=r.childCount;return r._appendChild(i.getChildren()),i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new g(r,o))}return e}mergeContainers(e){const t=e.nodeBefore,n=e.nodeAfter;if(!t||!n||!t.is("containerElement")||!n.is("containerElement"))throw new d("view-writer-merge-containers-invalid-position",this.document);const r=t.getChild(t.childCount-1),i=r instanceof R?g._createAt(r,"end"):g._createAt(t,"end");return this.move(w._createIn(n),g._createAt(t,"end")),this.remove(w._createOn(n)),i}insert(e,t){t=oe(t)?[...t]:[t],Xn(t,this.document);const n=t.reduce((o,a)=>{const l=o[o.length-1],c=!a.is("uiElement");return!l||l.breakAttributes!=c?o.push({breakAttributes:c,nodes:[a]}):l.nodes.push(a),o},[]);let r=null,i=e;for(const{nodes:o,breakAttributes:a}of n){const l=this._insertNodes(i,o,a);r||(r=l.start),i=l.end}return r?new w(r,i):new w(e)}remove(e){const t=e instanceof w?e:w._createOn(e);if(xe(t,this.document),t.isCollapsed)return new me(this.document);const{start:n,end:r}=this._breakAttributesRange(t,!0),i=n.parent,o=r.offset-n.offset,a=i._removeChildren(n.offset,o);for(const c of a)this._removeFromClonedElementsGroup(c);const l=this.mergeAttributes(n);return t.start=l,t.end=l.clone(),new me(this.document,a)}clear(e,t){xe(e,this.document);const n=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const r of n){const i=r.item;let o;if(i.is("element")&&t.isSimilar(i))o=w._createOn(i);else if(!r.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const a=i.getAncestors().find(l=>l.is("element")&&t.isSimilar(l));a&&(o=w._createIn(a))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let n;if(t.isAfter(e.end)){t=this._breakAttributes(t,!0);const r=t.parent,i=r.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=r.childCount-i}else n=this.remove(e);return this.insert(t,n)}wrap(e,t){if(!(t instanceof Ee))throw new d("view-writer-wrap-invalid-attribute",this.document);if(xe(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&!wr(n.parent)&&(n=n.getLastMatchingPosition(i=>i.item.is("uiElement"))),n=this._wrapPosition(n,t);const r=this.document.selection;return r.isCollapsed&&r.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new w(n)}else return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof Ee))throw new d("view-writer-unwrap-invalid-attribute",this.document);if(xe(e,this.document),e.isCollapsed)return e;const{start:n,end:r}=this._breakAttributesRange(e,!0),i=n.parent,o=this._unwrapChildren(i,n.offset,r.offset,t),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new w(a,l)}rename(e,t){const n=new Je(this.document,e,t.getAttributes());return this.insert(g._createAfter(t),n),this.move(w._createIn(t),g._createAt(n,0)),this.remove(w._createOn(t)),n}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return g._createAt(e,t)}createPositionAfter(e){return g._createAfter(e)}createPositionBefore(e){return g._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new G(...e)}createSlot(e="children"){if(!this._slotFactory)throw new d("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,n){let r;if(n?r=Nt(e):r=e.parent.is("$text")?e.parent.parent:e.parent,!r)throw new d("view-writer-invalid-position-container",this.document);let i;n?i=this._breakAttributes(e,!0):i=e.parent.is("$text")?kt(e):e;const o=r._insertChild(i.offset,t);for(const h of t)this._addToClonedElementsGroup(h);const a=i.getShiftedBy(o),l=this.mergeAttributes(i);l.isEqual(i)||a.offset--;const c=this.mergeAttributes(a);return new w(l,c)}_wrapChildren(e,t,n,r){let i=t;const o=[];for(;i<n;){const l=e.getChild(i),c=l.is("$text"),h=l.is("attributeElement");if(h&&l._canMergeAttributesFrom(r))l._mergeAttributesFrom(r),o.push(new g(e,i));else if(c||!h||br(r,l)){const f=r._clone();l._remove(),f._appendChild(l),e._insertChild(i,f),this._addToClonedElementsGroup(f),o.push(new g(e,i))}else this._wrapChildren(l,0,l.childCount,r);i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==t)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return w._createFromParentsAndOffsets(e,t,e,n)}_unwrapChildren(e,t,n,r){let i=t;const o=[];for(;i<n;){const l=e.getChild(i);if(!l.is("attributeElement")){i++;continue}if(l.isSimilar(r)){const c=l.getChildren(),h=l.childCount;l._remove(),e._insertChild(i,c),this._removeFromClonedElementsGroup(l),o.push(new g(e,i),new g(e,i+h)),i+=h,n+=h-1;continue}if(l._canSubtractAttributesOf(r)){l._subtractAttributesOf(r),o.push(new g(e,i),new g(e,i+1)),i++;continue}this._unwrapChildren(l,0,l.childCount,r),i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==t||l.offset==n)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return w._createFromParentsAndOffsets(e,t,e,n)}_wrapRange(e,t){const{start:n,end:r}=this._breakAttributesRange(e,!0),i=n.parent,o=this._wrapChildren(i,n.offset,r.offset,t),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new w(a,l)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return ln(e.clone());e.parent.is("$text")&&(e=kt(e));const n=this.createAttributeElement("_wrapPosition-fake-element");n._priority=Number.POSITIVE_INFINITY,n.isSimilar=()=>!1,e.parent._insertChild(e.offset,n);const r=new w(e,e.getShiftedBy(1));this.wrap(r,t);const i=new g(n.parent,n.index);n._remove();const o=i.nodeBefore,a=i.nodeAfter;return o&&o.is("view:$text")&&a&&a.is("view:$text")?cn(o,a):ln(i)}_breakAttributesRange(e,t=!1){const n=e.start,r=e.end;if(xe(e,this.document),e.isCollapsed){const l=this._breakAttributes(e.start,t);return new w(l,l)}const i=this._breakAttributes(r,t),o=i.parent.childCount,a=this._breakAttributes(n,t);return i.offset+=i.parent.childCount-o,new w(a,i)}_breakAttributes(e,t=!1){const n=e.offset,r=e.parent;if(e.parent.is("emptyElement"))throw new d("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new d("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new d("view-writer-cannot-break-raw-element",this.document);if(!t&&r.is("$text")&&xt(r.parent)||xt(r))return e.clone();if(r.is("$text"))return this._breakAttributes(kt(e),t);const i=r.childCount;if(n==i){const o=new g(r.parent,r.index+1);return this._breakAttributes(o,t)}else if(n===0){const o=new g(r.parent,r.index);return this._breakAttributes(o,t)}else{const o=r.index+1,a=r._clone();r.parent._insertChild(o,a),this._addToClonedElementsGroup(a);const l=r.childCount-n,c=r._removeChildren(n,l);a._appendChild(c);const h=new g(r.parent,o);return this._breakAttributes(h,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const r of e.getChildren())this._addToClonedElementsGroup(r);const t=e.id;if(!t)return;let n=this._cloneGroups.get(t);n||(n=new Set,this._cloneGroups.set(t,n)),n.add(e),e._clonesGroup=n}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const r of e.getChildren())this._removeFromClonedElementsGroup(r);const t=e.id;if(!t)return;const n=this._cloneGroups.get(t);n&&n.delete(e)}}function wr(s){return Array.from(s.getChildren()).some(e=>!e.is("uiElement"))}function Nt(s){let e=s.parent;for(;!xt(e);){if(!e)return;e=e.parent}return e}function br(s,e){return s.priority<e.priority?!0:s.priority>e.priority?!1:s.getIdentity()<e.getIdentity()}function ln(s){const e=s.nodeBefore;if(e&&e.is("$text"))return new g(e,e.data.length);const t=s.nodeAfter;return t&&t.is("$text")?new g(t,0):s}function kt(s){if(s.offset==s.parent.data.length)return new g(s.parent.parent,s.parent.index+1);if(s.offset===0)return new g(s.parent.parent,s.parent.index);const e=s.parent.data.slice(s.offset);return s.parent._data=s.parent.data.slice(0,s.offset),s.parent.parent._insertChild(s.parent.index+1,new R(s.root.document,e)),new g(s.parent.parent,s.parent.index+1)}function cn(s,e){const t=s.data.length;return s._data+=e.data,e._remove(),new g(s,t)}const yr=[R,Ee,Je,zt,Jt,dt];function Xn(s,e){for(const t of s){if(!yr.some(n=>t instanceof n))throw new d("view-writer-insert-invalid-node-type",e);t.is("$text")||Xn(t.getChildren(),e)}}function xt(s){return s&&(s.is("containerElement")||s.is("documentFragment"))}function xe(s,e){const t=Nt(s.start),n=Nt(s.end);if(!t||!n||t!==n)throw new d("view-writer-invalid-range-container",e)}function vr(s){return Lt(s)}const Yn=s=>s.createTextNode(" "),Qn=s=>{const e=s.createElement("span");return e.dataset.ckeFiller="true",e.innerText=" ",e},Zn=s=>{const e=s.createElement("br");return e.dataset.ckeFiller="true",e},$=7,Ue="⁠".repeat($);function D(s){return typeof s=="string"?s.substr(0,$)===Ue:E(s)&&s.data.substr(0,$)===Ue}function Se(s){return s.data.length==$&&D(s)}function hn(s){const e=typeof s=="string"?s:s.data;return D(s)?e.slice($):e}function Pr(s){s.document.on("arrowKey",Cr,{priority:"low"})}function Cr(s,e){if(e.keyCode==fe.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(t.rangeCount==1&&t.getRangeAt(0).collapsed){const n=t.getRangeAt(0).startContainer,r=t.getRangeAt(0).startOffset;D(n)&&r<=$&&t.collapse(n,0)}}}class kr extends z(){domDocuments=new Set;domConverter;markedAttributes=new Set;markedChildren=new Set;markedTexts=new Set;selection;_inlineFiller=null;_fakeSelectionContainer=null;constructor(e,t){super(),this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),N.isBlink&&!N.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,t){if(e==="text")this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if(e==="attributes")this.markedAttributes.add(t);else if(e==="children")this.markedChildren.add(t);else throw new d("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!N.isAndroid)return;let e=null;const t=N.isBlink&&!N.isAndroid?!this.isSelecting:!0;for(const n of this.markedChildren)this._updateChildrenMappings(n);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=g._createBefore(e.parent)));for(const n of this.markedAttributes)this._updateAttrs(n);for(const n of this.markedChildren)this._updateChildren(n,{inlineFillerPosition:e});for(const n of this.markedTexts)!this.markedChildren.has(n.parent)&&this.domConverter.mapViewToDom(n.parent)&&this._updateText(n,{inlineFillerPosition:e});if(t)if(e){const n=this.domConverter.viewPositionToDom(e),r=n.parent.ownerDocument;D(n.parent)?this._inlineFiller=n.parent:this._inlineFiller=un(r,n.parent,n.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(t.childNodes),r=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),i=this._diffNodeLists(n,r),o=this._findUpdateActions(i,n,r,Ar);if(o.indexOf("update")!==-1){const a={equal:0,insert:0,delete:0};for(const l of o)if(l==="update"){const c=a.equal+a.insert,h=a.equal+a.delete,f=e.getChild(c);f&&!f.is("uiElement")&&!f.is("rawElement")&&this._updateElementMappings(f,n[h]),Zt(r[c]),a.equal++}else a[l]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?g._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&E(t.parent)&&D(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!D(e))throw new d("view-renderer-filler-was-lost",this);Se(e)?e.remove():e.data=e.data.substr($),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,n=e.offset;if(!this.domConverter.mapViewToDom(t.root)||!t.is("element")||!Sr(t))return!1;const r=e.nodeBefore,i=e.nodeAfter;return!(r instanceof R||i instanceof R||n===t.getFillerOffset()&&(!r||!r.is("element","br"))||N.isAndroid&&(r||i))}_updateText(e,t){const n=this.domConverter.findCorrespondingDomText(e);let i=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(i=Ue+i),this._updateTextNode(n,i)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const n of Array.from(t.attributes)){const r=n.name;e.hasAttribute(r)||this.domConverter.removeDomElementAttribute(t,r)}for(const n of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,n,e.getAttribute(n),e)}}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;if(N.isAndroid){let f=null;for(const p of Array.from(n.childNodes)){if(f&&E(f)&&E(p)){n.normalize();break}f=p}}const r=t.inlineFillerPosition,i=n.childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));r&&r.parent===e&&un(n.ownerDocument,o,r.offset);const a=this._diffNodeLists(i,o),l=this._findUpdateActions(a,i,o,Er);let c=0;const h=new Set;for(const f of l)f==="delete"?(h.add(i[c]),Zt(i[c])):(f==="equal"||f==="update")&&c++;c=0;for(const f of l)f==="insert"?(zn(n,c,o[c]),c++):f==="update"?(this._updateTextNode(i[c],o[c].data),c++):f==="equal"&&(this._markDescendantTextToSync(this.domConverter.domToView(o[c])),c++);for(const f of h)f.parentNode||this.domConverter.unbindDomElement(f)}_diffNodeLists(e,t){return e=Mr(e,this._fakeSelectionContainer),mt(e,t,Rr.bind(null,this.domConverter))}_findUpdateActions(e,t,n,r){if(e.indexOf("insert")===-1||e.indexOf("delete")===-1)return e;let i=[],o=[],a=[];const l={equal:0,insert:0,delete:0};for(const c of e)c==="insert"?a.push(n[l.equal+l.insert]):c==="delete"?o.push(t[l.equal+l.delete]):(i=i.concat(mt(o,a,r).map(h=>h==="equal"?"update":h)),i.push("equal"),o=[],a=[]),l[c]++;return i.concat(mt(o,a,r).map(c=>c==="equal"?"update":c))}_updateTextNode(e,t){const n=e.data;n!=t&&(N.isAndroid&&this.isComposing&&n.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const n=$s(e.data,t);for(const r of n)r.type==="insert"?e.insertData(r.index,r.values.join("")):e.deleteData(r.index,r.howMany)}_markDescendantTextToSync(e){if(e){if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}}_updateSelection(){if(N.isBlink&&!N.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this.selection.rangeCount===0){this._removeDomSelection(),this._removeFakeSelection();return}const e=this.domConverter.mapViewToDom(this.selection.editableElement);if(!this.isFocused||!e){!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection();return}this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&N.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=Nr(t));const n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!n.parentElement||n.parentElement!=e)&&e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const r=t.getSelection(),i=t.createRange();r.removeAllRanges(),i.selectNodeContents(n),r.addRange(i)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),r=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(n.parent,n.offset,r.parent,r.offset),N.isGecko&&Tr(r,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||n.anchorNode!==t&&!t.contains(n.anchorNode)?!0:t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const n=e.activeElement,r=this.domConverter.mapDomToView(n);n&&r&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Sr(s){if(s.getAttribute("contenteditable")=="false")return!1;const e=s.findAncestor(t=>t.hasAttribute("contenteditable"));return!e||e.getAttribute("contenteditable")=="true"}function un(s,e,t){const n=e instanceof Array?e:e.childNodes,r=n[t];if(E(r))return r.data=Ue+r.data,r;{const i=s.createTextNode(Ue);return Array.isArray(e)?n.splice(t,0,i):zn(e,t,i),i}}function Ar(s,e){return it(s)&&it(e)&&!E(s)&&!E(e)&&!Be(s)&&!Be(e)&&s.tagName.toLowerCase()===e.tagName.toLowerCase()}function Er(s,e){return it(s)&&it(e)&&E(s)&&E(e)}function Rr(s,e,t){return e===t?!0:E(e)&&E(t)?e.data===t.data:!!(s.isBlockFiller(e)&&s.isBlockFiller(t))}function Tr(s,e){let t=s.parent,n=s.offset;if(E(t)&&Se(t)&&(n=ke(t)+1,t=t.parentNode),t.nodeType!=Node.ELEMENT_NODE||n!=t.childNodes.length-1)return;const r=t.childNodes[n];r&&r.tagName=="BR"&&e.addRange(e.getRangeAt(0))}function Mr(s,e){const t=Array.from(s);return t.length==0||!e||t[t.length-1]==e&&t.pop(),t}function Nr(s){const e=s.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent=" ",e}const xr=Zn(ne.document),Or=Yn(ne.document),Ir=Qn(ne.document),Ze="data-ck-unsafe-attribute-",fn="data-ck-unsafe-element";class es{document;renderingMode;blockFillerMode;preElements;blockElements;inlineObjectElements;unsafeElements;_domDocument;_domToViewMapping=new WeakMap;_viewToDomMapping=new WeakMap;_fakeSelectionMapping=new WeakMap;_rawContentElementMatcher=new ze;_inlineObjectElementMatcher=new ze;_elementsWithTemporaryCustomProperties=new Set;constructor(e,{blockFillerMode:t,renderingMode:n="editing"}={}){this.document=e,this.renderingMode=n,this.blockFillerMode=t||(n==="editing"?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument=this.renderingMode==="editing"?ne.document:ne.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new G(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const n of e.children)this.unbindDomElement(n)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,n){return this.renderingMode==="data"?!0:(e=e.toLowerCase(),e.startsWith("on")||e==="srcdoc"&&t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i)?!1:n==="img"&&(e==="src"||e==="srcset")||n==="source"&&e==="srcset"?!0:!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if(this.renderingMode==="data"){e.innerHTML=t;return}const n=new DOMParser().parseFromString(t,"text/html"),r=n.createDocumentFragment(),i=n.body.childNodes;for(;i.length>0;)r.appendChild(i[0]);const o=n.createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a=[];let l;for(;l=o.nextNode();)a.push(l);for(const c of a){for(const f of c.getAttributeNames())this.setDomElementAttribute(c,f,c.getAttribute(f));const h=c.tagName.toLowerCase();this._shouldRenameElement(h)&&(pn(h),c.replaceWith(this._createReplacementDomElement(h,c)))}for(;e.firstChild;)e.firstChild.remove();e.append(r)}viewToDom(e,t={}){if(e.is("$text")){const n=this._processDataFromViewText(e);return this._domDocument.createTextNode(n)}else{const n=e;if(this.mapViewToDom(n))if(n.getCustomProperty("editingPipeline:doNotReuseOnce"))this._elementsWithTemporaryCustomProperties.add(n);else return this.mapViewToDom(n);let r;if(n.is("documentFragment"))r=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(r,n);else{if(n.is("uiElement"))return n.name==="$comment"?r=this._domDocument.createComment(n.getCustomProperty("$rawContent")):r=n.render(this._domDocument,this),t.bind&&this.bindElements(r,n),r;this._shouldRenameElement(n.name)?(pn(n.name),r=this._createReplacementDomElement(n.name)):n.hasAttribute("xmlns")?r=this._domDocument.createElementNS(n.getAttribute("xmlns"),n.name):r=this._domDocument.createElement(n.name),n.is("rawElement")&&n.render(r,this),t.bind&&this.bindElements(r,n);for(const i of n.getAttributeKeys())this.setDomElementAttribute(r,i,n.getAttribute(i),n)}if(t.withChildren!==!1)for(const i of this.viewChildrenToDom(n,t))r instanceof HTMLTemplateElement?r.content.appendChild(i):r.appendChild(i);return r}}setDomElementAttribute(e,t,n,r){const i=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||r&&r.shouldRenderUnsafeAttribute(t);if(i||J("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:n}),!Bs(t)){J("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:n});return}e.hasAttribute(t)&&!i?e.removeAttribute(t):e.hasAttribute(Ze+t)&&i&&e.removeAttribute(Ze+t),e.setAttribute(i?t:Ze+t,n)}removeDomElementAttribute(e,t){t!=fn&&(e.removeAttribute(t),e.removeAttribute(Ze+t))}*viewChildrenToDom(e,t={}){const n=e.getFillerOffset&&e.getFillerOffset();let r=0;for(const i of e.getChildren()){n===r&&(yield this._getBlockFiller());const o=i.is("element")&&!!i.getCustomProperty("dataPipeline:transparentRendering")&&!Vt(i.getAttributes());if(o&&this.renderingMode=="data")if(i.is("rawElement")){const a=this._domDocument.createElement(i.name);i.render(a,this),yield*[...a.childNodes]}else yield*this.viewChildrenToDom(i,t);else o&&J("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:i}),yield this.viewToDom(i,t);r++}n===r&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),r=this._domDocument.createRange();return r.setStart(t.parent,t.offset),r.setEnd(n.parent,n.offset),r}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const n=this.findCorrespondingDomText(t);if(!n)return null;let r=e.offset;return D(n)&&(r+=$),n.data&&r>n.data.length&&(r=n.data.length),{parent:n,offset:r}}else{let n,r,i;if(e.offset===0){if(n=this.mapViewToDom(t),!n)return null;i=n.childNodes[0]}else{const a=e.nodeBefore;if(r=a.is("$text")?this.findCorrespondingDomText(a):this.mapViewToDom(a),!r)return null;n=r.parentNode,i=r.nextSibling}if(E(i)&&D(i))return{parent:i,offset:$};const o=r?ke(r)+1:0;return{parent:n,offset:o}}}domToView(e,t={}){const n=[],r=this._domToView(e,t,n),i=r.next().value;return!i||(r.next(),this._processDomInlineNodes(null,n,t),this.blockFillerMode=="br"&&mn(i))||i.is("$text")&&i.data.length==0?null:i}*domChildrenToView(e,t={},n=[]){let r=[];e instanceof HTMLTemplateElement?r=[...e.content.childNodes]:r=[...e.childNodes];for(let i=0;i<r.length;i++){const o=r[i],a=this._domToView(o,t,n),l=a.next().value;l!==null&&(this._isBlockViewElement(l)&&this._processDomInlineNodes(e,n,t),this.blockFillerMode=="br"&&mn(l)||(yield l),a.next())}this._processDomInlineNodes(e,n,t)}domSelectionToView(e){if(Lr(e))return new G([]);if(e.rangeCount===1){let r=e.getRangeAt(0).startContainer;E(r)&&(r=r.parentNode);const i=this.fakeSelectionToView(r);if(i)return i}const t=this.isDomSelectionBackward(e),n=[];for(let r=0;r<e.rangeCount;r++){const i=e.getRangeAt(r),o=this.domRangeToView(i);o&&n.push(o)}return new G(n,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),n=this.domPositionToView(e.endContainer,e.endOffset);return t&&n?new w(t,n):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,ke(e));const n=this.mapDomToView(e);if(n&&(n.is("uiElement")||n.is("rawElement")))return g._createBefore(n);if(E(e)){if(Se(e))return this.domPositionToView(e.parentNode,ke(e));const r=this.findCorrespondingViewText(e);let i=t;return r?(D(e)&&(i-=$,i=i<0?0:i),new g(r,i)):null}else{if(t===0){const r=this.mapDomToView(e);if(r)return new g(r,0)}else{const r=e.childNodes[t-1];if(E(r)&&Se(r)||r&&this.isBlockFiller(r))return this.domPositionToView(r.parentNode,ke(r));const i=E(r)?this.findCorrespondingViewText(r):this.mapDomToView(r);if(i&&i.parent)return new g(i.parent,i.index+1)}return null}}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(Se(e))return null;const t=this.getHostViewElement(e);if(t)return t;const n=e.previousSibling;if(n){if(!this.isElement(n))return null;const r=this.mapDomToView(n);if(r){const i=r.nextSibling;return i instanceof R?i:null}}else{const r=this.mapDomToView(e.parentNode);if(r){const i=r.getChild(0);return i instanceof R?i:null}}return null}mapViewToDom(e){return this._viewToDomMapping.get(e)}findCorrespondingDomText(e){const t=e.previousSibling;return t&&this.mapViewToDom(t)?this.mapViewToDom(t).nextSibling:!t&&e.parent&&this.mapViewToDom(e.parent)?this.mapViewToDom(e.parent).childNodes[0]:null}focus(e){const t=this.mapViewToDom(e);if(!t||t.ownerDocument.activeElement===t)return;const{scrollX:n,scrollY:r}=ne.window,i=[];dn(t,o=>{const{scrollLeft:a,scrollTop:l}=o;i.push([a,l])}),t.focus({preventScroll:!0}),dn(t,o=>{const[a,l]=i.shift();o.scrollLeft=a,o.scrollTop=l}),ne.window.scrollTo(n,r)}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),n=this.domSelectionToView(t);n&&n.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return this.blockFillerMode=="br"?e.isEqualNode(xr):gn(e,this.blockElements)?!0:e.isEqualNode(Ir)||Dr(e,this.blockElements)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch{return!1}const n=t.collapsed;return t.detach(),n}getHostViewElement(e){const t=Vs(e);for(t.pop();t.length;){const n=t.pop(),r=this._domToViewMapping.get(n);if(r&&(r.is("uiElement")||r.is("rawElement")))return r}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return Yn(this._domDocument);case"markedNbsp":return Qn(this._domDocument);case"br":return Zn(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(E(e)&&D(e)&&t<$||this.isElement(e)&&D(e.childNodes[t]))return!1;const n=this.mapDomToView(e);return!(n&&(n.is("uiElement")||n.is("rawElement")))}*_domToView(e,t,n){if(this.blockFillerMode!="br"&&gn(e,this.blockElements))return null;const r=this.getHostViewElement(e);if(r)return r;if(Be(e)&&t.skipComments)return null;if(E(e)){if(Se(e))return null;{const i=e.data;if(i==="")return null;const o=new R(this.document,i);return n.push(o),o}}else{let i=this.mapDomToView(e);if(i)return this._isInlineObjectElement(i)&&n.push(i),i;if(this.isDocumentFragment(e))i=new me(this.document),t.bind&&this.bindDocumentFragments(e,i);else{i=this._createViewElement(e,t),t.bind&&this.bindElements(e,i);const a=e.attributes;if(a)for(let l=a.length,c=0;c<l;c++)i._setAttribute(a[c].name,a[c].value);if(this._isViewElementWithRawContent(i,t))return i._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(i)||n.push(i),i;if(Be(e))return i._setCustomProperty("$rawContent",e.data),i}yield i;const o=[];if(t.withChildren!==!1)for(const a of this.domChildrenToView(e,t,o))i._appendChild(a);if(this._isInlineObjectElement(i))n.push(i),this._processDomInlineNodes(null,o,t);else for(const a of o)n.push(a)}}_processDomInlineNodes(e,t,n){if(!t.length||e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let r=!1;for(let i=0;i<t.length;i++){const o=t[i];if(!o.is("$text")){r=!1;continue}let a,l=!1;if(this._isPreFormatted(o))a=hn(o.data);else{a=o.data.replace(/[ \n\t\r]{1,}/g," "),l=/[^\S\u00A0]/.test(a.charAt(a.length-1));const c=i>0?t[i-1]:null,h=i+1<t.length?t[i+1]:null,f=!c||c.is("element")&&c.name=="br"||r,p=h?!1:!D(o.data);n.withChildren!==!1&&(f&&(a=a.replace(/^ /,"")),p&&(a=a.replace(/ $/,""))),a=hn(a),this.blockFillerMode!="br"&&o.parent&&(Vr(o.parent,a)?(a="",o.parent.parent&&(o.parent.parent._setCustomProperty("$hasBlockFiller",!0),o.parent._remove())):Br(o.parent,a,this.blockElements)&&(a="",o.parent._setCustomProperty("$hasBlockFiller",!0))),a=a.replace(/ \u00A0/g," ");const _=h&&h.is("element")&&h.name!="br",y=h&&h.is("$text")&&h.data.charAt(0)==" ";(/[ \u00A0]\u00A0$/.test(a)||!h||_||y)&&(a=a.replace(/\u00A0$/," ")),(f||c&&c.is("element")&&c.name!="br")&&(a=a.replace(/^\u00A0/," "))}a.length==0&&o.parent?(o._remove(),t.splice(i,1),i--):(o._data=a,r=l)}t.length=0}_processDataFromViewText(e){let t=e.data;if(this._isPreFormatted(e))return t;if(t.charAt(0)==" "){const n=this._getTouchingInlineViewNode(e,!1);(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n)||!n)&&(t=" "+t.substr(1))}if(t.charAt(t.length-1)==" "){const n=this._getTouchingInlineViewNode(e,!0),r=n&&n.is("$textProxy")&&n.data.charAt(0)==" ";(t.charAt(t.length-2)==" "||!n||r)&&(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(this._isPreFormatted(e))return!1;const t=this._processDataFromViewText(e);return t.charAt(t.length-1)==" "}_isPreFormatted(e){if(Fr(e,this.preElements))return!0;for(const t of e.getAncestors({parentFirst:!0}))if(!(!t.is("element")||!t.hasStyle("white-space")||t.getStyle("white-space")==="inherit"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){const n=new de({startPosition:t?g._createAfter(e):g._createBefore(e),direction:t?"forward":"backward"});for(const{item:r}of n){if(r.is("$textProxy"))return r;if(r.is("element")&&r.getCustomProperty("dataPipeline:transparentRendering"))continue;if(r.is("element","br"))return null;if(this._isInlineObjectElement(r))return r;if(r.is("containerElement")||this._isBlockViewElement(r))return null}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return e.is("element")?e.name=="br"||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e):!1}_createViewElement(e,t){if(Be(e))return new dt(this.document,"$comment");const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new H(this.document,n)}_isViewElementWithRawContent(e,t){return t.withChildren!==!1&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return this.renderingMode==="editing"&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const n=this._domDocument.createElement("span");if(n.setAttribute(fn,e),t){for(;t.firstChild;)n.appendChild(t.firstChild);for(const r of t.getAttributeNames())n.setAttribute(r,t.getAttribute(r))}return n}}function Fr(s,e){return s.getAncestors().some(t=>t.is("element")&&e.includes(t.name))}function dn(s,e){let t=s;for(;t;)e(t),t=t.parentElement}function Dr(s,e){return s.isEqualNode(Or)&&ts(s,e)&&s.parentNode.childNodes.length===1}function ts(s,e){const t=s.parentNode;return!!t&&!!t.tagName&&e.includes(t.tagName.toLowerCase())}function Br(s,e,t){return e==" "&&s&&s.is("element")&&s.childCount==1&&t.includes(s.name)}function Vr(s,e){return e==" "&&s&&s.is("element","span")&&s.childCount==1&&s.hasAttribute("data-cke-filler")}function mn(s){return s.is("element","br")&&s.hasAttribute("data-cke-filler")}function gn(s,e){return s.tagName==="BR"&&ts(s,e)&&s.parentNode.childNodes.length===1}function pn(s){s==="script"&&J("domconverter-unsafe-script-element-detected"),s==="style"&&J("domconverter-unsafe-style-element-detected")}function Lr(s){if(!N.isGecko||!s.rangeCount)return!1;const e=s.getRangeAt(0).startContainer;try{Object.prototype.toString.call(e)}catch{return!0}return!1}class Re extends Ds(){view;document;_isEnabled=!1;constructor(e){super(),this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&e.nodeType===3&&(e=e.parentNode),!e||e.nodeType!==1?!1:e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}class $r{view;document;domEvent;domTarget;constructor(e,t,n){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Us(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class le extends Re{useCapture=!1;usePassive=!1;observe(e){(typeof this.domEventType=="string"?[this.domEventType]:this.domEventType).forEach(n=>{this.listenTo(e,n,(r,i)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(i.target)&&this.onDomEvent(i)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,n){this.isEnabled&&this.document.fire(e,new $r(this.view,t,n))}}class Wr extends le{domEventType=["keydown","keyup"];onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return zs(this)}};this.fire(e.type,e,t)}}class qr extends Re{_fireSelectionChangeDoneDebounced;constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Tt(t=>{this.document.fire("selectionChangeDone",t)},200)}observe(){const e=this.document;e.on("arrowKey",(t,n)=>{e.selection.isFake&&this.isEnabled&&n.preventDefault()},{context:"$capture"}),e.on("arrowKey",(t,n)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)},{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,n=new G(t.getRanges(),{backward:t.isBackward,fake:!1});(e==fe.arrowleft||e==fe.arrowup)&&n.setTo(n.getFirstPosition()),(e==fe.arrowright||e==fe.arrowdown)&&n.setTo(n.getLastPosition());const r={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",r),this._fireSelectionChangeDoneDebounced(r)}}class ns extends Re{domConverter;_config;_domElements;_mutationObserver;constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const t of this._domElements)this._mutationObserver.observe(t,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(e.length===0)return;const t=this.domConverter,n=new Set,r=new Set;for(const o of e){const a=t.mapDomToView(o.target);a&&(a.is("uiElement")||a.is("rawElement")||o.type==="childList"&&!this._isBogusBrMutation(o)&&r.add(a))}for(const o of e){const a=t.mapDomToView(o.target);if(!(a&&(a.is("uiElement")||a.is("rawElement")))&&o.type==="characterData"){const l=t.findCorrespondingViewText(o.target);l&&!r.has(l.parent)?n.add(l):!l&&D(o.target)&&r.add(t.mapDomToView(o.target.parentNode))}}const i=[];for(const o of n)i.push({type:"text",node:o});for(const o of r){const a=t.mapViewToDom(o),l=Array.from(o.getChildren()),c=Array.from(t.domChildrenToView(a,{withChildren:!1}));Gs(l,c,zr)||i.push({type:"children",node:o})}i.length&&this.document.fire("mutations",{mutations:i})}_isBogusBrMutation(e){let t=null;return e.nextSibling===null&&e.removedNodes.length===0&&e.addedNodes.length==1&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function zr(s,e){if(!Array.isArray(s))return s===e?!0:s.is("$text")&&e.is("$text")?s.data===e.data:!1}class Ot extends le{_renderTimeoutId=null;_isFocusChanging=!1;domEventType=["focus","blur"];constructor(e){super(e),this.useCapture=!0;const t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(n,r)=>this._handleBlur(r)),t.on("beforeinput",()=>{t.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){const t=this.document.selection.editableElement;(t===null||t===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class Jr extends Re{mutationObserver;focusObserver;selection;domConverter;_documents=new WeakSet;_fireSelectionChangeDoneDebounced;_clearInfiniteLoopInterval;_documentIsSelectingInactivityTimeoutDebounced;_loopbackCounter=0;_pendingSelectionChange=new Set;constructor(e){super(e),this.mutationObserver=e.getObserver(ns),this.focusObserver=e.getObserver(Ot),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=Tt(t=>{this.document.fire("selectionChangeDone",t)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Tt(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(t,n,r)=>{if(r&&this._pendingSelectionChange.size){for(const i of Array.from(this._pendingSelectionChange))this._handleSelectionChange(i);this._pendingSelectionChange.clear()}})}observe(e){const t=e.ownerDocument,n=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},r=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",n,{priority:"highest"}),this.listenTo(e,"keydown",r,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",r,{priority:"highest",useCapture:!0}),!this._documents.has(t)&&(this.listenTo(t,"mouseup",r,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>{this.document.isComposing&&!N.isAndroid||(this._handleSelectionChange(t),this._documentIsSelectingInactivityTimeoutDebounced())}),this.listenTo(this.view.document,"compositionstart",()=>{this._handleSelectionChange(t)},{priority:"lowest"}),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e){if(!this.isEnabled)return;const t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(t);if(n.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly){this._pendingSelectionChange.add(e);return}if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(n)&&this.domConverter.isDomSelectionCorrect(t))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(!Ur(n))this.view.forceRender();else if(this.selection.isSimilar(n))this.view.forceRender();else{const r={oldSelection:this.selection,newSelection:n,domSelection:t};this.document.fire("selectionChange",r),this._fireSelectionChangeDoneDebounced(r)}}}_clearInfiniteLoop(){this._loopbackCounter=0}}function Ur(s){return Array.from(s.getRanges()).flatMap(e=>[e.start.root,e.end.root]).every(e=>e&&e.is("rootElement"))}class jr extends le{domEventType=["compositionstart","compositionupdate","compositionend"];constructor(e){super(e);const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0}),t.on("compositionend",()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}class Gr{_files;_native;constructor(e,t={}){this._files=t.cacheFiles?_n(e):null,this._native=e}get files(){return this._files||(this._files=_n(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,n){this._native.setDragImage(e,t,n)}get isCanceled(){return this._native.dropEffect=="none"||!!this._native.mozUserCancelled}}function _n(s){const e=Array.from(s.files||[]),t=Array.from(s.items||[]);return e.length?e:t.filter(n=>n.kind==="file").map(n=>n.getAsFile())}class Hr extends le{domEventType="beforeinput";onDomEvent(e){const t=e.getTargetRanges(),n=this.view,r=n.document;let i=null,o=null,a=[];if(e.dataTransfer&&(i=new Gr(e.dataTransfer)),e.data!==null?o=e.data:i&&(o=i.getData("text/plain")),r.selection.isFake)a=Array.from(r.selection.getRanges()),e.preventDefault();else if(t.length)a=t.map(l=>{let c=n.domConverter.domPositionToView(l.startContainer,l.startOffset);const h=n.domConverter.domPositionToView(l.endContainer,l.endOffset);if(c&&D(l.startContainer)&&l.startOffset<$){e.preventDefault();let f=$-l.startOffset;c=c.getLastMatchingPosition(p=>!!(p.item.is("attributeElement")||p.item.is("uiElement")||p.item.is("$textProxy")&&f--),{direction:"backward",singleCharacters:!0})}if(Kr(l.endContainer,l.endOffset)&&e.preventDefault(),c)return n.createRange(c,h);if(h)return n.createRange(h)}).filter(l=>!!l);else if(N.isAndroid){const l=e.target.ownerDocument.defaultView.getSelection();a=Array.from(n.domConverter.domSelectionToView(l).getRanges())}if(N.isAndroid&&e.inputType=="insertCompositionText"&&o&&o.endsWith(`
2
+ `)){this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[n.createRange(a[0].end)]});return}if(["insertText","insertReplacementText"].includes(e.inputType)&&o&&o.includes(`
3
+ `)){const l=o.split(/\n{1,2}/g);let c=a;e.preventDefault();for(let h=0;h<l.length;h++){const f=l[h];f!=""&&(this.fire(e.type,e,{data:f,dataTransfer:i,targetRanges:c,inputType:e.inputType,isComposing:e.isComposing}),c=[r.selection.getFirstRange()]),h+1<l.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:c}),c=[r.selection.getFirstRange()])}return}this.fire(e.type,e,{data:o,dataTransfer:i,targetRanges:a,inputType:e.inputType,isComposing:e.isComposing})}}function Kr(s,e){for(;s.parentNode;){if(E(s)){if(e!=s.data.length)return!1}else if(e!=s.childNodes.length)return!1;if(e=ke(s)+1,s=s.parentNode,e<s.childNodes.length&&D(s.childNodes[e]))return!0}return!1}class Xr extends Re{constructor(e){super(e),this.document.on("keydown",(t,n)=>{if(this.isEnabled&&Ws(n.keyCode)){const r=new qt(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(r,n),r.stop.called&&t.stop()}})}observe(){}stopObserving(){}}class Yr extends Re{constructor(e){super(e);const t=this.document;t.on("keydown",(n,r)=>{if(!this.isEnabled||r.keyCode!=fe.tab||r.ctrlKey)return;const i=new qt(t,"tab",t.selection.getFirstRange());t.fire(i,r),i.stop.called&&n.stop()})}observe(){}stopObserving(){}}class Qr extends z(){document;domConverter;domRoots=new Map;_renderer;_initialDomRootAttributes=new WeakMap;_observers=new Map;_writer;_ongoingChange=!1;_postFixersInProgress=!1;_renderingDisabled=!1;_hasChangedSinceTheLastRendering=!1;constructor(e){super(),this.document=new Hn(e),this.domConverter=new es(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new kr(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new Kn(this.document),this.addObserver(ns),this.addObserver(Ot),this.addObserver(Jr),this.addObserver(Wr),this.addObserver(qr),this.addObserver(jr),this.addObserver(Xr),this.addObserver(Hr),this.addObserver(Yr),Pr(this),dr(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0}),this.listenTo(this.document,"change:isFocused",()=>{this._hasChangedSinceTheLastRendering=!0}),N.isiOS&&this.listenTo(this.document,"blur",(t,n)=>{this.domConverter.mapDomToView(n.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(t,{mutations:n})=>{n.forEach(r=>this._renderer.markToSync(r.type,r.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(e,t="main"){const n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();const r={};for(const{name:o,value:a}of Array.from(e.attributes))r[o]=a,o==="class"?this._writer.addClass(a.split(" "),n):n.hasAttribute(o)||this._writer.setAttribute(o,a,n);this._initialDomRootAttributes.set(e,r);const i=()=>{this._writer.setAttribute("contenteditable",(!n.isReadOnly).toString(),n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};i(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(e.ownerDocument),n.on("change:children",(o,a)=>this._renderer.markToSync("children",a)),n.on("change:attributes",(o,a)=>this._renderer.markToSync("attributes",a)),n.on("change:text",(o,a)=>this._renderer.markToSync("text",a)),n.on("change:isReadOnly",()=>this.change(i)),n.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const o of this._observers.values())o.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:r})=>t.removeAttribute(r));const n=this._initialDomRootAttributes.get(t);for(const r in n)t.setAttribute(r,n[r]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const r of this._observers.values())r.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[n,r]of this.domRoots)t.observe(r,n);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:n=20,ancestorOffset:r=20}={}){const i=this.document.selection.getFirstRange();if(!i)return;const o=ae({alignToTop:e,forceScroll:t,viewportOffset:n,ancestorOffset:r});typeof n=="number"&&(n={top:n,bottom:n,left:n,right:n});const a={target:this.domConverter.viewRangeToDom(i),viewportOffset:n,ancestorOffset:r,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",a,o),Ls(a)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new d("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),t}catch(t){d.rethrowUnexpectedError(t,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Ot).flush(),this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return g._createAt(e,t)}createPositionAfter(e){return g._createAfter(e)}createPositionBefore(e){return g._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new G(...e)}_disableRendering(e){this._renderingDisabled=e,e==!1&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}class ce{is(){throw new Error("is() method is abstract")}}class j extends ce{textNode;data;offsetInText;constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new d("model-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.offsetSize)throw new d("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get startOffset(){return this.textNode.startOffset!==null?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return this.startOffset!==null?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}j.prototype.is=function(s){return s==="$textProxy"||s==="model:$textProxy"||s==="textProxy"||s==="model:textProxy"};class se{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;_visitedParent;constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new d("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if(t!="forward"&&t!="backward")throw new d("model-tree-walker-unknown-direction",e,{direction:t});this.direction=t,this.boundaries=e.boundaries||null,e.startPosition?this._position=e.startPosition.clone():this._position=m._createAt(this.boundaries[this.direction=="backward"?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,n,r,i;do r=this.position,i=this._visitedParent,{done:t,value:n}=this.next();while(!t&&e(n));t||(this._position=r,this._visitedParent=i)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone(),this._visitedParent=e.parent}next(){return this.direction=="forward"?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(n.parent===null&&t.offset===n.maxOffset)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const r=Le(t,n),i=r||ss(t,n,r);if(i&&i.is("model:element")){if(!this.shallow)t.path.push(0),this._visitedParent=i;else{if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}return this._position=t,ue("elementStart",i,e,t,1)}if(i&&i.is("model:$text")){let o;if(this.singleCharacters)o=1;else{let c=i.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offset<c&&(c=this.boundaries.end.offset),o=c-t.offset}const a=t.offset-i.startOffset,l=new j(i,a,o);return t.offset+=o,this._position=t,ue("text",l,e,t,o)}return t.path.pop(),t.offset++,this._position=t,this._visitedParent=n.parent,this.ignoreElementEnd?this._next():ue("elementEnd",n,e,t)}_previous(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(n.parent===null&&t.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const r=t.parent,i=Le(t,r),o=i||rs(t,r,i);if(o&&o.is("model:element"))return t.offset--,this.shallow?(this._position=t,ue("elementStart",o,e,t,1)):(t.path.push(o.maxOffset),this._position=t,this._visitedParent=o,this.ignoreElementEnd?this._previous():ue("elementEnd",o,e,t));if(o&&o.is("model:$text")){let a;if(this.singleCharacters)a=1;else{let h=o.startOffset;this._boundaryStartParent==n&&this.boundaries.start.offset>h&&(h=this.boundaries.start.offset),a=t.offset-h}const l=t.offset-o.startOffset,c=new j(o,l-a,a);return t.offset-=a,this._position=t,ue("text",c,e,t,a)}return t.path.pop(),this._position=t,this._visitedParent=n.parent,ue("elementStart",n,e,t,1)}}function ue(s,e,t,n,r){return{done:!1,value:{type:s,item:e,previousPosition:t,nextPosition:n,length:r}}}class m extends ce{root;path;stickiness;constructor(e,t,n="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new d("model-position-root-invalid",e);if(!Array.isArray(t)||t.length===0)throw new d("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=n}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)throw new d("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new d("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return Le(this,this.parent)}get nodeAfter(){const e=this.parent;return ss(this,e,Le(this,e))}get nodeBefore(){const e=this.parent;return rs(this,e,Le(this,e))}get isAtStart(){return this.offset===0}get isAtEnd(){return this.offset==this.parent.maxOffset}isValid(){if(this.offset<0)return!1;let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=F(this.path,e.path);switch(t){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[t]<e.path[t]?"before":"after"}}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new se(t);return n.skip(e),n.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){const e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){const t=this.parent;return t.is("element")?t.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];const t=F(this.path,e.path),n=typeof t=="string"?Math.min(this.path.length,e.path.length):t;return this.path.slice(0,n)}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let r=0;for(;t[r]==n[r]&&t[r];)r++;return r===0?null:t[r-1]}getShiftedBy(e){const t=this.clone(),n=t.offset+e;return t.offset=n<0?0:n,t}isAfter(e){return this.compareWith(e)=="after"}isBefore(e){return this.compareWith(e)=="before"}isEqual(e){return this.compareWith(e)=="same"}isTouching(e){if(this.root!==e.root)return!1;const t=Math.min(this.path.length,e.path.length);for(let n=0;n<t;n++){const r=this.path[n]-e.path[n];if(r<-1||r>1)return!1;if(r===1)return wn(e,this,n);if(r===-1)return wn(this,e,n)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?It(this.path,t):It(e.path,t)}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),n=e.getParentPath();return F(t,n)=="same"}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=m._createAt(this);break}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&this.stickiness=="toNext"?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange,n=t.containsPosition(this)||t.start.isEqual(this);let r;return n?(r=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(r=r._getTransformedByDeletion(e.deletionPosition,1))):this.isEqual(e.deletionPosition)?r=m._createAt(e.deletionPosition):r=this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),r}_getTransformedByDeletion(e,t){const n=m._createAt(this);if(this.root!=e.root)return n;if(F(e.getParentPath(),this.getParentPath())=="same"){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;n.offset-=t}}else if(F(e.getParentPath(),this.getParentPath())=="prefix"){const r=e.path.length-1;if(e.offset<=this.path[r]){if(e.offset+t>this.path[r])return null;n.path[r]-=t}}return n}_getTransformedByInsertion(e,t){const n=m._createAt(this);if(this.root!=e.root)return n;if(F(e.getParentPath(),this.getParentPath())=="same")(e.offset<this.offset||e.offset==this.offset&&this.stickiness!="toPrevious")&&(n.offset+=t);else if(F(e.getParentPath(),this.getParentPath())=="prefix"){const r=e.path.length-1;e.offset<=this.path[r]&&(n.path[r]+=t)}return n}_getTransformedByMove(e,t,n){if(t=t._getTransformedByDeletion(e,n),e.isEqual(t))return m._createAt(this);const r=this._getTransformedByDeletion(e,n);return r===null||e.isEqual(this)&&this.stickiness=="toNext"||e.getShiftedBy(n).isEqual(this)&&this.stickiness=="toPrevious"?this._getCombined(e,t):r._getTransformedByInsertion(t,n)}_getCombined(e,t){const n=e.path.length-1,r=m._createAt(t);return r.stickiness=this.stickiness,r.offset=r.offset+this.path[n]-e.offset,r.path=[...r.path,...this.path.slice(n+1)],r}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(e,t,n="toNone"){if(e.is("model:position"))return new m(e.root,e.path,e.stickiness);{const r=e;if(t=="end")t=r.maxOffset;else{if(t=="before")return this._createBefore(r,n);if(t=="after")return this._createAfter(r,n);if(t!==0&&!t)throw new d("model-createpositionat-offset-required",[this,e])}if(!r.is("element")&&!r.is("documentFragment"))throw new d("model-position-parent-incorrect",[this,e]);const i=r.getPath();return i.push(t),new this(r.root,i,n)}}static _createAfter(e,t){if(!e.parent)throw new d("model-position-after-root",[this,e],{root:e});return this._createAt(e.parent,e.endOffset,t)}static _createBefore(e,t){if(!e.parent)throw new d("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if(e.root==="$graveyard"){const n=new m(t.graveyard,e.path);return n.stickiness=e.stickiness,n}if(!t.getRoot(e.root))throw new d("model-position-fromjson-no-root",t,{rootName:e.root});return new m(t.getRoot(e.root),e.path,e.stickiness)}}m.prototype.is=function(s){return s==="position"||s==="model:position"};function Le(s,e){const t=e.getChildAtOffset(s.offset);return t&&t.is("$text")&&t.startOffset<s.offset?t:null}function ss(s,e,t){return t!==null?null:e.getChildAtOffset(s.offset)}function rs(s,e,t){return t!==null?null:e.getChild(e.offsetToIndex(s.offset)-1)}function wn(s,e,t){return!(t+1===s.path.length||!It(e.path,t+1)||!Zr(s,t+1))}function It(s,e){for(;e<s.length;){if(s[e]!==0)return!1;e++}return!0}function Zr(s,e){let t=s.parent,n=s.path.length-1,r=0;for(;n>=e;){if(s.path[n]+r!==t.maxOffset)return!1;r=1,n--,t=t.parent}return!0}class u extends ce{start;end;constructor(e,t){super(),this.start=m._createAt(e),this.end=t?m._createAt(t):m._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new se({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){const e=this.start.getParentPath(),t=this.end.getParentPath();return F(e,t)=="same"}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const n=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),r=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&r}containsItem(e){const t=m._createBefore(e);return this.containsPosition(t)||this.start.isEqual(t)}isEqual(e){return this.start.isEqual(e.start)&&this.end.isEqual(e.end)}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new u(this.start,e.start)),this.containsPosition(e.end)&&t.push(new u(e.end,this.end))):t.push(new u(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,n=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(n=e.end),new u(t,n)}return null}getJoined(e,t=!1){let n=this.isIntersecting(e);if(n||(this.start.isBefore(e.start)?n=t?this.end.isTouching(e.start):this.end.isEqual(e.start):n=t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!n)return null;let r=this.start,i=this.end;return e.start.isBefore(r)&&(r=e.start),e.end.isAfter(i)&&(i=e.end),new u(r,i)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,n=m._createAt(this.start);let r=n.parent;for(;n.path.length>t+1;){const i=r.maxOffset-n.offset;i!==0&&e.push(new u(n,n.getShiftedBy(i))),n.path=n.path.slice(0,-1),n.offset++,r=r.parent}for(;n.path.length<=this.end.path.length;){const i=this.end.path[n.path.length-1],o=i-n.offset;o!==0&&e.push(new u(n,n.getShiftedBy(o))),n.offset=i,n.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new se(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new se(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new se(e);yield t.position;for(const n of t)yield n.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new u(this.start,this.end)]}getTransformedByOperations(e){const t=[new u(this.start,this.end)];for(const n of e)for(let r=0;r<t.length;r++){const i=t[r].getTransformedByOperation(n);t.splice(r,1,...i),r+=i.length-1}for(let n=0;n<t.length;n++){const r=t[n];for(let i=n+1;i<t.length;i++){const o=t[i];(r.containsRange(o)||o.containsRange(r)||r.isEqual(o))&&t.splice(i,1)}}return t}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;const e=this.start.nodeAfter,t=this.end.nodeBefore;return e&&e.is("element")&&e===t?e:null}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(e,t=!1){return this._getTransformedByInsertion(e.position,e.howMany,t)}_getTransformedByMoveOperation(e,t=!1){const n=e.sourcePosition,r=e.howMany,i=e.targetPosition;return this._getTransformedByMove(n,i,r,t)}_getTransformedBySplitOperation(e){const t=this.start._getTransformedBySplitOperation(e);let n=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(n=this.end.getShiftedBy(1)),t.root!=n.root&&(n=this.end.getShiftedBy(-1)),new u(t,n)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new u(this.start);let t=this.start._getTransformedByMergeOperation(e),n=this.end._getTransformedByMergeOperation(e);return t.root!=n.root&&(n=this.end.getShiftedBy(-1)),t.isAfter(n)?(e.sourcePosition.isBefore(e.targetPosition)?(t=m._createAt(n),t.offset=0):(e.deletionPosition.isEqual(t)||(n=e.deletionPosition),t=e.targetPosition),new u(t,n)):new u(t,n)}_getTransformedByInsertion(e,t,n=!1){if(n&&this.containsPosition(e))return[new u(this.start,e),new u(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const r=new u(this.start,this.end);return r.start=r.start._getTransformedByInsertion(e,t),r.end=r.end._getTransformedByInsertion(e,t),[r]}}_getTransformedByMove(e,t,n,r=!1){if(this.isCollapsed){const f=this.start._getTransformedByMove(e,t,n);return[new u(f)]}const i=u._createFromPositionAndShift(e,n),o=t._getTransformedByDeletion(e,n);if(this.containsPosition(t)&&!r&&(i.containsPosition(this.start)||i.containsPosition(this.end))){const f=this.start._getTransformedByMove(e,t,n),p=this.end._getTransformedByMove(e,t,n);return[new u(f,p)]}let a;const l=this.getDifference(i);let c=null;const h=this.getIntersection(i);if(l.length==1?c=new u(l[0].start._getTransformedByDeletion(e,n),l[0].end._getTransformedByDeletion(e,n)):l.length==2&&(c=new u(this.start,this.end._getTransformedByDeletion(e,n))),c?a=c._getTransformedByInsertion(o,n,h!==null||r):a=[],h){const f=new u(h.start._getCombined(i.start,o),h.end._getCombined(i.start,o));a.length==2?a.splice(1,0,f):a.push(f)}return a}_getTransformedByDeletion(e,t){let n=this.start._getTransformedByDeletion(e,t),r=this.end._getTransformedByDeletion(e,t);return n==null&&r==null?null:(n==null&&(n=e),r==null&&(r=e),new u(n,r))}static _createFromPositionAndShift(e,t){const n=e,r=e.getShiftedBy(t);return t>0?new this(n,r):new this(r,n)}static _createIn(e){return new this(m._createAt(e,0),m._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(m._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new d("range-create-from-ranges-empty-array",null);if(e.length==1)return e[0].clone();const t=e[0];e.sort((i,o)=>i.start.isAfter(o.start)?1:-1);const n=e.indexOf(t),r=new this(t.start,t.end);for(let i=n-1;i>=0&&e[i].end.isEqual(r.start);i--)r.start=m._createAt(e[i].start);for(let i=n+1;i<e.length&&e[i].start.isEqual(r.end);i++)r.end=m._createAt(e[i].end);return r}static fromJSON(e,t){return new this(m.fromJSON(e.start,t),m.fromJSON(e.end,t))}}u.prototype.is=function(s){return s==="range"||s==="model:range"};class is extends x(){_modelToViewMapping=new WeakMap;_viewToModelMapping=new WeakMap;_viewToModelLengthCallbacks=new Map;_markerNameToElements=new Map;_elementToMarkerNames=new Map;_deferredBindingRemovals=new Map;_unboundMarkerNames=new Set;_cache=new ei;constructor(){super(),this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new d("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;const n=this.findMappedViewAncestor(t.viewPosition),r=this._viewToModelMapping.get(n),i=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=m._createAt(r,i)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const n=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const r of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(r);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)&&this._cache.stopTracking(t)}bindElementToMarker(e,t){const n=this._markerNameToElements.get(t)||new Set;n.add(e);const r=this._elementToMarkerNames.get(e)||new Set;r.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,r)}unbindElementFromMarkerName(e,t){const n=this._markerNameToElements.get(t);n&&(n.delete(e),n.size==0&&this._markerNameToElements.delete(t));const r=this._elementToMarkerNames.get(e);r&&(r.delete(t),r.size==0&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new u(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new w(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const n={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const n=new Set;for(const r of t)if(r.is("attributeElement"))for(const i of r.getElementsWithSameId())n.add(i);else n.add(r);return n}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,n){if(n!=e){const i=this._toModelOffset(e.parent,e.index,n),o=this._toModelOffset(e,t,e);return i+o}if(e.is("$text"))return t;let r=0;for(let i=0;i<t;i++)r+=this.getModelLength(e.getChild(i));return r}getModelLength(e){const t=[e];let n=0;for(;t.length>0;){const r=t.pop(),i=r.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(r.name);if(i)n+=i(r);else if(this._viewToModelMapping.has(r))n+=1;else if(r.is("$text"))n+=r.data.length;else{if(r.is("uiElement"))continue;for(const o of r.getChildren())t.push(o)}}return n}findPositionIn(e,t){if(t===0)return this._moveViewPositionToTextNode(new g(e,0));if(this._viewToModelLengthCallbacks.size==0&&this._viewToModelMapping.has(e)){const r=this._cache.getClosest(e,t);return this._findPositionStartingFrom(r.viewPosition,r.modelOffset,t,e,!0)}else return this._findPositionStartingFrom(new g(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,n,r,i){let o=e.parent,a=e.offset;if(o.is("$text"))return new g(o,n-t);let l,c=t,h=0;for(;c<n;){if(l=o.getChild(a),!l){if(o==r)throw new d("mapping-model-offset-not-found",this,{modelOffset:n,viewContainer:r});a=o.parent.getChildIndex(o)+1,o=o.parent,i&&this._cache.save(o,a,r,c);continue}i?h=this._getModelLengthAndCache(l,r,c):h=this.getModelLength(l),c+=h,a++}let f=new g(o,a);if(i)for(;f.isAtEnd&&f.parent!==r&&f.parent.parent;){const p=f.parent.parent,_=p.getChildIndex(f.parent)+1;this._cache.save(p,_,r,c),f=new g(p,_)}return c==n?this._moveViewPositionToTextNode(f):this._findPositionStartingFrom(new g(l,0),c-h,n,r,i)}_getModelLengthAndCache(e,t,n){let r=0;if(this._viewToModelMapping.has(e))r=1;else if(e.is("$text"))r=e.data.length;else if(!e.is("uiElement"))for(const i of e.getChildren())r+=this._getModelLengthAndCache(i,t,n+r);return this._cache.save(e.parent,e.index+1,t,n+r),r}_moveViewPositionToTextNode(e){const t=e.nodeBefore,n=e.nodeAfter;return t&&t.is("view:$text")?new g(t,t.data.length):n&&n.is("view:$text")?new g(n,0):e}}class ei extends x(){_cachedMapping=new WeakMap;_nodeToCacheListIndex=new WeakMap;_invalidateOnChildrenChangeCallback=(e,t,n)=>{this._clearCacheInsideParent(t,n.index)};_invalidateOnTextChangeCallback=(e,t)=>{this._clearCacheAfter(t)};save(e,t,n,r){const i=this._cachedMapping.get(n),o=i.cacheMap.get(r);if(o){const h=e.getChild(t-1),f=o.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(o.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(h,f);return}const l={viewPosition:new g(e,t),modelOffset:r};i.maxModelOffset=r>i.maxModelOffset?r:i.maxModelOffset,i.cacheMap.set(r,l);let c=i.cacheList.length-1;for(;c>=0&&i.cacheList[c].modelOffset>r;)c--;if(i.cacheList.splice(c+1,0,l),t>0){const h=e.getChild(t-1);this._nodeToCacheListIndex.set(h,c+1)}}getClosest(e,t){const n=this._cachedMapping.get(e);let r;if(n)if(t>n.maxModelOffset)r=n.cacheList[n.cacheList.length-1];else{const i=n.cacheMap.get(t);i?r=i:r=this._findInCacheList(n.cacheList,t)}else r=this.startTracking(e);return{modelOffset:r.modelOffset,viewPosition:r.viewPosition.clone()}}startTracking(e){const n={viewPosition:new g(e,0),modelOffset:0},r={maxModelOffset:0,cacheList:[n],cacheMap:new Map([[0,n]])};return this._cachedMapping.set(e,r),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),n}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(t==0)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{const n=e.getChild(t-1);this._clearCacheAfter(n)}}_clearCacheAll(e){const t=this._cachedMapping.get(e);t.maxModelOffset>0&&(t.maxModelOffset=0,t.cacheList.length=1,t.cacheMap.clear(),t.cacheMap.set(0,t.cacheList[0]))}_clearCacheAfter(e){const t=this._nodeToCacheListIndex.get(e);if(t===void 0){const r=e.parent;this._cachedMapping.has(r)||this._clearCacheInsideParent(r.parent,r.index);return}let n=e.parent;for(;!this._cachedMapping.has(n);)n=n.parent;this._clearCacheFromCacheIndex(n,t)}_clearCacheFromCacheIndex(e,t){t===0&&(t=1);const n=this._cachedMapping.get(e),r=n.cacheList[t-1];if(!r)return;n.maxModelOffset=r.modelOffset;const i=n.cacheList.splice(t);for(const o of i){n.cacheMap.delete(o.modelOffset);const a=o.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(a)}}_findInCacheList(e,t){let n=0,r=e.length-1,i=r-n>>1,o=e[i];for(;n<r;)o.modelOffset<t?n=i+1:r=i-1,i=n+(r-n>>1),o=e[i];return o.modelOffset<=t?o:e[i-1]}}class ti{_consumable=new Map;_textProxyRegistry=new Map;add(e,t){t=et(t),e instanceof j&&(e=this._getSymbolForTextProxy(e)),this._consumable.has(e)||this._consumable.set(e,new Map),this._consumable.get(e).set(t,!0)}consume(e,t){return t=et(t),e instanceof j&&(e=this._getSymbolForTextProxy(e)),this.test(e,t)?(this._consumable.get(e).set(t,!1),!0):!1}test(e,t){t=et(t),e instanceof j&&(e=this._getSymbolForTextProxy(e));const n=this._consumable.get(e);if(n===void 0)return null;const r=n.get(t);return r===void 0?null:r}revert(e,t){t=et(t),e instanceof j&&(e=this._getSymbolForTextProxy(e));const n=this.test(e,t);return n===!1?(this._consumable.get(e).set(t,!0),!0):n===!0?!1:null}verifyAllConsumed(e){const t=[];for(const[n,r]of this._consumable)for(const[i,o]of r){const a=i.split(":")[0];o&&e==a&&t.push({event:i,item:n.name||n.description})}if(t.length)throw new d("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const n=this._textProxyRegistry.get(e.startOffset);if(n){const r=n.get(e.endOffset);r&&(t=r.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,n=e.endOffset,r=e.parent,i=Symbol("$textProxy:"+e.data);let o,a;return o=this._textProxyRegistry.get(t),o||(o=new Map,this._textProxyRegistry.set(t,o)),a=o.get(n),a||(a=new Map,o.set(n,a)),a.set(r,i),i}}function et(s){const e=s.split(":");return e[0]=="insert"?e[0]:e[0]=="addMarker"||e[0]=="removeMarker"?s:e.length>1?e[0]+":"+e[1]:e[0]}class os extends x(){_conversionApi;_firedEventsMap;constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,n){const r=e.getRefreshedItems(),i=this._createConversionApi(n,r);for(const a of e.getMarkersToRemove())this._convertMarkerRemove(a.name,a.range,i);const o=this._reduceChanges(e.getChanges(),r);for(const a of o)a.type==="insert"?this._convertInsert(u._createFromPositionAndShift(a.position,a.length),i):a.type==="reinsert"?this._convertReinsert(u._createFromPositionAndShift(a.position,a.length),i):a.type==="remove"?this._convertRemove(a.position,a.length,a.name,i):this._convertAttribute(a.range,a.attributeKey,a.attributeOldValue,a.attributeNewValue,i);i.mapper.flushDeferredBindings();for(const a of i.mapper.flushUnboundMarkerNames()){const l=t.get(a).getRange();this._convertMarkerRemove(a,l,i),this._convertMarkerAdd(a,l,i)}for(const a of e.getMarkersToAdd())this._convertMarkerAdd(a.name,a.range,i);i.consumable.verifyAllConsumed("insert")}convert(e,t,n,r={}){const i=this._createConversionApi(n,void 0,r);this._convertInsert(e,i);for(const[o,a]of t)this._convertMarkerAdd(o,a,i);i.consumable.verifyAllConsumed("insert")}convertSelection(e,t,n){const r=this._createConversionApi(n);this.fire("cleanSelection",{selection:e},r);const i=e.getFirstPosition().root;if(!r.mapper.toViewElement(i))return;const o=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(r.consumable,e,o),this.fire("selection",{selection:e},r),!!e.isCollapsed){for(const a of o)if(r.consumable.test(e,"addMarker:"+a.name)){const l=a.getRange();if(!ni(e.getFirstPosition(),a,r.mapper))continue;const c={item:e,markerName:a.name,markerRange:l};this.fire(`addMarker:${a.name}`,c,r)}for(const a of e.getAttributeKeys())if(r.consumable.test(e,"attribute:"+a)){const l={item:e,range:e.getFirstRange(),attributeKey:a,attributeOldValue:null,attributeNewValue:e.getAttribute(a)};this.fire(`attribute:${a}:$text`,l,r)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const r of e.getWalker({shallow:!0}))this._testAndFire("insert",bn(r),t)}_convertRemove(e,t,n,r){this.fire(`remove:${n}`,{position:e,length:t},r)}_convertAttribute(e,t,n,r,i){this._addConsumablesForRange(i.consumable,e,`attribute:${t}`);for(const o of e){const a={item:o.item,range:u._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:n,attributeNewValue:r};this._testAndFire(`attribute:${t}`,a,i)}}_convertReinsert(e,t){const n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(const r of n.map(bn))this.fire(`remove:${r.item.is("element")?r.item.name:"$text"}`,{position:r.range.start,length:r.item.offsetSize,reconversion:!0},t),this._testAndFire("insert",{...r,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if(t.root.rootName=="$graveyard")return;const r=`addMarker:${e}`;if(n.consumable.add(t,r),this.fire(r,{markerName:e,markerRange:t},n),!!n.consumable.consume(t,r)){this._addConsumablesForRange(n.consumable,t,r);for(const i of t.getItems()){if(!n.consumable.test(i,r))continue;const o={item:i,range:u._createOn(i),markerName:e,markerRange:t};this.fire(r,o,n)}}}_convertMarkerRemove(e,t,n){t.root.rootName!="$graveyard"&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},n)}_reduceChanges(e,t){const n={changes:e,refreshedItems:t};return this.fire("reduceChanges",n),n.changes}_addConsumablesForInsert(e,t){for(const n of t){const r=n.item;if(e.test(r,"insert")===null){e.add(r,"insert");for(const i of r.getAttributeKeys())e.add(r,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,n){for(const r of t.getItems())e.add(r,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,"selection");for(const r of n)e.add(t,"addMarker:"+r.name);for(const r of t.getAttributeKeys())e.add(t,"attribute:"+r);return e}_testAndFire(e,t,n){const r=si(e,t),i=t.item.is("$textProxy")?n.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(n),a=o.get(i);if(!a)o.set(i,new Set([r]));else if(!a.has(r))a.add(r);else return;this.fire(r,t,n)}_testAndFireAddAttributes(e,t){const n={item:e,range:u._createOn(e)};for(const r of n.item.getAttributeKeys())n.attributeKey=r,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(r),this._testAndFire(`attribute:${r}`,n,t)}_createConversionApi(e,t=new Set,n={}){const r={...this._conversionApi,consumable:new ti,writer:e,options:n,convertItem:i=>this._convertInsert(u._createOn(i),r),convertChildren:i=>this._convertInsert(u._createIn(i),r,{doNotAddConsumables:!0}),convertAttributes:i=>this._testAndFireAddAttributes(i,r),canReuseView:i=>!t.has(r.mapper.toModelElement(i))};return this._firedEventsMap.set(r,new Map),r}}function ni(s,e,t){const n=e.getRange(),r=Array.from(s.getAncestors());return r.shift(),r.reverse(),!r.some(o=>{if(n.containsItem(o))return!!t.toViewElement(o).getCustomProperty("addHighlight")})}function si(s,e){const t=e.item.is("element")?e.item.name:"$text";return`${s}:${t}`}function bn(s){return{item:s.item,range:u._createFromPositionAndShift(s.previousPosition,s.length)}}class be extends ce{parent=null;_attrs;_index=null;_startOffset=null;constructor(e){super(),this._attrs=ge(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.parent===null?!1:this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),r=e.getAncestors(t);let i=0;for(;n[i]==r[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),r=F(t,n);switch(r){case"prefix":return!0;case"extension":return!1;default:return t[r]<n[r]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}hasAttribute(e){return this._attrs.has(e)}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce((t,n)=>(t[n[0]]=n[1],t),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=ge(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}be.prototype.is=function(s){return s==="node"||s==="model:node"};class L extends x(ce){_lastRangeBackward=!1;_attrs=new Map;_ranges=[];constructor(...e){super(),e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return this._ranges.length===1?this._ranges[0].isCollapsed:!1}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const r of e._ranges)if(t.isEqual(r)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new u(e.start,e.end)}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?new u(e.start,e.end):null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?new u(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,n,r]=e;if(typeof n=="object"&&(r=n,n=void 0),t===null)this._setRanges([]);else if(t instanceof L)this._setRanges(t.getRanges(),t.isBackward);else if(t&&typeof t.getRanges=="function")this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof u)this._setRanges([t],!!r&&!!r.backward);else if(t instanceof m)this._setRanges([new u(t)]);else if(t instanceof be){const i=!!r&&!!r.backward;let o;if(n=="in")o=u._createIn(t);else if(n=="on")o=u._createOn(t);else if(n!==void 0)o=new u(m._createAt(t,n));else throw new d("model-selection-setto-required-second-parameter",[this,t]);this._setRanges([o],i)}else if(oe(t))this._setRanges(t,r&&!!r.backward);else throw new d("model-selection-setto-not-selectable",[this,t])}_setRanges(e,t=!1){const n=Array.from(e),r=n.some(i=>{if(!(i instanceof u))throw new d("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(o=>!o.isEqual(i))});n.length===this._ranges.length&&!r||(this._replaceAllRanges(n),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(this.anchor===null)throw new d("model-selection-setfocus-no-ranges",[this,e]);const n=m._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const r=this.anchor;this._ranges.length&&this._popRange(),n.compareWith(r)=="before"?(this._pushRange(new u(n,r)),this._lastRangeBackward=!0):(this._pushRange(new u(r,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const n=yn(t.start,e);ii(n,t)&&(yield n);const r=t.getWalker();for(const o of r){const a=o.item;o.type=="elementEnd"&&ri(a,e,t)?yield a:o.type=="elementStart"&&a.is("model:element")&&a.root.document.model.schema.isBlock(a)&&r.jumpTo(m._createAt(a,"end"))}const i=yn(t.end,e);oi(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){const t=m._createAt(e,0),n=m._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}toJSON(){const e={ranges:Array.from(this.getRanges()).map(n=>n.toJSON())},t=Object.fromEntries(this.getAttributes());return Object.keys(t).length&&(e.attributes=t),this.isBackward&&(e.isBackward=!0),e}_pushRange(e){this._checkRange(e),this._ranges.push(new u(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new d("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_replaceAllRanges(e){this._removeAllRanges();for(const t of e)this._pushRange(t)}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}L.prototype.is=function(s){return s==="selection"||s==="model:selection"};function as(s,e){return e.has(s)?!1:(e.add(s),s.root.document.model.schema.isBlock(s)&&!!s.parent)}function ri(s,e,t){return as(s,e)&&Ut(s,t)}function yn(s,e){const n=s.parent.root.document.model.schema,r=s.parent.getAncestors({parentFirst:!0,includeSelf:!0});let i=!1;const o=r.find(a=>i?!1:(i=n.isLimit(a),!i&&as(a,e)));return r.forEach(a=>e.add(a)),o}function Ut(s,e){const t=ai(s);return t?!e.containsRange(u._createOn(t),!0):!0}function ii(s,e){return s?e.isCollapsed||s.isEmpty?!0:e.start.isTouching(m._createAt(s,s.maxOffset))?!1:Ut(s,e):!1}function oi(s,e){return s?e.isCollapsed||s.isEmpty?!0:e.end.isTouching(m._createAt(s,0))?!1:Ut(s,e):!1}function ai(s){const e=s.root.document.model.schema;let t=s.parent;for(;t;){if(e.isBlock(t))return t;t=t.parent}}class pe extends x(u){constructor(e,t){super(e,t),li.call(this)}detach(){this.stopListening()}toRange(){return new u(this.start,this.end)}static fromRange(e){return new pe(e.start,e.end)}}pe.prototype.is=function(s){return s==="liveRange"||s==="model:liveRange"||s=="range"||s==="model:range"};function li(){this.listenTo(this.root.document.model,"applyOperation",(s,e)=>{const t=e[0];t.isDocumentOperation&&ci.call(this,t)},{priority:"low"})}function ci(s){const e=this.getTransformedByOperation(s),t=u._createFromRanges(e),n=!t.isEqual(this),r=hi(this,s);let i=null;if(n){t.root.rootName=="$graveyard"&&(s.type=="remove"?i=s.sourcePosition:i=s.deletionPosition);const o=this.toRange();this.start=t.start,this.end=t.end,this.fire("change:range",o,{deletionPosition:i})}else r&&this.fire("change:content",this.toRange(),{deletionPosition:i})}function hi(s,e){switch(e.type){case"insert":return s.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return s.containsPosition(e.sourcePosition)||s.start.isEqual(e.sourcePosition)||s.containsPosition(e.targetPosition);case"split":return s.containsPosition(e.splitPosition)||s.containsPosition(e.insertionPosition)}return!1}class k extends be{_data;constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new k(this.data,this.getAttributes())}static fromJSON(e){return new k(e.data,e.attributes)}}k.prototype.is=function(s){return s==="$text"||s==="model:$text"||s==="text"||s==="model:text"||s==="node"||s==="model:node"};const je="selection:";class K extends x(ce){_selection;constructor(e){super(),this._selection=new ui(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}toJSON(){return this._selection.toJSON()}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return je+e}static _isStoreAttributeKey(e){return e.startsWith(je)}}K.prototype.is=function(s){return s==="selection"||s=="model:selection"||s=="documentSelection"||s=="model:documentSelection"};class ui extends L{markers=new Bt({idProperty:"name"});_model;_document;_attributePriority=new Map;_selectionRestorePosition=null;_hasChangedRange=!1;_overriddenGravityRegister=new Set;_observedMarkers=new Set;constructor(e){super(),this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(t,n)=>{const r=n[0];!r.isDocumentOperation||r.type=="marker"||r.type=="rename"||r.type=="noop"||(this._ranges.length==0&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,"update",(t,n,r,i)=>{this._updateMarker(n,i)}),this.listenTo(this._document,"change",(t,n)=>{fi(this._model,n)})}get isCollapsed(){return this._ranges.length===0?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e<this._ranges.length;e++)this._ranges[e].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...e){super.setTo(...e),this._updateAttributes(!0),this.updateMarkers()}setFocus(e,t){super.setFocus(e,t),this._updateAttributes(!0),this.updateMarkers()}setAttribute(e,t){if(this._setAttribute(e,t)){const n=[e];this.fire("change:attribute",{attributeKeys:n,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}overrideGravity(){const e=Fs();return this._overriddenGravityRegister.add(e),this._overriddenGravityRegister.size===1&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new d("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this.updateMarkers()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){const t=this._prepareRange(e);t&&this._ranges.push(t)}toJSON(){const e=super.toJSON();return this.markers.length&&(e.markers=this.markers.map(t=>t.toJSON())),e}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new d("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=pe.fromRange(e);return t.on("change:range",(n,r,i)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=i.deletionPosition;const o=this._ranges.indexOf(t);this._ranges.splice(o,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const r of this._model.markers){const i=r.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const o=r.getRange();for(const a of this.getRanges())o.containsRange(a,!a.isCollapsed)&&e.push(r)}const n=Array.from(this.markers);for(const r of e)this.markers.has(r)||(this.markers.add(r),t=!0);for(const r of Array.from(this.markers))e.includes(r)||(this.markers.remove(r),t=!0);t&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(e,t){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let r=!1;const i=Array.from(this.markers),o=this.markers.has(e);if(!t)o&&(this.markers.remove(e),r=!0);else{let a=!1;for(const l of this.getRanges())if(t.containsRange(l,!l.isCollapsed)){a=!0;break}a&&!o?(this.markers.add(e),r=!0):!a&&o&&(this.markers.remove(e),r=!0)}r&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateAttributes(e){const t=ge(this._getSurroundingAttributes()),n=ge(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[i,o]of this._attributePriority)o=="low"&&(this._attrs.delete(i),this._attributePriority.delete(i));this._setAttributesTo(t);const r=[];for(const[i,o]of this.getAttributes())(!n.has(i)||n.get(i)!==o)&&r.push(i);for(const[i]of n)this.hasAttribute(i)||r.push(i);r.length>0&&this.fire("change:attribute",{attributeKeys:r,directChange:!1})}_setAttribute(e,t,n=!0){const r=n?"normal":"low";return r=="low"&&this._attributePriority.get(e)=="normal"||super.getAttribute(e)===t?!1:(this._attrs.set(e,t),this._attributePriority.set(e,r),!0)}_removeAttribute(e,t=!0){const n=t?"normal":"low";return n=="low"&&this._attributePriority.get(e)=="normal"||(this._attributePriority.set(e,n),!super.hasAttribute(e))?!1:(this._attrs.delete(e),!0)}_setAttributesTo(e){const t=new Set;for(const[n,r]of this.getAttributes())e.get(n)!==r&&this._removeAttribute(n,!1);for(const[n,r]of e)this._setAttribute(n,r,!1)&&t.add(n);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())t.startsWith(je)&&(yield[t.substr(je.length),e.getAttribute(t)])}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if(e.root.rootName=="$graveyard")return null;let n=null;if(this.isCollapsed){const r=e.textNode?e.textNode:e.nodeBefore,i=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(n=Oe(r,t)),n||(n=Oe(i,t)),!this.isGravityOverridden&&!n){let o=r;for(;o&&!n;)o=o.previousSibling,n=Oe(o,t)}if(!n){let o=i;for(;o&&!n;)o=o.nextSibling,n=Oe(o,t)}n||(n=this.getStoredAttributes())}else{const r=this.getFirstRange();for(const i of r){if(i.item.is("element")&&t.isObject(i.item)){n=Oe(i.item,t);break}if(i.type=="text"){n=i.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Oe(s,e){if(!s)return null;if(s instanceof j||s instanceof k)return s.getAttributes();if(!e.isInline(s))return null;if(!e.isObject(s))return[];const t=[];for(const[n,r]of s.getAttributes())e.checkAttribute("$text",n)&&e.getAttributeProperties(n).copyFromObject!==!1&&t.push([n,r]);return t}function fi(s,e){const t=s.document.differ;for(const n of t.getChanges()){if(n.type!="insert")continue;const r=n.position.parent;n.length===r.maxOffset&&s.enqueueChange(e,o=>{const a=Array.from(r.getAttributeKeys()).filter(l=>l.startsWith(je));for(const l of a)o.removeAttribute(l,r)})}}class $e{_nodes=[];_offsetToNode=[];constructor(e){e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(e){return this._nodes[e]||null}getNodeAtOffset(e){return this._offsetToNode[e]||null}getNodeIndex(e){return e.index}getNodeStartOffset(e){return e.startOffset}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new d("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;const t=this._offsetToNode[e];if(!t)throw new d("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){const n=[];for(const i of t){if(!(i instanceof be))throw new d("model-nodelist-insertnodes-not-node",this);n.push(i)}let r=this.indexToOffset(e);Qt(this._nodes,n,e),Qt(this._offsetToNode,di(n),r);for(let i=e;i<this._nodes.length;i++)this._nodes[i]._index=i,this._nodes[i]._startOffset=r,r+=this._nodes[i].offsetSize}_removeNodes(e,t=1){if(t==0)return[];let n=this.indexToOffset(e);const r=this._nodes.splice(e,t),i=r[r.length-1],o=i.startOffset+i.offsetSize-n;this._offsetToNode.splice(n,o);for(const a of r)a._index=null,a._startOffset=null;for(let a=e;a<this._nodes.length;a++)this._nodes[a]._index=a,this._nodes[a]._startOffset=n,n+=this._nodes[a].offsetSize;return r}_removeNodesArray(e){if(e.length==0)return;for(const n of e)n._index=null,n._startOffset=null;this._nodes=this._nodes.filter(n=>n.index!==null),this._offsetToNode=this._offsetToNode.filter(n=>n.index!==null);let t=0;for(let n=0;n<this._nodes.length;n++)this._nodes[n]._index=n,this._nodes[n]._startOffset=t,t+=this._nodes[n].offsetSize}toJSON(){return this._nodes.map(e=>e.toJSON())}}function di(s){const e=[];let t=0;for(const n of s)for(let r=0;r<n.offsetSize;r++)e[t++]=n;return e}class C extends be{name;_children=new $e;constructor(e,t,n){super(t),this.name=e,n&&this._insertChild(0,n)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const n of e)t=t.getChildAtOffset(n);return t}findAncestor(e,t={}){let n=t.includeSelf?this:this.parent;for(;n;){if(n.name===e)return n;n=n.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?gi(this._children):void 0;return new C(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=mi(t);for(const r of n)r.parent!==null&&r._remove(),r.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const r of n)r.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}static fromJSON(e){let t;if(e.children){t=[];for(const n of e.children)n.name?t.push(C.fromJSON(n)):t.push(k.fromJSON(n))}return new C(e.name,e.attributes,t)}}C.prototype.is=function(s,e){return e?e===this.name&&(s==="element"||s==="model:element"):s==="element"||s==="model:element"||s==="node"||s==="model:node"};function mi(s){if(typeof s=="string")return[new k(s)];oe(s)||(s=[s]);const e=[];for(const t of s)typeof t=="string"?e.push(new k(t)):t instanceof j?e.push(new k(t.data,t.getAttributes())):e.push(t);return e}function gi(s){const e=[];for(const t of s)e.push(t._clone(!0));return e}class ls{_dispatchers;constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class pi extends ls{elementToElement(e){return this.add(Ii(e))}elementToStructure(e){return this.add(Fi(e))}attributeToElement(e){return this.add(Di(e))}attributeToAttribute(e){return this.add(Bi(e))}markerToElement(e){return this.add(Vi(e))}markerToHighlight(e){return this.add($i(e))}markerToData(e){return this.add(Li(e))}}function cs(){return(s,e,t)=>{if(!t.consumable.consume(e.item,s.name))return;const n=t.writer,r=t.mapper.toViewPosition(e.range.start),i=n.createText(e.item.data);n.insert(r,i)}}function hs(){return(s,e,t)=>{t.convertAttributes(e.item),!e.reconversion&&e.item.is("element")&&!e.item.isEmpty&&t.convertChildren(e.item)}}function _i(){return(s,e,t)=>{if(e.reconversion)return;const n=t.mapper.toViewPosition(e.position),r=e.position.getShiftedBy(e.length),i=t.mapper.toViewPosition(r,{isPhantom:!0}),o=t.writer.createRange(n,i);fs(o.getTrimmed(),t)}}function us(s,e){const t=s.createAttributeElement("span",e.attributes);return e.classes&&t._addClass(e.classes),typeof e.priority=="number"&&(t._priority=e.priority),t._id=e.id,t}function wi(){return(s,e,t)=>{const n=e.selection;if(n.isCollapsed||!t.consumable.consume(n,"selection"))return;const r=[];for(const i of n.getRanges())r.push(t.mapper.toViewRange(i));t.writer.setSelection(r,{backward:n.isBackward})}}function bi(){return(s,e,t)=>{const n=e.selection;if(!n.isCollapsed||!t.consumable.consume(n,"selection"))return;const r=t.writer,i=n.getFirstPosition(),o=t.mapper.toViewPosition(i),a=r.breakAttributes(o);r.setSelection(a)}}function yi(){return(s,e,t)=>{const n=t.writer,r=n.document.selection;for(const i of r.getRanges())i.isCollapsed&&i.end.parent.isAttached()&&t.writer.mergeAttributes(i.start);n.setSelection(null)}}function vi(s){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const r=s(t.attributeOldValue,n,t),i=s(t.attributeNewValue,n,t);if(!r&&!i)return;n.consumable.consume(t.item,e.name);const o=n.writer,a=o.document.selection;if(t.item instanceof L||t.item instanceof K)o.wrap(a.getFirstRange(),i);else{let l=n.mapper.toViewRange(t.range);t.attributeOldValue!==null&&r&&(l=o.unwrap(l,r)),t.attributeNewValue!==null&&i&&o.wrap(l,i)}}}function Pi(s,e=Gi){return(t,n,r)=>{if(!e(n.item,r.consumable,{preflight:!0}))return;const i=s(n.item,r,n);if(!i)return;e(n.item,r.consumable);const o=n.reconversion&&ds(n.item,r)||r.mapper.toViewPosition(n.range.start);r.mapper.bindElements(n.item,i),r.writer.insert(o,i),r.convertAttributes(n.item),ws(i,n.item.getChildren(),r,{reconversion:n.reconversion})}}function Ci(s,e){return(t,n,r)=>{if(!e(n.item,r.consumable,{preflight:!0}))return;const i=new Map;r.writer._registerSlotFactory(zi(n.item,i,r));const o=s(n.item,r,n);if(r.writer._clearSlotFactory(),!o)return;Ji(n.item,i,r),e(n.item,r.consumable);const a=n.reconversion&&ds(n.item,r)||r.mapper.toViewPosition(n.range.start);r.mapper.bindElements(n.item,o),r.writer.insert(a,o),r.convertAttributes(n.item),Ui(o,i,r,{reconversion:n.reconversion})}}function ki(s){return(e,t,n)=>{t.isOpening=!0;const r=s(t,n);t.isOpening=!1;const i=s(t,n);if(!r||!i)return;const o=t.markerRange;if(o.isCollapsed&&!n.consumable.consume(o,e.name))return;for(const c of o)if(!n.consumable.consume(c.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(o.start),r),n.mapper.bindElementToMarker(r,t.markerName),o.isCollapsed||(l.insert(a.toViewPosition(o.end),i),n.mapper.bindElementToMarker(i,t.markerName)),e.stop()}}function fs(s,e){const t=e.writer.remove(s);for(const n of e.writer.createRangeIn(t).getItems())e.mapper.unbindViewElement(n,{defer:!0});return s.start}function ds(s,e){const t=e.mapper.toViewElement(s);return t&&fs(e.writer.createRangeOn(t),e)}function Si(){return(s,e,t)=>{const n=t.mapper.markerNameToElements(e.markerName);if(n){for(const r of n)t.mapper.unbindElementFromMarkerName(r,e.markerName),t.writer.clear(t.writer.createRangeOn(r),r);t.writer.clearClonedElementsGroup(e.markerName),s.stop()}}}function Ai(s){return(e,t,n)=>{const r=s(t.markerName,n);if(!r)return;const i=t.markerRange;n.consumable.consume(i,e.name)&&(vn(i,!1,n,t,r),vn(i,!0,n,t,r),e.stop())}}function vn(s,e,t,n,r){const i=e?s.start:s.end,o=i.nodeAfter&&i.nodeAfter.is("element")?i.nodeAfter:null,a=i.nodeBefore&&i.nodeBefore.is("element")?i.nodeBefore:null;if(o||a){let c,h;e&&o||!e&&!a?(c=o,h=!0):(c=a,h=!1);const f=t.mapper.toViewElement(c);if(f){Ei(f,e,h,t,n,r);return}}const l=t.mapper.toViewPosition(i);Ri(l,e,t,n,r)}function Ei(s,e,t,n,r,i){const o=`data-${i.group}-${e?"start":"end"}-${t?"before":"after"}`,a=s.hasAttribute(o)?s.getAttribute(o).split(","):[];a.unshift(i.name),n.writer.setAttribute(o,a.join(","),s),n.mapper.bindElementToMarker(s,r.markerName)}function Ri(s,e,t,n,r){const i=`${r.group}-${e?"start":"end"}`,o=r.name?{name:r.name}:null,a=t.writer.createUIElement(i,o);t.writer.insert(s,a),t.mapper.bindElementToMarker(a,n.markerName)}function Ti(s){return(e,t,n)=>{const r=s(t.markerName,n);if(!r)return;const i=n.mapper.markerNameToElements(t.markerName);if(!i)return;for(const a of i)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("containerElement")?(o(`data-${r.group}-start-before`,a),o(`data-${r.group}-start-after`,a),o(`data-${r.group}-end-before`,a),o(`data-${r.group}-end-after`,a)):n.writer.clear(n.writer.createRangeOn(a),a);n.writer.clearClonedElementsGroup(t.markerName),e.stop();function o(a,l){if(l.hasAttribute(a)){const c=new Set(l.getAttribute(a).split(","));c.delete(r.name),c.size==0?n.writer.removeAttribute(a,l):n.writer.setAttribute(a,Array.from(c).join(","),l)}}}}function Mi(s){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const r=s(t.attributeOldValue,n,t),i=s(t.attributeNewValue,n,t);if(!r&&!i)return;n.consumable.consume(t.item,e.name);const o=n.mapper.toViewElement(t.item),a=n.writer;if(!o)throw new d("conversion-attribute-to-attribute-on-text",n.dispatcher,t);if(t.attributeOldValue!==null&&r){let l=r.value;r.key=="style"&&(typeof r.value=="string"?l=new Ve(a.document.stylesProcessor).setTo(r.value).getStylesEntries().map(([c])=>c):l=Object.keys(r.value)),a.removeAttribute(r.key,l,o)}if(t.attributeNewValue!==null&&i){let l=i.value;i.key=="style"&&typeof i.value=="string"&&(l=Object.fromEntries(new Ve(a.document.stylesProcessor).setTo(i.value).getStylesEntries())),a.setAttribute(i.key,l,!1,o)}}}function Ni(s){return(e,t,n)=>{if(!t.item||!(t.item instanceof L||t.item instanceof K)&&!t.item.is("$textProxy"))return;const r=jt(s,t,n);if(!r||!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=us(i,r),a=i.document.selection;if(t.item instanceof L||t.item instanceof K)i.wrap(a.getFirstRange(),o);else{const l=n.mapper.toViewRange(t.range),c=i.wrap(l,o);for(const h of c.getItems())if(h.is("attributeElement")&&h.isSimilar(o)){n.mapper.bindElementToMarker(h,t.markerName);break}}}}function xi(s){return(e,t,n)=>{if(!t.item||!(t.item instanceof C))return;const r=jt(s,t,n);if(!r||!n.consumable.test(t.item,e.name))return;const i=n.mapper.toViewElement(t.item);if(i&&i.getCustomProperty("addHighlight")){n.consumable.consume(t.item,e.name);for(const a of u._createIn(t.item))n.consumable.consume(a.item,e.name);i.getCustomProperty("addHighlight")(i,r,n.writer),n.mapper.bindElementToMarker(i,t.markerName)}}}function Oi(s){return(e,t,n)=>{if(t.markerRange.isCollapsed)return;const r=jt(s,t,n);if(!r)return;const i=us(n.writer,r),o=n.mapper.markerNameToElements(t.markerName);if(o){for(const a of o)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(a),i):a.getCustomProperty("removeHighlight")(a,r.id,n.writer);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}}function Ii(s){const e=ms(s.model),t=Ge(s.view,"container");return e.attributes.length&&(e.children=!0),n=>{n.on(`insert:${e.name}`,Pi(t,_s(e)),{priority:s.converterPriority||"normal"}),(e.children||e.attributes.length)&&n.on("reduceChanges",ps(e),{priority:"low"})}}function Fi(s){const e=ms(s.model),t=Ge(s.view,"container");return e.children=!0,n=>{if(n._conversionApi.schema.checkChild(e.name,"$text"))throw new d("conversion-element-to-structure-disallowed-text",n,{elementName:e.name});n.on(`insert:${e.name}`,Ci(t,_s(e)),{priority:s.converterPriority||"normal"}),n.on("reduceChanges",ps(e),{priority:"low"})}}function Di(s){s=ae(s);let e=s.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const r of e.values)s.view[r]=Ge(s.view[r],"attribute");else s.view=Ge(s.view,"attribute");const n=gs(s);return r=>{r.on(t,vi(n),{priority:s.converterPriority||"normal"})}}function Bi(s){s=ae(s);let e=s.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const r of e.values)s.view[r]=Pn(s.view[r]);else s.view=Pn(s.view);const n=gs(s);return r=>{r.on(t,Mi(n),{priority:s.converterPriority||"normal"})}}function Vi(s){const e=Ge(s.view,"ui");return t=>{t.on(`addMarker:${s.model}`,ki(e),{priority:s.converterPriority||"normal"}),t.on(`removeMarker:${s.model}`,Si(),{priority:s.converterPriority||"normal"})}}function Li(s){s=ae(s);const e=s.model;let t=s.view;return t||(t=n=>({group:e,name:n.substr(s.model.length+1)})),n=>{n.on(`addMarker:${e}`,Ai(t),{priority:s.converterPriority||"normal"}),n.on(`removeMarker:${e}`,Ti(t),{priority:s.converterPriority||"normal"})}}function $i(s){return e=>{e.on(`addMarker:${s.model}`,Ni(s.view),{priority:s.converterPriority||"normal"}),e.on(`addMarker:${s.model}`,xi(s.view),{priority:s.converterPriority||"normal"}),e.on(`removeMarker:${s.model}`,Oi(s.view),{priority:s.converterPriority||"normal"})}}function ms(s){return typeof s=="string"&&(s={name:s}),{name:s.name,attributes:s.attributes?ie(s.attributes):[],children:!!s.children}}function Ge(s,e){return typeof s=="function"?s:(t,n)=>Wi(s,n,e)}function Wi(s,e,t){typeof s=="string"&&(s={name:s});let n;const r=e.writer,i=Object.assign({},s.attributes);if(t=="container")n=r.createContainerElement(s.name,i);else if(t=="attribute"){const o={priority:s.priority||Ee.DEFAULT_PRIORITY};n=r.createAttributeElement(s.name,i,o)}else n=r.createUIElement(s.name,i);if(s.styles){const o=Object.keys(s.styles);for(const a of o)r.setStyle(a,s.styles[a],n)}if(s.classes){const o=s.classes;if(typeof o=="string")r.addClass(o,n);else for(const a of o)r.addClass(a,n)}return n}function gs(s){return s.model.values?(e,t,n)=>{const r=s.view[e];return r?r(e,t,n):null}:s.view}function Pn(s){return typeof s=="string"?e=>({key:s,value:e}):typeof s=="object"?s.value?()=>s:e=>({key:s.key,value:e}):s}function jt(s,e,t){const n=typeof s=="function"?s(e,t):{...s};return n?(n.priority||(n.priority=10),n.id||(n.id=e.markerName),n):null}function qi(s){return(e,t)=>{if(!e.is("element",s.name))return!1;if(t.type=="attribute"){if(s.attributes.includes(t.attributeKey))return!0}else{if(s.children)return!0}return!1}}function ps(s){const e=qi(s);return(t,n)=>{const r=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const i of n.changes){const o=i.type=="attribute"?i.range.start.nodeAfter:i.position.parent;if(!o||!e(o,i)||i.type=="reinsert"){r.push(i);continue}if(i.type=="insert"&&i.action=="rename"&&n.refreshedItems.add(i.position.nodeAfter),!n.reconvertedElements.has(o)){n.reconvertedElements.add(o);const a=m._createBefore(o);let l=r.length;for(let c=r.length-1;c>=0;c--){const h=r[c],p=(h.type=="attribute"?h.range.start:h.position).compareWith(a);if(p=="before"||h.type=="remove"&&p=="same")break;l=c}r.splice(l,0,{type:"reinsert",name:o.name,position:a,length:1})}}n.changes=r}}function _s(s){return(e,t,n={})=>{const r=["insert"];for(const i of s.attributes)e.hasAttribute(i)&&r.push(`attribute:${i}`);return r.every(i=>t.test(e,i))?(n.preflight||r.forEach(i=>t.consume(e,i)),!0):!1}}function zi(s,e,t){return(n,r)=>{const i=n.createContainerElement("$slot");let o=null;if(r==="children")o=Array.from(s.getChildren());else if(typeof r=="function")o=Array.from(s.getChildren()).filter(a=>r(a));else throw new d("conversion-slot-mode-unknown",t.dispatcher,{modeOrFilter:r});return e.set(i,o),i}}function Ji(s,e,t){const n=Array.from(e.values()).flat(),r=new Set(n);if(r.size!=n.length)throw new d("conversion-slot-filter-overlap",t.dispatcher,{element:s});if(r.size!=s.childCount)throw new d("conversion-slot-filter-incomplete",t.dispatcher,{element:s})}function Ui(s,e,t,n){t.mapper.on("modelToViewPosition",o,{priority:"highest"});let r=null,i=null;for([r,i]of e)ws(s,i,t,n),t.writer.setCustomProperty("$structureSlotParent",!0,r.parent),t.writer.move(t.writer.createRangeIn(r),t.writer.createPositionBefore(r)),t.writer.remove(r);t.mapper.off("modelToViewPosition",o);function o(a,l){const c=l.modelPosition.nodeAfter,h=i.indexOf(c);h<0||(l.viewPosition=l.mapper.findPositionIn(r,h))}}function ws(s,e,t,n){for(const r of e)ji(s.root,r,t,n)||t.convertItem(r)}function ji(s,e,t,n){const{writer:r,mapper:i}=t;if(!n.reconversion)return!1;const o=i.toViewElement(e);return!o||o.root==s||!t.canReuseView(o)?!1:(r.move(r.createRangeOn(o),i.toViewPosition(m._createBefore(e))),!0)}function Gi(s,e,{preflight:t}={}){return t?e.test(s,"insert"):e.consume(s,"insert")}function bs(s){const{schema:e,document:t}=s.model;for(const n of t.getRoots())if(n.isEmpty&&!e.checkChild(n,"$text")&&e.checkChild(n,"paragraph"))return s.insertElement("paragraph",n),!0;return!1}function ys(s,e,t){const n=t.createContext(s);return!(!t.checkChild(n,"paragraph")||!t.checkChild(n.push("paragraph"),e))}function vs(s,e){const t=e.createElement("paragraph");return e.insert(t,s),e.createPositionAt(t,0)}class Hi extends ls{elementToElement(e){return this.add(Ps(e))}elementToAttribute(e){return this.add(Yi(e))}attributeToAttribute(e){return this.add(Qi(e))}elementToMarker(e){return this.add(Zi(e))}dataToMarker(e){return this.add(eo(e))}}function Cn(){return(s,e,t)=>{if(!e.modelRange&&t.consumable.consume(e.viewItem,{name:!0})){const{modelRange:n,modelCursor:r}=t.convertChildren(e.viewItem,e.modelCursor);e.modelRange=n,e.modelCursor=r}}}function Ki(){return(s,e,{schema:t,consumable:n,writer:r})=>{let i=e.modelCursor;if(!n.test(e.viewItem))return;if(!t.checkChild(i,"$text")){if(!ys(i,"$text",t)||e.viewItem.data.trim().length==0)return;i=vs(i,r)}n.consume(e.viewItem);const o=r.createText(e.viewItem.data);r.insert(o,i),e.modelRange=r.createRange(i,i.getShiftedBy(o.offsetSize)),e.modelCursor=e.modelRange.end}}function Xi(s,e){return(t,n)=>{const r=n.newSelection,i=[];for(const a of r.getRanges())i.push(e.toModelRange(a));const o=s.createSelection(i,{backward:r.isBackward});o.isEqual(s.document.selection)||s.change(a=>{a.setSelection(o)})}}function Ps(s){s=ae(s);const e=Ft(s),t=Gt(s.view),n=t?`element:${t}`:"element";return r=>{r.on(n,e,{priority:s.converterPriority||"normal"})}}function Yi(s){s=ae(s),Cs(s);const e=ks(s,!1),t=Gt(s.view),n=t?`element:${t}`:"element";return r=>{r.on(n,e,{priority:s.converterPriority||"low"})}}function Qi(s){s=ae(s);let e=null;(typeof s.view=="string"||s.view.key)&&(e=so(s)),Cs(s,e);const t=ks(s,!0);return n=>{n.on("element",t,{priority:s.converterPriority||"low"})}}function Zi(s){const e=oo(s.model);return Ps({...s,model:e})}function eo(s){s=ae(s),s.model||(s.model=r=>r?s.view+":"+r:s.view);const e={view:s.view,model:s.model},t=Ft(kn(e,"start")),n=Ft(kn(e,"end"));return r=>{r.on(`element:${s.view}-start`,t,{priority:s.converterPriority||"normal"}),r.on(`element:${s.view}-end`,n,{priority:s.converterPriority||"normal"});const i=gt.low,o=gt.highest,a=gt.get(s.converterPriority)/o;r.on("element",to(e),{priority:i+a})}}function to(s){return(e,t,n)=>{const r=`data-${s.view}`;if(!n.consumable.test(t.viewItem,{attributes:r+"-end-after"})&&!n.consumable.test(t.viewItem,{attributes:r+"-start-after"})&&!n.consumable.test(t.viewItem,{attributes:r+"-end-before"})&&!n.consumable.test(t.viewItem,{attributes:r+"-start-before"}))return;t.modelRange||Object.assign(t,n.convertChildren(t.viewItem,t.modelCursor)),n.consumable.consume(t.viewItem,{attributes:r+"-end-after"})&&i(t.modelRange.end,t.viewItem.getAttribute(r+"-end-after").split(",")),n.consumable.consume(t.viewItem,{attributes:r+"-start-after"})&&i(t.modelRange.end,t.viewItem.getAttribute(r+"-start-after").split(",")),n.consumable.consume(t.viewItem,{attributes:r+"-end-before"})&&i(t.modelRange.start,t.viewItem.getAttribute(r+"-end-before").split(",")),n.consumable.consume(t.viewItem,{attributes:r+"-start-before"})&&i(t.modelRange.start,t.viewItem.getAttribute(r+"-start-before").split(","));function i(o,a){for(const l of a){const c=s.model(l,n),h=n.writer.createElement("$marker",{"data-name":c});n.writer.insert(h,o),t.modelCursor.isEqual(o)?t.modelCursor=t.modelCursor.getShiftedBy(1):t.modelCursor=t.modelCursor._getTransformedByInsertion(o,1),t.modelRange=t.modelRange._getTransformedByInsertion(o,1)[0]}}}}function Gt(s){return typeof s=="string"?s:typeof s=="object"&&typeof s.name=="string"?s.name:null}function Ft(s){const e=new ze(s.view);return(t,n,r)=>{const i=e.match(n.viewItem);if(!i)return;const o=i.match;if(o.name=!0,!r.consumable.test(n.viewItem,o))return;const a=no(s.model,n.viewItem,r);a&&r.safeInsert(a,n.modelCursor)&&(r.consumable.consume(n.viewItem,o),r.convertChildren(n.viewItem,a),r.updateConversionResult(a,n))}}function no(s,e,t){return s instanceof Function?s(e,t):t.writer.createElement(s)}function so(s){typeof s.view=="string"&&(s.view={key:s.view});const e=s.view.key,t=typeof s.view.value>"u"?/[\s\S]*/:s.view.value;let n;return e=="class"||e=="style"?n={[e=="class"?"classes":"styles"]:t}:n={attributes:{[e]:t}},s.view.name&&(n.name=s.view.name),s.view=n,e}function Cs(s,e=null){const t=e===null?!0:i=>i.getAttribute(e),n=typeof s.model!="object"?s.model:s.model.key,r=typeof s.model!="object"||typeof s.model.value>"u"?t:s.model.value;s.model={key:n,value:r}}function ks(s,e){const t=new ze(s.view);return(n,r,i)=>{if(!r.modelRange&&e)return;const o=t.match(r.viewItem);if(!o||(ro(s.view,r.viewItem)?o.match.name=!0:delete o.match.name,!i.consumable.test(r.viewItem,o.match)))return;const a=s.model.key,l=typeof s.model.value=="function"?s.model.value(r.viewItem,i,r):s.model.value;if(l==null)return;r.modelRange||Object.assign(r,i.convertChildren(r.viewItem,r.modelCursor)),io(r.modelRange,{key:a,value:l},e,i)&&(i.consumable.test(r.viewItem,{name:!0})&&(o.match.name=!0),i.consumable.consume(r.viewItem,o.match))}}function ro(s,e){const t=typeof s=="function"?s(e):s;return typeof t=="object"&&!Gt(t)?!1:!t.classes&&!t.attributes&&!t.styles}function io(s,e,t,n){let r=!1;for(const i of Array.from(s.getItems({shallow:t})))n.schema.checkAttribute(i,e.key)&&(r=!0,!i.hasAttribute(e.key)&&n.writer.setAttribute(e.key,e.value,i));return r}function oo(s){return(e,t)=>{const n=typeof s=="string"?s:s(e,t);return t.writer.createElement("$marker",{"data-name":n})}}function kn(s,e){const t=(n,r)=>{const i=n.getAttribute("name"),o=s.model(i,r);return r.writer.createElement("$marker",{"data-name":o})};return{view:`${s.view}-${e}`,model:t}}class fl extends z(){model;view;mapper;downcastDispatcher;constructor(e,t){super(),this.model=e,this.view=new Qr(t),this.mapper=new is,this.downcastDispatcher=new os({mapper:this.mapper,schema:e.schema});const n=this.model.document,r=n.selection,i=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(n,"change",()=>{this.view.change(o=>{this.downcastDispatcher.convertChanges(n.differ,i,o),this.downcastDispatcher.convertSelection(r,i,o)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",Xi(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",cs(),{priority:"lowest"}),this.downcastDispatcher.on("insert",hs(),{priority:"lowest"}),this.downcastDispatcher.on("remove",_i(),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",yi()),this.downcastDispatcher.on("selection",wi(),{priority:"low"}),this.downcastDispatcher.on("selection",bi(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(o=>{if(o.rootName=="$graveyard")return null;const a=new Gn(this.view.document,o.name);return a.rootName=o.rootName,this.mapper.bindElements(o,a),a})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t=typeof e=="string"?e:e.name,n=this.model.markers.get(t);if(!n)throw new d("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(n)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}class ao extends z(){_sourceDefinitions={};_attributeProperties=Object.create(null);_customChildChecks=new Map;_customAttributeChecks=new Map;_genericCheckSymbol=Symbol("$generic");_compiledDefinitions;constructor(){super(),this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new re(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new re(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new d("schema-cannot-register-item-twice",this,{itemName:e});this._sourceDefinitions[e]=[Object.assign({},t)],this._clearCache()}extend(e,t){if(!this._sourceDefinitions[e])throw new d("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return typeof e=="string"?t=e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?t="$text":t=e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!!(t&&t.isBlock)}isLimit(e){const t=this.getDefinition(e);return t?!!(t.isLimit||t.isObject):!1}isObject(e){const t=this.getDefinition(e);return t?!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent):!1}isInline(e){const t=this.getDefinition(e);return!!(t&&t.isInline)}isSelectable(e){const t=this.getDefinition(e);return t?!!(t.isSelectable||t.isObject):!1}isContent(e){const t=this.getDefinition(e);return t?!!(t.isContent||t.isObject):!1}checkChild(e,t){return t?this._checkContextMatch(e,t):!1}checkAttribute(e,t){const n=this.getDefinition(e.last);if(!n)return!1;const r=this._evaluateAttributeChecks(e,t);return r!==void 0?r:n.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof m){const n=e.nodeBefore,r=e.nodeAfter;if(!(n instanceof C))throw new d("schema-check-merge-no-element-before",this);if(!(r instanceof C))throw new d("schema-check-merge-no-element-after",this);return this.checkMerge(n,r)}if(this.isLimit(e)||this.isLimit(t))return!1;for(const n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e,t){const n=t!==void 0?t:this._genericCheckSymbol,r=this._customChildChecks.get(n)||[];r.push(e),this._customChildChecks.set(n,r)}addAttributeCheck(e,t){const n=t!==void 0?t:this._genericCheckSymbol,r=this._customAttributeChecks.get(n)||[];r.push(e),this._customAttributeChecks.set(n,r)}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||Object.create(null)}getLimitElement(e){let t;for(e instanceof m?t=e.parent:t=(e instanceof u?[e]:Array.from(e.getRanges())).reduce((r,i)=>{const o=i.getCommonAncestor();return r?r.getCommonAncestor(o,{includeSelf:!0}):o},null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const r=[...e.getFirstPosition().getAncestors(),new k("",e.getAttributes())];return this.checkAttribute(r,t)}else{const n=e.getRanges();for(const r of n)for(const i of r)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=ko(e);for(const n of e)yield*this._getValidRangesForRange(n,t)}getNearestSelectionRange(e,t="both"){if(e.root.rootName=="$graveyard")return null;if(this.checkChild(e,"$text"))return new u(e);let n,r;const i=e.getAncestors().reverse().find(o=>this.isLimit(o))||e.root;(t=="both"||t=="backward")&&(n=new se({boundaries:u._createIn(i),startPosition:e,direction:"backward"})),(t=="both"||t=="forward")&&(r=new se({boundaries:u._createIn(i),startPosition:e}));for(const o of Co(n,r)){const a=o.walker==n?"elementEnd":"elementStart",l=o.value;if(l.type==a&&this.isObject(l.item))return u._createOn(l.item);if(this.checkChild(l.nextPosition,"$text"))return new u(l.nextPosition)}return null}findAllowedParent(e,t){let n=e.parent;for(;n;){if(this.checkChild(n,t))return n;if(this.isLimit(n))return null;n=n.parent}return null}setAllowedAttributes(e,t,n){const r=n.model;for(const[i,o]of Object.entries(t))r.schema.checkAttribute(e,i)&&n.setAttribute(i,o,e)}removeDisallowedAttributes(e,t){for(const n of e)if(n.is("$text"))Sn(this,n,t);else{const i=u._createIn(n).getPositions();for(const o of i){const a=o.nodeBefore||o.parent;Sn(this,a,t)}}}getAttributesWithProperty(e,t,n){const r={};for(const[i,o]of e.getAttributes()){const a=this.getAttributeProperties(i);a[t]!==void 0&&(n===void 0||n===a[t])&&(r[i]=o)}return r}createContext(e){return new re(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,n=Object.keys(t);for(const i of n)e[i]=lo(t[i],i);const r=Object.values(e);for(const i of r)co(e,i),ho(e,i),uo(e,i),fo(e,i);for(const i of r)mo(e,i);for(const i of r)go(e,i);for(const i of r)po(e,i);for(const i of r)wo(e,i);for(const i of r)bo(e,i);this._compiledDefinitions=_o(e)}_checkContextMatch(e,t){const n=e.last;let r=this._evaluateChildChecks(e,t);if(r=r!==void 0?r:t.allowIn.includes(n.name),!r)return!1;const i=this.getDefinition(n),o=e.trimLast();return i?o.length==0?!0:this._checkContextMatch(o,i):!1}_evaluateChildChecks(e,t){const n=this._customChildChecks.get(this._genericCheckSymbol)||[],r=this._customChildChecks.get(t.name)||[];for(const i of[...n,...r]){const o=i(e,t);if(o!==void 0)return o}}_evaluateAttributeChecks(e,t){const n=this._customAttributeChecks.get(this._genericCheckSymbol)||[],r=this._customAttributeChecks.get(t)||[];for(const i of[...n,...r]){const o=i(e,t);if(o!==void 0)return o}}*_getValidRangesForRange(e,t){let n=e.start,r=e.start;for(const i of e.getItems({shallow:!0}))i.is("element")&&(yield*this._getValidRangesForRange(u._createIn(i),t)),this.checkAttribute(i,t)||(n.isEqual(r)||(yield new u(n,r)),n=m._createAfter(i)),r=m._createAfter(i);n.isEqual(r)||(yield new u(n,r))}findOptimalInsertionRange(e,t){const n=e.getSelectedElement();if(n&&this.isObject(n)&&!this.isInline(n))return t=="before"||t=="after"?new u(m._createAt(n,t)):u._createOn(n);const r=Vt(e.getSelectedBlocks());if(!r)return new u(e.focus);if(r.isEmpty)return new u(m._createAt(r,0));const i=m._createAfter(r);return e.focus.isTouching(i)?new u(i):new u(m._createBefore(r))}}class re{_items;constructor(e){if(e instanceof re)return e;let t;typeof e=="string"?t=[e]:Array.isArray(e)?t=e:t=e.getAncestors({includeSelf:!0}),this._items=t.map(Po)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){const t=new re([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new re([]);return e._items=this._items.slice(0,-1),e}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function lo(s,e){const t={name:e,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};return yo(s,t),X(s,t,"allowIn"),X(s,t,"allowChildren"),X(s,t,"disallowIn"),X(s,t,"disallowChildren"),X(s,t,"allowContentOf"),X(s,t,"allowWhere"),X(s,t,"allowAttributes"),X(s,t,"disallowAttributes"),X(s,t,"allowAttributesOf"),X(s,t,"inheritTypesFrom"),vo(s,t),t}function co(s,e){for(const t of e.allowIn){const n=s[t];n?n.allowChildren.add(e.name):e.allowIn.delete(t)}}function ho(s,e){for(const t of e.allowChildren){const n=s[t];n?n.allowIn.add(e.name):e.allowChildren.delete(t)}}function uo(s,e){for(const t of e.disallowIn){const n=s[t];n?n.disallowChildren.add(e.name):e.disallowIn.delete(t)}}function fo(s,e){for(const t of e.disallowChildren){const n=s[t];n?n.disallowIn.add(e.name):e.disallowChildren.delete(t)}}function mo(s,e){for(const t of e.disallowChildren)e.allowChildren.delete(t);for(const t of e.disallowIn)e.allowIn.delete(t);for(const t of e.disallowAttributes)e.allowAttributes.delete(t)}function go(s,e){for(const t of e.allowContentOf){const n=s[t];n&&(n.disallowChildren.forEach(r=>{e.allowChildren.has(r)||(e.disallowChildren.add(r),s[r].disallowIn.add(e.name))}),n.allowChildren.forEach(r=>{e.disallowChildren.has(r)||(e.allowChildren.add(r),s[r].allowIn.add(e.name))}))}}function po(s,e){for(const t of e.allowWhere){const n=s[t];n&&(n.disallowIn.forEach(r=>{e.allowIn.has(r)||(e.disallowIn.add(r),s[r].disallowChildren.add(e.name))}),n.allowIn.forEach(r=>{e.disallowIn.has(r)||(e.allowIn.add(r),s[r].allowChildren.add(e.name))}))}}function _o(s){const e={};for(const t of Object.values(s))e[t.name]={name:t.name,isBlock:!!t.isBlock,isContent:!!t.isContent,isInline:!!t.isInline,isLimit:!!t.isLimit,isObject:!!t.isObject,isSelectable:!!t.isSelectable,allowIn:Array.from(t.allowIn).filter(n=>!!s[n]),allowChildren:Array.from(t.allowChildren).filter(n=>!!s[n]),allowAttributes:Array.from(t.allowAttributes)};return e}function wo(s,e){for(const t of e.allowAttributesOf){const n=s[t];if(!n)return;n.allowAttributes.forEach(r=>{e.disallowAttributes.has(r)||e.allowAttributes.add(r)})}}function bo(s,e){for(const t of e.inheritTypesFrom){const n=s[t];if(n){const r=Object.keys(n).filter(i=>i.startsWith("is"));for(const i of r)i in e||(e[i]=n[i])}}}function yo(s,e){for(const t of s){const n=Object.keys(t).filter(r=>r.startsWith("is"));for(const r of n)e[r]=!!t[r]}}function X(s,e,t){for(const n of s){let r=n[t];typeof r=="string"&&(r=[r]),Array.isArray(r)&&r.forEach(i=>e[t].add(i))}}function vo(s,e){for(const t of s){const n=t.inheritAllFrom;n&&(e.allowContentOf.add(n),e.allowWhere.add(n),e.allowAttributesOf.add(n),e.inheritTypesFrom.add(n))}}function Po(s){return typeof s=="string"||s.is("documentFragment")?{name:typeof s=="string"?s:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:s.is("element")?s.name:"$text",*getAttributeKeys(){yield*s.getAttributeKeys()},getAttribute(e){return s.getAttribute(e)}}}function*Co(s,e){let t=!1;for(;!t;){if(t=!0,s){const n=s.next();n.done||(t=!1,yield{walker:s,value:n.value})}if(e){const n=e.next();n.done||(t=!1,yield{walker:e,value:n.value})}}}function*ko(s){for(const e of s)yield*e.getMinimalFlatRanges()}function Sn(s,e,t){for(const n of e.getAttributeKeys())s.checkAttribute(e,n)||t.removeAttribute(n,e)}class So extends x(){conversionApi;_splitParts=new Map;_cursorParents=new Map;_modelCursor=null;_emptyElementsToKeep=new Set;constructor(e){super(),this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(t,n)=>this._convertItem(t,n),convertChildren:(t,n)=>this._convertChildren(t,n),safeInsert:(t,n)=>this._safeInsert(t,n),updateConversionResult:(t,n)=>this._updateConversionResult(t,n),splitToAllowedParent:(t,n)=>this._splitToAllowedParent(t,n),getSplitParts:t=>this._getSplitParts(t),keepEmptyElement:t=>this._keepEmptyElement(t)}}convert(e,t,n=["$root"]){this.fire("viewCleanup",e),this._modelCursor=Eo(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=lt.createFrom(e),this.conversionApi.store={};const{modelRange:r}=this._convertItem(e,this._modelCursor),i=t.createDocumentFragment();if(r){this._removeEmptyElements();const o=this._modelCursor.parent,a=o._removeChildren(0,o.childCount);i._insertChild(0,a),i.markers=Ao(i,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,i}_convertItem(e,t){const n={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,n,this.conversionApi):e.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof u))throw new d("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is("position")?t:m._createAt(t,0);const r=new u(n);for(const i of Array.from(e.getChildren())){const o=this._convertItem(i,n);o.modelRange instanceof u&&(r.end=o.modelRange.end,n=o.modelCursor)}return{modelRange:r,modelCursor:n}}_safeInsert(e,t){const n=this._splitToAllowedParent(e,t);return n?(this.conversionApi.writer.insert(e,n.position),!0):!1}_updateConversionResult(e,t){const n=this._getSplitParts(e),r=this.conversionApi.writer;t.modelRange||(t.modelRange=r.createRange(r.createPositionBefore(e),r.createPositionAfter(n[n.length-1])));const i=this._cursorParents.get(e);i?t.modelCursor=r.createPositionAt(i,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){const{schema:n,writer:r}=this.conversionApi;let i=n.findAllowedParent(t,e);if(i){if(i===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(i)&&(i=null)}if(!i)return ys(t,e,n)?{position:vs(t,r)}:null;const o=this.conversionApi.writer.split(t,i),a=[];for(const c of o.range.getWalker())if(c.type=="elementEnd")a.push(c.item);else{const h=a.pop(),f=c.item;this._registerSplitPair(h,f)}const l=o.range.end.parent;return this._cursorParents.set(e,l),{position:o.position,cursorParent:l}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const n=this._splitParts.get(e);this._splitParts.set(t,n),n.push(t)}_getSplitParts(e){let t;return this._splitParts.has(e)?t=this._splitParts.get(e):t=[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){const e=new Map;for(const t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){const n=e.get(t.parent)||[];n.push(t),this._splitParts.delete(t),e.set(t.parent,n)}for(const[t,n]of e)t._removeChildrenArray(n);e.size&&this._removeEmptyElements()}}function Ao(s,e){const t=new Set,n=new Map,r=u._createIn(s).getItems();for(const i of r)i.is("element","$marker")&&t.add(i);for(const i of t){const o=i.getAttribute("data-name"),a=e.createPositionBefore(i);n.has(o)?n.get(o).end=a.clone():n.set(o,new u(a.clone())),e.remove(i)}return n}function Eo(s,e){let t;for(const n of new re(s)){const r={};for(const o of n.getAttributeKeys())r[o]=n.getAttribute(o);const i=e.createElement(n.name,r);t&&e.insert(i,t),t=m._createAt(i,0)}return t}class Ro{getHtml(e){const n=ne.document.implementation.createHTMLDocument("").createElement("div");return n.appendChild(e),n.innerHTML}}class To{domParser;domConverter;htmlWriter;skipComments=!0;constructor(e){this.domParser=new DOMParser,this.domConverter=new es(e,{renderingMode:"data"}),this.htmlWriter=new Ro}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e=="marked"?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`<body>${e}</body>`);const t=this.domParser.parseFromString(e,"text/html"),n=t.createDocumentFragment(),r=t.body.childNodes;for(;r.length>0;)n.appendChild(r[0]);return n}}class dl extends x(){model;mapper;downcastDispatcher;upcastDispatcher;viewDocument;stylesProcessor;htmlProcessor;processor;_viewWriter;constructor(e,t){super(),this.model=e,this.mapper=new is,this.downcastDispatcher=new os({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",cs(),{priority:"lowest"}),this.downcastDispatcher.on("insert",hs(),{priority:"lowest"}),this.upcastDispatcher=new So({schema:e.schema}),this.viewDocument=new Hn(t),this.stylesProcessor=t,this.htmlProcessor=new To(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Kn(this.viewDocument),this.upcastDispatcher.on("text",Ki(),{priority:"lowest"}),this.upcastDispatcher.on("element",Cn(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",Cn(),{priority:"lowest"}),z().prototype.decorate.call(this,"init"),z().prototype.decorate.call(this,"set"),z().prototype.decorate.call(this,"get"),z().prototype.decorate.call(this,"toView"),z().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},bs)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:n="empty"}=e;if(!this._checkIfRootsExists([t]))throw new d("datacontroller-get-non-existent-root",this);const r=this.model.document.getRoot(t);return r.isAttached()||J("datacontroller-get-detached-root",this),n==="empty"&&!this.model.hasContent(r,{ignoreWhitespaces:!0})?"":this.stringify(r,e)}stringify(e,t={}){const n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){const n=this.viewDocument,r=this._viewWriter;this.mapper.clearBindings();const i=u._createIn(e),o=new me(n);this.mapper.bindElements(e,o);const a=e.is("documentFragment")?e.markers:Mo(e);return this.downcastDispatcher.convert(i,a,r,t),o}init(e){if(this.model.document.version)throw new d("datacontroller-init-document-not-empty",this);let t={};if(typeof e=="string"?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new d("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},n=>{for(const r of Object.keys(t)){const i=this.model.document.getRoot(r);n.insert(this.parse(t[r],i),i,0)}}),Promise.resolve()}set(e,t={}){let n={};if(typeof e=="string"?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new d("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},r=>{r.setSelection(null),r.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const i of Object.keys(n)){const o=this.model.document.getRoot(i);r.remove(r.createRangeIn(o)),r.insert(this.parse(n[i],o),o,0)}})}parse(e,t="$root"){const n=this.processor.toView(e);return this.toModel(n,t)}toModel(e,t="$root"){return this.model.change(n=>this.upcastDispatcher.convert(e,n,t))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}function Mo(s){const e=[],t=s.root.document;if(!t)return new Map;const n=u._createIn(s);for(const r of t.model.markers){const i=r.getRange(),o=i.isCollapsed,a=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&a)e.push([r.name,i]);else{const l=n.getIntersection(i);l&&e.push([r.name,l])}}return e.sort(([r,i],[o,a])=>{if(i.end.compareWith(a.start)!=="after")return 1;if(i.start.compareWith(a.end)!=="before")return-1;switch(i.start.compareWith(a.start)){case"before":return 1;case"after":return-1;default:switch(i.end.compareWith(a.end)){case"before":return 1;case"after":return-1;default:return o.localeCompare(r)}}}),new Map(e)}class ml{_helpers=new Map;_downcast;_upcast;constructor(e,t){this._downcast=ie(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=ie(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const n=this._downcast.includes(t);if(!this._upcast.includes(t)&&!n)throw new d("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}for(e){if(!this._helpers.has(e))throw new d("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:n}of St(e))this.for("upcast").elementToElement({model:t,view:n,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:n}of St(e))this.for("upcast").elementToAttribute({view:n,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:n}of St(e))this.for("upcast").attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new d("conversion-group-exists",this);const r=n?new pi(t):new Hi(t);this._helpers.set(e,r)}}function*St(s){if(s.model.values)for(const e of s.model.values){const t={key:s.model.key,value:e},n=s.view[e],r=s.upcastAlso?s.upcastAlso[e]:void 0;yield*An(t,n,r)}else yield*An(s.model,s.view,s.upcastAlso)}function*An(s,e,t){if(yield{model:s,view:e},t)for(const n of ie(t))yield{model:s,view:n}}class W{baseVersion;isDocumentOperation;batch;constructor(e){this.baseVersion=e,this.isDocumentOperation=this.baseVersion!==null,this.batch=null}_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}}function Ht(s,e){const t=As(e),n=t.reduce((o,a)=>o+a.offsetSize,0),r=s.parent;Xe(s);const i=s.index;return r._insertChild(i,t),Ke(r,i+t.length),Ke(r,i),new u(s,s.getShiftedBy(n))}function Ss(s){if(!s.isFlat)throw new d("operation-utils-remove-range-not-flat",this);const e=s.start.parent;Xe(s.start),Xe(s.end);const t=e._removeChildren(s.start.index,s.end.index-s.start.index);return Ke(e,s.start.index),t}function He(s,e){if(!s.isFlat)throw new d("operation-utils-move-range-not-flat",this);const t=Ss(s);return e=e._getTransformedByDeletion(s.start,s.end.offset-s.start.offset),Ht(e,t)}function No(s,e,t){Xe(s.start),Xe(s.end);for(const n of s.getItems({shallow:!0})){const r=n.is("$textProxy")?n.textNode:n;t!==null?r._setAttribute(e,t):r._removeAttribute(e),Ke(r.parent,r.index)}Ke(s.end.parent,s.end.index)}function As(s){const e=[];function t(n){if(typeof n=="string")e.push(new k(n));else if(n instanceof j)e.push(new k(n.data,n.getAttributes()));else if(n instanceof be)e.push(n);else if(oe(n))for(const r of n)t(r)}t(s);for(let n=1;n<e.length;n++){const r=e[n],i=e[n-1];r instanceof k&&i instanceof k&&Es(r,i)&&(e.splice(n-1,2,new k(i.data+r.data,i.getAttributes())),n--)}return e}function Ke(s,e){const t=s.getChild(e-1),n=s.getChild(e);if(t&&n&&t.is("$text")&&n.is("$text")&&Es(t,n)){const r=new k(t.data+n.data,t.getAttributes());s._removeChildren(e-1,2),s._insertChild(e-1,r)}}function Xe(s){const e=s.textNode,t=s.parent;if(e){const n=s.offset-e.startOffset,r=e.index;t._removeChildren(r,1);const i=new k(e.data.substr(0,n),e.getAttributes()),o=new k(e.data.substr(n),e.getAttributes());t._insertChild(r,[i,o])}}function Es(s,e){const t=s.getAttributes(),n=e.getAttributes();for(const r of t){if(r[1]!==e.getAttribute(r[0]))return!1;n.next()}return n.next().done}class v extends W{sourcePosition;howMany;targetPosition;constructor(e,t,n,r){super(r),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNone"}get type(){return this.targetPosition.root.rootName==this.sourcePosition.root.rootName?"move":this.targetPosition.root.rootName=="$graveyard"?"remove":this.sourcePosition.root.rootName=="$graveyard"?"reinsert":"move"}get affectedSelectable(){return[u._createFromPositionAndShift(this.sourcePosition,this.howMany),u._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new v(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new v(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,n=this.sourcePosition.offset,r=this.targetPosition.offset;if(n+this.howMany>e.maxOffset)throw new d("move-operation-nodes-do-not-exist",this);if(e===t&&n<r&&r<n+this.howMany)throw new d("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&F(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())=="prefix"){const i=this.sourcePosition.path.length-1;if(this.targetPosition.path[i]>=n&&this.targetPosition.path[i]<n+this.howMany)throw new d("move-operation-node-into-itself",this)}}_execute(){He(u._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,t){const n=m.fromJSON(e.sourcePosition,t),r=m.fromJSON(e.targetPosition,t);return new this(n,e.howMany,r,e.baseVersion)}}class M extends W{position;nodes;shouldReceiveAttributes;constructor(e,t,n){super(n),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new $e(As(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new $e([...this.nodes].map(n=>n._clone(!0))),t=new M(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new m(e,[0]);return new v(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new d("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new $e([...e].map(t=>t._clone(!0))),Ht(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const n=[];for(const i of e.nodes)i.name?n.push(C.fromJSON(i)):n.push(k.fromJSON(i));const r=new M(m.fromJSON(e.position,t),n,e.baseVersion);return r.shouldReceiveAttributes=e.shouldReceiveAttributes,r}}class P extends W{splitPosition;howMany;insertionPosition;graveyardPosition;constructor(e,t,n,r,i){super(i),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=n,this.graveyardPosition=r?r.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new m(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new u(this.splitPosition,e)}get affectedSelectable(){const e=[u._createFromPositionAndShift(this.splitPosition,0),u._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(u._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new P(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new m(e,[0]);return new S(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new d("split-operation-position-invalid",this);if(e.parent){if(this.howMany!==Number.NEGATIVE_INFINITY&&this.howMany!=e.maxOffset-this.splitPosition.offset)throw new d("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new d("split-operation-graveyard-position-invalid",this)}else throw new d("split-operation-split-in-root",this);this.howMany=this.splitPosition.parent.maxOffset-this.splitPosition.offset}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)He(u._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const n=e._clone();Ht(this.insertionPosition,n)}const t=new u(m._createAt(e,this.splitPosition.offset),m._createAt(e,e.maxOffset));He(t,this.moveTargetPosition)}toJSON(){const e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){const t=e.path.slice(0,-1);return t[t.length-1]++,new m(e.root,t,"toPrevious")}static fromJSON(e,t){const n=m.fromJSON(e.splitPosition,t),r=m.fromJSON(e.insertionPosition,t),i=e.graveyardPosition?m.fromJSON(e.graveyardPosition,t):null;return new this(n,e.howMany,r,i,e.baseVersion)}}class S extends W{sourcePosition;howMany;targetPosition;graveyardPosition;constructor(e,t,n,r,i){super(i),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=r.clone()}get type(){return"merge"}get deletionPosition(){return new m(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new u(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[u._createOn(e),u._createFromPositionAndShift(this.targetPosition,0),u._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new S(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),n=new m(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new P(e,this.howMany,n,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(e.parent)if(t.parent){if(this.howMany!==Number.NEGATIVE_INFINITY&&this.howMany!=e.maxOffset)throw new d("merge-operation-how-many-invalid",this)}else throw new d("merge-operation-target-position-invalid",this);else throw new d("merge-operation-source-position-invalid",this);this.howMany=this.sourcePosition.parent.maxOffset}_execute(){const e=this.sourcePosition.parent,t=u._createIn(e);He(t,this.targetPosition),He(u._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const n=m.fromJSON(e.sourcePosition,t),r=m.fromJSON(e.targetPosition,t),i=m.fromJSON(e.graveyardPosition,t);return new this(n,e.howMany,r,i,e.baseVersion)}}class B extends W{name;oldRange;newRange;affectsData;_markers;constructor(e,t,n,r,i,o){super(o),this.name=e,this.oldRange=t?t.clone():null,this.newRange=n?n.clone():null,this.affectsData=i,this._markers=r}get type(){return"marker"}get affectedSelectable(){const e=[];return this.oldRange&&e.push(this.oldRange.clone()),this.newRange&&(this.oldRange?e.push(...this.newRange.getDifference(this.oldRange)):e.push(this.newRange.clone())),e}clone(){return new B(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new B(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new B(e.name,e.oldRange?u.fromJSON(e.oldRange,t):null,e.newRange?u.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class A extends W{range;key;oldValue;newValue;constructor(e,t,n,r,i){super(i),this.range=e.clone(),this.key=t,this.oldValue=n===void 0?null:n,this.newValue=r===void 0?null:r}get type(){return this.oldValue===null?"addAttribute":this.newValue===null?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new A(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new A(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new d("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(this.oldValue!==null&&!en(e.getAttribute(this.key),this.oldValue))throw new d("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(this.oldValue===null&&this.newValue!==null&&e.hasAttribute(this.key))throw new d("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){en(this.oldValue,this.newValue)||No(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new A(u.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}class T extends W{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new T(this.baseVersion)}getReversed(){return new T(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class V extends W{position;oldName;newName;constructor(e,t,n,r){super(r),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=n}get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new V(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new V(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(e instanceof C){if(this.oldName!==""&&e.name!==this.oldName)throw new d("rename-operation-wrong-name",this)}else throw new d("rename-operation-wrong-position",this);this.oldName=e.name}_execute(){const e=this.position.nodeAfter;e.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new V(m.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class ee extends W{root;key;oldValue;newValue;constructor(e,t,n,r,i){super(i),this.root=e,this.key=t,this.oldValue=n===void 0?null:n,this.newValue=r===void 0?null:r}get type(){return this.oldValue===null?"addRootAttribute":this.newValue===null?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new ee(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new ee(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new d("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(this.oldValue!==null&&this.root.getAttribute(this.key)!==this.oldValue)throw new d("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(this.oldValue===null&&this.newValue!==null&&this.root.hasAttribute(this.key))throw new d("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){this.newValue!==null?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new d("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new ee(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class Q extends W{rootName;elementName;isAdd;_document;constructor(e,t,n,r,i){if(super(i),this.rootName=e,this.elementName=t,this.isAdd=n,this._document=r,!this._document.getRoot(this.rootName)){const o=this._document.createRoot(this.elementName,this.rootName);o._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new Q(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new Q(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){const e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,t){return new Q(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}const U={};U[A.className]=A;U[M.className]=M;U[B.className]=B;U[v.className]=v;U[T.className]=T;U[W.className]=W;U[V.className]=V;U[ee.className]=ee;U[Q.className]=Q;U[P.className]=P;U[S.className]=S;class xo{static fromJSON(e,t){return U[e.__className].fromJSON(e,t)}}const Dt=new Map;function b(s,e,t){let n=Dt.get(s);n||(n=new Map,Dt.set(s,n)),n.set(e,t)}function Oo(s,e){const t=Dt.get(s);return t&&t.has(e)?t.get(e):Io}function Io(s){return[s]}function En(s,e,t={}){const n=Oo(s.constructor,e.constructor);try{return s=s.clone(),n(s,e,t)}catch(r){throw r}}function gl(s,e,t){s=s.slice(),e=e.slice();const n=new Fo(t.document,t.useRelations,t.forceWeakRemove);n.setOriginalOperations(s),n.setOriginalOperations(e);const r=n.originalOperations;if(s.length==0||e.length==0)return{operationsA:s,operationsB:e,originalOperations:r};const i=new WeakMap;for(const l of s)i.set(l,0);const o={nextBaseVersionA:s[s.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:s.length,originalOperationsBCount:e.length};let a=0;for(;a<s.length;){const l=s[a],c=i.get(l);if(c==e.length){a++;continue}const h=e[c],f=En(l,h,n.getContext(l,h,!0)),p=En(h,l,n.getContext(h,l,!1));n.updateRelation(l,h),n.setOriginalOperations(f,l),n.setOriginalOperations(p,h);for(const _ of f)i.set(_,c+p.length);s.splice(a,1,...f),e.splice(c,1,...p)}return Tn(s),Tn(e),Rn(s,o.nextBaseVersionB),Rn(e,o.nextBaseVersionA),{operationsA:s,operationsB:e,originalOperations:r}}class Fo{originalOperations;_history;_useRelations;_forceWeakRemove;_relations;constructor(e,t,n=!1){this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!n,this._relations=new Map}setOriginalOperations(e,t=null){const n=t?this.originalOperations.get(t):null;for(const r of e)this.originalOperations.set(r,n||r)}updateRelation(e,t){if(e instanceof v)t instanceof S?e.targetPosition.isEqual(t.sourcePosition)||t.movedRange.containsPosition(e.targetPosition)?this._setRelation(e,t,"insertAtSource"):e.targetPosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"insertBetween"):e.targetPosition.isAfter(t.sourcePosition)?this._setRelation(e,t,"moveTargetAfter"):e.howMany>1&&e.sourcePosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"firstToMoveMerged"):e.howMany>1&&e.sourcePosition.getShiftedBy(e.howMany-1).isEqual(t.deletionPosition)&&this._setRelation(e,t,"lastToMoveMerged"):t instanceof v&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof P){if(t instanceof S)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof v)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const n=u._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const r=n.end.offset-e.splitPosition.offset,i=e.splitPosition.offset-n.start.offset;this._setRelation(e,t,{howMany:r,offset:i})}}}else if(e instanceof S)t instanceof S?(e.targetPosition.isEqual(t.sourcePosition)||this._setRelation(e,t,"mergeTargetNotMoved"),e.sourcePosition.isEqual(t.targetPosition)&&this._setRelation(e,t,"mergeSourceNotMoved"),e.sourcePosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeSameElement")):t instanceof P?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof v&&t.howMany>0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));else if(e instanceof B){const n=e.newRange;if(!n)return;if(t instanceof S){const r=n.start.isEqual(t.targetPosition),i=n.start.isEqual(t.deletionPosition),o=n.end.isEqual(t.deletionPosition),a=n.end.isEqual(t.sourcePosition);(r||i||o||a)&&this._setRelation(e,t,{wasInLeftElement:r,wasStartBeforeMergedElement:i,wasEndBeforeMergedElement:o,wasInRightElement:a})}}}getContext(e,t,n){return{aIsStrong:n,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const n=this.originalOperations.get(t),r=this._history.getUndoneOperation(n);if(!r)return null;const i=this.originalOperations.get(e),o=this._relations.get(i);return o&&o.get(r)||null}_setRelation(e,t,n){const r=this.originalOperations.get(e),i=this.originalOperations.get(t);let o=this._relations.get(r);o||(o=new Map,this._relations.set(r,o)),o.set(i,n)}}function Rn(s,e){for(const t of s)t.baseVersion=e++}function Tn(s){const e=new Map;for(let t=0;t<s.length;t++){const n=s[t];n instanceof B&&(n.baseVersion!==-1?e.set(n.name,{op:n,ranges:n.newRange?[n.newRange]:[]}):(n.newRange&&e.get(n.name).ranges.push(n.newRange),s.splice(t,1),t--))}for(const{op:t,ranges:n}of e.values())n.length?t.newRange=u._createFromRanges(n):t.newRange=null}b(A,A,(s,e,t)=>{if(s.key===e.key&&s.range.start.hasSameParentAs(e.range.start)){const n=s.range.getDifference(e.range).map(i=>new A(i,s.key,s.oldValue,s.newValue,0)),r=s.range.getIntersection(e.range);return r&&t.aIsStrong&&n.push(new A(r,e.key,e.newValue,s.newValue,0)),n.length==0?[new T(0)]:n}else return[s]});b(A,M,(s,e)=>{if(s.range.start.hasSameParentAs(e.position)&&s.range.containsPosition(e.position)){const n=s.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map(r=>new A(r,s.key,s.oldValue,s.newValue,s.baseVersion));if(e.shouldReceiveAttributes){const r=Rs(e,s.key,s.oldValue);r&&n.unshift(r)}return n}return s.range=s.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[s]});function Rs(s,e,t){const r=s.nodes.getNode(0).getAttribute(e);if(r==t)return null;const i=new u(s.position,s.position.getShiftedBy(s.howMany));return new A(i,e,r,t,0)}b(A,S,(s,e)=>{const t=[];s.range.start.hasSameParentAs(e.deletionPosition)&&(s.range.containsPosition(e.deletionPosition)||s.range.start.isEqual(e.deletionPosition))&&t.push(u._createFromPositionAndShift(e.graveyardPosition,1));const n=s.range._getTransformedByMergeOperation(e);return n.isCollapsed||t.push(n),t.map(r=>new A(r,s.key,s.oldValue,s.newValue,s.baseVersion))});b(A,v,(s,e)=>Do(s.range,e).map(n=>new A(n,s.key,s.oldValue,s.newValue,s.baseVersion)));function Do(s,e){const t=u._createFromPositionAndShift(e.sourcePosition,e.howMany);let n=null,r=[];t.containsRange(s,!0)?n=s:s.start.hasSameParentAs(t.start)?(r=s.getDifference(t),n=s.getIntersection(t)):r=[s];const i=[];for(let o of r){o=o._getTransformedByDeletion(e.sourcePosition,e.howMany);const a=e.getMovedRangeStart(),l=o.start.hasSameParentAs(a),c=o._getTransformedByInsertion(a,e.howMany,l);i.push(...c)}return n&&i.push(n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]),i}b(A,P,(s,e)=>{if(s.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||s.range.end.offset++,[s];if(s.range.start.hasSameParentAs(e.splitPosition)&&s.range.containsPosition(e.splitPosition)){const t=s.clone();return t.range=new u(e.moveTargetPosition.clone(),s.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),s.range.end=e.splitPosition.clone(),s.range.end.stickiness="toPrevious",[s,t]}return s.range=s.range._getTransformedBySplitOperation(e),[s]});b(M,A,(s,e)=>{const t=[s];if(s.shouldReceiveAttributes&&s.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(s.position)){const n=Rs(s,e.key,e.newValue);n&&t.push(n)}return t});b(M,M,(s,e,t)=>s.position.isEqual(e.position)&&t.aIsStrong?[s]:(s.position=s.position._getTransformedByInsertOperation(e),[s]));b(M,v,(s,e)=>(s.position=s.position._getTransformedByMoveOperation(e),[s]));b(M,P,(s,e)=>(s.position=s.position._getTransformedBySplitOperation(e),[s]));b(M,S,(s,e)=>(s.position=s.position._getTransformedByMergeOperation(e),[s]));b(B,M,(s,e)=>(s.oldRange&&(s.oldRange=s.oldRange._getTransformedByInsertOperation(e)[0]),s.newRange&&(s.newRange=s.newRange._getTransformedByInsertOperation(e)[0]),[s]));b(B,B,(s,e,t)=>{if(s.name==e.name)if(t.aIsStrong)s.oldRange=e.newRange?e.newRange.clone():null;else return[new T(0)];return[s]});b(B,S,(s,e)=>(s.oldRange&&(s.oldRange=s.oldRange._getTransformedByMergeOperation(e)),s.newRange&&(s.newRange=s.newRange._getTransformedByMergeOperation(e)),[s]));b(B,v,(s,e)=>{const t=[s];if(s.oldRange&&(s.oldRange=u._createFromRanges(s.oldRange._getTransformedByMoveOperation(e))),s.newRange){const n=s.newRange._getTransformedByMoveOperation(e);s.newRange=n[0];for(let r=1;r<n.length;r++){const i=s.clone();i.oldRange=null,i.newRange=n[r],i.baseVersion=-1,t.push(i)}}return t});b(B,P,(s,e,t)=>{if(s.oldRange&&(s.oldRange=s.oldRange._getTransformedBySplitOperation(e)),s.newRange){if(t.abRelation){const n=s.newRange._getTransformedBySplitOperation(e);return s.newRange.start.isEqual(e.splitPosition)?t.abRelation.wasStartBeforeMergedElement?s.newRange.start=m._createAt(e.insertionPosition):t.abRelation.wasInLeftElement?s.newRange.start=m._createAt(s.newRange.start):s.newRange.start=m._createAt(e.moveTargetPosition):s.newRange.start=n.start,s.newRange.end.isEqual(e.splitPosition)?s.newRange.end.isEqual(e.splitPosition)&&t.abRelation.wasEndBeforeMergedElement?s.newRange.end=m._createAt(e.insertionPosition):t.abRelation.wasInRightElement?s.newRange.end=m._createAt(e.moveTargetPosition):s.newRange.end=m._createAt(s.newRange.end):s.newRange.end=n.end,[s]}s.newRange=s.newRange._getTransformedBySplitOperation(e)}return[s]});b(S,M,(s,e)=>(s.sourcePosition.hasSameParentAs(e.position)&&(s.howMany+=e.howMany),s.sourcePosition=s.sourcePosition._getTransformedByInsertOperation(e),s.targetPosition=s.targetPosition._getTransformedByInsertOperation(e),[s]));b(S,S,(s,e,t)=>{if(s.sourcePosition.isEqual(e.sourcePosition)&&s.targetPosition.isEqual(e.targetPosition))if(t.bWasUndone){const n=e.graveyardPosition.path.slice();return n.push(0),s.sourcePosition=new m(e.graveyardPosition.root,n),s.howMany=0,[s]}else return[new T(0)];if(s.sourcePosition.isEqual(e.sourcePosition)&&!s.targetPosition.isEqual(e.targetPosition)&&!t.bWasUndone&&t.abRelation!="splitAtSource"){const n=s.targetPosition.root.rootName=="$graveyard",r=e.targetPosition.root.rootName=="$graveyard";if(r&&!n||!(n&&!r)&&t.aIsStrong){const l=e.targetPosition._getTransformedByMergeOperation(e),c=s.targetPosition._getTransformedByMergeOperation(e);return[new v(l,s.howMany,c,0)]}else return[new T(0)]}return s.sourcePosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.sourcePosition=s.sourcePosition._getTransformedByMergeOperation(e),s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),(!s.graveyardPosition.isEqual(e.graveyardPosition)||!t.aIsStrong)&&(s.graveyardPosition=s.graveyardPosition._getTransformedByMergeOperation(e)),[s]});b(S,v,(s,e,t)=>{const n=u._createFromPositionAndShift(e.sourcePosition,e.howMany);return e.type=="remove"&&!t.bWasUndone&&s.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(s.sourcePosition)?[new T(0)]:(e.sourcePosition.getShiftedBy(e.howMany).isEqual(s.sourcePosition)?s.sourcePosition.stickiness="toNone":e.targetPosition.isEqual(s.sourcePosition)&&t.abRelation=="mergeSourceAffected"?s.sourcePosition.stickiness="toNext":e.sourcePosition.isEqual(s.targetPosition)?(s.targetPosition.stickiness="toNone",s.howMany-=e.howMany):e.targetPosition.isEqual(s.targetPosition)&&t.abRelation=="mergeTargetWasBefore"?(s.targetPosition.stickiness="toPrevious",s.howMany+=e.howMany):(s.sourcePosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.sourcePosition.hasSameParentAs(e.sourcePosition)&&(s.howMany-=e.howMany)),s.sourcePosition=s.sourcePosition._getTransformedByMoveOperation(e),s.targetPosition=s.targetPosition._getTransformedByMoveOperation(e),s.sourcePosition.stickiness="toPrevious",s.targetPosition.stickiness="toNext",s.graveyardPosition.isEqual(e.targetPosition)||(s.graveyardPosition=s.graveyardPosition._getTransformedByMoveOperation(e)),[s])});b(S,P,(s,e,t)=>{if(e.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),s.deletionPosition.isEqual(e.graveyardPosition)&&(s.howMany=e.howMany)),s.targetPosition.isEqual(e.splitPosition)&&(e.graveyardPosition&&s.deletionPosition.isEqual(e.graveyardPosition)||t.abRelation=="mergeTargetNotMoved"))return s.sourcePosition=s.sourcePosition._getTransformedBySplitOperation(e),[s];if(s.sourcePosition.isEqual(e.splitPosition)){if(t.abRelation=="mergeSourceNotMoved")return s.howMany=0,s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s];if(t.abRelation=="mergeSameElement"||s.sourcePosition.offset>0)return s.sourcePosition=e.moveTargetPosition.clone(),s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s]}return s.sourcePosition.hasSameParentAs(e.splitPosition)&&(s.howMany=e.splitPosition.offset),s.sourcePosition=s.sourcePosition._getTransformedBySplitOperation(e),s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s]});b(v,M,(s,e)=>{const n=u._createFromPositionAndShift(s.sourcePosition,s.howMany)._getTransformedByInsertOperation(e,!1)[0];return s.sourcePosition=n.start,s.howMany=n.end.offset-n.start.offset,s.targetPosition.isEqual(e.position)||(s.targetPosition=s.targetPosition._getTransformedByInsertOperation(e)),[s]});b(v,v,(s,e,t)=>{const n=u._createFromPositionAndShift(s.sourcePosition,s.howMany),r=u._createFromPositionAndShift(e.sourcePosition,e.howMany);let i=t.aIsStrong,o=!t.aIsStrong;t.abRelation=="insertBefore"||t.baRelation=="insertAfter"?o=!0:(t.abRelation=="insertAfter"||t.baRelation=="insertBefore")&&(o=!1);let a;if(s.targetPosition.isEqual(e.targetPosition)&&o?a=s.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):a=s.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Mn(s,e)&&Mn(e,s))return[e.getReversed()];if(n.containsPosition(e.targetPosition)&&n.containsRange(r,!0))return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Ae([n],a);if(r.containsPosition(s.targetPosition)&&r.containsRange(n,!0))return n.start=n.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),n.end=n.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),Ae([n],a);const h=F(s.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if(h=="prefix"||h=="extension")return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Ae([n],a);s.type=="remove"&&e.type!="remove"&&!t.aWasUndone&&!t.forceWeakRemove?i=!0:s.type!="remove"&&e.type=="remove"&&!t.bWasUndone&&!t.forceWeakRemove&&(i=!1);const f=[],p=n.getDifference(r);for(const y of p){y.start=y.start._getTransformedByDeletion(e.sourcePosition,e.howMany),y.end=y.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const I=F(y.start.getParentPath(),e.getMovedRangeStart().getParentPath())=="same",he=y._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,I);f.push(...he)}const _=n.getIntersection(r);return _!==null&&i&&(_.start=_.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),_.end=_.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),f.length===0?f.push(_):f.length==1?r.start.isBefore(n.start)||r.start.isEqual(n.start)?f.unshift(_):f.push(_):f.splice(1,0,_)),f.length===0?[new T(s.baseVersion)]:Ae(f,a)});b(v,P,(s,e,t)=>{let n=s.targetPosition.clone();if((!s.targetPosition.isEqual(e.insertionPosition)||!e.graveyardPosition||t.abRelation=="moveTargetAfter")&&(n=s.targetPosition._getTransformedBySplitOperation(e)),s.sourcePosition.isEqual(e.insertionPosition)&&t.abRelation=="firstToMoveMerged")return s.howMany++,s.targetPosition=n,[s];const r=u._createFromPositionAndShift(s.sourcePosition,s.howMany);if(r.end.isEqual(e.insertionPosition))return(!e.graveyardPosition||t.abRelation=="lastToMoveMerged")&&s.howMany++,s.targetPosition=n,[s];if(r.start.hasSameParentAs(e.splitPosition)&&r.containsPosition(e.splitPosition)){let a=new u(e.splitPosition,r.end);a=a._getTransformedBySplitOperation(e);const l=[new u(r.start,e.splitPosition),a];return Ae(l,n)}s.targetPosition.isEqual(e.splitPosition)&&t.abRelation=="insertAtSource"&&(n=e.moveTargetPosition),s.targetPosition.isEqual(e.insertionPosition)&&t.abRelation=="insertBetween"&&(n=s.targetPosition);const o=[r._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const a=r.start.isEqual(e.graveyardPosition)||r.containsPosition(e.graveyardPosition);s.howMany>1&&a&&!t.aWasUndone&&o.push(u._createFromPositionAndShift(e.insertionPosition,1))}return Ae(o,n)});b(v,S,(s,e,t)=>{const n=u._createFromPositionAndShift(s.sourcePosition,s.howMany);if(e.deletionPosition.hasSameParentAs(s.sourcePosition)&&n.containsPosition(e.sourcePosition)){if(s.type=="remove"&&!t.forceWeakRemove){if(!t.aWasUndone){const o=[];let a=e.graveyardPosition.clone(),l=e.targetPosition._getTransformedByMergeOperation(e);const c=s.targetPosition.getTransformedByOperation(e);s.howMany>1&&(o.push(new v(s.sourcePosition,s.howMany-1,c,0)),a=a._getTransformedByMove(s.sourcePosition,c,s.howMany-1),l=l._getTransformedByMove(s.sourcePosition,c,s.howMany-1));const h=e.deletionPosition._getCombined(s.sourcePosition,c),f=new v(a,1,h,0),p=f.getMovedRangeStart().path.slice();p.push(0);const _=new m(f.targetPosition.root,p);l=l._getTransformedByMove(a,h,1);const y=new v(l,e.howMany,_,0);return o.push(f),o.push(y),o}}else if(s.howMany==1)return t.bWasUndone?(s.sourcePosition=e.graveyardPosition.clone(),s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),[s]):[new T(0)]}const i=u._createFromPositionAndShift(s.sourcePosition,s.howMany)._getTransformedByMergeOperation(e);return s.sourcePosition=i.start,s.howMany=i.end.offset-i.start.offset,s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),[s]});b(V,M,(s,e)=>(s.position=s.position._getTransformedByInsertOperation(e),[s]));b(V,S,(s,e)=>s.position.isEqual(e.deletionPosition)?(s.position=e.graveyardPosition.clone(),s.position.stickiness="toNext",[s]):(s.position=s.position._getTransformedByMergeOperation(e),[s]));b(V,v,(s,e)=>(s.position=s.position._getTransformedByMoveOperation(e),[s]));b(V,V,(s,e,t)=>{if(s.position.isEqual(e.position))if(t.aIsStrong)s.oldName=e.newName;else return[new T(0)];return[s]});b(V,P,(s,e)=>{const t=s.position.path,n=e.splitPosition.getParentPath();if(F(t,n)=="same"&&!e.graveyardPosition){const r=new V(s.position.getShiftedBy(1),s.oldName,s.newName,0);return[s,r]}return s.position=s.position._getTransformedBySplitOperation(e),[s]});b(ee,ee,(s,e,t)=>{if(s.root===e.root&&s.key===e.key){if(!t.aIsStrong||s.newValue===e.newValue)return[new T(0)];s.oldValue=e.newValue}return[s]});b(Q,Q,(s,e)=>s.rootName===e.rootName&&s.isAdd===e.isAdd?[new T(0)]:[s]);b(P,M,(s,e)=>(s.splitPosition.hasSameParentAs(e.position)&&s.splitPosition.offset<e.position.offset&&(s.howMany+=e.howMany),s.splitPosition=s.splitPosition._getTransformedByInsertOperation(e),s.insertionPosition=s.insertionPosition._getTransformedByInsertOperation(e),[s]));b(P,S,(s,e,t)=>{if(!s.graveyardPosition&&!t.bWasUndone&&s.splitPosition.hasSameParentAs(e.sourcePosition)){const n=e.graveyardPosition.path.slice();n.push(0);const r=new m(e.graveyardPosition.root,n),i=P.getInsertionPosition(new m(e.graveyardPosition.root,n)),o=new P(r,0,i,null,0);return s.splitPosition=s.splitPosition._getTransformedByMergeOperation(e),s.insertionPosition=P.getInsertionPosition(s.splitPosition),s.graveyardPosition=o.insertionPosition.clone(),s.graveyardPosition.stickiness="toNext",[o,s]}return s.splitPosition.hasSameParentAs(e.deletionPosition)&&!s.splitPosition.isAfter(e.deletionPosition)&&s.howMany--,s.splitPosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.splitPosition=s.splitPosition._getTransformedByMergeOperation(e),s.insertionPosition=P.getInsertionPosition(s.splitPosition),s.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedByMergeOperation(e)),[s]});b(P,v,(s,e,t)=>{const n=u._createFromPositionAndShift(e.sourcePosition,e.howMany);if(s.graveyardPosition){const i=n.start.isEqual(s.graveyardPosition)||n.containsPosition(s.graveyardPosition);if(!t.bWasUndone&&i){const o=s.splitPosition._getTransformedByMoveOperation(e),a=s.graveyardPosition._getTransformedByMoveOperation(e),l=a.path.slice();l.push(0);const c=new m(a.root,l);return[new v(o,s.howMany,c,0)]}s.graveyardPosition=s.graveyardPosition._getTransformedByMoveOperation(e)}const r=s.splitPosition.isEqual(e.targetPosition);if(r&&(t.baRelation=="insertAtSource"||t.abRelation=="splitBefore"))return s.howMany+=e.howMany,s.splitPosition=s.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s];if(r&&t.abRelation&&t.abRelation.howMany){const{howMany:i,offset:o}=t.abRelation;return s.howMany+=i,s.splitPosition=s.splitPosition.getShiftedBy(o),[s]}if(s.splitPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(s.splitPosition)){const i=e.howMany-(s.splitPosition.offset-e.sourcePosition.offset);return s.howMany-=i,s.splitPosition.hasSameParentAs(e.targetPosition)&&s.splitPosition.offset<e.targetPosition.offset&&(s.howMany+=e.howMany),s.splitPosition=e.sourcePosition.clone(),s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s]}return e.sourcePosition.isEqual(e.targetPosition)||(s.splitPosition.hasSameParentAs(e.sourcePosition)&&s.splitPosition.offset<=e.sourcePosition.offset&&(s.howMany-=e.howMany),s.splitPosition.hasSameParentAs(e.targetPosition)&&s.splitPosition.offset<e.targetPosition.offset&&(s.howMany+=e.howMany)),s.splitPosition.stickiness="toNone",s.splitPosition=s.splitPosition._getTransformedByMoveOperation(e),s.splitPosition.stickiness="toNext",s.graveyardPosition?s.insertionPosition=s.insertionPosition._getTransformedByMoveOperation(e):s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s]});b(P,P,(s,e,t)=>{if(s.splitPosition.isEqual(e.splitPosition)){if(!s.graveyardPosition&&!e.graveyardPosition)return[new T(0)];if(s.graveyardPosition&&e.graveyardPosition&&s.graveyardPosition.isEqual(e.graveyardPosition))return[new T(0)];if(t.abRelation=="splitBefore")return s.howMany=0,s.graveyardPosition=s.graveyardPosition._getTransformedBySplitOperation(e),[s]}if(s.graveyardPosition&&e.graveyardPosition&&s.graveyardPosition.isEqual(e.graveyardPosition)){const n=s.splitPosition.root.rootName=="$graveyard",r=e.splitPosition.root.rootName=="$graveyard";if(r&&!n||!(n&&!r)&&t.aIsStrong){const l=[];return e.howMany&&l.push(new v(e.moveTargetPosition,e.howMany,e.splitPosition,0)),s.howMany&&l.push(new v(s.splitPosition,s.howMany,s.moveTargetPosition,0)),l}else return[new T(0)]}if(s.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedBySplitOperation(e)),s.splitPosition.isEqual(e.insertionPosition)&&t.abRelation=="splitBefore")return s.howMany++,[s];if(e.splitPosition.isEqual(s.insertionPosition)&&t.baRelation=="splitBefore"){const n=e.insertionPosition.path.slice();n.push(0);const r=new m(e.insertionPosition.root,n),i=new v(s.insertionPosition,1,r,0);return[s,i]}return s.splitPosition.hasSameParentAs(e.splitPosition)&&s.splitPosition.offset<e.splitPosition.offset&&(s.howMany-=e.howMany),s.splitPosition=s.splitPosition._getTransformedBySplitOperation(e),s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s]});function Mn(s,e){return s.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany)===null}function Ae(s,e){const t=[];for(let n=0;n<s.length;n++){const r=s[n],i=new v(r.start,r.end.offset-r.start.offset,e,0);t.push(i);for(let o=n+1;o<s.length;o++)s[o]=s[o]._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)[0];e=e._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)}return t}class O extends x(m){constructor(e,t,n="toNone"){if(super(e,t,n),!this.root.is("rootElement"))throw new d("model-liveposition-root-not-rootelement",e);Bo.call(this)}detach(){this.stopListening()}toPosition(){return new m(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}O.prototype.is=function(s){return s==="livePosition"||s==="model:livePosition"||s=="position"||s==="model:position"};function Bo(){this.listenTo(this.root.document.model,"applyOperation",(s,e)=>{const t=e[0];t.isDocumentOperation&&Vo.call(this,t)},{priority:"low"})}function Vo(s){const e=this.getTransformedByOperation(s);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}class ve{operations;isUndoable;isLocal;isUndo;isTyping;constructor(e={}){typeof e=="string"&&(e=e==="transparent"?{isUndoable:!1}:{},J("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:n=!0,isUndo:r=!1,isTyping:i=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=r,this.isTyping=i}get baseVersion(){for(const e of this.operations)if(e.baseVersion!==null)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}class ht{static _statesPriority=[void 0,"refresh","rename","move"];_markerCollection;_changesInElement=new Map;_elementsSnapshots=new Map;_elementChildrenSnapshots=new Map;_elementState=new Map;_changedMarkers=new Map;_changedRoots=new Map;_changeCount=0;_cachedChanges=null;_cachedChangesWithGraveyard=null;_refreshedItems=new Set;constructor(e){this._markerCollection=e}get isEmpty(){return this._changesInElement.size==0&&this._changedMarkers.size==0&&this._changedRoots.size==0}bufferOperation(e){const t=e;switch(t.type){case"insert":{if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break}case"addAttribute":case"removeAttribute":case"changeAttribute":{for(const n of t.range.getItems({shallow:!0}))this._isInInsertedElement(n.parent)||this._markAttribute(n);break}case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const n=this._isInInsertedElement(t.sourcePosition.parent),r=this._isInInsertedElement(t.targetPosition.parent);n||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),r||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const i=u._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const o of i.getItems({shallow:!0}))this._setElementState(o,"move");break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const n=u._createFromPositionAndShift(t.position,1);for(const r of this._markerCollection.getMarkersIntersectingRange(n)){const i=r.getData();this.bufferMarkerChange(r.name,i,i)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const n=t.splitPosition.parent;if(!this._isInInsertedElement(n)){this._markRemove(n,t.splitPosition.offset,t.howMany);const r=u._createFromPositionAndShift(t.splitPosition,t.howMany);for(const i of r.getItems({shallow:!0}))this._setElementState(i,"move")}this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&(this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1),this._setElementState(t.graveyardPosition.nodeAfter,"move"));break}case"merge":{const n=t.sourcePosition.parent;this._isInInsertedElement(n.parent)||this._markRemove(n.parent,n.startOffset,1);const r=t.graveyardPosition.parent;this._markInsert(r,t.graveyardPosition.offset,1),this._setElementState(n,"move");const i=t.targetPosition.parent;if(!this._isInInsertedElement(i)){this._markInsert(i,t.targetPosition.offset,n.maxOffset);const o=u._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const a of o.getItems({shallow:!0}))this._setElementState(a,"move")}break}case"detachRoot":case"addRoot":{const n=t.affectedSelectable;if(!n._isLoaded||n.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const n=t.root.rootName;this._bufferRootAttributeChange(n,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,n){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),n.range&&n.range.root.is("rootElement")&&!n.range.root._isLoaded&&(n.range=null);let r=this._changedMarkers.get(e);r?r.newMarkerData=n:(r={newMarkerData:n,oldMarkerData:t},this._changedMarkers.set(e,r)),r.oldMarkerData.range==null&&n.range==null&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,n]of this._changedMarkers)n.oldMarkerData.range!=null&&e.push({name:t,range:n.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,n]of this._changedMarkers)n.newMarkerData.range!=null&&e.push({name:t,range:n.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const n=e.range&&!t.range,r=!e.range&&t.range,i=e.range&&t.range&&!e.range.isEqual(t.range);if(n||r||i)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const n of this._changesInElement.keys()){const r=this._changesInElement.get(n).sort((h,f)=>h.offset===f.offset?h.type!=f.type?h.type=="remove"?-1:1:0:h.offset<f.offset?-1:1),i=this._elementChildrenSnapshots.get(n),o=xn(n.getChildren()),a=Lo(i.length,r);let l=0,c=0;for(const h of a)if(h==="i"){const f=this._getDiffActionForNode(o[l].node,"insert"),p=this._elementsSnapshots.get(o[l].node),_=this._getInsertDiff(n,l,f,o[l],p);t.push(_),l++}else if(h==="r"){const f=this._getDiffActionForNode(i[c].node,"remove"),p=this._getRemoveDiff(n,l,f,i[c]);t.push(p),c++}else if(h==="a"){const f=i[c].attributes,p=o[l].attributes;let _;if(o[l].name=="$text")_=new u(m._createAt(n,l),m._createAt(n,l+1));else{const I=n.offsetToIndex(l);_=new u(m._createAt(n,l),m._createAt(n.getChild(I),0))}const y=this._getAttributesDiff(_,f,p);t.push(...y),l++,c++}else l++,c++}t.sort((n,r)=>n.position.root!=r.position.root?n.position.root.rootName<r.position.root.rootName?-1:1:n.position.isEqual(r.position)?n.changeCount-r.changeCount:n.position.isBefore(r.position)?-1:1);for(let n=1,r=0;n<t.length;n++){const i=t[r],o=t[n],a=i.type=="remove"&&o.type=="remove"&&i.name=="$text"&&o.name=="$text"&&i.position.isEqual(o.position),l=i.type=="insert"&&o.type=="insert"&&i.name=="$text"&&o.name=="$text"&&i.position.parent==o.position.parent&&i.position.offset+i.length==o.position.offset,c=i.type=="attribute"&&o.type=="attribute"&&i.position.parent==o.position.parent&&i.range.isFlat&&o.range.isFlat&&i.position.offset+i.length==o.position.offset&&i.attributeKey==o.attributeKey&&i.attributeOldValue==o.attributeOldValue&&i.attributeNewValue==o.attributeNewValue;a||l||c?(i.length++,c&&(i.range.end=i.range.end.getShiftedBy(1)),t[n]=null):r=n}t=t.filter(n=>n);for(const n of t)delete n.changeCount,n.type=="attribute"&&(delete n.position,delete n.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter($o),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{const t={...e};return t.state!==void 0&&delete t.attributes,t})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e),this._setElementState(e,"refresh");const t=u._createOn(e);for(const n of this._markerCollection.getMarkersIntersectingRange(t)){const r=n.getData();this.bufferMarkerChange(n.name,r,r)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const n=t.getData();this.bufferMarkerChange(t.name,{...n,range:null},n)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e)){this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});return}const n=this._changedRoots.get(e);n.state!==void 0?(delete n.state,n.attributes===void 0&&this._changedRoots.delete(e)):n.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,n,r){const i=this._changedRoots.get(e)||{name:e},o=i.attributes||{};if(o[t]){const a=o[t];r===a.oldValue?delete o[t]:a.newValue=r}else o[t]={oldValue:n,newValue:r};Object.entries(o).length===0?(delete i.attributes,i.state===void 0&&this._changedRoots.delete(e)):(i.attributes=o,this._changedRoots.set(e,i))}_markInsert(e,t,n){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const r={type:"insert",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,r)}_markRemove(e,t,n){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const r={type:"remove",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,r),this._removeAllNestedChanges(e,t,n)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);const n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let r=0;r<n.length;r++)n[r].howMany<1&&(n.splice(r,1),r--)}_setElementState(e,t){if(!e.is("element"))return;const n=ht._statesPriority.indexOf(this._elementState.get(e));ht._statesPriority.indexOf(t)>n&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element")||!this._elementsSnapshots.has(e))return t;const n=this._elementState.get(e);return!n||n=="move"?t:n}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshots(e){if(this._elementChildrenSnapshots.has(e))return;const t=xn(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const n of t)this._elementsSnapshots.set(n.node,n)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const n of t){const r=e.offset+e.howMany,i=n.offset+n.howMany;if(e.type=="insert"&&(n.type=="insert"&&(e.offset<=n.offset?n.offset+=e.howMany:e.offset<i&&(n.howMany+=e.nodesToHandle,e.nodesToHandle=0)),n.type=="remove"&&e.offset<n.offset&&(n.offset+=e.howMany),n.type=="attribute")){if(e.offset<=n.offset)n.offset+=e.howMany;else if(e.offset<i){const o=n.howMany;n.howMany=e.offset-n.offset,t.unshift({type:"attribute",offset:r,howMany:o-n.howMany,count:this._changeCount++})}}if(e.type=="remove"){if(n.type=="insert"){if(r<=n.offset)n.offset-=e.howMany;else if(r<=i)if(e.offset<n.offset){const o=r-n.offset;n.offset=e.offset,n.howMany-=o,e.nodesToHandle-=o}else n.howMany-=e.nodesToHandle,e.nodesToHandle=0;else if(e.offset<=n.offset)e.nodesToHandle-=n.howMany,n.howMany=0;else if(e.offset<i){const o=i-e.offset;n.howMany-=o,e.nodesToHandle-=o}}if(n.type=="remove"&&(r<=n.offset?n.offset-=e.howMany:e.offset<n.offset&&(e.nodesToHandle+=n.howMany,n.howMany=0)),n.type=="attribute"){if(r<=n.offset)n.offset-=e.howMany;else if(e.offset<n.offset){const o=r-n.offset;n.offset=e.offset,n.howMany-=o}else if(e.offset<i)if(r<=i){const o=n.howMany;n.howMany=e.offset-n.offset;const a=o-n.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:a,count:this._changeCount++})}else n.howMany-=i-e.offset}}if(e.type=="attribute"){if(n.type=="insert")if(e.offset<n.offset&&r>n.offset){if(r>i){const o={type:"attribute",offset:i,howMany:r-i,count:this._changeCount++};this._handleChange(o,t),t.push(o)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offset<i&&(r>i?(e.nodesToHandle=r-i,e.offset=i):e.nodesToHandle=0);if(n.type=="remove"&&e.offset<n.offset&&r>n.offset){const o={type:"attribute",offset:n.offset,howMany:r-n.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}n.type=="attribute"&&(e.offset>=n.offset&&r<=i?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&r>=i&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n,r,i){const o={type:"insert",position:m._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++,action:n};return n!="insert"&&i&&(o.before={name:i.name,attributes:new Map(i.attributes)}),o}_getRemoveDiff(e,t,n,r){return{type:"remove",action:n,position:m._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){const r=[];n=new Map(n);for(const[i,o]of t){const a=n.has(i)?n.get(i):null;a!==o&&r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:i,attributeOldValue:o,attributeNewValue:a,changeCount:this._changeCount++}),n.delete(i)}for(const[i,o]of n)r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:i,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return r}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const n=this._changesInElement.get(t),r=e.startOffset;if(n){for(const i of n)if(i.type=="insert"&&r>=i.offset&&r<i.offset+i.howMany)return!0}return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,n){const r=new u(m._createAt(e,t),m._createAt(e,t+n));for(const i of r.getItems({shallow:!0}))i.is("element")&&(this._changesInElement.delete(i),this._removeAllNestedChanges(i,0,i.maxOffset))}}function Nn(s){return{node:s,name:s.is("$text")?"$text":s.name,attributes:new Map(s.getAttributes())}}function xn(s){const e=[];for(const t of s)if(t.is("$text"))for(let n=0;n<t.data.length;++n)e.push(Nn(t));else e.push(Nn(t));return e}function Lo(s,e){const t=[];let n=0,r=0;for(const i of e){if(i.offset>n){for(let o=0;o<i.offset-n;o++)t.push("e");r+=i.offset-n}if(i.type=="insert"){for(let o=0;o<i.howMany;o++)t.push("i");n=i.offset+i.howMany}else if(i.type=="remove"){for(let o=0;o<i.howMany;o++)t.push("r");n=i.offset,r+=i.howMany}else{if(i.howMany>1500)for(let o=0;o<i.howMany;o++)t.push("a");else t.push(..."a".repeat(i.howMany).split(""));n=i.offset+i.howMany,r+=i.howMany}}if(r<s)for(let i=0;i<s-r-n;i++)t.push("e");return t}function $o(s){const e="position"in s&&s.position.root.rootName=="$graveyard",t="range"in s&&s.range.root.rootName=="$graveyard";return!e&&!t}class Wo{_operations=[];_undoPairs=new Map;_undoneOperations=new Set;_baseVersionToOperationIndex=new Map;_version=0;_gaps=new Map;get version(){return this._version}set version(e){this._operations.length&&e>this._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new d("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const n=this._operations[0];e===void 0&&(e=n.baseVersion);let r=t-1;for(const[a,l]of this._gaps)e>a&&e<l&&(e=l),r>a&&r<l&&(r=a-1);if(r<n.baseVersion||e>this.lastOperation.baseVersion)return[];let i=this._baseVersionToOperationIndex.get(e);i===void 0&&(i=0);let o=this._baseVersionToOperationIndex.get(r);return o===void 0&&(o=this._operations.length-1),this._operations.slice(i,o+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(t!==void 0)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class ut extends C{rootName;_document;_isAttached=!0;_isLoaded=!0;constructor(e,t,n="main"){super(t),this._document=e,this.rootName=n}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}ut.prototype.is=function(s,e){return e?e===this.name&&(s==="rootElement"||s==="model:rootElement"||s==="element"||s==="model:element"):s==="rootElement"||s==="model:rootElement"||s==="element"||s==="model:element"||s==="node"||s==="model:node"};const On="$graveyard";class qo extends x(){model;history;selection;roots;differ;isReadOnly;_postFixers;_hasSelectionChangedFromTheLastChangeBlock;constructor(e){super(),this.model=e,this.history=new Wo,this.selection=new K(this),this.roots=new Bt({idProperty:"rootName"}),this.differ=new ht(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",On),this.listenTo(e,"applyOperation",(t,n)=>{const r=n[0];r.isDocumentOperation&&this.differ.bufferOperation(r)},{priority:"high"}),this.listenTo(e,"applyOperation",(t,n)=>{const r=n[0];r.isDocumentOperation&&this.history.addOperation(r)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(t,n,r,i,o)=>{const a={...n.getData(),range:i};this.differ.bufferMarkerChange(n.name,o,a),r===null&&n.on("change",(l,c)=>{const h=n.getData();this.differ.bufferMarkerChange(n.name,{...h,range:c},h)})}),this.registerPostFixer(t=>{let n=!1;for(const r of this.roots)!r.isAttached()&&!r.isEmpty&&(t.remove(t.createRangeIn(r)),n=!0);for(const r of this.model.markers)r.getRange().root.isAttached()||(t.removeMarker(r),n=!0);return n})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(On)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new d("model-document-createroot-name-exists",this,{name:t});const n=new ut(this,e,t);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(t=>t.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=js(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,n=t.schema,r=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(r)||t.createRange(r)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&In(e.start)&&In(e.end)}_callPostFixers(e){let t=!1;do for(const n of this._postFixers)if(this.selection.refresh(),t=n(e),t)break;while(t)}}function In(s){const e=s.textNode;if(e){const t=e.data,n=s.offset-e.startOffset;return!Wn(t,n)&&!qn(t,n)}return!0}class zo extends x(){_markers=new Map;[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Pe?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,n=!1,r=!1){const i=e instanceof Pe?e.name:e;if(i.includes(","))throw new d("markercollection-incorrect-marker-name",this);const o=this._markers.get(i);if(o){const c=o.getData(),h=o.getRange();let f=!1;return h.isEqual(t)||(o._attachLiveRange(pe.fromRange(t)),f=!0),n!=o.managedUsingOperations&&(o._managedUsingOperations=n,f=!0),typeof r=="boolean"&&r!=o.affectsData&&(o._affectsData=r,f=!0),f&&this.fire(`update:${i}`,o,h,t,c),o}const a=pe.fromRange(t),l=new Pe(i,a,n,r);return this._markers.set(i,l),this.fire(`update:${i}`,l,null,t,{...l.getData(),range:null}),l}_remove(e){const t=e instanceof Pe?e.name:e,n=this._markers.get(t);return n?(this._markers.delete(t),this.fire(`update:${t}`,n,n.getRange(),null,n.getData()),this._destroyMarker(n),!0):!1}_refresh(e){const t=e instanceof Pe?e.name:e,n=this._markers.get(t);if(!n)throw new d("markercollection-refresh-marker-not-exists",this);const r=n.getRange();this.fire(`update:${t}`,n,r,r,n.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)t.getRange().getIntersection(e)!==null&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Pe extends x(ce){name;_managedUsingOperations;_affectsData;_liveRange;constructor(e,t,n,r){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=r}get managedUsingOperations(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.toRange()}toJSON(){return{name:this.name,range:this._liveRange?.toJSON(),usingOperations:this._managedUsingOperations,affectsData:this._affectsData}}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}Pe.prototype.is=function(s){return s==="marker"||s==="model:marker"};class Jo extends W{sourcePosition;howMany;constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new d("detach-operation-on-document-node",this)}_execute(){Ss(u._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class Y extends ce{markers=new Map;_children=new $e;constructor(e){super(),e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const n of e)t=t.getChildAtOffset(n);return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const n of e)n.name?t.push(C.fromJSON(n)):t.push(k.fromJSON(n));return new Y(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=Uo(t);for(const r of n)r.parent!==null&&r._remove(),r.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const r of n)r.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}Y.prototype.is=function(s){return s==="documentFragment"||s==="model:documentFragment"};function Uo(s){return typeof s=="string"?[new k(s)]:(oe(s)||(s=[s]),Array.from(s).map(e=>typeof e=="string"?new k(e):e instanceof j?new k(e.data,e.getAttributes()):e))}class jo{model;batch;constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new k(e,t)}createElement(e,t){return new C(e,t)}createDocumentFragment(){return new Y}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,n=0){if(this._assertWriterUsedCorrectly(),e instanceof k&&e.data=="")return;const r=m._createAt(t,n);if(e.parent)if(Bn(e.root,r.root)){this.move(u._createOn(e),r);return}else{if(e.root.document)throw new d("model-writer-insert-forbidden-move",this);this.remove(e)}const i=r.root.document?r.root.document.version:null,o=e instanceof Y?e._removeChildren(0,e.childCount):e,a=new M(r,o,i);if(e instanceof k&&(a.shouldReceiveAttributes=!0),this.batch.addOperation(a),this.model.applyOperation(a),e instanceof Y)for(const[l,c]of e.markers){const h=m._createAt(c.root,0),p={range:new u(c.start._getCombined(h,r),c.end._getCombined(h,r)),usingOperation:!0,affectsData:!0};this.model.markers.has(l)?this.updateMarker(l,p):this.addMarker(l,p)}}insertText(e,t,n,r){t instanceof Y||t instanceof C||t instanceof m?this.insert(this.createText(e),t,n):this.insert(this.createText(e,t),n,r)}insertElement(e,t,n,r){t instanceof Y||t instanceof C||t instanceof m?this.insert(this.createElement(e),t,n):this.insert(this.createElement(e,t),n,r)}append(e,t){this.insert(e,t,"end")}appendText(e,t,n){t instanceof Y||t instanceof C?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),n,"end")}appendElement(e,t,n){t instanceof Y||t instanceof C?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),n,"end")}setAttribute(e,t,n){if(this._assertWriterUsedCorrectly(),n instanceof u){const r=n.getMinimalFlatRanges();for(const i of r)Fn(this,e,t,i)}else Dn(this,e,t,n)}setAttributes(e,t){for(const[n,r]of ge(e))this.setAttribute(n,r,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof u){const n=t.getMinimalFlatRanges();for(const r of n)Fn(this,e,null,r)}else Dn(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=n=>{for(const r of n.getAttributeKeys())this.removeAttribute(r,n)};if(!(e instanceof u))t(e);else for(const n of e.getItems())t(n)}move(e,t,n){if(this._assertWriterUsedCorrectly(),!(e instanceof u))throw new d("writer-move-invalid-range",this);if(!e.isFlat)throw new d("writer-move-range-not-flat",this);const r=m._createAt(t,n);if(r.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Bn(e.root,r.root))throw new d("writer-move-different-document",this);const i=e.root.document?e.root.document.version:null,o=new v(e.start,e.end.offset-e.start.offset,r,i);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const n=(e instanceof u?e:u._createOn(e)).getMinimalFlatRanges().reverse();for(const r of n)this._addOperationForAffectedMarkers("move",r),Go(r.start,r.end.offset-r.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,n=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof C))throw new d("writer-merge-no-element-before",this);if(!(n instanceof C))throw new d("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,n){return this.model.createPositionFromPath(e,t,n)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,n=e.nodeAfter;this.move(u._createIn(n),m._createAt(t,"end")),this.remove(n)}_merge(e){const t=m._createAt(e.nodeBefore,"end"),n=m._createAt(e.nodeAfter,0),r=e.root.document.graveyard,i=new m(r,[0]),o=e.root.document.version,a=new S(n,e.nodeAfter.maxOffset,t,i,o);this.batch.addOperation(a),this.model.applyOperation(a)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof C))throw new d("writer-rename-not-element-instance",this);const n=e.root.document?e.root.document.version:null,r=new V(m._createBefore(e),e.name,t,n);this.batch.addOperation(r),this.model.applyOperation(r)}split(e,t){this._assertWriterUsedCorrectly();let n=e.parent;if(!n.parent)throw new d("writer-split-element-no-parent",this);if(t||(t=n.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new d("writer-split-invalid-limit-element",this);let r,i;do{const o=n.root.document?n.root.document.version:null,a=n.maxOffset-e.offset,l=P.getInsertionPosition(e),c=new P(e,a,l,null,o);this.batch.addOperation(c),this.model.applyOperation(c),!r&&!i&&(r=n,i=e.parent.nextSibling),e=this.createPositionAfter(e.parent),n=e.parent}while(n!==t);return{position:e,range:new u(m._createAt(r,"end"),m._createAt(i,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new d("writer-wrap-range-not-flat",this);const n=t instanceof C?t:new C(t);if(n.childCount>0)throw new d("writer-wrap-element-not-empty",this);if(n.parent!==null)throw new d("writer-wrap-element-attached",this);this.insert(n,e.start);const r=new u(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(r,m._createAt(n,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),e.parent===null)throw new d("writer-unwrap-element-no-parent",this);this.move(u._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||typeof t.usingOperation!="boolean")throw new d("writer-addmarker-no-usingoperation",this);const n=t.usingOperation,r=t.range,i=t.affectsData===void 0?!1:t.affectsData;if(this.model.markers.has(e))throw new d("writer-addmarker-marker-exists",this);if(!r)throw new d("writer-addmarker-no-range",this);return n?(Ie(this,e,null,r,i),this.model.markers.get(e)):this.model.markers._set(e,r,n,i)}updateMarker(e,t){this._assertWriterUsedCorrectly();const n=typeof e=="string"?e:e.name,r=this.model.markers.get(n);if(!r)throw new d("writer-updatemarker-marker-not-exists",this);if(!t){J("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),this.model.markers._refresh(r);return}const i=typeof t.usingOperation=="boolean",o=typeof t.affectsData=="boolean",a=o?t.affectsData:r.affectsData;if(!i&&!t.range&&!o)throw new d("writer-updatemarker-wrong-options",this);const l=r.getRange(),c=t.range?t.range:l;if(i&&t.usingOperation!==r.managedUsingOperations){t.usingOperation?Ie(this,n,null,c,a):(Ie(this,n,l,null,a),this.model.markers._set(n,c,void 0,a));return}r.managedUsingOperations?Ie(this,n,l,c,a):this.model.markers._set(n,c,void 0,a)}removeMarker(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?e:e.name;if(!this.model.markers.has(t))throw new d("writer-removemarker-no-marker",this);const n=this.model.markers.get(t);if(!n.managedUsingOperations){this.model.markers._remove(t);return}const r=n.getRange();Ie(this,t,r,null,n.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const n=this.model.document.getRoot(e);if(n&&n.isAttached())throw new d("writer-addroot-root-exists",this);const r=this.model.document,i=new Q(e,t,!0,r,r.version);return this.batch.addOperation(i),this.model.applyOperation(i),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new d("writer-detachroot-no-root",this);for(const i of this.model.markers)i.getRange().root===t&&this.removeMarker(i);for(const i of t.getAttributeKeys())this.removeAttribute(i,t);this.remove(this.createRangeIn(t));const n=this.model.document,r=new Q(t.rootName,t.name,!1,n,n.version);this.batch.addOperation(r),this.model.applyOperation(r)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._setSelectionAttribute(e,t);else for(const[n,r]of ge(e))this._setSelectionAttribute(n,r)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const r=K._getStoreAttributeKey(e);this.setAttribute(r,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const n=K._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new d("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const r=n.getRange();let i=!1;if(e==="move"){const o=t;i=o.containsPosition(r.start)||o.start.isEqual(r.start)||o.containsPosition(r.end)||o.end.isEqual(r.end)}else{const o=t,a=o.nodeBefore,l=o.nodeAfter,c=r.start.parent==a&&r.start.isAtEnd,h=r.end.parent==l&&r.end.offset==0,f=r.end.nodeAfter==l,p=r.start.nodeAfter==l;i=c||h||f||p}i&&this.updateMarker(n.name,{range:r})}}}function Fn(s,e,t,n){const r=s.model,i=r.document;let o=n.start,a,l,c;for(const f of n.getWalker({shallow:!0}))c=f.item.getAttribute(e),a&&l!=c&&(l!=t&&h(),o=a),a=f.nextPosition,l=c;a instanceof m&&a!=o&&l!=t&&h();function h(){const f=new u(o,a),p=f.root.document?i.version:null,_=new A(f,e,l,t,p);s.batch.addOperation(_),r.applyOperation(_)}}function Dn(s,e,t,n){const r=s.model,i=r.document,o=n.getAttribute(e);let a,l;if(o!=t){if(n.root===n){const h=n.document?i.version:null;l=new ee(n,e,o,t,h)}else{a=new u(m._createBefore(n),s.createPositionAfter(n));const h=a.root.document?i.version:null;l=new A(a,e,o,t,h)}s.batch.addOperation(l),r.applyOperation(l)}}function Ie(s,e,t,n,r){const i=s.model,o=i.document,a=new B(e,t,n,i.markers,!!r,o.version);s.batch.addOperation(a),i.applyOperation(a)}function Go(s,e,t,n){let r;if(s.root.document){const i=n.document,o=new m(i.graveyard,[0]);r=new v(s,e,o,i.version)}else r=new Jo(s,e);t.addOperation(r),n.applyOperation(r)}function Bn(s,e){return s===e||s instanceof ut&&e instanceof ut}function Ho(s){s.document.registerPostFixer(e=>Ko(e,s))}function Ko(s,e){const t=e.document.selection,n=e.schema,r=[];let i=!1;for(const o of t.getRanges()){const a=Xo(o,n);a&&!a.isEqual(o)?(r.push(a),i=!0):r.push(o)}return i&&s.setSelection(ea(r),{backward:t.isBackward}),!1}function Xo(s,e){return s.isCollapsed?Yo(s,e):Qo(s,e)}function Yo(s,e){const t=s.start,n=e.getNearestSelectionRange(t);if(!n){const i=t.getAncestors().reverse().find(o=>e.isObject(o));return i?u._createOn(i):null}if(!n.isCollapsed)return n;const r=n.start;return t.isEqual(r)?null:new u(r)}function Qo(s,e){const{start:t,end:n}=s,r=e.checkChild(t,"$text"),i=e.checkChild(n,"$text"),o=e.getLimitElement(t),a=e.getLimitElement(n);if(o===a){if(r&&i)return null;if(Zo(t,n,e)){const f=t.nodeAfter&&e.isSelectable(t.nodeAfter)?null:e.getNearestSelectionRange(t,"forward"),_=n.nodeBefore&&e.isSelectable(n.nodeBefore)?null:e.getNearestSelectionRange(n,"backward"),y=f?f.start:t,I=_?_.end:n;return new u(y,I)}}const l=o&&!o.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const h=t.nodeAfter&&n.nodeBefore&&t.nodeAfter.parent===n.nodeBefore.parent,f=l&&(!h||!Ln(t.nodeAfter,e)),p=c&&(!h||!Ln(n.nodeBefore,e));let _=t,y=n;return f&&(_=m._createBefore(Vn(o,e))),p&&(y=m._createAfter(Vn(a,e))),new u(_,y)}return null}function Vn(s,e){let t=s,n=t;for(;e.isLimit(n)&&n.parent;)t=n,n=n.parent;return t}function Zo(s,e,t){const n=s.nodeAfter&&!t.isLimit(s.nodeAfter)||t.checkChild(s,"$text"),r=e.nodeBefore&&!t.isLimit(e.nodeBefore)||t.checkChild(e,"$text");return n||r}function ea(s){const e=[...s],t=new Set;let n=1;for(;n<e.length;){const i=e[n],o=e.slice(0,n);for(const[a,l]of o.entries())if(!t.has(a)){if(i.isEqual(l))t.add(a);else if(i.isIntersecting(l)){t.add(a),t.add(n);const c=i.getJoined(l);e.push(c)}}n++}return e.filter((i,o)=>!t.has(o))}function Ln(s,e){return s&&e.isSelectable(s)}function ta(s,e,t={}){if(e.isCollapsed)return;const n=e.getFirstRange();if(n.root.rootName=="$graveyard")return;const r=s.schema;s.change(i=>{if(!t.doNotResetEntireContent&&ha(r,e)){ca(i,e);return}const o={};if(!t.doNotAutoparagraph){const c=e.getSelectedElement();c&&Object.assign(o,r.getAttributesWithProperty(c,"copyOnReplace",!0))}let a,l;t.doNotFixSelection?(a=O.fromPosition(n.start,"toPrevious"),l=O.fromPosition(n.end,"toNext")):[a,l]=na(n),a.isTouching(l)||i.remove(i.createRange(a,l)),t.leaveUnmerged||(ra(i,a,l),r.removeDisallowedAttributes(a.parent.getChildren(),i)),xs(i,e,a),!t.doNotAutoparagraph&&aa(r,a)&&Ns(i,a,e,o),a.detach(),l.detach()})}function na(s){const e=s.root.document.model,t=s.start;let n=s.end;if(e.hasContent(s,{ignoreMarkers:!0})){const r=sa(n);if(r&&n.isTouching(e.createPositionAt(r,0))){const i=e.createSelection(s);e.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),a=e.createRange(o,n);e.hasContent(a,{ignoreMarkers:!0})||(n=o)}}return[O.fromPosition(t,"toPrevious"),O.fromPosition(n,"toNext")]}function sa(s){const e=s.parent,t=e.root.document.model.schema,n=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const r of n){if(t.isLimit(r))return null;if(t.isBlock(r))return r}}function ra(s,e,t){const n=s.model;if(!Kt(s.model.schema,e,t))return;const[r,i]=oa(e,t);!r||!i||(!n.hasContent(r,{ignoreMarkers:!0})&&n.hasContent(i,{ignoreMarkers:!0})?Ms(s,e,t,r.parent):Ts(s,e,t,r.parent))}function Ts(s,e,t,n){const r=e.parent,i=t.parent;if(!(r==n||i==n)){for(e=s.createPositionAfter(r),t=s.createPositionBefore(i),t.isEqual(e)||s.insert(i,e),s.merge(e);t.parent.isEmpty;){const o=t.parent;t=s.createPositionBefore(o),s.remove(o)}Kt(s.model.schema,e,t)&&Ts(s,e,t,n)}}function Ms(s,e,t,n){const r=e.parent,i=t.parent;if(!(r==n||i==n)){for(e=s.createPositionAfter(r),t=s.createPositionBefore(i),t.isEqual(e)||s.insert(r,t);e.parent.isEmpty;){const o=e.parent;e=s.createPositionBefore(o),s.remove(o)}t=s.createPositionBefore(i),ia(s,t),Kt(s.model.schema,e,t)&&Ms(s,e,t,n)}}function ia(s,e){const t=e.nodeBefore,n=e.nodeAfter;t.name!=n.name&&s.rename(t,n.name),s.clearAttributes(t),s.setAttributes(Object.fromEntries(n.getAttributes()),t),s.merge(e)}function Kt(s,e,t){const n=e.parent,r=t.parent;return n==r||s.isLimit(n)||s.isLimit(r)?!1:la(e,t,s)}function oa(s,e){const t=s.getAncestors(),n=e.getAncestors();let r=0;for(;t[r]&&t[r]==n[r];)r++;return[t[r],n[r]]}function aa(s,e){const t=s.checkChild(e,"$text"),n=s.checkChild(e,"paragraph");return!t&&n}function la(s,e,t){const n=new u(s,e);for(const r of n.getWalker())if(t.isLimit(r.item))return!1;return!0}function Ns(s,e,t,n={}){const r=s.createElement("paragraph");s.model.schema.setAllowedAttributes(r,n,s),s.insert(r,e),xs(s,t,s.createPositionAt(r,0))}function ca(s,e){const t=s.model.schema.getLimitElement(e);s.remove(s.createRangeIn(t)),Ns(s,s.createPositionAt(t,0),e)}function ha(s,e){const t=s.getLimitElement(e);if(!e.containsEntireContent(t))return!1;const n=e.getFirstRange();return n.start.parent==n.end.parent?!1:s.checkChild(t,"paragraph")}function xs(s,e,t){e instanceof K?s.setSelection(t):e.setTo(t)}function ua(s,e){return s.change(t=>{const n=t.createDocumentFragment(),r=e.getFirstRange();if(!r||r.isCollapsed)return n;const i=r.start.root,o=r.start.getCommonPath(r.end),a=i.getNodeByPath(o);let l;r.start.parent==r.end.parent?l=r:l=t.createRange(t.createPositionAt(a,r.start.path[o.length]),t.createPositionAt(a,r.end.path[o.length]+1));const c=l.end.offset-l.start.offset;for(const h of l.getItems({shallow:!0}))h.is("$textProxy")?t.appendText(h.data,h.getAttributes(),n):t.append(t.cloneElement(h,!0),n);if(l!=r){const h=r._getTransformedByMove(l.start,t.createPositionAt(n,0),c)[0],f=t.createRange(t.createPositionAt(n,0),h.start),p=t.createRange(h.end,t.createPositionAt(n,"end"));$n(p,t),$n(f,t)}return n})}function $n(s,e){const t=[];Array.from(s.getItems({direction:"backward"})).map(n=>e.createRangeOn(n)).filter(n=>(n.start.isAfter(s.start)||n.start.isEqual(s.start))&&(n.end.isBefore(s.end)||n.end.isEqual(s.end))).forEach(n=>{t.push(n.start.parent),e.remove(n)}),t.forEach(n=>{let r=n;for(;r.parent&&r.isEmpty;){const i=e.createRangeOn(r);r=r.parent,e.remove(i)}})}function fa(s,e,t){return s.change(n=>{const r=t||s.document.selection;r.isCollapsed||s.deleteContent(r,{doNotAutoparagraph:!0});const i=new da(s,n,r.anchor),o=[];let a;if(e.is("documentFragment")){if(e.markers.size){const h=[];for(const[f,p]of e.markers){const{start:_,end:y}=p,I=_.isEqual(y);h.push({position:_,name:f,isCollapsed:I},{position:y,name:f,isCollapsed:I})}h.sort(({position:f},{position:p})=>f.isBefore(p)?1:-1);for(const{position:f,name:p,isCollapsed:_}of h){let y=null,I=null;const he=f.parent===e&&f.isAtStart,te=f.parent===e&&f.isAtEnd;!he&&!te?(y=n.createElement("$marker"),n.insert(y,f)):_&&(I=he?"start":"end"),o.push({name:p,element:y,collapsed:I})}}a=e.getChildren()}else a=[e];i.handleNodes(a);let l=i.getSelectionRange();if(e.is("documentFragment")&&o.length){const h=l?pe.fromRange(l):null,f={};for(let p=o.length-1;p>=0;p--){const{name:_,element:y,collapsed:I}=o[p],he=!f[_];if(he&&(f[_]=[]),y){const te=n.createPositionAt(y,"before");f[_].push(te),n.remove(y)}else{const te=i.getAffectedRange();if(!te){I&&f[_].push(i.position);continue}I?f[_].push(te[I]):f[_].push(he?te.start:te.end)}}for(const[p,[_,y]]of Object.entries(f))_&&y&&_.root===y.root&&_.root.document&&!n.model.markers.has(p)&&n.addMarker(p,{usingOperation:!0,affectsData:!0,range:new u(_,y)});h&&(l=h.toRange(),h.detach())}l&&(r instanceof K?n.setSelection(l):r.setTo(l));const c=i.getAffectedRange()||s.createRange(r.anchor);return i.destroy(),c})}class da{model;writer;position;canMergeWith;schema;_documentFragment;_documentFragmentPosition;_firstNode=null;_lastNode=null;_lastAutoParagraph=null;_filterAttributesAndChildrenOf=[];_affectedStart=null;_affectedEnd=null;_nodeToSelect=null;constructor(e,t,n){this.model=e,this.writer=t,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))t.offsetSize>0&&this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesAndChildrenOf,this.writer),this.model._config?.get("experimentalFlags.modelInsertContentDeepSchemaVerification")&&this._removeDisallowedChildren(this._filterAttributesAndChildrenOf),this._filterAttributesAndChildrenOf=[]}_removeDisallowedChildren(e){const t=Array.from(e);for(const n of t){if(!n.is("element"))continue;const r=[],i=[],o=this.writer.createRangeIn(n).getWalker({ignoreElementEnd:!0});for(const{item:a}of o){const l=a.parent;this.schema.checkChild(l,a)||(a.is("element")&&!this.schema.isObject(a)?(i.push(a),t.push(l)):r.push(a),o.jumpTo(this.writer.createPositionAfter(a)))}for(const a of i)this.writer.unwrap(a);for(const a of r)this.writer.remove(a)}}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){this._lastNode=e;if(this.position.parent!=e||!this.position.isAtEnd)throw new d("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?u._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new u(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(!this._checkAndSplitToAllowedPosition(e)){this.schema.isObject(e)||this._handleDisallowedNode(e);return}e=this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=O.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleDisallowedNode(e){e.is("element")&&this.handleNodes(e.getChildren())}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new d("insertcontent-wrong-position",this,{node:e,position:this.position});return this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),e.parent||(e=this._documentFragmentPosition.nodeBefore),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesAndChildrenOf.push(e),e}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=O.fromPosition(e,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=O.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof C)||!this._canMergeLeft(e))return;const t=O._createBefore(e);t.stickiness="toNext";const n=O.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=O._createAt(t.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=O._createAt(t.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof C)||!this._canMergeRight(e))return;const t=O._createAfter(e);t.stickiness="toNext";if(!this.position.isEqual(t))throw new d("insertcontent-invalid-insertion-position",this);this.position=m._createAt(t.nodeBefore,"end");const n=O.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=O._createAt(t.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=O._createAt(t.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof C&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof C&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();const e=this.writer.createElement("paragraph");this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0)}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const n=this.position.parent;this.position=this.writer.createPositionBefore(n),n.isEmpty&&n.parent===t&&this.writer.remove(n)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const n=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=n,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){const n=this.schema.createContext(e);return this.schema.checkChild(n,t)||this.schema.checkChild(n,"paragraph")&&this.schema.checkChild(n.push("paragraph"),t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function ma(s,e,t,n={}){if(!s.schema.isObject(e))throw new d("insertobject-element-not-an-object",s,{object:e});const r=t||s.document.selection;let i=r;n.findOptimalPosition&&s.schema.isBlock(e)&&(i=s.createSelection(s.schema.findOptimalInsertionRange(r,n.findOptimalPosition)));const o=Vt(r.getSelectedBlocks()),a={};return o&&Object.assign(a,s.schema.getAttributesWithProperty(o,"copyOnReplace",!0)),s.change(l=>{i.isCollapsed||s.deleteContent(i,{doNotAutoparagraph:!0});let c=e;const h=i.anchor.parent,f=s.schema.createContext(h);!s.schema.checkChild(f,e)&&s.schema.checkChild(f,"paragraph")&&s.schema.checkChild(f.push("paragraph"),e)&&(c=l.createElement("paragraph"),l.insert(e,c)),s.schema.setAllowedAttributes(c,a,l);const p=s.insertContent(c,i);return p.isCollapsed||n.setSelection&&ga(l,e,n.setSelection,a),p})}function ga(s,e,t,n){const r=s.model;if(t=="on"){s.setSelection(e,"on");return}if(t!="after")throw new d("insertobject-invalid-place-parameter-value",r);let i=e.nextSibling;if(r.schema.isInline(e)){s.setSelection(e,"after");return}!(i&&r.schema.checkChild(i,"$text"))&&r.schema.checkChild(e.parent,"paragraph")&&(i=s.createElement("paragraph"),r.schema.setAllowedAttributes(i,n,s),r.insertContent(i,s.createPositionAfter(e))),i&&s.setSelection(i,0)}const pa=' ,.?!:;"-()';function _a(s,e,t={}){const n=s.schema,r=t.direction!="backward",i=t.unit?t.unit:"character",o=!!t.treatEmojiAsSingleUnit,a=e.focus,l=new se({boundaries:va(a,r),singleCharacters:!0,direction:r?"forward":"backward"}),c={walker:l,schema:n,isForward:r,unit:i,treatEmojiAsSingleUnit:o};let h;for(;h=l.next();){if(h.done)return;const f=wa(c,h.value);if(f){e instanceof K?s.change(p=>{p.setSelectionFocus(f)}):e.setFocus(f);return}}}function wa(s,e){const{isForward:t,walker:n,unit:r,schema:i,treatEmojiAsSingleUnit:o}=s,{type:a,item:l,nextPosition:c}=e;if(a=="text")return s.unit==="word"?ya(n,t):ba(n,r,o);if(a==(t?"elementStart":"elementEnd")){if(i.isSelectable(l))return m._createAt(l,t?"after":"before");if(i.checkChild(c,"$text"))return c}else{if(i.isLimit(l)){n.skip(()=>!0);return}if(i.checkChild(c,"$text"))return c}}function ba(s,e,t){const n=s.position.textNode;if(n){const r=n.data;let i=s.position.offset-n.startOffset;for(;Wn(r,i)||e=="character"&&qn(r,i)||t&&qs(r,i);)s.next(),i=s.position.offset-n.startOffset}return s.position}function ya(s,e){let t=s.position.textNode;for(t||(t=e?s.position.nodeAfter:s.position.nodeBefore);t&&t.is("$text");){const n=s.position.offset-t.startOffset;if(Ca(t,n,e))t=e?s.position.nodeAfter:s.position.nodeBefore;else{if(Pa(t.data,n,e))break;s.next()}}return s.position}function va(s,e){const t=s.root,n=m._createAt(t,e?"end":0);return e?new u(s,n):new u(n,s)}function Pa(s,e,t){const n=e+(t?0:-1);return pa.includes(s.charAt(n))}function Ca(s,e,t){return e===(t?s.offsetSize:0)}class pl extends z(){markers;document;schema;_config;_pendingChanges;_currentWriter;constructor(e){super(),this.markers=new zo,this.document=new qo(this),this.schema=new ao,this._config=e,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(t=>this.decorate(t)),this.on("applyOperation",(t,n)=>{n[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),Ho(this),this.document.registerPostFixer(bs),this.on("insertContent",(t,[n,r])=>{t.return=fa(this,n,r)}),this.on("insertObject",(t,[n,r,i])=>{t.return=ma(this,n,r,i)}),this.on("canEditAt",t=>{const n=!this.document.isReadOnly;t.return=n,n||t.stop()})}change(e){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new ve,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(t){d.rethrowUnexpectedError(t,this)}}enqueueChange(e,t){try{e?typeof e=="function"?(t=e,e=new ve):e instanceof ve||(e=new ve(e)):e=new ve,this._pendingChanges.push({batch:e,callback:t}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(n){d.rethrowUnexpectedError(n,this)}}applyOperation(e){e._execute()}insertContent(e,t,n,...r){const i=At(t,n);return this.fire("insertContent",[e,i,n,...r])}insertObject(e,t,n,r,...i){const o=At(t,n);return this.fire("insertObject",[e,o,r,r,...i])}deleteContent(e,t){ta(this,e,t)}modifySelection(e,t){_a(this,e,t)}getSelectedContent(e){return ua(this,e)}hasContent(e,t={}){const n=e instanceof u?e:u._createIn(e);if(n.isCollapsed)return!1;const{ignoreWhitespaces:r=!1,ignoreMarkers:i=!1}=t;if(!i){for(const o of this.markers.getMarkersIntersectingRange(n))if(o.affectsData)return!0}for(const o of n.getItems())if(this.schema.isContent(o))if(o.is("$textProxy"))if(r){if(o.data.search(/\S/)!==-1)return!0}else return!0;else return!0;return!1}canEditAt(e){const t=At(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,n){return new m(e,t,n)}createPositionAt(e,t){return m._createAt(e,t)}createPositionAfter(e){return m._createAfter(e)}createPositionBefore(e){return m._createBefore(e)}createRange(e,t){return new u(e,t)}createRangeIn(e){return u._createIn(e)}createRangeOn(e){return u._createOn(e)}createSelection(...e){return new L(...e)}createBatch(e){return new ve(e)}createOperationFromJSON(e){return xo.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new jo(this,t);const n=this._pendingChanges[0].callback(this._currentWriter);e.push(n),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function At(s,e){if(s)return s instanceof L||s instanceof K?s:s instanceof be?e||e===0?new L(s,e):s.is("rootElement")?new L(s,"in"):new L(s,"on"):new L(s)}class _l extends le{domEventType="click";onDomEvent(e){this.fire(e.type,e)}}class wl extends le{domEventType=["mousedown","mouseup","mouseover","mouseout"];onDomEvent(e){this.fire(e.type,e)}}class bl extends le{domEventType=["touchstart","touchend","touchmove"];onDomEvent(e){this.fire(e.type,e)}}class yl extends le{domEventType=["pointerdown","pointerup","pointermove"];onDomEvent(e){this.fire(e.type,e)}}class vl{document;constructor(e){this.document=e}createDocumentFragment(e){return new me(this.document,e)}createElement(e,t,n){return new H(this.document,e,t,n)}createText(e){return new R(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const r=n.getChildIndex(e);return this.removeChildren(r,1,n),this.insertChild(r,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new H(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){Lt(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return g._createAt(e,t)}createPositionAfter(e){return g._createAfter(e)}createPositionBefore(e){return g._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new G(...e)}}const ka=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Sa=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Aa=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Ea=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,Ra=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Ta=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Ma=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function Na(s){return s.startsWith("#")?ka.test(s):s.startsWith("rgb")?Sa.test(s)||Aa.test(s):s.startsWith("hsl")?Ea.test(s)||Ra.test(s):Ma.has(s.toLowerCase())}const xa=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function Oa(s){return xa.includes(s)}const Ia=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function Fa(s){return Ia.test(s)}const Da=/^[+-]?[0-9]*([.][0-9]+)?%$/;function Pl(s){return Da.test(s)}const Ba=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function Va(s){return Ba.includes(s)}const La=["center","top","bottom","left","right"];function $a(s){return La.includes(s)}const Wa=["fixed","scroll","local"];function qa(s){return Wa.includes(s)}const za=/^url\(/;function Ja(s){return za.test(s)}function We(s=""){if(s==="")return{top:void 0,right:void 0,bottom:void 0,left:void 0};const e=Xt(s),t=e[0],n=e[2]||t,r=e[1]||t,i=e[3]||r;return{top:t,bottom:n,right:r,left:i}}function qe(s){return e=>{const{top:t,right:n,bottom:r,left:i}=e,o=[];return[t,n,i,r].every(a=>!!a)?o.push([s,Ua(e)]):(t&&o.push([s+"-top",t]),n&&o.push([s+"-right",n]),r&&o.push([s+"-bottom",r]),i&&o.push([s+"-left",i])),o}}function Ua({top:s,right:e,bottom:t,left:n}){const r=[];return n!==e?r.push(s,e,t,n):t!==s?r.push(s,e,t):e!==s?r.push(s,e):r.push(s),r.join(" ")}function Os(s){return e=>({path:s,value:We(e)})}function Xt(s){const e=s.trim().slice(0,1500).matchAll(Ta);return Array.from(e).map(t=>t[0])}function Cl(s){s.setNormalizer("background",ja()),s.setNormalizer("background-color",Ga()),s.setReducer("background",Ha()),s.setStyleRelation("background",["background-color"])}function ja(){return s=>{const e={},t=Xt(s);for(const n of t)Va(n)?(e.repeat=e.repeat||[],e.repeat.push(n)):$a(n)?(e.position=e.position||[],e.position.push(n)):qa(n)?e.attachment=n:Na(n)?e.color=n:Ja(n)&&(e.image=n);return{path:"background",value:e}}}function Ga(){return s=>({path:"background.color",value:s})}function Ha(){return s=>{const e=[];return e.push(["background-color",s.color]),e}}function kl(s){s.setNormalizer("border",Ka()),s.setNormalizer("border-top",tt("top")),s.setNormalizer("border-right",tt("right")),s.setNormalizer("border-bottom",tt("bottom")),s.setNormalizer("border-left",tt("left")),s.setNormalizer("border-color",Et("color")),s.setNormalizer("border-width",Et("width")),s.setNormalizer("border-style",Et("style")),s.setNormalizer("border-top-color",q("color","top")),s.setNormalizer("border-top-style",q("style","top")),s.setNormalizer("border-top-width",q("width","top")),s.setNormalizer("border-right-color",q("color","right")),s.setNormalizer("border-right-style",q("style","right")),s.setNormalizer("border-right-width",q("width","right")),s.setNormalizer("border-bottom-color",q("color","bottom")),s.setNormalizer("border-bottom-style",q("style","bottom")),s.setNormalizer("border-bottom-width",q("width","bottom")),s.setNormalizer("border-left-color",q("color","left")),s.setNormalizer("border-left-style",q("style","left")),s.setNormalizer("border-left-width",q("width","left")),s.setExtractor("border-top",nt("top")),s.setExtractor("border-right",nt("right")),s.setExtractor("border-bottom",nt("bottom")),s.setExtractor("border-left",nt("left")),s.setExtractor("border-top-color","border.color.top"),s.setExtractor("border-right-color","border.color.right"),s.setExtractor("border-bottom-color","border.color.bottom"),s.setExtractor("border-left-color","border.color.left"),s.setExtractor("border-top-width","border.width.top"),s.setExtractor("border-right-width","border.width.right"),s.setExtractor("border-bottom-width","border.width.bottom"),s.setExtractor("border-left-width","border.width.left"),s.setExtractor("border-top-style","border.style.top"),s.setExtractor("border-right-style","border.style.right"),s.setExtractor("border-bottom-style","border.style.bottom"),s.setExtractor("border-left-style","border.style.left"),s.setReducer("border-color",qe("border-color")),s.setReducer("border-style",qe("border-style")),s.setReducer("border-width",qe("border-width")),s.setReducer("border-top",st("top")),s.setReducer("border-right",st("right")),s.setReducer("border-bottom",st("bottom")),s.setReducer("border-left",st("left")),s.setReducer("border",Ya()),s.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),s.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),s.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),s.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),s.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),s.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),s.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),s.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Ka(){return s=>{const{color:e,style:t,width:n}=Is(s);return{path:"border",value:{color:We(e),style:We(t),width:We(n)}}}}function tt(s){return e=>{const{color:t,style:n,width:r}=Is(e),i={};return t!==void 0&&(i.color={[s]:t}),n!==void 0&&(i.style={[s]:n}),r!==void 0&&(i.width={[s]:r}),{path:"border",value:i}}}function Et(s){return e=>({path:"border",value:Xa(e,s)})}function Xa(s,e){return{[e]:We(s)}}function q(s,e){return t=>({path:"border",value:{[s]:{[e]:t}}})}function nt(s){return(e,t)=>{if(t.border)return De(t.border,s)}}function De(s,e){const t={};return s.width&&s.width[e]&&(t.width=s.width[e]),s.style&&s.style[e]&&(t.style=s.style[e]),s.color&&s.color[e]&&(t.color=s.color[e]),t}function Is(s){const e={},t=Xt(s);for(const n of t)Fa(n)||/thin|medium|thick/.test(n)?e.width=n:Oa(n)?e.style=n:e.color=n;return e}function Ya(){return e=>{const t=De(e,"top"),n=De(e,"right"),r=De(e,"bottom"),i=De(e,"left"),o=[t,n,r,i],a={width:s(o,"width"),style:s(o,"style"),color:s(o,"color")},l=Ce(a,"all");return l.length?l:[...Object.entries(a).reduce((h,[f,p])=>(p&&(h.push([`border-${f}`,p]),o.forEach(_=>delete _[f])),h),[]),...Ce(t,"top"),...Ce(n,"right"),...Ce(r,"bottom"),...Ce(i,"left")]};function s(e,t){return e.map(n=>n[t]).reduce((n,r)=>n==r?n:null)}}function st(s){return e=>Ce(e,s)}function Ce(s,e){const t=[];if(s&&s.width&&t.push("width"),s&&s.style&&t.push("style"),s&&s.color&&t.push("color"),t.length==3){const n=t.map(r=>s[r]).join(" ");return[e=="all"?["border",n]:[`border-${e}`,n]]}return e=="all"?[]:t.map(n=>[`border-${e}-${n}`,s[n]])}function Sl(s){s.setNormalizer("margin",Os("margin")),s.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),s.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),s.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),s.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),s.setReducer("margin",qe("margin")),s.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function Al(s){s.setNormalizer("padding",Os("padding")),s.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),s.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),s.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),s.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),s.setReducer("padding",qe("padding")),s.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}export{A as AttributeOperation,ve as Batch,ar as BubblingEmitterMixin,qt as BubblingEventInfo,_l as ClickObserver,jr as CompositionObserver,ml as Conversion,ls as ConversionHelpers,dl as DataController,ht as Differ,le as DomEventObserver,pi as DowncastHelpers,fl as EditingController,Qr as EditingView,qr as FakeSelectionObserver,Ot as FocusObserver,Wo as History,To as HtmlDataProcessor,Hr as InputObserver,M as InsertOperation,Wr as KeyObserver,is as Mapper,zo as MarkerCollection,B as MarkerOperation,ze as Matcher,S as MergeOperation,pl as Model,qo as ModelDocument,Y as ModelDocumentFragment,K as ModelDocumentSelection,C as ModelElement,O as ModelLivePosition,pe as ModelLiveRange,be as ModelNode,$e as ModelNodeList,m as ModelPosition,u as ModelRange,ut as ModelRootElement,ao as ModelSchema,re as ModelSchemaContext,L as ModelSelection,k as ModelText,j as ModelTextProxy,se as ModelTreeWalker,ce as ModelTypeCheckable,jo as ModelWriter,wl as MouseObserver,v as MoveOperation,ns as MutationObserver,T as NoOperation,Re as Observer,xo as OperationFactory,yl as PointerObserver,V as RenameOperation,ee as RootAttributeOperation,Q as RootOperation,Jr as SelectionObserver,P as SplitOperation,Ve as StylesMap,ul as StylesProcessor,Yr as TabObserver,bl as TouchObserver,Hi as UpcastHelpers,vl as UpcastWriter,Ee as ViewAttributeElement,Je as ViewContainerElement,Gr as ViewDataTransfer,Hn as ViewDocument,$r as ViewDocumentDomEventData,me as ViewDocumentFragment,Wt as ViewDocumentSelection,es as ViewDomConverter,Kn as ViewDowncastWriter,ft as ViewEditableElement,H as ViewElement,zt as ViewEmptyElement,we as ViewNode,g as ViewPosition,w as ViewRange,Jt as ViewRawElement,kr as ViewRenderer,Gn as ViewRootEditableElement,G as ViewSelection,R as ViewText,Z as ViewTextProxy,wt as ViewTokenList,de as ViewTreeWalker,_e as ViewTypeCheckable,dt as ViewUIElement,vl as ViewUpcastWriter,Ro as _DataProcessorBasicHtmlWriter,Jo as _DetachOperation,ei as _MapperCache,Zn as _VIEW_BR_FILLER,Ue as _VIEW_INLINE_FILLER,$ as _VIEW_INLINE_FILLER_LENGTH,Qn as _VIEW_MARKED_NBSP_FILLER,Yn as _VIEW_NBSP_FILLER,Zs as _ViewElementConversionConsumables,bs as _autoParagraphEmptyModelRoots,ta as _deleteModelContent,yi as _downcastCleanSelection,bi as _downcastConvertCollapsedSelection,wi as _downcastConvertRangeSelection,us as _downcastCreateViewElementFromDowncastHighlightDescriptor,hs as _downcastInsertAttributesAndChildren,Pi as _downcastInsertElement,Ci as _downcastInsertStructure,cs as _downcastInsertText,ki as _downcastInsertUIElement,_i as _downcastRemove,vi as _downcastWrap,hn as _getDataWithoutViewFiller,ss as _getModelNodeAfterPosition,rs as _getModelNodeBeforePosition,Le as _getModelTextNodeAtPosition,ua as _getSelectedModelContent,Ho as _injectModelSelectionPostFixer,Pr as _injectViewQuirksHandling,dr as _injectViewUIElementHandling,Ht as _insertIntoModelNodeList,fa as _insertModelContent,ma as _insertModelObject,Se as _isInlineViewFiller,ys as _isParagraphableModelNode,ct as _isViewPatternMatched,ea as _mergeIntersectingModelRanges,_a as _modifyModelSelection,He as _moveInModelNodeList,Fe as _normalizeConversionConsumables,As as _normalizeInModelNodeList,En as _operationTransform,Ss as _removeFromModelNodeList,No as _setAttributeInModelNodeList,D as _startsWithViewFiller,Xo as _tryFixingModelRange,Xi as _upcastConvertSelectionChange,Ki as _upcastConvertText,Cn as _upcastConvertToModelFragment,vs as _wrapInModelParagraph,Cl as addBackgroundStylesRules,kl as addBorderStylesRules,Sl as addMarginStylesRules,Al as addPaddingStylesRules,bs as autoParagraphEmptyRoots,hl as enableViewPlaceholder,Ua as getBoxSidesStyleShorthandValue,qe as getBoxSidesStyleValueReducer,We as getBoxSidesStyleValues,Os as getPositionStyleShorthandNormalizer,Xt as getShorthandStylesValues,or as getViewFillerOffset,Un as hideViewPlaceholder,qa as isAttachmentStyleValue,Na as isColorStyleValue,Fa as isLengthStyleValue,Oa as isLineStyleValue,ys as isParagraphable,Pl as isPercentageStyleValue,$a as isPositionStyleValue,Va as isRepeatStyleValue,Ja as isURLStyleValue,Ks as needsViewPlaceholder,Hs as showViewPlaceholder,gl as transformOperationSets,vs as wrapInParagraph};