@novaprose/tinymce-compat 0.7.0 → 0.9.0

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 (240) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +2 -0
  3. package/dist/ai-XVSDIIQI.js +127 -0
  4. package/dist/ai-XVSDIIQI.js.map +1 -0
  5. package/dist/dialog-3UZZZW6Y.js +300 -0
  6. package/dist/dialog-3UZZZW6Y.js.map +1 -0
  7. package/dist/index.cjs +1335 -409
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +92 -45
  10. package/dist/index.d.ts +92 -45
  11. package/dist/index.js +831 -366
  12. package/dist/index.js.map +1 -1
  13. package/dist/novaprose.css +376 -550
  14. package/dist/tinymce-chunks/a11ychecker-fe78c552.js +2 -0
  15. package/dist/tinymce-chunks/a11ychecker-fe78c552.js.map +7 -0
  16. package/dist/tinymce-chunks/accordion-ui-4272c63b.js +2 -0
  17. package/dist/tinymce-chunks/accordion-ui-4272c63b.js.map +7 -0
  18. package/dist/tinymce-chunks/advcode-840793ca.js +2 -0
  19. package/dist/tinymce-chunks/advcode-840793ca.js.map +7 -0
  20. package/dist/tinymce-chunks/advcode-editor-37bc0a02.js +26 -0
  21. package/dist/tinymce-chunks/advcode-editor-37bc0a02.js.map +7 -0
  22. package/dist/tinymce-chunks/advlist-67b98670.js +2 -0
  23. package/dist/tinymce-chunks/{advlist-7a360f16.js.map → advlist-67b98670.js.map} +2 -2
  24. package/dist/tinymce-chunks/advtable-ui-db2e667d.js +2 -0
  25. package/dist/tinymce-chunks/advtable-ui-db2e667d.js.map +7 -0
  26. package/dist/tinymce-chunks/ai-e0658729.js +6 -0
  27. package/dist/tinymce-chunks/ai-e0658729.js.map +7 -0
  28. package/dist/tinymce-chunks/ai2-ddf912a7.js +34 -0
  29. package/dist/tinymce-chunks/ai2-ddf912a7.js.map +7 -0
  30. package/dist/tinymce-chunks/anchor-ui-da0966bb.js +2 -0
  31. package/dist/tinymce-chunks/anchor-ui-da0966bb.js.map +7 -0
  32. package/dist/tinymce-chunks/autocorrect-907e1296.js +3 -0
  33. package/dist/tinymce-chunks/autocorrect-907e1296.js.map +7 -0
  34. package/dist/tinymce-chunks/autolink-897e8650.js +2 -0
  35. package/dist/tinymce-chunks/{autolink-7e2e7be2.js.map → autolink-897e8650.js.map} +2 -2
  36. package/dist/tinymce-chunks/autoresize-f8a4a52a.js +2 -0
  37. package/dist/tinymce-chunks/autoresize-f8a4a52a.js.map +7 -0
  38. package/dist/tinymce-chunks/autosave-60381295.js +2 -0
  39. package/dist/tinymce-chunks/autosave-60381295.js.map +7 -0
  40. package/dist/tinymce-chunks/bash-f3f8783a.js +2 -0
  41. package/dist/tinymce-chunks/bash-f3f8783a.js.map +7 -0
  42. package/dist/tinymce-chunks/c-8e3b278b.js +2 -0
  43. package/dist/tinymce-chunks/c-8e3b278b.js.map +7 -0
  44. package/dist/tinymce-chunks/casechange-8ad6a2c3.js +6 -0
  45. package/dist/tinymce-chunks/casechange-8ad6a2c3.js.map +7 -0
  46. package/dist/tinymce-chunks/charmap-5deb524c.js +2 -0
  47. package/dist/tinymce-chunks/charmap-5deb524c.js.map +7 -0
  48. package/dist/tinymce-chunks/checklist-5a0c95d3.js +2 -0
  49. package/dist/tinymce-chunks/checklist-5a0c95d3.js.map +7 -0
  50. package/dist/tinymce-chunks/codesample-b91dcd91.js +4 -0
  51. package/dist/tinymce-chunks/codesample-b91dcd91.js.map +7 -0
  52. package/dist/tinymce-chunks/comments-panel-152e9cbe.js +2 -0
  53. package/dist/tinymce-chunks/comments-panel-152e9cbe.js.map +7 -0
  54. package/dist/tinymce-chunks/core-f5b3fd3e.js +4 -0
  55. package/dist/tinymce-chunks/core-f5b3fd3e.js.map +7 -0
  56. package/dist/tinymce-chunks/cpp-525b2c81.js +2 -0
  57. package/dist/tinymce-chunks/cpp-525b2c81.js.map +7 -0
  58. package/dist/tinymce-chunks/csharp-b95db858.js +2 -0
  59. package/dist/tinymce-chunks/csharp-b95db858.js.map +7 -0
  60. package/dist/tinymce-chunks/css-bb736f0c.js +2 -0
  61. package/dist/tinymce-chunks/css-bb736f0c.js.map +7 -0
  62. package/dist/tinymce-chunks/de-21549c7e.js +2 -0
  63. package/dist/tinymce-chunks/de-21549c7e.js.map +7 -0
  64. package/dist/tinymce-chunks/dialog-126a0355.js +2 -0
  65. package/dist/tinymce-chunks/dialog-126a0355.js.map +7 -0
  66. package/dist/tinymce-chunks/diff-02578ed2.js +2 -0
  67. package/dist/tinymce-chunks/diff-02578ed2.js.map +7 -0
  68. package/dist/tinymce-chunks/directionality-185b3810.js +2 -0
  69. package/dist/tinymce-chunks/{directionality-60dba768.js.map → directionality-185b3810.js.map} +2 -2
  70. package/dist/tinymce-chunks/dockerfile-ff44475c.js +2 -0
  71. package/dist/tinymce-chunks/dockerfile-ff44475c.js.map +7 -0
  72. package/dist/tinymce-chunks/draghandle-a1d99987.js +4 -0
  73. package/dist/tinymce-chunks/draghandle-a1d99987.js.map +7 -0
  74. package/dist/tinymce-chunks/editimage-36199bc6.js +2 -0
  75. package/dist/tinymce-chunks/editimage-36199bc6.js.map +7 -0
  76. package/dist/tinymce-chunks/email-1926dd8a.js +62 -0
  77. package/dist/tinymce-chunks/email-1926dd8a.js.map +7 -0
  78. package/dist/tinymce-chunks/email2-e9c49586.js +2 -0
  79. package/dist/tinymce-chunks/email2-e9c49586.js.map +7 -0
  80. package/dist/tinymce-chunks/emoticons-a5ab437d.js +2 -0
  81. package/dist/tinymce-chunks/emoticons-a5ab437d.js.map +7 -0
  82. package/dist/tinymce-chunks/es-1de93a3f.js +2 -0
  83. package/dist/tinymce-chunks/es-1de93a3f.js.map +7 -0
  84. package/dist/tinymce-chunks/exportpdf-1dfcbddc.js +2 -0
  85. package/dist/tinymce-chunks/exportpdf-1dfcbddc.js.map +7 -0
  86. package/dist/tinymce-chunks/exportword-ad95abb4.js +2 -0
  87. package/dist/tinymce-chunks/exportword-ad95abb4.js.map +7 -0
  88. package/dist/tinymce-chunks/footnotes-ui-3f167c2c.js +2 -0
  89. package/dist/tinymce-chunks/footnotes-ui-3f167c2c.js.map +7 -0
  90. package/dist/tinymce-chunks/form-dialog-9eb62199.js +2 -0
  91. package/dist/tinymce-chunks/form-dialog-9eb62199.js.map +7 -0
  92. package/dist/tinymce-chunks/formatpainter-cbeeffa7.js +2 -0
  93. package/dist/tinymce-chunks/formatpainter-cbeeffa7.js.map +7 -0
  94. package/dist/tinymce-chunks/fr-6fbcca9f.js +2 -0
  95. package/dist/tinymce-chunks/fr-6fbcca9f.js.map +7 -0
  96. package/dist/tinymce-chunks/fullpagehtml-ui-9dd804af.js +2 -0
  97. package/dist/tinymce-chunks/fullpagehtml-ui-9dd804af.js.map +7 -0
  98. package/dist/tinymce-chunks/go-14612282.js +2 -0
  99. package/dist/tinymce-chunks/go-14612282.js.map +7 -0
  100. package/dist/tinymce-chunks/graphql-032121b4.js +2 -0
  101. package/dist/tinymce-chunks/graphql-032121b4.js.map +7 -0
  102. package/dist/tinymce-chunks/history-diff-a0db052c.js +2 -0
  103. package/dist/tinymce-chunks/history-diff-a0db052c.js.map +7 -0
  104. package/dist/tinymce-chunks/importcss-28610ab5.js +3 -0
  105. package/dist/tinymce-chunks/importcss-28610ab5.js.map +7 -0
  106. package/dist/tinymce-chunks/importword-d6c2636a.js +2 -0
  107. package/dist/tinymce-chunks/importword-d6c2636a.js.map +7 -0
  108. package/dist/tinymce-chunks/index-a1feed69.js +5 -0
  109. package/dist/tinymce-chunks/index-a1feed69.js.map +7 -0
  110. package/dist/tinymce-chunks/index2-610900bb.js +2 -0
  111. package/dist/tinymce-chunks/index2-610900bb.js.map +7 -0
  112. package/dist/tinymce-chunks/insertdatetime-a48ee6e0.js +2 -0
  113. package/dist/tinymce-chunks/{insertdatetime-e0dbcf63.js.map → insertdatetime-a48ee6e0.js.map} +2 -2
  114. package/dist/tinymce-chunks/it-ca70815f.js +2 -0
  115. package/dist/tinymce-chunks/it-ca70815f.js.map +7 -0
  116. package/dist/tinymce-chunks/java-e051279c.js +2 -0
  117. package/dist/tinymce-chunks/java-e051279c.js.map +7 -0
  118. package/dist/tinymce-chunks/javascript-d7a6fb3d.js +2 -0
  119. package/dist/tinymce-chunks/javascript-d7a6fb3d.js.map +7 -0
  120. package/dist/tinymce-chunks/json-08c0b631.js +2 -0
  121. package/dist/tinymce-chunks/json-08c0b631.js.map +7 -0
  122. package/dist/tinymce-chunks/kotlin-b34d5ff2.js +3 -0
  123. package/dist/tinymce-chunks/kotlin-b34d5ff2.js.map +7 -0
  124. package/dist/tinymce-chunks/linkchecker-820845fd.js +2 -0
  125. package/dist/tinymce-chunks/linkchecker-820845fd.js.map +7 -0
  126. package/dist/tinymce-chunks/lua-9b0ae20a.js +2 -0
  127. package/dist/tinymce-chunks/lua-9b0ae20a.js.map +7 -0
  128. package/dist/tinymce-chunks/markdown-5698ebec.js +34 -0
  129. package/dist/tinymce-chunks/markdown-5698ebec.js.map +7 -0
  130. package/dist/tinymce-chunks/markdown2-943bcf90.js +2 -0
  131. package/dist/tinymce-chunks/markdown2-943bcf90.js.map +7 -0
  132. package/dist/tinymce-chunks/math-ui-1b57f7eb.js +2 -0
  133. package/dist/tinymce-chunks/math-ui-1b57f7eb.js.map +7 -0
  134. package/dist/tinymce-chunks/media-ui-de819f11.js +2 -0
  135. package/dist/tinymce-chunks/media-ui-de819f11.js.map +7 -0
  136. package/dist/tinymce-chunks/mediaembed-ui-7be11324.js +2 -0
  137. package/dist/tinymce-chunks/mediaembed-ui-7be11324.js.map +7 -0
  138. package/dist/tinymce-chunks/mentions-ui-b1bb2d15.js +2 -0
  139. package/dist/tinymce-chunks/mentions-ui-b1bb2d15.js.map +7 -0
  140. package/dist/tinymce-chunks/mergetags-ui-f5bdd1f9.js +2 -0
  141. package/dist/tinymce-chunks/mergetags-ui-f5bdd1f9.js.map +7 -0
  142. package/dist/tinymce-chunks/nonbreaking-f15226ad.js +2 -0
  143. package/dist/tinymce-chunks/{nonbreaking-49bdb0d2.js.map → nonbreaking-f15226ad.js.map} +2 -2
  144. package/dist/tinymce-chunks/pagebreak-ui-7476f5c2.js +2 -0
  145. package/dist/tinymce-chunks/pagebreak-ui-7476f5c2.js.map +7 -0
  146. package/dist/tinymce-chunks/pageembed-ui-da39f1ee.js +2 -0
  147. package/dist/tinymce-chunks/pageembed-ui-da39f1ee.js.map +7 -0
  148. package/dist/tinymce-chunks/pagelayout-ui-01757669.js +2 -0
  149. package/dist/tinymce-chunks/pagelayout-ui-01757669.js.map +7 -0
  150. package/dist/tinymce-chunks/paste-office-4e8e9cb7.js +3 -0
  151. package/dist/tinymce-chunks/paste-office-4e8e9cb7.js.map +7 -0
  152. package/dist/tinymce-chunks/permanentpen-fc96f445.js +2 -0
  153. package/dist/tinymce-chunks/permanentpen-fc96f445.js.map +7 -0
  154. package/dist/tinymce-chunks/php-6b723470.js +3 -0
  155. package/dist/tinymce-chunks/php-6b723470.js.map +7 -0
  156. package/dist/tinymce-chunks/powershell-e6c3fdb8.js +2 -0
  157. package/dist/tinymce-chunks/powershell-e6c3fdb8.js.map +7 -0
  158. package/dist/tinymce-chunks/print-86762549.js +27 -0
  159. package/dist/tinymce-chunks/print-86762549.js.map +7 -0
  160. package/dist/tinymce-chunks/pt-BR-f6958ec0.js +2 -0
  161. package/dist/tinymce-chunks/pt-BR-f6958ec0.js.map +7 -0
  162. package/dist/tinymce-chunks/python-a20cacce.js +2 -0
  163. package/dist/tinymce-chunks/python-a20cacce.js.map +7 -0
  164. package/dist/tinymce-chunks/quickbars-35c87c0e.js +2 -0
  165. package/dist/tinymce-chunks/{quickbars-d937e10a.js.map → quickbars-35c87c0e.js.map} +3 -3
  166. package/dist/tinymce-chunks/revisionhistory-741dfb24.js +2 -0
  167. package/dist/tinymce-chunks/revisionhistory-741dfb24.js.map +7 -0
  168. package/dist/tinymce-chunks/ru-982f3476.js +2 -0
  169. package/dist/tinymce-chunks/ru-982f3476.js.map +7 -0
  170. package/dist/tinymce-chunks/ruby-93c325c7.js +2 -0
  171. package/dist/tinymce-chunks/ruby-93c325c7.js.map +7 -0
  172. package/dist/tinymce-chunks/rust-d80fbab5.js +2 -0
  173. package/dist/tinymce-chunks/rust-d80fbab5.js.map +7 -0
  174. package/dist/tinymce-chunks/save-a65e56cd.js +2 -0
  175. package/dist/tinymce-chunks/save-a65e56cd.js.map +7 -0
  176. package/dist/tinymce-chunks/scss-7cffeb15.js +2 -0
  177. package/dist/tinymce-chunks/scss-7cffeb15.js.map +7 -0
  178. package/dist/tinymce-chunks/search-bar-1c8ef2ee.js +3 -0
  179. package/dist/tinymce-chunks/search-bar-1c8ef2ee.js.map +7 -0
  180. package/dist/tinymce-chunks/spellchecker-91509fc1.js +6 -0
  181. package/dist/tinymce-chunks/spellchecker-91509fc1.js.map +7 -0
  182. package/dist/tinymce-chunks/sql-eeac1a81.js +2 -0
  183. package/dist/tinymce-chunks/sql-eeac1a81.js.map +7 -0
  184. package/dist/tinymce-chunks/suggestions-panel-c29362cf.js +2 -0
  185. package/dist/tinymce-chunks/suggestions-panel-c29362cf.js.map +7 -0
  186. package/dist/tinymce-chunks/suggestions-ui-c5f6bad4.js +2 -0
  187. package/dist/tinymce-chunks/suggestions-ui-c5f6bad4.js.map +7 -0
  188. package/dist/tinymce-chunks/swift-2b081f3e.js +2 -0
  189. package/dist/tinymce-chunks/swift-2b081f3e.js.map +7 -0
  190. package/dist/tinymce-chunks/table-4d43f60d.js +2 -0
  191. package/dist/tinymce-chunks/table-4d43f60d.js.map +7 -0
  192. package/dist/tinymce-chunks/table-dialogs-0445847c.js +2 -0
  193. package/dist/tinymce-chunks/table-dialogs-0445847c.js.map +7 -0
  194. package/dist/tinymce-chunks/tableofcontents-ui-01a9af06.js +2 -0
  195. package/dist/tinymce-chunks/tableofcontents-ui-01a9af06.js.map +7 -0
  196. package/dist/tinymce-chunks/temml-d637f801.js +97 -0
  197. package/dist/tinymce-chunks/temml-d637f801.js.map +7 -0
  198. package/dist/tinymce-chunks/template-b522c8ed.js +2 -0
  199. package/dist/tinymce-chunks/template-b522c8ed.js.map +7 -0
  200. package/dist/tinymce-chunks/typescript-fa085d66.js +2 -0
  201. package/dist/tinymce-chunks/typescript-fa085d66.js.map +7 -0
  202. package/dist/tinymce-chunks/typography-469ce11a.js +3 -0
  203. package/dist/tinymce-chunks/typography-469ce11a.js.map +7 -0
  204. package/dist/tinymce-chunks/visualblocks-8b7cba25.js +2 -0
  205. package/dist/tinymce-chunks/{visualblocks-58c88e5d.js.map → visualblocks-8b7cba25.js.map} +2 -2
  206. package/dist/tinymce-chunks/visualchars-7cda4c00.js +2 -0
  207. package/dist/tinymce-chunks/visualchars-7cda4c00.js.map +7 -0
  208. package/dist/tinymce-chunks/xml-77617a8f.js +2 -0
  209. package/dist/tinymce-chunks/xml-77617a8f.js.map +7 -0
  210. package/dist/tinymce-chunks/yaml-5bb3ad37.js +2 -0
  211. package/dist/tinymce-chunks/yaml-5bb3ad37.js.map +7 -0
  212. package/dist/tinymce.global.js +34 -27
  213. package/dist/tinymce.global.js.map +4 -4
  214. package/dist/tinymce.licenses.txt +1094 -0
  215. package/package.json +2 -2
  216. package/dist/tinymce-chunks/advlist-7a360f16.js +0 -2
  217. package/dist/tinymce-chunks/autolink-7e2e7be2.js +0 -2
  218. package/dist/tinymce-chunks/autoresize-d6c9537b.js +0 -2
  219. package/dist/tinymce-chunks/autoresize-d6c9537b.js.map +0 -7
  220. package/dist/tinymce-chunks/autosave-4fd46720.js +0 -2
  221. package/dist/tinymce-chunks/autosave-4fd46720.js.map +0 -7
  222. package/dist/tinymce-chunks/charmap-4b14307a.js +0 -2
  223. package/dist/tinymce-chunks/charmap-4b14307a.js.map +0 -7
  224. package/dist/tinymce-chunks/comments-panel-37cba890.js +0 -2
  225. package/dist/tinymce-chunks/comments-panel-37cba890.js.map +0 -7
  226. package/dist/tinymce-chunks/directionality-60dba768.js +0 -2
  227. package/dist/tinymce-chunks/emoticons-7e6da0b6.js +0 -2
  228. package/dist/tinymce-chunks/emoticons-7e6da0b6.js.map +0 -7
  229. package/dist/tinymce-chunks/form-dialog-9cde0ef7.js +0 -2
  230. package/dist/tinymce-chunks/form-dialog-9cde0ef7.js.map +0 -7
  231. package/dist/tinymce-chunks/insertdatetime-e0dbcf63.js +0 -2
  232. package/dist/tinymce-chunks/nonbreaking-49bdb0d2.js +0 -2
  233. package/dist/tinymce-chunks/paste-office-a38659d6.js +0 -3
  234. package/dist/tinymce-chunks/paste-office-a38659d6.js.map +0 -7
  235. package/dist/tinymce-chunks/quickbars-d937e10a.js +0 -2
  236. package/dist/tinymce-chunks/revisionhistory-d6306426.js +0 -2
  237. package/dist/tinymce-chunks/revisionhistory-d6306426.js.map +0 -7
  238. package/dist/tinymce-chunks/table-80284f6f.js +0 -2
  239. package/dist/tinymce-chunks/table-80284f6f.js.map +0 -7
  240. package/dist/tinymce-chunks/visualblocks-58c88e5d.js +0 -2
@@ -1,17 +1,27 @@
1
+ /*! NovaProse 0.9.0 | MIT | third-party licenses: tinymce.licenses.txt */
1
2
  var __novaChunkBase=typeof document!=="undefined"&&(document.currentScript&&document.currentScript.src||document.baseURI)||"";function __novaChunk(p){return new URL(p,__novaChunkBase).href}
2
- (()=>{var Sf=Object.create;var Er=Object.defineProperty;var wf=Object.getOwnPropertyDescriptor;var Ef=Object.getOwnPropertyNames;var Cf=Object.getPrototypeOf,Af=Object.prototype.hasOwnProperty;var Tf=(n,e,t)=>e in n?Er(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var me=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Z=(n,e)=>{for(var t in e)Er(n,t,{get:e[t],enumerable:!0})},Nf=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ef(e))!Af.call(n,o)&&o!==t&&Er(n,o,{get:()=>e[o],enumerable:!(r=wf(e,o))||r.enumerable});return n};var ge=(n,e,t)=>(t=n!=null?Sf(Cf(n)):{},Nf(e||!n||!n.__esModule?Er(t,"default",{value:n,enumerable:!0}):t,n));var E=(n,e,t)=>Tf(n,typeof e!="symbol"?e+"":e,t);var pi={};Z(pi,{definePlugin:()=>Sa,isPluginRegistered:()=>Cr,loadPlugin:()=>di,orderPlugins:()=>Ar,registerPlugin:()=>U,resolveEntries:()=>ui});function Sa(n){return n}var ci=new Map;function U(n,e){ci.set(n,e)}function Cr(n){return ci.has(n)}function xa(n){return typeof n=="function"}function ui(n){let e=[],t=[],r=[];for(let o of n)if(typeof o=="string"){let i=ci.get(o);i?xa(i)?t.push(i):e.push(i):r.push(`Plugin "${o}" is not registered`)}else xa(o)?t.push(o):e.push(o);return{plugins:e,loaders:t,errors:r}}function Ar(n,e=new Set){let t=new Map(n.map(l=>[l.name,l])),r=[],o=[],i=new Map,s=(l,a)=>{let c=i.get(l.name);if(c==="done")return!0;if(c==="failed")return!1;if(c==="visiting")return o.push(`Plugin dependency cycle: ${[...a,l.name].join(" \u2192 ")}`),!1;i.set(l.name,"visiting");for(let u of l.requires??[]){if(e.has(u))continue;let d=t.get(u);if(!d)return o.push(`Plugin "${l.name}" requires "${u}", which is not loaded`),i.set(l.name,"failed"),!1;if(!s(d,[...a,l.name]))return i.set(l.name,"failed"),!1}return i.set(l.name,"done"),r.push(l),!0};for(let l of n)s(l,[]);return{ordered:r,errors:o}}async function di(n){let e=await n();return"default"in e&&e.default?e.default:e}var fi={};Z(fi,{icons:()=>S});var T=n=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,S={undo:T('<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />'),redo:T('<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />'),bold:T('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),italic:T('<line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" />'),underline:T('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),strike:T('<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />'),code:T('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),subscript:T('<path d="m4 5 8 8" /><path d="m12 5-8 8" /><path d="M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07" />'),superscript:T('<path d="m4 19 8-8" /><path d="m12 19-8-8" /><path d="M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" />'),bulletList:T('<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />'),orderedList:T('<path d="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" />'),indent:T('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'),outdent:T('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'),blockquote:T('<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'),codeBlock:T('<path d="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" />'),alignLeft:T('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),alignCenter:T('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),alignRight:T('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),alignJustify:T('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),horizontalRule:T('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),link:T('<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />'),unlink:T('<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" />'),image:T('<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />'),clearFormatting:T('<path d="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" />'),formatMore:T('<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />'),imageLeft:T('<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />'),imageCenter:T('<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />'),imageRight:T('<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />'),resize:T('<path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" />'),altText:T('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),imageCaption:T('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),trash:T('<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />'),paragraph:T('<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'),h1:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),h2:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" />'),h3:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" />'),pasteText:T('<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /><path d="M9 12v-1h6v1" /><path d="M11 17h2" /><path d="M12 11v6" />'),table:T('<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'),rowBefore:T('<path d="M12 2v6" /><path d="M18.464 3H19a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h.535" /><path d="M21 12H3" /><path d="M9 5h6" />'),rowAfter:T('<path d="M12 22v-6" /><path d="M18.464 21H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h.535" /><path d="M21 12H3" /><path d="M9 19h6" />'),rowDelete:T('<path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" />'),colBefore:T('<path d="M12 3v18" /><path d="M3 5.536V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-.535" /><path d="M5 15V9" /><path d="M8 12H2" />'),colAfter:T('<path d="M12 3v18" /><path d="M16 12h6" /><path d="M19 15V9" /><path d="M21 5.536V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-.535" />'),colDelete:T('<g transform="rotate(90 12 12)"><path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" /></g>'),merge:T('<path d="M12 21v-6" /><path d="M12 9V3" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),split:T('<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),rowHeader:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),colHeader:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),sort:T('<path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" />'),tableProps:T('<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'),cellProps:T('<path d="M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6" /><path d="m14.305 19.53.923-.382" /><path d="M15 3v7.6" /><path d="m15.229 16.852-.924-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.773 16.852.922-.383" /><path d="m20.773 19.148.922.383" /><path d="M9 3v18" /><circle cx="18" cy="18" r="3" />'),tableDelete:T('<path d="M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3" /><path d="m16.5 16.5 5 5" /><path d="m16.5 21.5 5-5" />'),chevronUp:T('<path d="m18 15-6-6-6 6" />'),search:T('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),fullscreen:T('<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />'),fullscreenExit:T('<path d="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" />'),preview:T('<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />'),sourceCode:T('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),help:T('<circle cx="12" cy="12" r="10" /><path d="M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5" /><path d="M12 17h.01" />'),print:T('<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" />'),check:T('<path d="M20 6 9 17l-5-5" />'),close:T('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),chevronDown:T('<path d="m6 9 6 6 6-6" />'),more:T('<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'),textColor:T('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),highlight:T('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),lineHeight:T('<path d="M15 14H9" /><path d="M21 21H3" /><path d="M21 3H3" /><path d="m8 16 3.453-7.648a.6.6 0 011.094.001L16 16" />'),upload:T('<path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />'),externalLink:T('<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" /><path d="m21 3-9 9" /><path d="M15 3h6v6" />'),copy:T('<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),edit:T('<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" />'),resizeHandle:T('<circle cx="12" cy="9" r="1" /><circle cx="19" cy="9" r="1" /><circle cx="5" cy="9" r="1" /><circle cx="12" cy="15" r="1" /><circle cx="19" cy="15" r="1" /><circle cx="5" cy="15" r="1" />'),browse:T('<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />'),mergeTags:T('<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" /><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />'),resizeHandleBoth:T('<path d="M19 13v6h-6" /><path d="M5 11V5h6" /><path d="m5 5 14 14" />'),anchor:T('<path d="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" />'),save:T('<path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" />'),charmap:T('<path d="M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21" />'),commentAdd:T('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M12 8v6" /><path d="M9 11h6" />'),comments:T('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M7 11h10" /><path d="M7 15h6" /><path d="M7 7h8" />'),emoji:T('<path d="M15 10V9" /><path d="M16.472 15a6 6 0 01-8.943 0" /><path d="M9 10V9" /><circle cx="12" cy="12" r="10" />'),dateTime:T('<path d="M16 2v3" /><path d="M17 15.5v1.7l1 .625" /><path d="M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935" /><path d="M3 9h9.873" /><path d="M8 2v3" /><circle cx="17" cy="17" r="5" />'),media:T('<rect x="3" y="3" width="18" height="18" rx="2" /><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z" />'),nonBreaking:T('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),pageBreak:T('<path d="M5.42 9.42 8 12" /><circle cx="4" cy="8" r="2" /><path d="m14 6-8.58 8.58" /><circle cx="4" cy="16" r="2" /><path d="M10.8 14.8 14 18" /><path d="M16 12h-2" /><path d="M22 12h-2" />'),sidebar:T('<rect x="3" y="4" width="18" height="16" rx="2" /><path d="M15 4v16" />'),history:T('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />'),suggest:T('<path d="M13 21h8" /><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />'),review:T('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><path d="m3 7 2 2 4-4" />'),visualBlocks:T('<path d="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" />'),ltr:T('<path d="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" />'),rtl:T('<path d="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" />')};var Ri={};Z(Ri,{AllSelection:()=>se,EditorState:()=>Vn,NodeSelection:()=>P,Plugin:()=>z,PluginKey:()=>K,Selection:()=>F,SelectionRange:()=>Bt,TextSelection:()=>I,Transaction:()=>Fr});var xi={};Z(xi,{ContentMatch:()=>ht,DOMParser:()=>Qe,DOMSerializer:()=>Le,Fragment:()=>A,Mark:()=>_,MarkType:()=>Yt,Node:()=>Ae,NodeRange:()=>ft,NodeType:()=>qe,ReplaceError:()=>Xe,ResolvedPos:()=>Dn,Schema:()=>Xt,Slice:()=>D});function be(n){this.content=n}be.prototype={constructor:be,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new be(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new be(t)},addToStart:function(n,e){return new be([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new be(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new be(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=be.from(n),n.size?new be(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=be.from(n),n.size?new be(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=be.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};be.from=function(n){if(n instanceof be)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new be(e)};var hi=be;function Ia(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&Fa(s.charCodeAt(a-1))&&Ba(s.charCodeAt(a))&&t--,t}if(o.content.size||i.content.size){let s=Ia(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Ha(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,p=u.length;for(;d>0&&p>0&&c[d-1]==u[p-1];)d--,p--,t--,r--;return d&&p&&d<c.length&&Fa(c.charCodeAt(d-1))&&Ba(c.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=Ha(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Ba(n){return n>=56320&&n<57344}function Fa(n){return n>=55296&&n<56320}var A=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new n(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Ia(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Ha(this,e,t,r)}findIndex(e){if(e==0)return Tr(0,e);if(e==this.size)return Tr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?Tr(t+1,i):Tr(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};A.empty=new A([],0);var mi={index:0,offset:0};function Tr(n,e){return mi.index=n,mi.offset=e,mi}function Dr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Dr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Dr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var _=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Dr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};_.none=[];var Xe=class extends Error{},D=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=_a(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(za(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(A.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};D.empty=new D(A.empty,0,0);function za(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(za(i.content,e-o-1,t-o-1)))}function _a(n,e,t,r,o,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=_a(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?o-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function Of(n,e,t){if(t.openStart>n.depth)throw new Xe("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xe("Inconsistent open depths");return $a(n,e,t,0)}function $a(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=$a(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return Lt(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Df(t,n);return Lt(i,qa(n,s,l,e,r))}else return Lt(i,Lr(n,e,r))}function Va(n,e){if(!e.type.compatibleContent(n.type))throw new Xe("Cannot join "+e.type.name+" onto "+n.type.name)}function gi(n,e,t){let r=n.node(t);return Va(r,e.node(t)),r}function Dt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Nn(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Dt(n.nodeAfter,r),i++));for(let l=i;l<s;l++)Dt(o.child(l),r);e&&e.depth==t&&e.textOffset&&Dt(e.nodeBefore,r)}function Lt(n,e){if(!n.type.validContent(e))throw new Xe("Invalid content for node "+n.type.name);return n.copy(e)}function qa(n,e,t,r,o){let i=n.depth>o&&gi(n,e,o+1),s=r.depth>o&&gi(t,r,o+1),l=[];return Nn(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(Va(i,s),Dt(Lt(i,qa(n,e,t,r,o+1)),l)):(i&&Dt(Lt(i,Lr(n,e,o+1)),l),Nn(e,t,o,l),s&&Dt(Lt(s,Lr(t,r,o+1)),l)),Nn(r,null,o,l),new A(l)}function Lr(n,e,t){let r=[];if(Nn(null,n,t,r),n.depth>t){let o=gi(n,e,t+1);Dt(Lt(o,Lr(n,e,t+1)),r)}return Nn(e,null,t,r),new A(r)}function Df(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(A.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var Dn=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return _.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new ft(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=wa.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else wa.set(e,r=new bi);let o=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Lf,o}},bi=class{constructor(){this.elts=[],this.i=0}},Lf=12,wa=new WeakMap,ft=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Rf=Object.create(null),Ae=class n{constructor(e,t,r,o=_.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Dr(this.attrs,t||e.defaultAttrs||Rf)&&_.sameSet(this.marks,r||_.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return D.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new D(c,o.depth-s,i.depth-s)}replace(e,t,r){return Of(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Dn.resolveCached(this,e)}resolveNoCache(e){return Dn.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Wa(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=A.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ca(this.type.attrs,this.attrs,"node",this.type.name);let e=_.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];Ca(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!_.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=A.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};Ae.prototype.text=void 0;var Ea=(()=>{let{stack:n}=new Error("/");if(!n||!/\n\s*at\s/.test(n))return t=>t;let e=Object.create(null);return t=>(e[t],t)})(),yi=class n extends Ae{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wa(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return Ea(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(Ea(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Wa(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function Ca(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}var ht=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new vi(e,t);if(r.next==null)return n.empty;let o=ja(r);r.next&&r.err("Unexpected trailing text");let i=_f(zf(o));return $f(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return A.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let p=i(d,l.concat(u));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
3
- `)}};ht.empty=new ht(!0);var vi=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function ja(n){let e=[];do e.push(Pf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Pf(n){let e=[];do e.push(If(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function If(n){let e=Ff(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Hf(n,e);else break;return e}function Aa(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Hf(n,e){let t=Aa(n),r=t;return n.eat(",")&&(n.next!="}"?r=Aa(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Bf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Ff(n){if(n.eat("(")){let e=ja(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Bf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function zf(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ka(n,e){return e-n}function Ta(n,e){let t=[];return r(e),t.sort(Ka);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function _f(n){let e=Object.create(null);return t(Ta(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Ta(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new ht(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Ka);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function $f(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ua(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Ja(n,e){let t=Object.create(null);for(let r in n){let o=n[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(i);t[r]=i}return t}function Ga(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ki(n,r,e[r]);return t}var qe=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Ga(e,r.attrs),this.defaultAttrs=Ua(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ht.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ja(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ae(this,this.computeAttrs(e),A.from(t),_.setFrom(r))}createChecked(e=null,t,r){return t=A.from(t),this.checkContent(t),new Ae(this,this.computeAttrs(e),t,_.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=A.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(A.empty,!0);return i?new Ae(this,e,t.append(i),_.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:_.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Vf(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var ki=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Vf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Yt=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Ga(e,o.attrs),this.excluded=null;let i=Ua(this.attrs);this.instance=i?new _(this,i):null}create(e=null){return!e&&this.instance?this.instance:new _(this,Ja(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Xt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=hi.from(e.nodes),t.marks=hi.from(e.marks||{}),this.nodes=qe.compile(this.spec.nodes,this),this.marks=Yt.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=ht.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Na(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Na(this,s.split(" "))}this.nodeFromJSON=o=>Ae.fromJSON(this,o),this.markFromJSON=o=>_.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof qe){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new yi(r,r.defaultAttrs,e,_.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Na(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function qf(n){return n.tag!=null}function Wf(n){return n.style!=null}var Qe=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(qf(o))this.tags.push(o);else if(Wf(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Rr(this,t,!1);return r.addAll(e,_.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Rr(this,t,!0);return r.addAll(e,_.none,t.from,t.to),D.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Uf(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Da(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Da(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Ya={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},jf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xa={ol:!0,ul:!0},Ln=1,Mi=2,On=4;function Oa(n,e,t){return e!=null?(e?Ln:0)|(e==="full"?Mi:0):n&&n.whitespace=="pre"?Ln|Mi:t&~On}var Gt=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=_.none,this.match=i||(s&On?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(A.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ln)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=A.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ya.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Rr=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Oa(null,t.preserveWhitespace,0)|(r?On:0);o?i=new Gt(o.type,o.attrs,_.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Gt(null,null,_.none,!0,null,s):i=new Gt(e.schema.topNodeType,null,_.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&Mi?"full":this.localPreserveWS||(o.options&Ln)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
4
- `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Xa.hasOwnProperty(s)&&this.parser.normalizeLists&&Kf(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:jf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ya.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
5
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=_.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):La(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Oa(e,i,s.options);s.options&On&&s.content.length==0&&(l|=On);let a=_.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):La(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Gt(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Ln)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function Kf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Xa.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Uf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Da(n){let e={};for(let t in n)e[t]=n[t];return e}function La(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}var Le=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Nr(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return Nr(t).createTextNode(e.text);let{dom:r,contentDOM:o}=Or(Nr(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Or(Nr(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:Or(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ra(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Ra(e.marks)}};function Ra(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Nr(n){return n.document||window.document}var Pa=new WeakMap;function Jf(n){let e=Pa.get(n);return e===void 0&&Pa.set(n,e=Gf(n)),e}function Gf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Or(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Jf(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof p=="string")a.appendChild(n.createTextNode(p));else{let{dom:f,contentDOM:h}=Or(n,p,t,r);if(a.appendChild(f),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var Ni={};Z(Ni,{AddMarkStep:()=>mt,AddNodeMarkStep:()=>en,AttrStep:()=>Hn,DocAttrStep:()=>Bn,MapResult:()=>Qt,Mapping:()=>Zt,RemoveMarkStep:()=>Ze,RemoveNodeMarkStep:()=>Rt,ReplaceAroundStep:()=>ie,ReplaceStep:()=>ue,Step:()=>J,StepMap:()=>We,StepResult:()=>oe,Transform:()=>Fn,TransformError:()=>Pt,canJoin:()=>bt,canSplit:()=>et,dropPoint:()=>zn,findWrapping:()=>It,insertPoint:()=>dc,joinPoint:()=>uc,liftTarget:()=>gt,replaceStep:()=>_n});var nc=65535,rc=Math.pow(2,16);function Yf(n,e){return n+e*rc}function Qa(n){return n&nc}function Xf(n){return(n-(n&nc))/rc}var oc=1,ic=2,Pr=4,sc=8,Qt=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&sc)>0}get deletedBefore(){return(this.delInfo&(oc|Pr))>0}get deletedAfter(){return(this.delInfo&(ic|Pr))>0}get deletedAcross(){return(this.delInfo&Pr)>0}},We=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Qa(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Xf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let p=c?e==a?-1:e==d?1:t:t,f=a+o+(p<0?0:u);if(r)return f;let h=e==(t<0?a:d)?null:Yf(l/3,e-a),g=0;return c&&(g|=e==a?ic:e==d?oc:Pr,(t<0?e!=a:e!=d)&&(g|=sc)),new Qt(f,g,h)}o+=u-c}return r?e+o:new Qt(e+o,0,null)}touches(e,t){let r=0,o=Qa(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};We.empty=new We([]);var Zt=class n{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=e.from,r=this._maps.length;t<e.to;t++){let o=e.getMirror(t);o!=null&&(o=o<t&&o>=e.from?r+(o-e.from):void 0),this.appendMap(e._maps[t],o)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.to-1,r=this._maps.length+e._maps.length;t>=e.from;t--){let o=e.getMirror(t);o!=null&&(o=o>t&&o<e.to?r-(o-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),o)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Qt(e,o,null)}},Si=Object.create(null),J=class{getMap(){return We.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Si[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Si)throw new RangeError("Duplicate use of step JSON ID "+e);return Si[e]=t,t.prototype.jsonID=e,t}},oe=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,o){try{return n.ok(e.replace(t,r,o))}catch(i){if(i instanceof Xe)return n.fail(i.message);throw i}}};function Ai(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Ai(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return A.fromArray(r)}var mt=class n extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new D(Ai(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!_.sameSet(i,r.marks)){let s=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);Ir(Ze,s,l,this.mark,t);for(let a of r.marks)a.isInSet(i)||Ir(n,s,l,a,t)}}}),t.length==1?t[0]:new In(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};J.jsonID("addMark",mt);var Ze=class n extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new D(Ai(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Ir(mt,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new In(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};J.jsonID("removeMark",Ze);function Ir(n,e,t,r,o){let i=o.length?o[o.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(r)?o[o.length-1]=new n(i.from,t,r):o.push(new n(e,t,r))}var In=class n extends J{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new oe(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let o=r.map(e);o&&t.push(o)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>J.fromJSON(e,r)))}};J.jsonID("markSet",In);var en=class n extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return oe.fromReplace(e,this.pos,this.pos+1,new D(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new n(this.pos,t.marks[o]);return new n(this.pos,this.mark)}}return new Rt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};J.jsonID("addNodeMark",en);var Rt=class n extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return oe.fromReplace(e,this.pos,this.pos+1,new D(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new en(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};J.jsonID("removeNodeMark",Rt);var ue=class n extends J{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Ei(e,this.from,this.to)?oe.fail("Structure replace would overwrite content"):oe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new We([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,D.fromJSON(e,t.slice),!!t.structure)}};ue.MAP_BIAS=1;J.jsonID("replace",ue);var ie=class n extends J{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Ei(e,this.from,this.gapFrom)||Ei(e,this.gapTo,this.to)))return oe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return oe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?oe.fromReplace(e,this.from,this.to,r):oe.fail("Content does not fit in gap")}getMap(){return new We([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos||o>i?null:new n(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,D.fromJSON(e,t.slice),t.insert,!!t.structure)}};J.jsonID("replaceAround",ie);function Ei(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Qf(n,e,t,r){let o=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),u=Math.min(s+i.nodeSize,t);Ir(mt,c,u,r,o)}}),o.forEach(i=>n.step(i))}function Zf(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(r instanceof Yt){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],p;for(let f=0;f<o.length;f++){let h=o[f];h.step==i-1&&d.eq(o[f].style)&&(p=h)}p?(p.to=c,p.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Ze(s.from,s.to,s.style)))}function Ti(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new ue(l,u,D.empty));else{r=d;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Ze(l,u,c.marks[p]));if(o&&c.isText&&t.whitespace!="pre"){let p,f=/\r?\n|\r/g,h;for(;p=f.exec(c.text);)h||(h=new D(A.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new ue(l+p.index,l+p.index+p[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(A.empty,!0);n.replace(l,l,new D(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function eh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function gt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+o,a=n.$to.indexAfter(r)-i;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!eh(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function th(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=A.empty,d=0;for(let h=i,g=!1;h>t;h--)g||r.index(h)>0?(g=!0,u=A.from(r.node(h).copy(u)),d++):a--;let p=A.empty,f=0;for(let h=i,g=!1;h>t;h--)g||o.after(h+1)<o.end(h)?(g=!0,p=A.from(o.node(h).copy(p)),f++):c++;n.step(new ie(a,c,s,l,new D(u.append(p),d,f),u.size-d,!0))}function It(n,e,t=null,r=n){let o=nh(n,e),i=o&&rh(r,e);return i?o.map(Za).concat({type:e,attrs:t}).concat(i.map(Za)):null}function Za(n){return{type:n,attrs:null}}function nh(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function rh(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function oh(n,e,t){let r=A.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=A.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new ie(o,i,o,i,new D(r,0,0),t.length,!0))}function ih(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&sh(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?c=!1:!f&&h&&(c=!0)}c===!1&&ac(n,s,l,i),Ti(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),p=u.map(l+s.nodeSize,1);return n.step(new ie(d,p,d+1,p-1,new D(A.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&lc(n,s,l,i),!1}})}function lc(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ac(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
6
- `))}})}function sh(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function lh(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ie(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new D(A.from(s),0,0),1,!0))}function et(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>i;c--,u--){let d=o.node(c),p=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),h=r&&r[u+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let g=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!g.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function ah(n,e,t=1,r){let o=n.doc.resolve(e),i=A.empty,s=A.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=A.from(o.node(l).copy(i));let u=r&&r[c];s=A.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}n.step(new ue(e,e,new D(i.append(s),t,t),!0))}function bt(n,e){let t=n.resolve(e),r=t.index();return cc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function ch(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function cc(n,e){return!!(n&&e&&!n.isLeaf&&ch(n,e))}function uc(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):t>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&cc(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function uh(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);ac(n,u.node(),u.before(),l)}s.inlineContent&&Ti(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ue(c,a.map(e+t,-1),D.empty,!0)),r===!0){let u=n.doc.resolve(c);lc(n,u.node(),u.before(),n.steps.length)}return n}function dc(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function zn(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(s)+(l>0?1:0),u=r.node(s),d=!1;if(i==1)d=u.canReplace(c,c,o);else{let p=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=p&&u.canReplaceWith(c,c,p[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function _n(n,e,t=e,r=D.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return pc(o,i,r)?new ue(e,t,r):new Ci(o,i,r).fit()}function pc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Ci=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=A.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=A.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new D(i,s,l);return e>-1?new ie(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ue(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=ec(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(A.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return tc(e,-1)<=t?!1:(this.unplaced.size>1&&tc(e,1)>r&&r++,this.unplaced=new D(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=ec(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new D(Rn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new D(Rn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:p}=this.frontier[t];if(o){for(let g=0;g<o.childCount;g++)u.push(o.child(g));d=d.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let g=l.child(c),m=d.matchType(g.type);if(!m)break;c++,(c>1||a==0||g.content.size)&&(d=m,u.push(fc(g.mark(p.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let h=c==l.childCount;h||(f=-1),this.placed=Pn(this.placed,t,A.from(u)),this.frontier[t].match=d,h&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=u[u.length-1];m&&g<f;g++)this.frontier.push({type:m.type,match:m.contentMatchAt(m.childCount)}),m=m.lastChild;this.unplaced=h?e==0?D.empty:new D(Rn(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new D(Rn(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!wi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=wi(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=wi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Pn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Pn(this.placed,this.depth,A.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(A.empty,!0);t.childCount&&(this.placed=Pn(this.placed,this.frontier.length,t))}};function Rn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Rn(n.firstChild.content,e-1,t)))}function Pn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Pn(n.lastChild.content,e-1,t)))}function ec(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function fc(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,fc(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(A.empty,!0)))),n.copy(r)}function wi(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!dh(t,i.content,s)?l:null}function dh(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ph(n){return n.spec.defining||n.spec.definingForContent}function tc(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function fh(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(pc(o,i,r))return n.step(new ue(e,t,r));let s=mc(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let p=o.depth,f=o.pos-1;p>0;p--,f--){let h=o.node(p).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(p)>-1?l=p:o.before(p)==f&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],u=r.openStart;for(let p=r.content,f=0;;f++){let h=p.firstChild;if(c.push(h),f==r.openStart)break;p=h.content}for(let p=u-1;p>=0;p--){let f=c[p],h=ph(f.type);if(h&&!f.sameMarkup(o.node(Math.abs(l)-1)))u=p;else if(h||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+u+1)%(r.openStart+1),h=c[f];if(h)for(let g=0;g<s.length;g++){let m=s[(g+a)%s.length],b=!0;m<0&&(b=!1,m=-m);let k=o.node(m-1),y=o.index(m-1);if(k.canReplaceWith(y,y,h.type,h.marks))return n.replace(o.before(m),b?i.after(m):t,new D(hc(r.content,0,r.openStart,f),f,r.openEnd))}}let d=n.steps.length;for(let p=s.length-1;p>=0&&(n.replace(e,t,r),!(n.steps.length>d));p--){let f=s[p];f<0||(e=o.before(f),t=i.after(f))}}function hc(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(hc(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(A.empty,!0))}return n}function hh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=dc(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new D(A.from(r),0,0))}function mh(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=mc(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function mc(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}var Hn=class n extends J{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return oe.fromReplace(e,this.pos,this.pos+1,new D(A.from(o),0,t.isLeaf?0:1))}getMap(){return We.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};J.jsonID("attr",Hn);var Bn=class n extends J{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return oe.ok(r)}getMap(){return We.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};J.jsonID("docAttr",Bn);var Pt=class extends Error{};Pt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Pt.prototype=Object.create(Error.prototype);Pt.prototype.constructor=Pt;Pt.prototype.name="TransformError";var Fn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Zt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Pt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=D.empty){let o=_n(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new D(A.from(r),0,0))}delete(e,t){return this.replace(e,t,D.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return fh(this,e,t,r),this}replaceRangeWith(e,t,r){return hh(this,e,t,r),this}deleteRange(e,t){return mh(this,e,t),this}lift(e,t){return th(this,e,t),this}join(e,t=1){return uh(this,e,t),this}wrap(e,t){return oh(this,e,t),this}setBlockType(e,t=e,r,o=null){return ih(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return lh(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Hn(e,t,r)),this}setDocAttribute(e,t){return this.step(new Bn(e,t)),this}addNodeMark(e,t){return this.step(new en(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof _)t.isInSet(r.marks)&&this.step(new Rt(e,t));else{let o=r.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new Rt(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return ah(this,e,t,r),this}addMark(e,t,r){return Qf(this,e,t,r),this}removeMark(e,t,r){return Zf(this,e,t,r),this}clearIncompatible(e,t,r){return Ti(this,e,t,r),this}};var Oi=Object.create(null),F=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Bt(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=D.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?D.empty:t),l==0&&yc(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),yc(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new I(e):tn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?tn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):tn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new se(e.node(0))}static atStart(e){return tn(e,e,0,0,1)||new se(e)}static atEnd(e){return tn(e,e,e.content.size,e.childCount,-1)||new se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Oi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Oi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Oi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}};F.prototype.visible=!0;var Bt=class{constructor(e,t){this.$from=e,this.$to=t}},gc=!1;function bc(n){!gc&&!n.parent.inlineContent&&(gc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var I=class n extends F{constructor(e,t=e){bc(e),bc(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return F.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=D.empty){if(super.replace(e,t),t==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Br(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=F.findFrom(t,r,!0)||F.findFrom(t,-r,!0);if(i)t=i.$head;else return F.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(F.findFrom(e,-r,!0)||F.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new n(e,t)}};F.jsonID("text",I);var Br=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return I.between(e.resolve(this.anchor),e.resolve(this.head))}},P=class n extends F{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?F.near(i):new n(i)}content(){return new D(A.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Li(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};P.prototype.visible=!1;F.jsonID("node",P);var Li=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Br(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&P.isSelectable(r)?new P(t):F.near(t)}},se=class n extends F{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=D.empty){if(t==D.empty){e.delete(0,e.doc.content.size);let r=F.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return gh}};F.jsonID("all",se);var gh={map(){return this},resolve(n){return new se(n)}};function tn(n,e,t,r,o,i=!1){if(e.inlineContent)return I.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&P.isSelectable(l))return P.create(n,t-(o<0?l.nodeSize:0))}else{let a=tn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function yc(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof ue||o instanceof ie))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(F.near(n.doc.resolve(s),t))}var vc=1,Hr=2,kc=4,Fr=class extends Fn{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|vc)&~Hr,this.storedMarks=null,this}get selectionSet(){return(this.updated&vc)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hr,this}ensureMarks(e){return _.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Hr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Hr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||_.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(F.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=kc,this}get scrolledIntoView(){return(this.updated&kc)>0}};function Mc(n,e){return!e||!n?n:n.bind(e)}var Ht=class{constructor(e,t,r){this.name=e,this.init=Mc(t.init,r),this.apply=Mc(t.apply,r)}},bh=[new Ht("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ht("selection",{init(n,e){return n.selection||F.atStart(e.doc)},apply(n){return n.selection}}),new Ht("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ht("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],$n=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ht(r.key,r.spec.state,r))})}},Vn=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Fr(this)}static create(e){let t=new $n(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new $n(this.schema,e.plugins),r=t.fields,o=new n(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new $n(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Ae.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=F.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function xc(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=xc(o,e,{})),t[r]=o}return t}var z=class{constructor(e){this.spec=e,this.props={},e.props&&xc(e.props,this,this.props),this.key=e.key?e.key.key:Sc("plugin")}getState(e){return e[this.key]}},Di=Object.create(null);function Sc(n){return n in Di?n+"$"+ ++Di[n]:(Di[n]=0,n+"$")}var K=class{constructor(e="key"){this.key=Sc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ii={};Z(Ii,{FOCUSABLE:()=>nn,activeElement:()=>j,eventTarget:()=>Pi,formatShortcut:()=>tt,h:()=>M,icon:()=>V,isMac:()=>Ec,isRtl:()=>rn,listenDocument:()=>yt,logicalKey:()=>Me,uniqueId:()=>Te});function M(n,e={},...t){let r=document.createElement(n);for(let[o,i]of Object.entries(e))i==null||i===!1||(typeof i=="function"?r.addEventListener(o.replace(/^on/,"").toLowerCase(),i):o==="className"?r.className=String(i):r.setAttribute(o,i===!0?"":String(i)));for(let o of t.flat())o==null||o===!1||r.append(o);return r}function V(n){let e=document.createElement("span");return e.className="nova-icon",e.innerHTML=n,e}var wc=0;function Te(n="nova"){return wc+=1,`${n}-${wc}`}var Ec=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function tt(n){let e=n.split("-"),t=e.pop(),r=t.length===1?t.toUpperCase():t;if(Ec){let i={Mod:"\u2318",Shift:"\u21E7",Alt:"\u2325",Ctrl:"\u2303"};return e.map(s=>i[s]??s).join("")+r}let o={Mod:"Ctrl",Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl"};return[...e.map(i=>o[i]??i),r].join("+")}var nn='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function j(n){let e=n.getRootNode(),t=("activeElement"in e?e.activeElement:null)??document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function Pi(n){return n.composedPath?.()[0]??n.target}function yt(n,e,t){let r=n.getRootNode(),o=typeof ShadowRoot<"u"&&r instanceof ShadowRoot?r:null,i=l=>{o&&l.composedPath().includes(o.host)||t(l,Pi(l))},s=l=>t(l,Pi(l));return document.addEventListener(e,i,!0),o?.addEventListener(e,s,!0),()=>{document.removeEventListener(e,i,!0),o?.removeEventListener(e,s,!0)}}function rn(n){return n.closest("[dir]")?.getAttribute("dir")?.toLowerCase()==="rtl"}function Me(n,e){return n.key!=="ArrowLeft"&&n.key!=="ArrowRight"||!rn(e)?n.key:n.key==="ArrowLeft"?"ArrowRight":"ArrowLeft"}function Cc(n){let e=Te("nova-dialog-title"),t=M("p",{className:"nova-dialog-error",role:"alert",hidden:!0}),r=M("button",{type:"submit",className:"nova-button nova-button-primary",hidden:!n.submitLabel},n.submitLabel??""),o=M("button",{type:"button",className:"nova-button"},n.cancelLabel),i=M("button",{type:"button",className:"nova-btn nova-dialog-close","aria-label":n.closeLabel},V(S.close)),s=M("form",{className:n.size==="large"?"nova-dialog nova-dialog-large":"nova-dialog",role:"dialog","aria-modal":"true","aria-labelledby":e,novalidate:!0},M("header",{className:"nova-dialog-header"},M("h2",{id:e},n.title),i),M("div",{className:"nova-dialog-body"},n.body,t),M("footer",{className:"nova-dialog-footer"},o,r)),l=M("div",{className:"nova-dialog-backdrop"},s);n.host.append(l);let a=!1,c=()=>{a||(a=!0,l.remove(),p(),n.onClose?.(),n.returnFocus?.())},u=h=>{t.hidden=!h,t.textContent=h??""},d=h=>{r.disabled=h,s.setAttribute("aria-busy",String(h))};s.addEventListener("submit",async h=>{h.preventDefault(),u(null),d(!0);try{let g=n.onSubmit?await n.onSubmit():!0;typeof g=="string"?u(g):g!==!1&&c()}finally{a||d(!1)}}),o.addEventListener("click",c),i.addEventListener("click",c),l.addEventListener("mousedown",h=>{h.target===l&&c()}),s.addEventListener("keydown",h=>{if(h.key==="Escape")h.preventDefault(),h.stopPropagation(),c();else if(h.key==="Tab"){let g=[...s.querySelectorAll(nn)].filter(k=>!k.hidden),m=g[0],b=g[g.length-1];if(!m||!b)return;h.shiftKey&&j(s)===m?(h.preventDefault(),b.focus()):!h.shiftKey&&j(s)===b&&(h.preventDefault(),m.focus())}});let p=yt(s,"focusin",(h,g)=>{s.contains(g)||(s.querySelector(nn)??s).focus()});return(n.initialFocus??s.querySelector(".nova-dialog-body input, .nova-dialog-body textarea")??(n.submitLabel?r:o)).focus(),{el:s,close:c,setError:u,setBusy:d}}function ee(n){let e=Te("nova-field"),t=n.hint?`${e}-hint`:void 0,r=M("input",{id:e,type:n.type??"text",className:"nova-input",value:n.value??"",placeholder:n.placeholder,required:n.required??!1,autocomplete:n.autocomplete??"off",spellcheck:"false","aria-describedby":t});return r.value=n.value??"",{el:M("div",{className:"nova-field"},M("label",{for:e,className:"nova-label"},n.label),r,n.hint?M("p",{id:t,className:"nova-hint"},n.hint):null),input:r}}function Ac(n,e=!1){let t=Te("nova-check"),r=M("input",{id:t,type:"checkbox",className:"nova-checkbox"});return r.checked=e,{el:M("div",{className:"nova-field nova-field-inline"},r,M("label",{for:t},n)),input:r}}function qn(n){let e=Te("nova-field"),t=M("select",{id:e,className:"nova-input nova-select"},...n.options.map(o=>M("option",{value:o.value},o.label)));return t.value=n.value,{el:M("div",{className:"nova-field"},M("label",{for:e,className:"nova-label"},n.label),t),select:t}}var Fi={};Z(Fi,{insertText:()=>vh,openSymbolDialog:()=>Mh,pickLabels:()=>le,symbolPanel:()=>kh});var Ft={"toolbar.label":"Formatting","toolbar.options":"options","editor.label":"Rich text editor","editor.required":"Please fill in this field.",undo:"Undo",redo:"Redo",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",link:"Link",unlink:"Remove link",image:"Image",bulletList:"Bulleted list",orderedList:"Numbered list",indent:"Increase indent",outdent:"Decrease indent",align:"Alignment",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Justify",blockquote:"Quote",codeBlock:"Code block",horizontalRule:"Horizontal line",clearFormatting:"Clear formatting",more:"More",moreFormats:"More formatting",blocks:"Text style",styles:"Formats","styles.headings":"Headings","styles.inline":"Inline","styles.blocks":"Blocks","styles.align":"Align",paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",fontFamily:"Font",fontSize:"Font size",lineHeight:"Line height",default:"Default",textColor:"Text color",backgroundColor:"Highlight color",removeColor:"Remove color",customColor:"Custom color","dialog.cancel":"Cancel","dialog.save":"Save","dialog.insert":"Insert","dialog.close":"Close","dialog.required":"This field is required","dialog.invalid":"Check the format","link.title":"Insert link","link.editTitle":"Edit link","link.url":"URL","link.text":"Text to display","link.tooltip":"Title (tooltip)","link.newTab":"Open in new tab","link.open":"Open link","link.edit":"Edit link","link.copy":"Copy link","link.copied":"Link copied","link.invalid":"This URL is not allowed","image.title":"Insert image","image.url":"Image URL","image.alt":"Alternative text","image.altHint":"Describe the image for people using screen readers","image.upload":"Upload","image.drop":"Drop an image here or click to choose","image.uploading":"Uploading image\u2026","image.uploadFailed":"Image upload failed","image.retry":"Retry","image.retrying":"Connection problem \u2014 retrying the upload\u2026","image.invalid":"This image URL is not allowed","image.or":"or","image.toolbar":"Image options","image.alignLeft":"Float left","image.alignCenter":"Center","image.alignRight":"Float right","image.editAlt":"Alternative text","image.size":"Size","image.sizeSmall":"Small (25%)","image.sizeMedium":"Medium (50%)","image.sizeLarge":"Large (75%)","image.sizeFull":"Full width","image.sizeOriginal":"Original size","image.delete":"Remove image","image.caption":"Caption","image.captionPlaceholder":"Add a caption\u2026","status.words":"{count} words","status.resize":"Resize editor","dialog.browse":"Browse",pasteAsText:"Paste as text","menu.label":"Menu","menu.file":"File","menu.edit":"Edit","menu.view":"View","menu.insert":"Insert","menu.format":"Format","menu.table":"Table","menu.help":"Help",selectAll:"Select all",print:"Print","table.rows":"Rows","table.cols":"Columns","table.invalidSize":"Enter a number from 1 to 50","quickbars.selection":"Quick formatting","quickbars.insert":"Quick insert","search.title":"Find and replace","search.find":"Find","search.replace":"Replace with","search.next":"Next match","search.prev":"Previous match","search.replaceOne":"Replace","search.replaceAll":"Replace all","search.matchCase":"Match case","search.wholeWord":"Whole words only","search.count":"{current} of {total}","search.none":"No results",fullscreen:"Fullscreen",preview:"Preview",sourceCode:"Source code",help:"Keyboard shortcuts","help.formatting":"Text formatting","help.blocks":"Paragraphs and lists","help.editing":"Editing","help.navigation":"Navigation","help.slash":"Insert block (slash commands)","help.toMenubar":"Move to the menu bar","help.toToolbar":"Move to the toolbar","help.toContextToolbar":"Move to the image/table toolbar","help.toEditor":"Back to the text","help.nextCell":"Next table cell",table:"Table","table.insert":"Insert table","table.size":"{rows} \xD7 {cols}","table.toolbar":"Table options","table.rowBefore":"Insert row above","table.rowAfter":"Insert row below","table.rowDelete":"Delete row","table.colBefore":"Insert column left","table.colAfter":"Insert column right","table.colDelete":"Delete column","table.merge":"Merge cells","table.split":"Split cell","table.rowHeader":"Header row","table.colHeader":"Header column","table.cellBackground":"Cell background","table.delete":"Delete table","table.sort":"Sort","table.sortAsc":"Sort A \u2192 Z, 1 \u2192 9","table.sortDesc":"Sort Z \u2192 A, 9 \u2192 1","table.props":"Table properties","table.style":"Style","table.styleDefault":"Default","table.width":"Width","table.widthHint":"For example 100% or 600px. Leave empty to fit the content.","table.invalidWidth":"Enter a width such as 100% or 600px","table.align":"Alignment on the page","table.alignDefault":"Default","table.alignCenter":"Center","table.alignRight":"Right","table.cellProps":"Cell properties","table.valign":"Vertical alignment","table.valignTop":"Top","table.valignMiddle":"Middle","table.valignBottom":"Bottom","table.cellType":"Cell type","table.cellData":"Data cell","table.cellHeader":"Header cell","table.colWidth":"Column width, px","table.colWidthHint":"Leave empty to fit the content.","table.invalidColWidth":"Enter a number from 24 to 4000","slash.label":"Commands","slash.empty":"No matching commands"};var zr={},_r={en:Ft},Tc=new Set,Oc={};function yh(n){let e={};for(let[t,r]of Object.entries(n))typeof r=="string"?e[t]=r:r.forEach((o,i)=>e[`${t}.${i}`]=o);return e}function Hi(n,e){let t=n.toLowerCase();zr[t]={...zr[t],...e},_r[t]={...Ft,..._r[t],...e}}function Dc(n,e){let t={};for(let[r,o]of Object.entries(e))o&&(t[r]=yh(o));Oc[n]=t}var Nc=(n,e)=>e?n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`)):n;function Bi(n="en",e={}){let t=n.toLowerCase(),r=t.split("-")[0],o=_r[t]??_r[r]??Ft;o===Ft&&r!=="en"&&!Tc.has(r)&&(Tc.add(r),console.warn(`[nova] language "${n}" is not registered, using English. import pack from '@novaprose/core/i18n/${r}'; registerLanguage('${r}', pack);`));let i={...Ft,...o,...e},s={...zr[r],...zr[t]},l=e;return(a,c)=>{let u=i[a];if(u!==void 0)return Nc(u,c);let d=a.indexOf("."),p=d>0?Oc[a.slice(0,d)]:void 0,f=a.slice(d+1),h=l[a]??s[a]??p?.[t]?.[f]??p?.[r]?.[f]??p?.en?.[f]??a;return Nc(h,c)}}function le(n,e,t){Dc(e,t);let r={};for(let[o,i]of Object.entries(t.en))r[o]=typeof i=="string"?n.ui.t(`${e}.${o}`):i.map((s,l)=>n.ui.t(`${e}.${o}.${l}`));return r}function vh(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.insertText(e).scrollIntoView()),n.focus()}function kh(n){let e=M("input",{type:"search",className:"nova-input nova-symbols-search",placeholder:n.searchLabel,"aria-label":n.searchLabel}),t=M("div",{className:"nova-symbols-list"}),r=M("div",{className:`nova-symbols ${n.className}`},e,t),o=i=>{let s=i.trim().toLowerCase(),l=n.groups.map(a=>({title:a.title,items:s?a.items.filter(([c,u])=>u.includes(s)||c===s):a.items})).filter(a=>a.items.length);if(!l.length){t.replaceChildren(M("div",{className:"nova-symbols-empty"},n.emptyText));return}t.replaceChildren(...l.map(a=>M("div",{className:"nova-symbols-group",role:"group","aria-label":a.title},M("div",{className:"nova-symbols-title"},a.title),M("div",{className:"nova-symbols-grid"},...a.items.map(([c,u])=>M("button",{type:"button",className:"nova-symbols-cell",title:u,"aria-label":u,onclick:()=>n.onPick(c)},c))))))};return e.addEventListener("input",()=>o(e.value)),e.addEventListener("keydown",i=>{i.key==="ArrowDown"?(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.focus()):i.key==="Enter"&&(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.click())}),t.addEventListener("keydown",i=>{let s=[...t.querySelectorAll(".nova-symbols-cell")],l=s.indexOf(j(t));if(l<0)return;let a=Math.max(1,s.filter(p=>p.offsetTop===s[0].offsetTop).length),c={ArrowRight:1,ArrowLeft:-1,ArrowDown:a,ArrowUp:-a},u=Me(i,t);if(!(u in c))return;i.preventDefault();let d=l+c[u];d<0?e.focus():s[Math.min(s.length-1,d)]?.focus()}),o(""),queueMicrotask(()=>e.focus()),r}function Mh(n,e,t){let r=null,o=t(()=>r?.close());r=n.ui.openDialog({title:e,body:o,cancelLabel:n.ui.t("dialog.close")})}var Lc=S.anchor,xh={en:{title:"Anchor",id:"ID",hint:"Letters, digits, \u201C-\u201D, \u201C_\u201D, \u201C.\u201D; must start with a letter. Link to it with #ID.",invalid:"Use letters, digits, \u201C-\u201D, \u201C_\u201D or \u201C.\u201D, starting with a letter",save:"Save"}},$r=/^[A-Za-z][\w.-]{0,63}$/,Rc={name:"anchor",toolbar:"anchor",nodes:{anchor:{group:"inline",inline:!0,atom:!0,selectable:!0,attrs:{id:{}},parseDOM:[{tag:"a[id]:not([href])",getAttrs:n=>{let e=n.getAttribute("id")??"";return $r.test(e)?{id:e}:!1}},{tag:"a[name]:not([href])",getAttrs:n=>{let e=n.getAttribute("name")??"";return $r.test(e)?{id:e}:!1}}],toDOM:n=>["a",{id:$r.test(n.attrs.id)?n.attrs.id:null}]}},setup(n){let e=le(n,"anchor",xh),t=()=>{let{selection:o}=n.view.state;return o instanceof P&&o.node.type.name==="anchor"?o:null},r=()=>{let o=t(),i=ee({label:e.id,hint:e.hint,value:o?.node.attrs.id??""});n.ui.openDialog({title:e.title,body:M("div",{className:"nova-form"},i.el),submitLabel:e.save,onSubmit:()=>{let s=i.input.value.trim();if(!$r.test(s))return e.invalid;let{state:l,dispatch:a}=n.view,c=n.schema.nodes.anchor,u=t();return a(u?l.tr.setNodeMarkup(u.from,void 0,{id:s}):l.tr.replaceSelectionWith(c.create({id:s}),!1).scrollIntoView()),!0}})};n.ui.registry.addToggleButton("anchor",{icon:Lc,tooltip:e.title,isActive:()=>t()!==null,isEnabled:o=>o.isEditable(),onAction:r}),n.ui.registry.addMenuItem("anchor",{text:e.title,icon:Lc,onAction:r})}};var hs={};Z(hs,{Decoration:()=>ae,DecorationSet:()=>G,EditorView:()=>fn,__endComposition:()=>Jm,__parseFromClipboard:()=>Um});var xe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e};function an(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e}var qi=null;function rt(n,e,t){let r=qi||(qi=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r}function Sh(){qi=null}function Vr(n,e,t,r){return t&&(Ic(n,e,t,r,-1)||Ic(n,e,t,r,1))}var Pc=/^(img|br|input|textarea|hr)$/i;function Ic(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:ve(n))){let s=n.parentNode;if(!s||!H(s)||qr(n)||Pc.test(n.nodeName)||n.contentEditable=="false")return!1;e=xe(n)+(o<0?0:1),n=s}else if(H(n)){let s=n.childNodes[e+(o<0?-1:0)];if(H(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else{if(qr(s)||Pc.test(s.nodeName))return!1;n=s,e=o<0?ve(n):0}}else return!1}}function ve(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function H(n){return n.nodeType==1}function de(n){return n.nodeType==3}function cn(n,e){return e?n.contains(H(e)?e:e.parentNode):!1}function fu(n,e){for(;;){if(de(n)&&e)return n;if(H(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ve(n)}else if(n.parentNode&&!qr(n,!0))e=xe(n),n=n.parentNode;else return null}}function hu(n,e){for(;;){if(de(n)&&e<n.nodeValue.length)return n;if(H(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!qr(n,!0))e=xe(n)+1,n=n.parentNode;else return null}}function wh(n,e,t){for(let r=e==0,o=e==ve(n);r||o;){if(n==t)return!0;let i=xe(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==ve(n)}}function qr(n,e=!1){let t;for(let r=n;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&(!e||t.node.isBlock)&&(t.dom==n||t.contentDOM==n)}function Qr(n){return n.focusNode&&Vr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)}function mu(n,e){n.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&n.extend(e.focusNode,e.focusOffset)}function Eh(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ch(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ah(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ve(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ve(r.startContainer),r.startOffset)}}}var je=typeof navigator<"u"?navigator:null,Hc=typeof document<"u"?document:null,un=je&&je.userAgent||"",Ie=/gecko\/(\d+)/i.test(un)&&!/edge?\//i.test(un);Ie&&+(/Firefox\/(\d+)/.exec(un)||[0,0])[1];var Wi=/Chrome\/(\d+)/.exec(un),Se=!!Wi,gu=Wi?+Wi[1]:0,we=!!je&&/Apple Computer/.test(je.vendor),dn=we&&(/Mobile\/\w+/.test(un)||!!je&&je.maxTouchPoints>2),Re=dn||(je?/Mac/.test(je.platform):!1),bu=je?/Win/.test(je.platform):!1,ot=/Android \d/.test(un),Zr=!!Hc&&"webkitFontSmoothing"in Hc.documentElement.style,Th=Zr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function nt(n,e){return typeof n=="number"?n:n[e]}function Oh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Bc(n,e,t){if(!ji(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!H(s)){s=an(s);continue}let l=s==i.body,a=l?Nh(i):Oh(s),c=0,u=0;if(e.top<a.top+nt(r,"top")?u=-(a.top-e.top+nt(o,"top")):e.bottom>a.bottom-nt(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+nt(o,"top")-a.top:e.bottom-a.bottom+nt(o,"bottom")),e.left<a.left+nt(r,"left")?c=-(a.left-e.left+nt(o,"left")):e.right>a.right-nt(r,"right")&&(c=e.right-a.right+nt(o,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let p=s.scrollLeft,f=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let h=s.scrollLeft-p,g=s.scrollTop-f;e={left:e.left-h,top:e.top-g,right:e.right-h,bottom:e.bottom-g}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:an(s)}}function Dh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:yu(n.dom)}}function yu(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=an(r));return e}function Lh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;vu(t,r==0?0:r-e)}function vu(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var on=null;function ku(n){if(n.setActive)return n.setActive();if(on)return n.focus(on);let e=yu(n);n.focus(on==null?{get preventScroll(){return on={preventScroll:!0},!0}}:void 0),on||(on=!1,vu(e,0))}function Mu(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let p;if(H(u))p=u.getClientRects();else if(de(u))p=rt(u).getClientRects();else continue;for(let f=0;f<p.length;f++){let h=p[f];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let g=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(g<r){t=u,r=g,o=g&&de(t)?{left:h.right<e.left?h.right:h.left,top:e.top}:e,H(u)&&g&&(i=d+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=d+1)}}return!t&&a&&(t=a,o=c,r=0),t&&de(t)?Rh(t,o):!t||r?{node:n,offset:i}:Mu(t,o)}function Rh(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=vt(r,1);if(s.top!=s.bottom&&ss(e,s)){o={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function ss(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Ph(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Ih(n,e,t){let{node:r,offset:o}=Mu(e,t),i=-1;if(H(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function Hh(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(H(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function xu(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if(H(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ss(e,c))return xu(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function Bh(n,e){let t=n.dom.ownerDocument,r,o=0,i=Ah(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let c=n.dom.getBoundingClientRect();if(!ss(e,c)||(s=xu(n.dom,e,c),!s))return null}if(we)for(let c=s;r&&c;c=an(c))c.draggable&&(r=void 0);if(s=Ph(s,e),r){if(Ie&&H(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;Zr&&o&&H(r)&&H(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&H(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||!H(r)||r.childNodes[o-1].nodeName!="BR")&&(l=Hh(n,r,o,e))}l==null&&(l=Ih(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ji(n){return n.top<n.bottom||n.left<n.right}function vt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(ji(r))return r}return Array.prototype.find.call(t,ji)||n.getBoundingClientRect()}var Fh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Su(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=Zr||Ie;if(de(r))if(s&&(Fh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=vt(rt(r,o,o),t);if(Ie&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=vt(rt(r,o-1,o-1),-1);if(c.top==a.top){let u=vt(rt(r,o,o+1),-1);if(u.top!=a.top)return Wn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Wn(vt(rt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==ve(r))){let a=r.childNodes[o-1];if(H(a))return zi(a.getBoundingClientRect(),!1)}if(i==null&&o<ve(r)){let a=r.childNodes[o];if(H(a))return zi(a.getBoundingClientRect(),!0)}return zi(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==ve(r))){let a=r.childNodes[o-1],c=de(a)?rt(a,ve(a)-(s?0:1)):H(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Wn(vt(c,1),!1)}if(i==null&&o<ve(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?de(a)?rt(a,0,s?0:1):H(a)?a:null:null;if(c)return Wn(vt(c,-1),!0)}return Wn(vt(de(r)?rt(r):r,-t),t>=0)}function Wn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function zi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function wu(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function zh(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return wu(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Su(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(H(l))a=l.getClientRects();else if(de(l))a=rt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var _h=/[\u0590-\u08ac]/;function $h(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!_h.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:wu(n,e,()=>{let a=n.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",t,"character");let u=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:d,focusOffset:p}=n.domSel.readRange(),f=d&&!cn(u,d)||a.focusNode==d&&a.focusOffset==p;return mu(l,a),c!=null&&(l.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Fc=null,zc=null,_c=!1;function Vh(n,e,t){return Fc==e&&zc==t?_c:(Fc=e,zc=t,_c=t=="up"||t=="down"?zh(n,e,t):$h(n,e,t))}var qt=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&cn(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>xe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?o=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):o=!(i&4)}else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(H(s)?cn(s,e):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof jr||i instanceof Wr&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?xe(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?xe(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let d=l;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=xe(p.dom)+1;break}e-=p.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=xe(d.dom);break}t+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(!H(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Wr=class extends qt{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let l=H(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Ki=class extends qt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},_t=class n extends qt{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=Le.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var t;this.damage|=e,(t=this.parent)===null||t===void 0||t.markDamage(2)}slice(e,t,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=Ji(i,t,s,r)),e>0&&(i=Ji(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},St=class n extends qt{constructor(e,t,r,o,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!de(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Le.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Cu(u,r,t),c?a=new Kr(e,t,r,o,u,d||null,p,c):t.isText?new Jn(e,t,r,o,u,p):new n(e,t,r,o,u,d||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>H(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>A.empty}}return t}matchesNode(e,t,r){return!this.damage&&e.eq(this.node)&&Ur(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ui(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Kh(this.node,this.innerDeco,(d,p,f)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!f&&a.syncToMarks(p==this.node.childCount?_.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,o)},(d,p,f,h)=>{a.syncToMarks(d.marks,r,e,h),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let g;a.findNodeMatch(d,p,f,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(g=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,p,f,g,e,o)||a.updateNextNode(d,p,f,e,h,o)||a.addNode(d,p,f,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(s&&this.protectLocalComposition(e,s),Eu(this.contentDOM,this.children,e),dn&&Uh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof I)||r<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=Jh(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Ki(this,i,t,o);e.input.compositionNodes.push(s),this.children=Ji(this.children,r,r+o.length,e,s)}update(e,t,r,o,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o,i),!0)}updateInner(e,t,r,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,i+1),this.damage=0}updateOuterDeco(e){if(Ur(e,this.outerDeco))return;let t=!H(this.nodeDOM),r=this.dom;this.dom=ls(this.dom,this.nodeDOM,Gn(this.outerDeco,this.node,t),Gn(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){H(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){H(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function $c(n,e,t,r,o,i){i?ls(r,r,Gn(i,n,!1),Gn(e,n,!1)):Cu(r,e,n);let s=new St(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(o,0),s}var Jn=class n extends St{constructor(e,t,r,o,i,s){super(e,t,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.damage&8||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.damage=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return!1}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}},jr=class extends qt{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Kr=class extends St{constructor(e,t,r,o,i,s,l,a){super(e,t,r,o,i,s,l),this.spec=a}update(e,t,r,o,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Eu(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=Vc(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof _t){let a=r?r.previousSibling:n.lastChild;Eu(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Vc(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}var Kn=function(n){n&&(this.nodeName=n)};Kn.prototype=Object.create(null);var zt=[new Kn];function Gn(n,e,t){if(n.length==0)return zt;let r=t?zt[0]:new Kn,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new Kn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new Kn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function ls(n,e,t,r){if(t==zt&&r==zt)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=zt[0]),o=a}qh(o,l||zt[0],s)}return o}function qh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Cu(n,e,t){return ls(n,n,zt,Gn(e,t,!H(n)))}function Ur(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Vc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Ui=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Wh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof _t&&!(u.damage&4)&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=_t.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i,s){let l=this.top.children[o];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,t,r,i,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof St){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,p=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&!(a.damage&4)&&Ur(t,a.outerDeco));if(!p&&a.update(e,t,r,o,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(d=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.damage|=2,d.updateChildren(o,s+1),d.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ur(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=St.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=St.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Wr(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof _t;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Jn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((we||Se)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new jr(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||H(e)&&e.contains(this.lock.parentNode))}};function Wh(n,e){let t=e,r=t.children.length,o=[],i=n.childCount,s=new Map,l=[];e:for(;i>0;){let a;for(;;)if(r){let u=t.children[r-1];if(u instanceof _t)o.push(r-1),t=u,r=u.children.length;else{a=u,r--;break}}else{if(t==e)break e;r=o.pop(),t=t.parent}let c=a.node;if(c){if(c!=n.child(i-1))break;--i,s.set(a,i),l.push(a)}}return{index:i,matched:s,matches:l.reverse()}}function jh(n,e){return n.type.side-e.type.side}function Kh(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let m=o[s++];m.widget&&(u?(d||(d=[u])).push(m):u=m)}if(u)if(d){d.sort(jh);for(let m=0;m<d.length;m++)t(d[m],c,!!a)}else t(u,c,!!a);let p,f;if(a)f=-1,p=a,a=null;else if(c<n.childCount)f=c,p=n.child(c++);else break;for(let m=0;m<l.length;m++)l[m].to<=i&&l.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+p.nodeSize;if(p.isText){let m=h;s<o.length&&o[s].from<m&&(m=o[s].from);for(let b=0;b<l.length;b++)l[b].to<m&&(m=l[b].to);m<h&&(a=p.cut(m-i),p=p.cut(0,m-i),h=m,f=-1)}else for(;s<o.length&&o[s].to<h;)s++;let g=p.isInline&&!p.isLeaf?l.filter(m=>!m.inline):l.slice();r(p,g,e.forChild(i,p),f),i=h}}function Uh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Jh(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ji(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Gi(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&F.findFrom(i,e)}function kt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function qc(n,e,t){let r=n.state.selection;if(r instanceof I)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return kt(n,new I(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Gi(n.state,e);return o&&o instanceof P?kt(n,o):!1}else if(!Re||t.indexOf("m")<0){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?P.isSelectable(i)?kt(n,new P(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):kt(n,new I(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof P&&r.node.isInline)return kt(n,new I(e>0?r.$to:r.$from));{let o=Gi(n.state,e);return o?kt(n,o):!1}}}function Un(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):H(n)&&n.contentEditable=="false"}function sn(n,e){return e<0?Gh(n):Yh(n)}function Gh(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Ie&&H(t)&&r<ve(t)&&Un(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!H(t))break;let l=t.childNodes[r-1];if(Un(l,-1))o=t,i=--r;else if(de(l))t=l,r=t.nodeValue.length;else break}else{if(Au(t))break;{let l=t.previousSibling;for(;l&&Un(l,-1);)o=t.parentNode,i=xe(l),l=l.previousSibling;if(l)t=l,r=ve(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Yi(n,t,r):o&&Yi(n,o,i)}function Yh(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=ve(t),i,s;for(;;)if(r<o){if(!H(t))break;let l=t.childNodes[r];if(Un(l,1))i=t,s=++r;else break}else{if(Au(t))break;{let l=t.nextSibling;for(;l&&Un(l,1);)i=l.parentNode,s=xe(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=ve(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&Yi(n,i,s)}function Au(n){for(let e=n;e;e=e.parentNode){let t=e.pmViewDesc;if(t)return t.node?t.node.isBlock:!1}return!1}function Yi(n,e,t){if(!de(e)){let s,l;(l=hu(e,t))?(e=l,t=0):(s=fu(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),o=n.domSel.readRange();if(!r)return;Qr(o)?r.collapse(e,t):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,t)),n.domSel.ignore();let{state:i}=n;setTimeout(()=>{n.state==i&&n.domSel.sync()},50)}function Wc(n,e){let t=n.state.doc.resolve(e);if(!(Se||bu)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let r=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){r=n.nodeDOM(t.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function jc(n,e,t){let r=n.state.selection;if(r instanceof I&&!r.empty||t.indexOf("s")>-1||Re&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Gi(n.state,e);if(s&&s instanceof P)return kt(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof se?F.near(s,e):F.findFrom(s,e);return l?kt(n,l):!1}return!1}function Kc(n,e){if(!(n.state.selection instanceof I))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function Uc(n,e,t){n.domObserver.stopped(()=>e.contentEditable=t)}function Xh(n){if(!we||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSel.readRange();if(e&&H(e)&&t==0&&e.firstChild&&H(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Uc(n,r,"true"),setTimeout(()=>Uc(n,r,"false"),20)}return!1}function Qh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Zh(n,e){let t=e.keyCode,r=Qh(e);if(t==8||Re&&t==72&&r=="c")return Kc(n,-1)||sn(n,-1);if(t==46&&!e.shiftKey||Re&&t==68&&r=="c")return Kc(n,1)||sn(n,1);if(t==13||t==27)return!0;if(t==37||Re&&t==66&&r=="c"){let o=t==37?Wc(n,n.state.selection.from)=="ltr"?-1:1:-1;return qc(n,o,r)||sn(n,o)}else if(t==39||Re&&t==70&&r=="c"){let o=t==39?Wc(n,n.state.selection.from)=="ltr"?1:-1:1;return qc(n,o,r)||sn(n,o)}else{if(t==38||Re&&t==80&&r=="c")return jc(n,-1,r)||sn(n,-1);if(t==40||Re&&t==78&&r=="c")return Xh(n)||jc(n,1,r)||sn(n,1);if(r==(Re?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function as(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=n.someProp("clipboardSerializer")||Le.fromSchema(n.state.schema),l=Lu(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&H(c)&&(u=Du[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let h=l.createElement(u[f]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),d++}c=a.firstChild}c&&H(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
3
+ (()=>{var Dy=Object.create;var Eo=Object.defineProperty;var _y=Object.getOwnPropertyDescriptor;var Iy=Object.getOwnPropertyNames;var Hy=Object.getPrototypeOf,By=Object.prototype.hasOwnProperty;var Fy=(n,e,t)=>e in n?Eo(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var I=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var q=(n,e)=>{for(var t in e)Eo(n,t,{get:e[t],enumerable:!0})},zy=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Iy(e))!By.call(n,o)&&o!==t&&Eo(n,o,{get:()=>e[o],enumerable:!(r=_y(e,o))||r.enumerable});return n};var H=(n,e,t)=>(t=n!=null?Dy(Hy(n)):{},zy(e||!n||!n.__esModule?Eo(t,"default",{value:n,enumerable:!0}):t,n));var S=(n,e,t)=>Fy(n,typeof e!="symbol"?e+"":e,t);var gm={};var Fs={};q(Fs,{definePlugin:()=>Md,isPluginRegistered:()=>Co,loadPlugin:()=>Bs,orderPlugins:()=>Ln,pageHandlerOf:()=>kr,registerPlugin:()=>j,resolveEntries:()=>vr});function kr(n,e){for(let t of n)if(t.page)try{return typeof t.page=="function"?t.page(e):t.page}catch(r){console.error(`[nova] Plugin "${t.name}" failed to set up its page`,r)}return null}function Md(n){return n}var Hs=new Map;function j(n,e){Hs.set(n,e)}function Co(n){return Hs.has(n)}function Sd(n){return typeof n=="function"}function vr(n){let e=[],t=[],r=[];for(let o of n)if(typeof o=="string"){let i=Hs.get(o);i?Sd(i)?t.push(i):e.push(i):r.push(`Plugin "${o}" is not registered`)}else Sd(o)?t.push(o):e.push(o);return{plugins:e,loaders:t,errors:r}}function Ln(n,e=new Set){let t=new Map(n.map(l=>[l.name,l])),r=[],o=[],i=new Map,s=(l,a)=>{let c=i.get(l.name);if(c==="done")return!0;if(c==="failed")return!1;if(c==="visiting")return o.push(`Plugin dependency cycle: ${[...a,l.name].join(" \u2192 ")}`),!1;i.set(l.name,"visiting");for(let u of l.requires??[]){if(e.has(u))continue;let d=t.get(u);if(!d)return o.push(`Plugin "${l.name}" requires "${u}", which is not loaded`),i.set(l.name,"failed"),!1;if(!s(d,[...a,l.name]))return i.set(l.name,"failed"),!1}return i.set(l.name,"done"),r.push(l),!0};for(let l of n)s(l,[]);return{ordered:r,errors:o}}async function Bs(n){let e=await n();return"default"in e&&e.default?e.default:e}var gl={};q(gl,{LABELS:()=>dl,default:()=>ml,detailsAround:()=>Ib,isOpen:()=>pl,setOpen:()=>Dp,summaryEnd:()=>fl});var il={};q(il,{AllSelection:()=>de,EditorState:()=>un,NodeSelection:()=>R,Plugin:()=>z,PluginKey:()=>X,Selection:()=>U,SelectionRange:()=>cn,TextSelection:()=>F,Transaction:()=>Ho});var Js={};q(Js,{ContentMatch:()=>zt,DOMParser:()=>Mt,DOMSerializer:()=>qe,Fragment:()=>T,Mark:()=>Q,MarkType:()=>Rn,Node:()=>Te,NodeRange:()=>Ft,NodeType:()=>st,ReplaceError:()=>St,ResolvedPos:()=>Sr,Schema:()=>Dn,Slice:()=>D});function we(n){this.content=n}we.prototype={constructor:we,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new we(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new we(t)},addToStart:function(n,e){return new we([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new we(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new we(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=we.from(n),n.size?new we(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=we.from(n),n.size?new we(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=we.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};we.from=function(n){if(n instanceof we)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new we(e)};var zs=we;function Id(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&Fd(s.charCodeAt(a-1))&&Bd(s.charCodeAt(a))&&t--,t}if(o.content.size||i.content.size){let s=Id(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Hd(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,p=u.length;for(;d>0&&p>0&&c[d-1]==u[p-1];)d--,p--,t--,r--;return d&&p&&d<c.length&&Fd(c.charCodeAt(d-1))&&Bd(c.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=Hd(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Bd(n){return n>=56320&&n<57344}function Fd(n){return n>=55296&&n<56320}var T=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new n(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Id(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Hd(this,e,t,r)}findIndex(e){if(e==0)return Ao(0,e);if(e==this.size)return Ao(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?Ao(t+1,i):Ao(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};T.empty=new T([],0);var $s={index:0,offset:0};function Ao(n,e){return $s.index=n,$s.offset=e,$s}function Oo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Oo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Oo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var Q=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Oo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};Q.none=[];var St=class extends Error{},D=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=$d(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(zd(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(T.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};D.empty=new D(T.empty,0,0);function zd(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(zd(i.content,e-o-1,t-o-1)))}function $d(n,e,t,r,o,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=$d(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?o-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function $y(n,e,t){if(t.openStart>n.depth)throw new St("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new St("Inconsistent open depths");return Vd(n,e,t,0)}function Vd(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=Vd(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return nn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Vy(t,n);return nn(i,jd(n,s,l,e,r))}else return nn(i,Lo(n,e,r))}function qd(n,e){if(!e.type.compatibleContent(n.type))throw new St("Cannot join "+e.type.name+" onto "+n.type.name)}function Vs(n,e,t){let r=n.node(t);return qd(r,e.node(t)),r}function tn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function xr(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(tn(n.nodeAfter,r),i++));for(let l=i;l<s;l++)tn(o.child(l),r);e&&e.depth==t&&e.textOffset&&tn(e.nodeBefore,r)}function nn(n,e){if(!n.type.validContent(e))throw new St("Invalid content for node "+n.type.name);return n.copy(e)}function jd(n,e,t,r,o){let i=n.depth>o&&Vs(n,e,o+1),s=r.depth>o&&Vs(t,r,o+1),l=[];return xr(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(qd(i,s),tn(nn(i,jd(n,e,t,r,o+1)),l)):(i&&tn(nn(i,Lo(n,e,o+1)),l),xr(e,t,o,l),s&&tn(nn(s,Lo(t,r,o+1)),l)),xr(r,null,o,l),new T(l)}function Lo(n,e,t){let r=[];if(xr(null,n,t,r),n.depth>t){let o=Vs(n,e,t+1);tn(nn(o,Lo(n,e,t+1)),r)}return xr(e,null,t,r),new T(r)}function Vy(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(T.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var Sr=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Q.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Ft(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=Ed.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else Ed.set(e,r=new qs);let o=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%qy,o}},qs=class{constructor(){this.elts=[],this.i=0}},qy=12,Ed=new WeakMap,Ft=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},jy=Object.create(null),Te=class n{constructor(e,t,r,o=Q.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||T.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Oo(this.attrs,t||e.defaultAttrs||jy)&&Q.sameSet(this.marks,r||Q.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return D.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new D(c,o.depth-s,i.depth-s)}replace(e,t,r){return $y(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Sr.resolveCached(this,e)}resolveNoCache(e){return Sr.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Wd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=T.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ad(this.type.attrs,this.attrs,"node",this.type.name);let e=Q.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];Ad(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!Q.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=T.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};Te.prototype.text=void 0;var Cd=(()=>{let{stack:n}=new Error("/");if(!n||!/\n\s*at\s/.test(n))return t=>t;let e=Object.create(null);return t=>(e[t],t)})(),js=class n extends Te{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return Cd(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(Cd(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Wd(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function Ad(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}var zt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ws(e,t);if(r.next==null)return n.empty;let o=Kd(r);r.next&&r.err("Unexpected trailing text");let i=Xy(Yy(o));return Zy(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let p=i(d,l.concat(u));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
4
+ `)}};zt.empty=new zt(!0);var Ws=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Kd(n){let e=[];do e.push(Wy(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Wy(n){let e=[];do e.push(Ky(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ky(n){let e=Gy(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Uy(n,e);else break;return e}function Td(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Uy(n,e){let t=Td(n),r=t;return n.eat(",")&&(n.next!="}"?r=Td(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Jy(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Gy(n){if(n.eat("(")){let e=Kd(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Jy(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Yy(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ud(n,e){return e-n}function Nd(n,e){let t=[];return r(e),t.sort(Ud);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Xy(n){let e=Object.create(null);return t(Nd(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Nd(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new zt(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Ud);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function Zy(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Jd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Gd(n,e){let t=Object.create(null);for(let r in n){let o=n[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(i);t[r]=i}return t}function Yd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Ks(n,r,e[r]);return t}var st=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Yd(e,r.attrs),this.defaultAttrs=Jd(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==zt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Gd(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Te(this,this.computeAttrs(e),T.from(t),Q.setFrom(r))}createChecked(e=null,t,r){return t=T.from(t),this.checkContent(t),new Te(this,this.computeAttrs(e),t,Q.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=T.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(T.empty,!0);return i?new Te(this,e,t.append(i),Q.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Q.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Qy(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var Ks=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Qy(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Rn=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Yd(e,o.attrs),this.excluded=null;let i=Jd(this.attrs);this.instance=i?new Q(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Q(this,Gd(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Dn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=zs.from(e.nodes),t.marks=zs.from(e.marks||{}),this.nodes=st.compile(this.spec.nodes,this),this.marks=Rn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=zt.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Od(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Od(this,s.split(" "))}this.nodeFromJSON=o=>Te.fromJSON(this,o),this.markFromJSON=o=>Q.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof st){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new js(r,r.defaultAttrs,e,Q.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Od(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function eb(n){return n.tag!=null}function tb(n){return n.style!=null}var Mt=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(eb(o))this.tags.push(o);else if(tb(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Po(this,t,!1);return r.addAll(e,Q.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Po(this,t,!0);return r.addAll(e,Q.none,t.from,t.to),D.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(ob(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Pd(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Pd(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Xd={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},nb={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Zd={ol:!0,ul:!0},Mr=1,Us=2,wr=4;function Ld(n,e,t){return e!=null?(e?Mr:0)|(e==="full"?Us:0):n&&n.whitespace=="pre"?Mr|Us:t&~wr}var Pn=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=Q.none,this.match=i||(s&wr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Mr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Xd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Po=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Ld(null,t.preserveWhitespace,0)|(r?wr:0);o?i=new Pn(o.type,o.attrs,Q.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Pn(null,null,Q.none,!0,null,s):i=new Pn(e.schema.topNodeType,null,Q.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&Us?"full":this.localPreserveWS||(o.options&Mr)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
5
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Zd.hasOwnProperty(s)&&this.parser.normalizeLists&&rb(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:nb.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Xd.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
6
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=Q.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Rd(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Ld(e,i,s.options);s.options&wr&&s.content.length==0&&(l|=wr);let a=Q.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Rd(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Pn(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Mr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function rb(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Zd.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ob(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Pd(n){let e={};for(let t in n)e[t]=n[t];return e}function Rd(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}var qe=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=To(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return To(t).createTextNode(e.text);let{dom:r,contentDOM:o}=No(To(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&No(To(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:No(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Dd(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Dd(e.marks)}};function Dd(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function To(n){return n.document||window.document}var _d=new WeakMap;function ib(n){let e=_d.get(n);return e===void 0&&_d.set(n,e=sb(n)),e}function sb(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function No(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=ib(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof p=="string")a.appendChild(n.createTextNode(p));else{let{dom:f,contentDOM:h}=No(n,p,t,r);if(a.appendChild(f),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var tl={};q(tl,{AddMarkStep:()=>Je,AddNodeMarkStep:()=>Hn,AttrStep:()=>on,DocAttrStep:()=>Tr,MapResult:()=>_n,Mapping:()=>In,RemoveMarkStep:()=>Ge,RemoveNodeMarkStep:()=>rn,ReplaceAroundStep:()=>re,ReplaceStep:()=>le,Step:()=>oe,StepMap:()=>lt,StepResult:()=>me,Transform:()=>Et,TransformError:()=>sn,canJoin:()=>ct,canSplit:()=>Ct,dropPoint:()=>Nr,findWrapping:()=>ln,insertPoint:()=>pp,joinPoint:()=>dp,liftTarget:()=>at,replaceStep:()=>Or});var rp=65535,op=Math.pow(2,16);function lb(n,e){return n+e*op}function Qd(n){return n&rp}function ab(n){return(n-(n&rp))/op}var ip=1,sp=2,Ro=4,lp=8,_n=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&lp)>0}get deletedBefore(){return(this.delInfo&(ip|Ro))>0}get deletedAfter(){return(this.delInfo&(sp|Ro))>0}get deletedAcross(){return(this.delInfo&Ro)>0}},lt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Qd(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+ab(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let p=c?e==a?-1:e==d?1:t:t,f=a+o+(p<0?0:u);if(r)return f;let h=e==(t<0?a:d)?null:lb(l/3,e-a),m=0;return c&&(m|=e==a?sp:e==d?ip:Ro,(t<0?e!=a:e!=d)&&(m|=lp)),new _n(f,m,h)}o+=u-c}return r?e+o:new _n(e+o,0,null)}touches(e,t){let r=0,o=Qd(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};lt.empty=new lt([]);var In=class n{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=e.from,r=this._maps.length;t<e.to;t++){let o=e.getMirror(t);o!=null&&(o=o<t&&o>=e.from?r+(o-e.from):void 0),this.appendMap(e._maps[t],o)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.to-1,r=this._maps.length+e._maps.length;t>=e.from;t--){let o=e.getMirror(t);o!=null&&(o=o>t&&o<e.to?r-(o-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),o)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new _n(e,o,null)}},Gs=Object.create(null),oe=class{getMap(){return lt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Gs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Gs)throw new RangeError("Duplicate use of step JSON ID "+e);return Gs[e]=t,t.prototype.jsonID=e,t}},me=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,o){try{return n.ok(e.replace(t,r,o))}catch(i){if(i instanceof St)return n.fail(i.message);throw i}}};function Qs(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Qs(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return T.fromArray(r)}var Je=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new D(Qs(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return me.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!Q.sameSet(i,r.marks)){let s=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);Do(Ge,s,l,this.mark,t);for(let a of r.marks)a.isInSet(i)||Do(n,s,l,a,t)}}}),t.length==1?t[0]:new Ar(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("addMark",Je);var Ge=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new D(Qs(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return me.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Do(Je,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new Ar(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("removeMark",Ge);function Do(n,e,t,r,o){let i=o.length?o[o.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(r)?o[o.length-1]=new n(i.from,t,r):o.push(new n(e,t,r))}var Ar=class n extends oe{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new me(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let o=r.map(e);o&&t.push(o)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>oe.fromJSON(e,r)))}};oe.jsonID("markSet",Ar);var Hn=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return me.fromReplace(e,this.pos,this.pos+1,new D(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new n(this.pos,t.marks[o]);return new n(this.pos,this.mark)}}return new rn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("addNodeMark",Hn);var rn=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return me.fromReplace(e,this.pos,this.pos+1,new D(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Hn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("removeNodeMark",rn);var le=class n extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Xs(e,this.from,this.to)?me.fail("Structure replace would overwrite content"):me.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new lt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,D.fromJSON(e,t.slice),!!t.structure)}};le.MAP_BIAS=1;oe.jsonID("replace",le);var re=class n extends oe{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Xs(e,this.from,this.gapFrom)||Xs(e,this.gapTo,this.to)))return me.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return me.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?me.fromReplace(e,this.from,this.to,r):me.fail("Content does not fit in gap")}getMap(){return new lt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos||o>i?null:new n(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,D.fromJSON(e,t.slice),t.insert,!!t.structure)}};oe.jsonID("replaceAround",re);function Xs(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function cb(n,e,t,r){let o=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),u=Math.min(s+i.nodeSize,t);Do(Je,c,u,r,o)}}),o.forEach(i=>n.step(i))}function ub(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(r instanceof Rn){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],p;for(let f=0;f<o.length;f++){let h=o[f];h.step==i-1&&d.eq(o[f].style)&&(p=h)}p?(p.to=c,p.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Ge(s.from,s.to,s.style)))}function el(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new le(l,u,D.empty));else{r=d;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Ge(l,u,c.marks[p]));if(o&&c.isText&&t.whitespace!="pre"){let p,f=/\r?\n|\r/g,h;for(;p=f.exec(c.text);)h||(h=new D(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new le(l+p.index,l+p.index+p[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(T.empty,!0);n.replace(l,l,new D(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function db(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function at(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+o,a=n.$to.indexAfter(r)-i;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!db(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function pb(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=T.empty,d=0;for(let h=i,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,u=T.from(r.node(h).copy(u)),d++):a--;let p=T.empty,f=0;for(let h=i,m=!1;h>t;h--)m||o.after(h+1)<o.end(h)?(m=!0,p=T.from(o.node(h).copy(p)),f++):c++;n.step(new re(a,c,s,l,new D(u.append(p),d,f),u.size-d,!0))}function ln(n,e,t=null,r=n){let o=fb(n,e),i=o&&hb(r,e);return i?o.map(ep).concat({type:e,attrs:t}).concat(i.map(ep)):null}function ep(n){return{type:n,attrs:null}}function fb(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function hb(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function mb(n,e,t){let r=T.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=T.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new re(o,i,o,i,new D(r,0,0),t.length,!0))}function gb(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&yb(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?c=!1:!f&&h&&(c=!0)}c===!1&&cp(n,s,l,i),el(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),p=u.map(l+s.nodeSize,1);return n.step(new re(d,p,d+1,p-1,new D(T.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&ap(n,s,l,i),!1}})}function ap(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function cp(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
7
+ `))}})}function yb(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function bb(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new re(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new D(T.from(s),0,0),1,!0))}function Ct(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>i;c--,u--){let d=o.node(c),p=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),h=r&&r[u+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function kb(n,e,t=1,r){let o=n.doc.resolve(e),i=T.empty,s=T.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=T.from(o.node(l).copy(i));let u=r&&r[c];s=T.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}n.step(new le(e,e,new D(i.append(s),t,t),!0))}function ct(n,e){let t=n.resolve(e),r=t.index();return up(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function vb(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function up(n,e){return!!(n&&e&&!n.isLeaf&&vb(n,e))}function dp(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):t>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&up(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function xb(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);cp(n,u.node(),u.before(),l)}s.inlineContent&&el(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new le(c,a.map(e+t,-1),D.empty,!0)),r===!0){let u=n.doc.resolve(c);ap(n,u.node(),u.before(),n.steps.length)}return n}function pp(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Nr(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(s)+(l>0?1:0),u=r.node(s),d=!1;if(i==1)d=u.canReplace(c,c,o);else{let p=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=p&&u.canReplaceWith(c,c,p[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function Or(n,e,t=e,r=D.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return fp(o,i,r)?new le(e,t,r):new Zs(o,i,r).fit()}function fp(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Zs=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=T.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=T.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new D(i,s,l);return e>-1?new re(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new le(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=tp(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(T.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return np(e,-1)<=t?!1:(this.unplaced.size>1&&np(e,1)>r&&r++,this.unplaced=new D(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=tp(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new D(Er(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new D(Er(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:p}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(hp(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let h=c==l.childCount;h||(f=-1),this.placed=Cr(this.placed,t,T.from(u)),this.frontier[t].match=d,h&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=u[u.length-1];g&&m<f;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=h?e==0?D.empty:new D(Er(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new D(Er(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ys(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Ys(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Ys(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Cr(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Cr(this.placed,this.depth,T.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=Cr(this.placed,this.frontier.length,t))}};function Er(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Er(n.firstChild.content,e-1,t)))}function Cr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Cr(n.lastChild.content,e-1,t)))}function tp(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function hp(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,hp(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(T.empty,!0)))),n.copy(r)}function Ys(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!wb(t,i.content,s)?l:null}function wb(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Sb(n){return n.spec.defining||n.spec.definingForContent}function np(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function Mb(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(fp(o,i,r))return n.step(new le(e,t,r));let s=gp(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let p=o.depth,f=o.pos-1;p>0;p--,f--){let h=o.node(p).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(p)>-1?l=p:o.before(p)==f&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],u=r.openStart;for(let p=r.content,f=0;;f++){let h=p.firstChild;if(c.push(h),f==r.openStart)break;p=h.content}for(let p=u-1;p>=0;p--){let f=c[p],h=Sb(f.type);if(h&&!f.sameMarkup(o.node(Math.abs(l)-1)))u=p;else if(h||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+u+1)%(r.openStart+1),h=c[f];if(h)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],k=!0;g<0&&(k=!1,g=-g);let x=o.node(g-1),M=o.index(g-1);if(x.canReplaceWith(M,M,h.type,h.marks))return n.replace(o.before(g),k?i.after(g):t,new D(mp(r.content,0,r.openStart,f),f,r.openEnd))}}let d=n.steps.length;for(let p=s.length-1;p>=0&&(n.replace(e,t,r),!(n.steps.length>d));p--){let f=s[p];f<0||(e=o.before(f),t=i.after(f))}}function mp(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(mp(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(T.empty,!0))}return n}function Eb(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=pp(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new D(T.from(r),0,0))}function Cb(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=gp(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function gp(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}var on=class n extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return me.fromReplace(e,this.pos,this.pos+1,new D(T.from(o),0,t.isLeaf?0:1))}getMap(){return lt.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};oe.jsonID("attr",on);var Tr=class n extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return me.ok(r)}getMap(){return lt.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};oe.jsonID("docAttr",Tr);var sn=class extends Error{};sn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};sn.prototype=Object.create(Error.prototype);sn.prototype.constructor=sn;sn.prototype.name="TransformError";var Et=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new In}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new sn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=D.empty){let o=Or(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new D(T.from(r),0,0))}delete(e,t){return this.replace(e,t,D.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Mb(this,e,t,r),this}replaceRangeWith(e,t,r){return Eb(this,e,t,r),this}deleteRange(e,t){return Cb(this,e,t),this}lift(e,t){return pb(this,e,t),this}join(e,t=1){return xb(this,e,t),this}wrap(e,t){return mb(this,e,t),this}setBlockType(e,t=e,r,o=null){return gb(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return bb(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new on(e,t,r)),this}setDocAttribute(e,t){return this.step(new Tr(e,t)),this}addNodeMark(e,t){return this.step(new Hn(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Q)t.isInSet(r.marks)&&this.step(new rn(e,t));else{let o=r.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new rn(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return kb(this,e,t,r),this}addMark(e,t,r){return cb(this,e,t,r),this}removeMark(e,t,r){return ub(this,e,t,r),this}clearIncompatible(e,t,r){return el(this,e,t,r),this}};var nl=Object.create(null),U=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new cn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=D.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?D.empty:t),l==0&&kp(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),kp(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new F(e):Bn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?Bn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Bn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new de(e.node(0))}static atStart(e){return Bn(e,e,0,0,1)||new de(e)}static atEnd(e){return Bn(e,e,e.content.size,e.childCount,-1)||new de(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=nl[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in nl)throw new RangeError("Duplicate use of selection JSON ID "+e);return nl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}};U.prototype.visible=!0;var cn=class{constructor(e,t){this.$from=e,this.$to=t}},yp=!1;function bp(n){!yp&&!n.parent.inlineContent&&(yp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var F=class n extends U{constructor(e,t=e){bp(e),bp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return U.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=D.empty){if(super.replace(e,t),t==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Io(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=U.findFrom(t,r,!0)||U.findFrom(t,-r,!0);if(i)t=i.$head;else return U.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(U.findFrom(e,-r,!0)||U.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new n(e,t)}};U.jsonID("text",F);var Io=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}},R=class n extends U{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?U.near(i):new n(i)}content(){return new D(T.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ol(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};R.prototype.visible=!1;U.jsonID("node",R);var ol=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Io(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):U.near(t)}},de=class n extends U{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=D.empty){if(t==D.empty){e.delete(0,e.doc.content.size);let r=U.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return Ab}};U.jsonID("all",de);var Ab={map(){return this},resolve(n){return new de(n)}};function Bn(n,e,t,r,o,i=!1){if(e.inlineContent)return F.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&R.isSelectable(l))return R.create(n,t-(o<0?l.nodeSize:0))}else{let a=Bn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function kp(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof le||o instanceof re))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(U.near(n.doc.resolve(s),t))}var vp=1,_o=2,xp=4,Ho=class extends Et{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|vp)&~_o,this.storedMarks=null,this}get selectionSet(){return(this.updated&vp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_o,this}ensureMarks(e){return Q.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&_o)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~_o,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Q.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(U.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=xp,this}get scrolledIntoView(){return(this.updated&xp)>0}};function wp(n,e){return!e||!n?n:n.bind(e)}var an=class{constructor(e,t,r){this.name=e,this.init=wp(t.init,r),this.apply=wp(t.apply,r)}},Tb=[new an("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new an("selection",{init(n,e){return n.selection||U.atStart(e.doc)},apply(n){return n.selection}}),new an("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new an("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Lr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tb.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new an(r.key,r.spec.state,r))})}},un=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Ho(this)}static create(e){let t=new Lr(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Lr(this.schema,e.plugins),r=t.fields,o=new n(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Lr(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Te.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=U.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Sp(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Sp(o,e,{})),t[r]=o}return t}var z=class{constructor(e){this.spec=e,this.props={},e.props&&Sp(e.props,this,this.props),this.key=e.key?e.key.key:Mp("plugin")}getState(e){return e[this.key]}},rl=Object.create(null);function Mp(n){return n in rl?n+"$"+ ++rl[n]:(rl[n]=0,n+"$")}var X=class{constructor(e="key"){this.key=Mp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var ll={};q(ll,{FOCUSABLE:()=>$t,activeElement:()=>te,eventTarget:()=>sl,formatShortcut:()=>At,h:()=>w,icon:()=>ee,isMac:()=>Cp,isRtl:()=>Fn,listenDocument:()=>ut,logicalKey:()=>Ne,uniqueId:()=>je});function w(n,e={},...t){let r=document.createElement(n);for(let[o,i]of Object.entries(e))i==null||i===!1||(typeof i=="function"?r.addEventListener(o.replace(/^on/,"").toLowerCase(),i):o==="className"?r.className=String(i):r.setAttribute(o,i===!0?"":String(i)));for(let o of t.flat())o==null||o===!1||r.append(o);return r}function ee(n){let e=document.createElement("span");return e.className="nova-icon",e.innerHTML=n,e}var Ep=0;function je(n="nova"){return Ep+=1,`${n}-${Ep}`}var Cp=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Nb={ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192"};function At(n){let e=n.split("-"),t=e.pop(),r=t.length===1?t.toUpperCase():Nb[t]??t;if(Cp){let i={Mod:"\u2318",Shift:"\u21E7",Alt:"\u2325",Ctrl:"\u2303"};return e.map(s=>i[s]??s).join("")+r}let o={Mod:"Ctrl",Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl"};return[...e.map(i=>o[i]??i),r].join("+")}var $t='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function te(n){let e=n.getRootNode(),t=("activeElement"in e?e.activeElement:null)??document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function sl(n){return n.composedPath?.()[0]??n.target}function ut(n,e,t){let r=n.getRootNode(),o=typeof ShadowRoot<"u"&&r instanceof ShadowRoot?r:null,i=l=>{o&&l.composedPath().includes(o.host)||t(l,sl(l))},s=l=>t(l,sl(l));return document.addEventListener(e,i,!0),o?.addEventListener(e,s,!0),()=>{document.removeEventListener(e,i,!0),o?.removeEventListener(e,s,!0)}}function Fn(n){return n.closest("[dir]")?.getAttribute("dir")?.toLowerCase()==="rtl"}function Ne(n,e){return n.key!=="ArrowLeft"&&n.key!=="ArrowRight"||!Fn(e)?n.key:n.key==="ArrowLeft"?"ArrowRight":"ArrowLeft"}var al={};q(al,{icons:()=>C});var A=n=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,C={undo:A('<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />'),redo:A('<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />'),bold:A('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),italic:A('<line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" />'),underline:A('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),strike:A('<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />'),code:A('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),subscript:A('<path d="m4 5 8 8" /><path d="m12 5-8 8" /><path d="M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07" />'),superscript:A('<path d="m4 19 8-8" /><path d="m12 19-8-8" /><path d="M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" />'),bulletList:A('<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />'),orderedList:A('<path d="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" />'),indent:A('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'),outdent:A('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'),blockquote:A('<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'),codeBlock:A('<path d="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" />'),alignLeft:A('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),alignCenter:A('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),alignRight:A('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),alignJustify:A('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),horizontalRule:A('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),link:A('<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />'),unlink:A('<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" />'),image:A('<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />'),clearFormatting:A('<path d="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" />'),formatMore:A('<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />'),imageLeft:A('<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />'),imageCenter:A('<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />'),imageRight:A('<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />'),resize:A('<path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" />'),altText:A('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),imageCaption:A('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),trash:A('<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />'),paragraph:A('<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'),h1:A('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),h2:A('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" />'),h3:A('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" />'),pasteText:A('<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /><path d="M9 12v-1h6v1" /><path d="M11 17h2" /><path d="M12 11v6" />'),table:A('<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'),rowBefore:A('<path d="M12 2v6" /><path d="M18.464 3H19a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h.535" /><path d="M21 12H3" /><path d="M9 5h6" />'),rowAfter:A('<path d="M12 22v-6" /><path d="M18.464 21H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h.535" /><path d="M21 12H3" /><path d="M9 19h6" />'),rowDelete:A('<path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" />'),colBefore:A('<path d="M12 3v18" /><path d="M3 5.536V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-.535" /><path d="M5 15V9" /><path d="M8 12H2" />'),colAfter:A('<path d="M12 3v18" /><path d="M16 12h6" /><path d="M19 15V9" /><path d="M21 5.536V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-.535" />'),colDelete:A('<g transform="rotate(90 12 12)"><path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" /></g>'),merge:A('<path d="M12 21v-6" /><path d="M12 9V3" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),split:A('<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),rowHeader:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),colHeader:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),sort:A('<path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" />'),tableProps:A('<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'),cellProps:A('<path d="M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6" /><path d="m14.305 19.53.923-.382" /><path d="M15 3v7.6" /><path d="m15.229 16.852-.924-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.773 16.852.922-.383" /><path d="m20.773 19.148.922.383" /><path d="M9 3v18" /><circle cx="18" cy="18" r="3" />'),tableDelete:A('<path d="M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3" /><path d="m16.5 16.5 5 5" /><path d="m16.5 21.5 5-5" />'),chevronUp:A('<path d="m18 15-6-6-6 6" />'),search:A('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),fullscreen:A('<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />'),fullscreenExit:A('<path d="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" />'),preview:A('<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />'),sourceCode:A('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),help:A('<circle cx="12" cy="12" r="10" /><path d="M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5" /><path d="M12 17h.01" />'),print:A('<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" />'),check:A('<path d="M20 6 9 17l-5-5" />'),close:A('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),chevronDown:A('<path d="m6 9 6 6 6-6" />'),more:A('<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'),textColor:A('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),highlight:A('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),lineHeight:A('<path d="M15 14H9" /><path d="M21 21H3" /><path d="M21 3H3" /><path d="m8 16 3.453-7.648a.6.6 0 011.094.001L16 16" />'),language:A('<path d="m5 8 6 6" /><path d="m4 14 6-6 2-3" /><path d="M2 5h12" /><path d="M7 2h1" /><path d="m22 22-5-10-5 10" /><path d="M14 18h6" />'),upload:A('<path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />'),externalLink:A('<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" /><path d="m21 3-9 9" /><path d="M15 3h6v6" />'),copy:A('<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),edit:A('<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" />'),resizeHandle:A('<circle cx="12" cy="9" r="1" /><circle cx="19" cy="9" r="1" /><circle cx="5" cy="9" r="1" /><circle cx="12" cy="15" r="1" /><circle cx="19" cy="15" r="1" /><circle cx="5" cy="15" r="1" />'),browse:A('<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />'),mergeTags:A('<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" /><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />'),resizeHandleBoth:A('<path d="M19 13v6h-6" /><path d="M5 11V5h6" /><path d="m5 5 14 14" />'),sidebar:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M15 3v18" />'),anchor:A('<path d="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" />'),save:A('<path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" />'),charmap:A('<path d="M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21" />'),commentAdd:A('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M12 8v6" /><path d="M9 11h6" />'),comments:A('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M7 11h10" /><path d="M7 15h6" /><path d="M7 7h8" />'),emoji:A('<path d="M15 10V9" /><path d="M16.472 15a6 6 0 01-8.943 0" /><path d="M9 10V9" /><circle cx="12" cy="12" r="10" />'),dateTime:A('<path d="M16 2v3" /><path d="M17 15.5v1.7l1 .625" /><path d="M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935" /><path d="M3 9h9.873" /><path d="M8 2v3" /><circle cx="17" cy="17" r="5" />'),media:A('<rect x="3" y="3" width="18" height="18" rx="2" /><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z" />'),checklist:A('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><rect x="3" y="4" width="6" height="6" rx="1" />'),codeSample:A('<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 12.5 8 15l2 2.5" /><path d="m14 12.5 2 2.5-2 2.5" />'),dragHandle:A('<circle cx="9" cy="12" r="1" /><circle cx="9" cy="5" r="1" /><circle cx="9" cy="19" r="1" /><circle cx="15" cy="12" r="1" /><circle cx="15" cy="5" r="1" /><circle cx="15" cy="19" r="1" />'),accordion:A('<path d="M10 5h11" /><path d="M10 12h11" /><path d="M10 19h11" /><path d="m3 10 3-3-3-3" /><path d="m3 20 3-3-3-3" />'),tableOfContents:A('<path d="M16 5H3" /><path d="M16 12H3" /><path d="M16 19H3" /><path d="M21 5h.01" /><path d="M21 12h.01" /><path d="M21 19h.01" />'),math:A('<path d="M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2" />'),duplicate:A('<line x1="15" x2="15" y1="12" y2="18" /><line x1="12" x2="18" y1="15" y2="15" /><rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),nonBreaking:A('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),pageBreak:A('<path d="M5.42 9.42 8 12" /><circle cx="4" cy="8" r="2" /><path d="m14 6-8.58 8.58" /><circle cx="4" cy="16" r="2" /><path d="M10.8 14.8 14 18" /><path d="M16 12h-2" /><path d="M22 12h-2" />'),history:A('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />'),suggest:A('<path d="M13 21h8" /><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />'),review:A('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><path d="m3 7 2 2 4-4" />'),visualBlocks:A('<path d="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" />'),ltr:A('<path d="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" />'),rtl:A('<path d="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" />'),caseChange:A('<path d="m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16" /><path d="M22 9v7" /><path d="M3.304 13h6.392" /><circle cx="18.5" cy="12.5" r="3.5" />'),formatPainter:A('<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />'),permanentPen:A('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),visualChars:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M12 12H9.5a2.5 2.5 0 0 1 0-5H17" /><path d="M12 7v10" /><path d="M16 7v10" />'),cancelChanges:A('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />'),template:A('<rect width="18" height="7" x="3" y="3" rx="1" /><rect width="9" height="7" x="3" y="14" rx="1" /><rect width="5" height="7" x="16" y="14" rx="1" />'),footnote:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M12 8v8" /><path d="m8.5 14 7-4" /><path d="m8.5 10 7 4" />'),footnotesUpdate:A('<path d="M21 5H3" /><path d="M7 12H3" /><path d="M7 19H3" /><path d="M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14" /><path d="M11 10v4h4" />')};var Ap='.nova-details{position:relative;margin:0 0 .75em;padding-block:6px;padding-inline:34px 12px;border:1px solid var(--nova-border);border-radius:var(--nova-radius-sm)}.nova-details-toggle{position:absolute;top:7px;inset-inline-start:6px;display:flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:4px;background:none;color:var(--nova-muted);cursor:pointer}.nova-details-toggle:hover{background:var(--nova-hover);color:var(--nova-fg)}.nova-details-toggle:focus-visible{outline:2px solid var(--nova-accent);outline-offset:1px}.nova-details-toggle svg{width:16px;height:16px;transition:transform .12s ease}.nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(-90deg)}[dir=rtl] .nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(90deg)}.nova-details-content>summary{position:relative;display:block;margin:0;font-weight:600;cursor:text;list-style:none}.nova-details-content>summary::-webkit-details-marker{display:none}.nova-details-content>summary:has(>br.ProseMirror-trailingBreak:only-child):before{content:var(--nova-summary-placeholder, "");position:absolute;color:var(--nova-muted);font-weight:400;pointer-events:none}.nova-details-open>.nova-details-content>summary{margin-bottom:.4em}.nova-details:not(.nova-details-open)>.nova-details-content>:not(summary){display:none}.nova-details-content>:last-child{margin-bottom:0}.nova-details.ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}@media(prefers-reduced-motion:reduce){.nova-details-toggle svg{transition:none}}';var ul={};q(ul,{insertText:()=>Pb,openSymbolDialog:()=>Db,pickLabels:()=>Oe,symbolPanel:()=>Rb});var dn={"toolbar.label":"Formatting","toolbar.options":"options","editor.label":"Rich text editor","editor.required":"Please fill in this field.",undo:"Undo",redo:"Redo",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",link:"Link",unlink:"Remove link",image:"Image",bulletList:"Bulleted list",orderedList:"Numbered list",indent:"Increase indent",outdent:"Decrease indent",align:"Alignment",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Justify",blockquote:"Quote",codeBlock:"Code block",moveBlockUp:"Move block up",moveBlockDown:"Move block down",horizontalRule:"Horizontal line",clearFormatting:"Clear formatting",more:"More",moreFormats:"More formatting",blocks:"Text style",styles:"Formats","styles.headings":"Headings","styles.inline":"Inline","styles.blocks":"Blocks","styles.align":"Align",paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",fontFamily:"Font",fontSize:"Font size",lineHeight:"Line height",language:"Language","language.default":"Default language","language.field":"Language of the selected text",default:"Default",textColor:"Text color",backgroundColor:"Highlight color",removeColor:"Remove color",customColor:"Custom color","dialog.cancel":"Cancel","dialog.save":"Save","dialog.insert":"Insert","dialog.close":"Close","dialog.required":"This field is required","dialog.invalid":"Check the format","link.title":"Insert link","link.editTitle":"Edit link","link.url":"URL","link.text":"Text to display","link.tooltip":"Title (tooltip)","link.newTab":"Open in new tab","link.open":"Open link","link.edit":"Edit link","link.copy":"Copy link","link.copied":"Link copied","link.invalid":"This URL is not allowed","image.title":"Insert image","image.url":"Image URL","image.alt":"Alternative text","image.altHint":"Describe the image for people using screen readers","image.upload":"Upload","image.drop":"Drop an image here or click to choose","image.uploading":"Uploading image\u2026","image.uploadFailed":"Image upload failed","image.retry":"Retry","image.retrying":"Connection problem \u2014 retrying the upload\u2026","image.invalid":"This image URL is not allowed","image.or":"or","image.toolbar":"Image options","image.alignLeft":"Float left","image.alignCenter":"Center","image.alignRight":"Float right","image.editAlt":"Alternative text","image.size":"Size","image.sizeSmall":"Small (25%)","image.sizeMedium":"Medium (50%)","image.sizeLarge":"Large (75%)","image.sizeFull":"Full width","image.sizeOriginal":"Original size","image.delete":"Remove image","image.caption":"Caption","image.captionPlaceholder":"Add a caption\u2026","status.words":"{count} words","announce.on":"{name} on","announce.off":"{name} off","status.resize":"Resize editor","dialog.browse":"Browse","dialog.dropFiles":"Drop files here or","dialog.fileType":"This file type is not allowed","dialog.fileTooLarge":"The file is too large","dialog.removeFile":"Remove",pasteAsText:"Paste as text","menu.label":"Menu","menu.file":"File","menu.edit":"Edit","menu.view":"View","menu.insert":"Insert","menu.format":"Format","menu.table":"Table","menu.tools":"Tools","menu.help":"Help",selectAll:"Select all",print:"Print","table.rows":"Rows","table.cols":"Columns","table.invalidSize":"Enter a number from 1 to 50","quickbars.selection":"Quick formatting","quickbars.insert":"Quick insert","search.title":"Find and replace","search.find":"Find","search.replace":"Replace with","search.next":"Next match","search.prev":"Previous match","search.replaceOne":"Replace","search.replaceAll":"Replace all","search.matchCase":"Match case","search.wholeWord":"Whole words only","search.count":"{current} of {total}","search.none":"No results",fullscreen:"Fullscreen",preview:"Preview",sourceCode:"Source code",help:"Keyboard shortcuts","help.formatting":"Text formatting","help.blocks":"Paragraphs and lists","help.editing":"Editing","help.navigation":"Navigation","help.slash":"Insert block (slash commands)","help.toMenubar":"Move to the menu bar","help.toToolbar":"Move to the toolbar","help.toContextToolbar":"Move to the image/table toolbar","help.toEditor":"Back to the text","help.nextCell":"Next table cell",table:"Table","table.insert":"Insert table","table.size":"{rows} \xD7 {cols}","table.toolbar":"Table options","table.rowBefore":"Insert row above","table.rowAfter":"Insert row below","table.rowDelete":"Delete row","table.colBefore":"Insert column left","table.colAfter":"Insert column right","table.colDelete":"Delete column","table.merge":"Merge cells","table.split":"Split cell","table.rowHeader":"Header row","table.colHeader":"Header column","table.cellBackground":"Cell background","table.delete":"Delete table","table.sort":"Sort","table.sortAsc":"Sort A \u2192 Z, 1 \u2192 9","table.sortDesc":"Sort Z \u2192 A, 9 \u2192 1","table.props":"Table properties","table.style":"Style","table.styleDefault":"Default","table.width":"Width","table.widthHint":"For example 100% or 600px. Leave empty to fit the content.","table.invalidWidth":"Enter a width such as 100% or 600px","table.align":"Alignment on the page","table.alignDefault":"Default","table.alignCenter":"Center","table.alignRight":"Right","table.cellProps":"Cell properties","table.valign":"Vertical alignment","table.valignTop":"Top","table.valignMiddle":"Middle","table.valignBottom":"Bottom","table.cellType":"Cell type","table.cellData":"Data cell","table.cellHeader":"Header cell","table.colWidth":"Column width, px","table.colWidthHint":"Leave empty to fit the content.","table.invalidColWidth":"Enter a number from 24 to 4000","slash.label":"Commands","slash.empty":"No matching commands"};var zn={},Pr={en:dn},Tp=new Set,Fo={};function Lb(n){let e={};for(let[t,r]of Object.entries(n))typeof r=="string"?e[t]=r:r.forEach((o,i)=>e[`${t}.${i}`]=o);return e}var $n={},Bo={};function Op(n,e,t=!1){zn[n]=t?{...e,...zn[n]}:{...zn[n],...e},Pr[n]={...dn,...zn[n]}}function Vt(n,e){let t=n.toLowerCase();typeof e=="function"?$n[t]=e:Op(t,e)}function Lp(n){let e=n.toLowerCase();return e in Pr||e.split("-")[0]in Pr}function cl(n){let e=n.toLowerCase(),t=e.split("-")[0],r=e in $n?e:t in $n?t:null;return r?Bo[r]??(Bo[r]=$n[r]().then(o=>(Op(r,o.default??o,!0),!0),o=>{throw Bo[r]=void 0,o})):Promise.resolve(Lp(e))}function Pp(n,e){let t=Fo[n]??(Fo[n]={});for(let[r,o]of Object.entries(e))o&&(t[r]={...t[r],...Lb(o)})}var Np=(n,e)=>e?n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`)):n;function Rp(n="en",e={}){let t=n.toLowerCase(),r=t.split("-")[0],o=Pr[t]??Pr[r]??dn;o===dn&&r!=="en"&&!Tp.has(r)&&(Tp.add(r),console.warn(t in $n||r in $n?`[nova] language "${n}" is not loaded yet, using English. Load it before creating the editor: await loadLanguage('${n}');`:`[nova] language "${n}" is not registered, using English. import pack from '@novaprose/core/i18n/${r}'; registerLanguage('${r}', pack);`));let i={...dn,...o,...e},s={...zn[r],...zn[t]},l=e;return(a,c)=>{let u=i[a];if(u!==void 0)return Np(u,c);let d=a.indexOf("."),p=d>0?Fo[a.slice(0,d)]:void 0,f=a.slice(d+1),h=l[a]??s[a]??p?.[t]?.[f]??p?.[r]?.[f]??p?.en?.[f]??a;return Np(h,c)}}function Oe(n,e,t){Pp(e,t);let r={};for(let[o,i]of Object.entries(t.en))r[o]=typeof i=="string"?n.ui.t(`${e}.${o}`):i.map((s,l)=>n.ui.t(`${e}.${o}.${l}`));return r}function Pb(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.insertText(e).scrollIntoView()),n.focus()}function Rb(n){let e=w("input",{type:"search",className:"nova-input nova-symbols-search",placeholder:n.searchLabel,"aria-label":n.searchLabel}),t=w("div",{className:"nova-symbols-list"}),r=w("div",{className:`nova-symbols ${n.className}`},e,t),o=i=>{let s=i.trim().toLowerCase(),l=n.groups.map(a=>({title:a.title,items:s?a.items.filter(([c,u])=>u.includes(s)||c===s):a.items})).filter(a=>a.items.length);if(!l.length){t.replaceChildren(w("div",{className:"nova-symbols-empty"},n.emptyText));return}t.replaceChildren(...l.map(a=>w("div",{className:"nova-symbols-group",role:"group","aria-label":a.title},w("div",{className:"nova-symbols-title"},a.title),w("div",{className:"nova-symbols-grid"},...a.items.map(([c,u])=>w("button",{type:"button",className:"nova-symbols-cell",title:u,"aria-label":u,onclick:()=>n.onPick(c)},c))))))};return e.addEventListener("input",()=>o(e.value)),e.addEventListener("keydown",i=>{i.key==="ArrowDown"?(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.focus()):i.key==="Enter"&&(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.click())}),t.addEventListener("keydown",i=>{let s=[...t.querySelectorAll(".nova-symbols-cell")],l=s.indexOf(te(t));if(l<0)return;let a=Math.max(1,s.filter(p=>p.offsetTop===s[0].offsetTop).length),c={ArrowRight:1,ArrowLeft:-1,ArrowDown:a,ArrowUp:-a},u=Ne(i,t);if(!(u in c))return;i.preventDefault();let d=l+c[u];d<0?e.focus():s[Math.min(s.length-1,d)]?.focus()}),o(""),queueMicrotask(()=>e.focus()),r}function Db(n,e,t){let r=null,o=t(()=>r?.close());r=n.ui.openDialog({title:e,body:o,cancelLabel:n.ui.t("dialog.close")})}var dl={en:{accordion:"Accordion",summary:"Summary",expand:"Expand",collapse:"Collapse"}};function _b(n){let e=n.options.pluginOptions?.accordion??{},t=e.initialState??"inherited",r=e.serializedState??"inherited";return{details:{group:"block",content:"details_summary block+",defining:!0,attrs:{open:{default:!0}},parseDOM:[{tag:"details",getAttrs:o=>({open:t==="inherited"?o.hasAttribute("open"):t==="expanded"})}],toDOM:o=>["details",(r==="inherited"?o.attrs.open!==!1:r==="expanded")?{open:""}:{},0]},details_summary:{content:"inline*",defining:!0,isolating:!0,parseDOM:[{tag:"summary",context:"details/"}],toDOM:()=>["summary",0]}}}function Ib(n){for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name==="details")return{node:t,pos:n.before(e)}}return null}var pl=n=>n.attrs.open!==!1,fl=n=>n.pos+2+n.node.firstChild.content.size;function Dp(n,e,t){return n.setNodeAttribute(e.pos,"open",t).setMeta("addToHistory",!1)}var hl=class{constructor(e,t,r,o){S(this,"node",e);S(this,"labels",o);S(this,"dom");S(this,"contentDOM");S(this,"toggle");this.toggle=w("button",{type:"button",className:"nova-details-toggle",contentEditable:"false",tabIndex:-1}),this.toggle.append(ee(C.chevronDown)),this.toggle.addEventListener("mousedown",i=>i.preventDefault()),this.toggle.addEventListener("click",()=>{let i=r();if(i===void 0)return;let s=t.state.doc.nodeAt(i);if(s?.type.name!=="details")return;let l={node:s,pos:i},a=pl(s),c=Dp(t.state.tr,l,!a),{from:u}=t.state.selection;a&&u>fl(l)&&u<i+s.nodeSize&&c.setSelection(F.create(c.doc,fl(l))),t.dispatch(c)}),this.contentDOM=w("div",{className:"nova-details-content"}),this.dom=w("div",{className:"nova-details"},this.toggle,this.contentDOM),this.sync()}sync(){let e=pl(this.node);this.dom.classList.toggle("nova-details-open",e),this.toggle.setAttribute("aria-expanded",String(e)),this.toggle.setAttribute("aria-label",e?this.labels.collapse:this.labels.expand)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.sync(),!0)}stopEvent(e){return e.target instanceof Node&&this.toggle.contains(e.target)}ignoreMutation(e){return e.type!=="selection"&&!this.contentDOM.contains(e.target)}},ml={name:"accordion",nodes:_b,prosemirrorPlugins:n=>{let e=Oe(n,"accordion",dl);return[new z({key:new X("nova-accordion"),props:{nodeViews:{details:(t,r,o)=>new hl(t,r,o,e)}}})]},setup(n){n.ui.addStyles("nova-accordion",Ap);let{summary:e}=Oe(n,"accordion",dl);n.root.style.setProperty("--nova-summary-placeholder",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/accordion-ui-4272c63b.js") )};var yl={};q(yl,{ELEMENT_ID_RE:()=>zo,elementId:()=>Vn});var zo=/^[A-Za-z][\w.-]{0,63}$/;function Vn(n){return typeof n=="string"&&zo.test(n)?n:null}var bl=zo,_p={name:"anchor",toolbar:"anchor",nodes:{anchor:{group:"inline",inline:!0,atom:!0,selectable:!0,attrs:{id:{}},parseDOM:[{tag:"a[id]:not([href])",getAttrs:n=>{let e=n.getAttribute("id")??"";return bl.test(e)?{id:e}:!1}},{tag:"a[name]:not([href])",getAttrs:n=>{let e=n.getAttribute("name")??"";return bl.test(e)?{id:e}:!1}}],toDOM:n=>["a",{id:bl.test(n.attrs.id)?n.attrs.id:null}]}},load:()=>import(__novaChunk("tinymce-chunks/anchor-ui-da0966bb.js") )};var vl={};q(vl,{LABELS:()=>Bp,default:()=>kl,loadTemml:()=>Fp,mathLatex:()=>qn,renderMath:()=>zp});var Ip='.nova-math{border-radius:4px;cursor:pointer}.nova-math-inline{display:inline-block;padding:0 2px}.nova-math-block{display:block;margin:0 0 .75em;padding:6px 8px;overflow-x:auto;text-align:center}.nova-math:hover{background:var(--nova-hover)}.nova-math.is-selected{outline:2px solid var(--nova-accent)}.nova-math:not(:has(math)){font-family:var(--nova-mono);font-size:.9em}.nova-math-error{color:var(--nova-danger);text-decoration:underline wavy;text-underline-offset:3px}.nova-math-empty:before{content:var(--nova-math-empty, "");color:var(--nova-muted);font-family:var(--nova-font)}.nova-math-preview{min-height:2.5em;padding:8px;overflow-x:auto;border:1px dashed var(--nova-border);border-radius:var(--nova-radius-sm);text-align:center}';var Bp={en:{empty:"Formula"}};function qn(n){return typeof n=="string"?n.slice(0,1e4):""}var $o=null;function Fp(){return $o??($o=import(__novaChunk("tinymce-chunks/temml-d637f801.js") ).then(n=>n.default,n=>($o=null,console.warn("[nova] math: could not load the formula renderer",n),null))),$o}function zp(n,e,t,r){try{return n.render(e,t,{displayMode:r,throwOnError:!0,trust:!1,annotate:!0}),null}catch(o){return t.textContent=e,o instanceof Error?o.message.replace(/^ParseError:\s*/,""):String(o)}}function Hp(n){let e=n?"block-math":"inline-math",t=n?"div":"span";return{...n?{group:"block"}:{group:"inline",inline:!0},atom:!0,selectable:!0,draggable:!0,attrs:{latex:{default:""}},parseDOM:[{tag:`${t}[data-type="${e}"]`,getAttrs:r=>({latex:qn(r.getAttribute("data-latex"))})}],toDOM:r=>{let o=qn(r.attrs.latex);return[t,{"data-type":e,"data-latex":o},n?`\\[${o}\\]`:`\\(${o}\\)`]},leafText:r=>n?`$$${qn(r.attrs.latex)}$$`:`$${qn(r.attrs.latex)}$`}}var Vo=class{constructor(e,t,r,o){S(this,"node",e);S(this,"view",t);S(this,"getPos",r);S(this,"editor",o);S(this,"dom");S(this,"latex","");let i=e.type.name==="math_block";this.dom=document.createElement(i?"div":"span"),this.dom.className=`nova-math ${i?"nova-math-block":"nova-math-inline"}`,this.dom.contentEditable="false",this.dom.addEventListener("click",()=>this.edit()),this.render()}render(){let e=qn(this.node.attrs.latex);if(e===this.latex&&this.dom.childNodes.length)return;this.latex=e;let t=this.node.type.name==="math_block";this.dom.classList.toggle("nova-math-empty",!e.trim()),this.dom.textContent=e.trim()?e:"",e.trim()&&Fp().then(r=>{if(!r||this.latex!==e)return;let o=zp(r,e,this.dom,t);this.dom.classList.toggle("nova-math-error",!!o),o?this.dom.title=o:this.dom.removeAttribute("title")})}edit(){let e=this.getPos();if(e===void 0||!this.editor.isEditable())return;this.view.dispatch(this.view.state.tr.setSelection(R.create(this.view.state.doc,e)));let t=this.editor.ui.registry.get("math");t?.type==="button"&&t.onAction(this.editor)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}ignoreMutation(){return!0}},kl={name:"math",nodes:{math_inline:Hp(!1),math_block:Hp(!0)},prosemirrorPlugins:n=>[new z({key:new X("nova-math"),props:{nodeViews:{math_inline:(e,t,r)=>new Vo(e,t,r,n),math_block:(e,t,r)=>new Vo(e,t,r,n)}}})],setup(n){n.ui.addStyles("nova-math",Ip);let{empty:e}=Oe(n,"math",Bp);n.root.style.setProperty("--nova-math-empty",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/math-ui-1b57f7eb.js") )};var Sl={};q(Sl,{LABELS:()=>Vp,default:()=>wl,tocEntries:()=>xl,tocSettings:()=>qp});var $p='.nova-prosemirror nav[data-toc]{margin:0 0 .75em;padding:10px 14px;border-inline-start:3px solid var(--nova-accent);border-radius:var(--nova-radius-sm);background:var(--nova-code-bg)}.nova-prosemirror nav[data-toc]>:is(p,h1,h2,h3,h4,h5,h6):first-child{margin:0 0 6px;font-size:1em;font-weight:600}.nova-prosemirror nav[data-toc] :is(ul,ol){margin:0;padding-inline-start:1.2em}.nova-prosemirror nav[data-toc]>:is(ul,ol){padding-inline-start:0}.nova-prosemirror nav[data-toc] ul{list-style:none}.nova-prosemirror nav[data-toc] li{margin:2px 0}.nova-prosemirror nav[data-toc] a{color:var(--nova-accent);text-decoration:none;cursor:pointer}.nova-prosemirror nav[data-toc] a:hover{text-decoration:underline}.nova-prosemirror nav[data-toc]:not(:has(a)):after{content:var(--nova-toc-empty, "");color:var(--nova-muted)}.nova-prosemirror nav[data-toc].ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}';var Vp={en:{title:"Contents",insert:"Table of contents",update:"Update table of contents",empty:"Add headings \u2014 they will appear here"}},Fb=/^[A-Za-z_][\w-]{0,63}$/;function qp(n){let e=n.options.pluginOptions?.tableofcontents??{},t=Number(e.depth);return{depth:Number.isInteger(t)&&t>=1&&t<=6?t:3,className:typeof e.className=="string"&&Fb.test(e.className)?e.className:"nova-toc",titleTag:typeof e.titleTag=="string"&&/^(p|h[1-6])$/i.test(e.titleTag)?e.titleTag.toLowerCase():"p",title:typeof e.title=="string"?e.title.slice(0,200):null,list:e.orderedList?"ol":"ul"}}function xl(n){if(!Array.isArray(n))return[];let e=[];for(let t of n.slice(0,1e3)){if(!t||typeof t!="object")continue;let{level:r,id:o,text:i}=t,s=Number(r),l=Vn(o);!Number.isInteger(s)||s<1||s>6||!l||typeof i!="string"||e.push({level:s,id:l,text:i.slice(0,300)})}return e}function zb(n,e){if(!n.length)return null;let t=[e],r=[{level:n[0].level,list:t,last:null}];for(let o of n){let i=r[r.length-1];if(o.level>i.level&&i.last){let l=[e];i.last.push(l),r.push({level:o.level,list:l,last:null})}else for(;r.length>1&&o.level<r[r.length-1].level;)r.pop();i=r[r.length-1];let s=["li",["a",{href:`#${o.id}`},o.text]];i.list.push(s),i.last=s}return t}function $b(n){let e=[];for(let t of n.querySelectorAll('a[href^="#"]')){let r=0;for(let o=t;o&&o!==n;o=o.parentElement)(o.tagName==="UL"||o.tagName==="OL")&&r++;e.push({level:Math.min(Math.max(r,1),6),id:t.getAttribute("href").slice(1),text:(t.textContent??"").trim()})}return xl(e)}function Vb(n){let e=qp(n);return{toc:{group:"block",atom:!0,selectable:!0,attrs:{entries:{default:[]},title:{default:null}},parseDOM:[...["nav[data-toc]","div.mce-toc",`.${e.className}`].map(t=>({tag:t,getAttrs:r=>{let o=r.querySelector(":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6, :scope > p");return{entries:$b(r),title:o?.textContent?.trim()||null}}}))],toDOM:t=>{let r=typeof t.attrs.title=="string"?t.attrs.title.slice(0,200):"",o=zb(xl(t.attrs.entries),e.list);return["nav",{class:e.className,"data-toc":""},...r?[[e.titleTag,r]]:[],...o?[o]:[]]}}}}var wl={name:"tableofcontents",nodes:Vb,setup(n){n.ui.addStyles("nova-tableofcontents",$p);let{empty:e}=Oe(n,"tableofcontents",Vp);n.root.style.setProperty("--nova-toc-empty",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/tableofcontents-ui-01a9af06.js") )};var fa={};q(fa,{LABELS:()=>ah,commentsKey:()=>ft,default:()=>pa,getComments:()=>ci});var Zl={};q(Zl,{Decoration:()=>ge,DecorationSet:()=>ae,EditorView:()=>Zn,__endComposition:()=>hv,__parseFromClipboard:()=>fv});var Le=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e};function Un(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e}var Tl=null;function Nt(n,e,t){let r=Tl||(Tl=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r}function qb(){Tl=null}function qo(n,e,t,r){return t&&(Wp(n,e,t,r,-1)||Wp(n,e,t,r,1))}var jp=/^(img|br|input|textarea|hr)$/i;function Wp(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||!W(s)||jo(n)||jp.test(n.nodeName)||n.contentEditable=="false")return!1;e=Le(n)+(o<0?0:1),n=s}else if(W(n)){let s=n.childNodes[e+(o<0?-1:0)];if(W(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else{if(jo(s)||jp.test(s.nodeName))return!1;n=s,e=o<0?Me(n):0}}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function W(n){return n.nodeType==1}function ke(n){return n.nodeType==3}function Jn(n,e){return e?n.contains(W(e)?e:e.parentNode):!1}function Mf(n,e){for(;;){if(ke(n)&&e)return n;if(W(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!jo(n,!0))e=Le(n),n=n.parentNode;else return null}}function Ef(n,e){for(;;){if(ke(n)&&e<n.nodeValue.length)return n;if(W(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!jo(n,!0))e=Le(n)+1,n=n.parentNode;else return null}}function jb(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let i=Le(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==Me(n)}}function jo(n,e=!1){let t;for(let r=n;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&(!e||t.node.isBlock)&&(t.dom==n||t.contentDOM==n)}function Qo(n){return n.focusNode&&qo(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)}function Cf(n,e){n.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&n.extend(e.focusNode,e.focusOffset)}function Wb(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Kb(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ub(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}var dt=typeof navigator<"u"?navigator:null,Kp=typeof document<"u"?document:null,Gn=dt&&dt.userAgent||"",Ye=/gecko\/(\d+)/i.test(Gn)&&!/edge?\//i.test(Gn);Ye&&+(/Firefox\/(\d+)/.exec(Gn)||[0,0])[1];var Nl=/Chrome\/(\d+)/.exec(Gn),Pe=!!Nl,Af=Nl?+Nl[1]:0,Re=!!dt&&/Apple Computer/.test(dt.vendor),Yn=Re&&(/Mobile\/\w+/.test(Gn)||!!dt&&dt.maxTouchPoints>2),We=Yn||(dt?/Mac/.test(dt.platform):!1),Tf=dt?/Win/.test(dt.platform):!1,Ot=/Android \d/.test(Gn),ei=!!Kp&&"webkitFontSmoothing"in Kp.documentElement.style,Jb=ei?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Gb(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Tt(n,e){return typeof n=="number"?n:n[e]}function Yb(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Up(n,e,t){if(!Ol(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!W(s)){s=Un(s);continue}let l=s==i.body,a=l?Gb(i):Yb(s),c=0,u=0;if(e.top<a.top+Tt(r,"top")?u=-(a.top-e.top+Tt(o,"top")):e.bottom>a.bottom-Tt(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Tt(o,"top")-a.top:e.bottom-a.bottom+Tt(o,"bottom")),e.left<a.left+Tt(r,"left")?c=-(a.left-e.left+Tt(o,"left")):e.right>a.right-Tt(r,"right")&&(c=e.right-a.right+Tt(o,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let p=s.scrollLeft,f=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let h=s.scrollLeft-p,m=s.scrollTop-f;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:Un(s)}}function Xb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Nf(n.dom)}}function Nf(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Un(r));return e}function Zb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Of(t,r==0?0:r-e)}function Of(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var jn=null;function Lf(n){if(n.setActive)return n.setActive();if(jn)return n.focus(jn);let e=Nf(n);n.focus(jn==null?{get preventScroll(){return jn={preventScroll:!0},!0}}:void 0),jn||(jn=!1,Of(e,0))}function Pf(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let p;if(W(u))p=u.getClientRects();else if(ke(u))p=Nt(u).getClientRects();else continue;for(let f=0;f<p.length;f++){let h=p[f];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(m<r){t=u,r=m,o=m&&ke(t)?{left:h.right<e.left?h.right:h.left,top:e.top}:e,W(u)&&m&&(i=d+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=d+1)}}return!t&&a&&(t=a,o=c,r=0),t&&ke(t)?Qb(t,o):!t||r?{node:n,offset:i}:Pf(t,o)}function Qb(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=qt(r,1);if(s.top!=s.bottom&&jl(e,s)){o={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function jl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ek(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function tk(n,e,t){let{node:r,offset:o}=Pf(e,t),i=-1;if(W(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function nk(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(W(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Rf(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if(W(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(jl(e,c))return Rf(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function rk(n,e){let t=n.dom.ownerDocument,r,o=0,i=Ub(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let c=n.dom.getBoundingClientRect();if(!jl(e,c)||(s=Rf(n.dom,e,c),!s))return null}if(Re)for(let c=s;r&&c;c=Un(c))c.draggable&&(r=void 0);if(s=ek(s,e),r){if(Ye&&W(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;ei&&o&&W(r)&&W(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&W(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||!W(r)||r.childNodes[o-1].nodeName!="BR")&&(l=nk(n,r,o,e))}l==null&&(l=tk(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ol(n){return n.top<n.bottom||n.left<n.right}function qt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ol(r))return r}return Array.prototype.find.call(t,Ol)||n.getBoundingClientRect()}var ok=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Df(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=ei||Ye;if(ke(r))if(s&&(ok.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=qt(Nt(r,o,o),t);if(Ye&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=qt(Nt(r,o-1,o-1),-1);if(c.top==a.top){let u=qt(Nt(r,o,o+1),-1);if(u.top!=a.top)return Rr(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Rr(qt(Nt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(W(a))return Ml(a.getBoundingClientRect(),!1)}if(i==null&&o<Me(r)){let a=r.childNodes[o];if(W(a))return Ml(a.getBoundingClientRect(),!0)}return Ml(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=ke(a)?Nt(a,Me(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Rr(qt(c,1),!1)}if(i==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?ke(a)?Nt(a,0,s?0:1):W(a)?a:null:null;if(c)return Rr(qt(c,-1),!0)}return Rr(qt(ke(r)?Nt(r):r,-t),t>=0)}function Rr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ml(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function _f(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function ik(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return _f(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Df(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(ke(l))a=Nt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var sk=/[\u0590-\u08ac]/;function lk(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!sk.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:_f(n,e,()=>{let a=n.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",t,"character");let u=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:d,focusOffset:p}=n.domSel.readRange(),f=d&&!Jn(u,d)||a.focusNode==d&&a.focusOffset==p;return Cf(l,a),c!=null&&(l.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Jp=null,Gp=null,Yp=!1;function ak(n,e,t){return Jp==e&&Gp==t?Yp:(Jp=e,Gp=t,Yp=t=="up"||t=="down"?ik(n,e,t):lk(n,e,t))}var gn=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&Jn(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Le(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?o=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):o=!(i&4)}else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(W(s)?Jn(s,e):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Ko||i instanceof Wo&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Le(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Le(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let d=l;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=Le(p.dom)+1;break}e-=p.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=Le(d.dom);break}t+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(!W(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Wo=class extends gn{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let l=W(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Ll=class extends gn{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},fn=class n extends gn{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=qe.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var t;this.damage|=e,(t=this.parent)===null||t===void 0||t.markDamage(2)}slice(e,t,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=Rl(i,t,s,r)),e>0&&(i=Rl(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Ut=class n extends gn{constructor(e,t,r,o,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!ke(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=qe.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Hf(u,r,t),c?a=new Uo(e,t,r,o,u,d||null,p,c):t.isText?new Hr(e,t,r,o,u,p):new n(e,t,r,o,u,d||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>W(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>T.empty}}return t}matchesNode(e,t,r){return!this.damage&&e.eq(this.node)&&Jo(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Pl(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;pk(this.node,this.innerDeco,(d,p,f)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!f&&a.syncToMarks(p==this.node.childCount?Q.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,o)},(d,p,f,h)=>{a.syncToMarks(d.marks,r,e,h),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,p,f,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,p,f,m,e,o)||a.updateNextNode(d,p,f,e,h,o)||a.addNode(d,p,f,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(s&&this.protectLocalComposition(e,s),If(this.contentDOM,this.children,e),Yn&&fk(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=hk(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Ll(this,i,t,o);e.input.compositionNodes.push(s),this.children=Rl(this.children,r,r+o.length,e,s)}update(e,t,r,o,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o,i),!0)}updateInner(e,t,r,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,i+1),this.damage=0}updateOuterDeco(e){if(Jo(e,this.outerDeco))return;let t=!W(this.nodeDOM),r=this.dom;this.dom=Wl(this.dom,this.nodeDOM,Br(this.outerDeco,this.node,t),Br(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Xp(n,e,t,r,o,i){i?Wl(r,r,Br(i,n,!1),Br(e,n,!1)):Hf(r,e,n);let s=new Ut(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(o,0),s}var Hr=class n extends Ut{constructor(e,t,r,o,i,s){super(e,t,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.damage&8||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.damage=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return!1}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ko=class extends gn{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Uo=class extends Ut{constructor(e,t,r,o,i,s,l,a){super(e,t,r,o,i,s,l),this.spec=a}update(e,t,r,o,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function If(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=Zp(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof fn){let a=r?r.previousSibling:n.lastChild;If(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Zp(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}var _r=function(n){n&&(this.nodeName=n)};_r.prototype=Object.create(null);var pn=[new _r];function Br(n,e,t){if(n.length==0)return pn;let r=t?pn[0]:new _r,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new _r(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new _r(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Wl(n,e,t,r){if(t==pn&&r==pn)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=pn[0]),o=a}ck(o,l||pn[0],s)}return o}function ck(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Hf(n,e,t){return Wl(n,n,pn,Br(e,t,!W(n)))}function Jo(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Zp(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Pl=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=uk(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof fn&&!(u.damage&4)&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=fn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i,s){let l=this.top.children[o];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,t,r,i,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ut){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,p=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&!(a.damage&4)&&Jo(t,a.outerDeco));if(!p&&a.update(e,t,r,o,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(d=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.damage|=2,d.updateChildren(o,s+1),d.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Jo(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=Ut.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=Ut.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Wo(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof fn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Hr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Re||Pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Ko(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||W(e)&&e.contains(this.lock.parentNode))}};function uk(n,e){let t=e,r=t.children.length,o=[],i=n.childCount,s=new Map,l=[];e:for(;i>0;){let a;for(;;)if(r){let u=t.children[r-1];if(u instanceof fn)o.push(r-1),t=u,r=u.children.length;else{a=u,r--;break}}else{if(t==e)break e;r=o.pop(),t=t.parent}let c=a.node;if(c){if(c!=n.child(i-1))break;--i,s.set(a,i),l.push(a)}}return{index:i,matched:s,matches:l.reverse()}}function dk(n,e){return n.type.side-e.type.side}function pk(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(dk);for(let g=0;g<d.length;g++)t(d[g],c,!!a)}else t(u,c,!!a);let p,f;if(a)f=-1,p=a,a=null;else if(c<n.childCount)f=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+p.nodeSize;if(p.isText){let g=h;s<o.length&&o[s].from<g&&(g=o[s].from);for(let k=0;k<l.length;k++)l[k].to<g&&(g=l[k].to);g<h&&(a=p.cut(g-i),p=p.cut(0,g-i),h=g,f=-1)}else for(;s<o.length&&o[s].to<h;)s++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();r(p,m,e.forChild(i,p),f),i=h}}function fk(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function hk(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Rl(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Dl(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&U.findFrom(i,e)}function jt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Qp(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return jt(n,new F(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Dl(n.state,e);return o&&o instanceof R?jt(n,o):!1}else if(!We||t.indexOf("m")<0){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?R.isSelectable(i)?jt(n,new R(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):jt(n,new F(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof R&&r.node.isInline)return jt(n,new F(e>0?r.$to:r.$from));{let o=Dl(n.state,e);return o?jt(n,o):!1}}}function Ir(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):W(n)&&n.contentEditable=="false"}function Wn(n,e){return e<0?mk(n):gk(n)}function mk(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Ye&&W(t)&&r<Me(t)&&Ir(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!W(t))break;let l=t.childNodes[r-1];if(Ir(l,-1))o=t,i=--r;else if(ke(l))t=l,r=t.nodeValue.length;else break}else{if(Bf(t))break;{let l=t.previousSibling;for(;l&&Ir(l,-1);)o=t.parentNode,i=Le(l),l=l.previousSibling;if(l)t=l,r=Me(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?_l(n,t,r):o&&_l(n,o,i)}function gk(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Me(t),i,s;for(;;)if(r<o){if(!W(t))break;let l=t.childNodes[r];if(Ir(l,1))i=t,s=++r;else break}else{if(Bf(t))break;{let l=t.nextSibling;for(;l&&Ir(l,1);)i=l.parentNode,s=Le(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Me(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&_l(n,i,s)}function Bf(n){for(let e=n;e;e=e.parentNode){let t=e.pmViewDesc;if(t)return t.node?t.node.isBlock:!1}return!1}function _l(n,e,t){if(!ke(e)){let s,l;(l=Ef(e,t))?(e=l,t=0):(s=Mf(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),o=n.domSel.readRange();if(!r)return;Qo(o)?r.collapse(e,t):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,t)),n.domSel.ignore();let{state:i}=n;setTimeout(()=>{n.state==i&&n.domSel.sync()},50)}function ef(n,e){let t=n.state.doc.resolve(e);if(!(Pe||Tf)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let r=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){r=n.nodeDOM(t.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function tf(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||We&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Dl(n.state,e);if(s&&s instanceof R)return jt(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof de?U.near(s,e):U.findFrom(s,e);return l?jt(n,l):!1}return!1}function nf(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function rf(n,e,t){n.domObserver.stopped(()=>e.contentEditable=t)}function yk(n){if(!Re||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSel.readRange();if(e&&W(e)&&t==0&&e.firstChild&&W(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;rf(n,r,"true"),setTimeout(()=>rf(n,r,"false"),20)}return!1}function bk(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function kk(n,e){let t=e.keyCode,r=bk(e);if(t==8||We&&t==72&&r=="c")return nf(n,-1)||Wn(n,-1);if(t==46&&!e.shiftKey||We&&t==68&&r=="c")return nf(n,1)||Wn(n,1);if(t==13||t==27)return!0;if(t==37||We&&t==66&&r=="c"){let o=t==37?ef(n,n.state.selection.from)=="ltr"?-1:1:-1;return Qp(n,o,r)||Wn(n,o)}else if(t==39||We&&t==70&&r=="c"){let o=t==39?ef(n,n.state.selection.from)=="ltr"?1:-1:1;return Qp(n,o,r)||Wn(n,o)}else{if(t==38||We&&t==80&&r=="c")return tf(n,-1,r)||Wn(n,-1);if(t==40||We&&t==78&&r=="c")return yk(n)||tf(n,1,r)||Wn(n,1);if(r==(We?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Kl(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=n.someProp("clipboardSerializer")||qe.fromSchema(n.state.schema),l=qf(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&W(c)&&(u=Vf[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let h=l.createElement(u[f]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),d++}c=a.firstChild}c&&W(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
7
8
 
8
- `);return{dom:a,text:p,slice:e}}function cs(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,i||r,n)}),i)return l=new D(A.from(n.state.schema.text(e.replace(/\r\n?/g,`
9
- `))),0,0),n.someProp("transformPasted",p=>{l=p(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",p=>p(e,o,r,n));if(d)l=d;else{let p=o.marks(),{schema:f}=n.state,h=Le.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(h.serializeNode(f.text(g,p)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),s=rm(t),Zr&&om(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let p=s.firstChild;for(;p&&!H(p);)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Qe.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!em.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=im(Jc(l,+u[1],+u[2]),u[4]);else if(l=D.maxOpen(tm(l.content,o),!0),l.openStart||l.openEnd){let d=0,p=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;p<l.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);l=Jc(l,d,p)}return n.someProp("transformPasted",d=>{l=d(l,n,r)}),l}var em=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function tm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Nu(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Ou(s[s.length-1],i.length));let u=Tu(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return A.from(s)}return n}function Tu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,A.from(n));return n}function Nu(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=Nu(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(A.from(Tu(t,n,o+1))))}}function Ou(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ou(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(A.empty,!0);return n.copy(t.append(r))}function Xi(n,e,t,r,o,i){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(i=0),o<r-1&&(l=Xi(l,e,t,r,o+1,i)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(A.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Jc(n,e,t){return e<n.openStart&&(n=new D(Xi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new D(Xi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Du={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Lu(){return document.implementation.createHTMLDocument("title")}var jn=null;function nm(n){let e=window.trustedTypes;if(!e)return n;if(!jn){if(jn=e.defaultPolicy)try{return jn.createHTML(n)}catch{}jn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return jn.createHTML(n)}function rm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Lu(),r=t.body,o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&Du[o[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=nm(n),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function om(n){let e=n.querySelectorAll(Se?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function im(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs()||!a.createAndFill(null,o))break;try{o=A.from(a.create(r[l+1],o))}catch{break}i++,s++}return new D(o,i,s)}var Ne=class n{constructor(e,t,r,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=o}static from(e){return e instanceof n?e:new n(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};Ne.null=new Ne(null,0,null,0);var Qi=class{constructor(e){this.view=e,this.range=Ne.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=Ne.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?we&&e.root.nodeType===11&&Ch(e.dom.ownerDocument)==e.dom?Ne.from(sm(e,t)||t):Ne.from(t):Ne.null}read(){this.ensureListener();let e=Iu(this.view);if(!e){this.active=!1,this.range=Ne.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{dm(t,t.state.selection);let r=t.state.selection;if(t.input.mouseDown||Ru(t)){let{desc:o,start:i}=Pu(t.docView,r.from,r.to,0);t.cursorWrapper?um(t):o instanceof Kr&&o.spec.setSelection?o.spec.setSelection(r.anchor-i,r.head-i,t.root):lm(t,e,o,i),this.synced=this.active=!0}r.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),cm(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=Ne.from(e),this.synced=!0}deactivate(){this.range=Ne.null,this.active=this.synced=!1}};function sm(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Gc(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Gc(n,t):null}function Gc(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return Vr(s.node,s.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),new Ne(t,r,o,i)}function us(n,e,t=null){let r=n.state.doc;if(!e.focusNode)return null;let o=n.docView.nearestDesc(e.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Qr(e)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&P.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&wh(e.focusNode,e.focusOffset,o.dom))){let d=o.posBefore;c=new P(s==d?l:r.resolve(d))}else if(Ie&&t=="key"&&s>n.state.selection.to&&H(e.focusNode)&&e.focusOffset==e.focusNode.childNodes.length&&o&&o.posAtStart>n.state.selection.to)for(let d=e.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=F.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!H(d.parentNode))break}}else{if(e instanceof n.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let d=s,p=s;for(let f=0;f<e.rangeCount;f++){let h=e.getRangeAt(f);d=Math.min(d,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(d<0)return null;[a,s]=p==n.state.selection.anchor?[p,d]:[d,p],l=r.resolve(s)}else a=n.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=t=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=pn(n,u,l,d)}return c}function Ru(n){return n.editable?n.hasFocus():Hu(n,n.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(n.dom))}function lm(n,e,t,r){let o=n.state.selection,{anchor:i,head:s}=o,l,a;Yc&&!(o instanceof I)&&(o.$from.parent.inlineContent||(l=Xc(n,o.from)),!o.empty&&!o.$from.parent.inlineContent&&(a=Xc(n,o.to)));let c=t.domFromPos(i-r,i>r?-1:1),u=s==i?c:t.domFromPos(s-r,s>r?-1:1);am(i,s,c,u,n,e),Yc&&(l&&Qc(l),a&&Qc(a))}function Pu(n,e,t,r=0){for(let o=0,i=r;o<n.children.length;o++){let s=n.children[o],l=i+s.size;if(e>i&&t<l)return Pu(s,e,t,i+s.border);i=l}return{desc:n,start:r}}function am(n,e,t,r,o,i){let s=!1;if((Ie||we)&&n==e){let{node:a,offset:c}=t;if(de(a)){if(s=!!(c&&a.nodeValue[c-1]==`
10
- `),s&&c==a.nodeValue.length)for(let u=a,d;u;u=u.parentNode){if(d=u.nextSibling){d.nodeName=="BR"&&(t=r={node:d.parentNode,offset:xe(d)+1});break}let p=u.pmViewDesc;if(p&&p.node&&p.node.isBlock)break}}else{let u=a.childNodes[c-1];s=u&&(u.nodeName=="BR"||u.contentEditable=="false")}}let l=o.domSel.readRange();if(Ie&&l.focusNode&&l.focusNode!=r.node&&H(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(i=!0)}!(i||s&&we)&&Vr(t.node,t.offset,l.anchorNode,l.anchorOffset)&&Vr(r.node,r.offset,l.focusNode,l.focusOffset)||mu(o.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:t.node,anchorOffset:t.offset})}var Yc=we||Se&&gu<63;function Xc(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(we&&o&&o.contentEditable=="false")return _i(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return _i(o);if(i)return _i(i)}}function _i(n){return n.contentEditable="true",we&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Qc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function cm(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSel.readRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ru(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function um(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom;t.nodeName=="IMG"?e.collapse(t.parentNode,xe(t)+1):e.collapse(t,0)}function dm(n,e){if(e instanceof P){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Zc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Zc(n)}function Zc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function pn(n,e,t,r){let o=n.someProp("createSelectionBetween",i=>i(n,e,t))||I.between(e,t,r);return n.someProp("adjustSelectionFromDOM",i=>{o=i(n,o)}),o}function Iu(n){if(n.editable&&!n.hasFocus())return null;let e=n.domSel.readRange();return e&&Hu(n,e)?e:null}function Hu(n,e){if(!e.anchorNode)return!1;try{return cn(n.dom,e.anchorNode)&&(n.editable||cn(n.dom,e.focusNode))}catch{return!1}}var Ee={},Ce={},pm={touchstart:!0,touchmove:!0},Zi=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function fm(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{mm(n,r)&&(n.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&zu(n,!0),!ds(n,r)&&(n.editable||!(r.type in Ce))&&t(n,r))},pm[e]?{passive:!0}:void 0)}we&&n.dom.addEventListener("input",()=>null),es(n)}function eo(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function hm(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function es(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ds(n,r))})}function ds(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function mm(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function gm(n,e){!ds(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Ce))&&Ee[e.type](n,e)}function Mt(n,e){let{input:t}=n;return t.lastKeyDispatched||n.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=Eh(e=="Backspace"?8:13,e)),n.someProp("handleKeyDown",r=>r(n,e)))}Ce.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),n.input.lastKeyDispatched=!1,!(ot&&Se&&t.keyCode==13)){if(dn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(Mt(n,"Enter"),n.input.lastIOSEnter=0)},200);return}t.keyCode!=229&&n.domObserver.forceFlush(!0),Mt(n,t)||Zh(n,t)?t.preventDefault():eo(n,"key")}};Ce.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ce.keypress=(n,e)=>{let t=e;if(wm(n)||!t.charCode||t.ctrlKey&&!t.altKey||Re&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};function Yn(n){return{left:n.clientX,top:n.clientY}}function bm(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ps(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function Bu(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function ym(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&P.isSelectable(r)?(Bu(n,new P(t)),!0):!1}function vm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof P&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(P.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(Bu(n,P.create(n.state.doc,o)),!0):!1}function km(n,e,t,r,o){return ps(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?vm(n,t):ym(n,t))}function Mm(n,e,t,r){return ps(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function xm(n,e,t,r){return ps(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))}function eu(n,e,t){if(e==-1)return n.inlineContent?I.create(n,0,n.content.size):null;let r=n.resolve(e);for(let o=r.depth+1;o>0;o--){let i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)return I.create(n,s+1,s+1+i.content.size);if(t&&P.isSelectable(i))return P.create(n,s)}return null}var ts=/[\w_\u00a1-\uffff]+/g;try{ts=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function tu(n,e){let t=n.resolve(e),r=t.node(),o="",i=e,s=e;for(let g=t.indexAfter(),m=!1;g>0;g--){let b=r.child(g-1);if(!b.text)break;let k=i==e?e-t.posAtIndex(g-1):b.text.length,y=k;for(;y>0;y--)if(/\S/.test(b.text[y-1]))m=!0;else if(m)break;if(o=b.text.slice(y,k)+o,i-=k-y,y||i<e-50)break}for(let g=t.index(),m=!1;g<r.childCount;g++){let b=r.child(g);if(!b.text)break;let k=s==e?e-t.posAtIndex(g):0,y=k;for(;y<b.text.length;y++)if(/\S/.test(b.text[y]))m=!0;else if(m)break;if(o+=b.text.slice(k,y),s+=y-k,y<b.text.length||s>e+50)break}let l=i,a=s;if(Intl.Segmenter){for(let g of new Intl.Segmenter(void 0,{granularity:"word"}).segment(o))if(g.isWordLike){let m=g.index+i,b=m+g.segment.length;if(b<e)l=b;else if(m>e){a=m;break}else return I.create(n,m,b)}}else{ts.lastIndex=0;for(let g;g=ts.exec(o);){let m=g.index+i,b=m+g[0].length;if(b<e)l=b;else if(m>e){a=m;break}else return I.create(n,m,b)}}let c=o.slice(l-i,e-i),u=o.slice(e-i,a-i),d=/\S*$/.exec(c)[0].length,p=/^\S*/.exec(u)[0].length;if(d||p)return I.create(n,e-d,e+p);let f=/\s*$/.exec(c)[0].length,h=/^\s*/.exec(u)[0].length;return I.create(n,e-f,e+h)}var Fu=Re?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e,r=Date.now();if(n.input.shiftKey=t.shiftKey,n.input.lastTouch>r-500)return!1;wt(n);let o="singleClick";r-n.input.lastClick.time<500&&bm(t,n.input.lastClick)&&!t[Fu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let i=n.posAtCoords(Yn(t));if(i)if(t.button==0){if(!n.hasFocus()){ku(n.dom);let l=n.root.activeElement;l&&!l.contains(n.dom)&&l.blur()}(n.input.mouseDown=new ns(n,i,t,o)).mightDrag||t.preventDefault()}else eo(n,"pointer")};var ns=class{constructor(e,t,r,o){var i;this.view=e,this.startPos=t,this.event=r,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[Fu],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let s=nu(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof P?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof P?e.nodeDOM(l.from).getBoundingClientRect():e.coordsAtPos(l.anchor);this.anchorOffset={x:(a.left+a.right)/2-s.x,y:(a.top+a.bottom)/2-s.y}}else this.anchorOffset={x:r.clientX-s.x,y:r.clientY-s.y};if(o=="singleClick"){let{selection:l}=e.state,a,c,u=!1;if(l instanceof P&&l.from<=t.pos&&l.to>=t.pos)c=l.from,a=l.node,u=!0;else if(t.inside>-1)a=e.state.doc.nodeAt(t.inside),c=t.inside;else{let d=e.state.doc.resolve(t.pos);a=d.parent,c=d.depth?d.before():-1}if(u||c>-1&&a.type.spec.draggable&&a.type.spec.selectable!==!1){let d=(i=e.docView.descAt(c))===null||i===void 0?void 0:i.nodeDOM;this.mightDrag={node:a,elt:d,pos:c,addAttr:!1},d&&!d.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>d.draggable=!0))}else this.mightDrag=Sm(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,t){return(this.type=="singleClick"?km:this.type=="doubleClick"?Mm:xm)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Yn(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(Yn(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:o}=r.state,i=this.type=="singleClick"?ru(r,o,e):this.type=="doubleClick"?tu(o,e.pos):eu(o,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=pn(r,o.resolve(this.anchorRange.from),o.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=pn(r,o.resolve(this.anchorRange.to),o.resolve(i.from)))),i.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()))}restoreAnchor(){let e=nu(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?ru(this.view,r,t):this.type=="doubleClick"?tu(r,t.pos):eu(r,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function nu(n){let e=n.dom.getBoundingClientRect();return{x:e.left-n.dom.scrollLeft,y:e.top-n.dom.scrollTop}}function ru(n,e,t){if(t.inside>-1){let o=e.nodeAt(t.inside);if(o.isAtom&&P.isSelectable(o))return P.create(e,t.inside)}let r=e.resolve(t.pos);return pn(n,r,r)}function Sm(n,e){let{selection:t}=n.state;if(t.empty)return!1;let r=n.domSelection();if(!r||r.rangeCount==0)return!0;let o=r.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}Ee.touchstart=n=>{n.input.lastTouch=Date.now(),wt(n),eo(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),eo(n,"pointer")};Ee.contextmenu=n=>wt(n);function wm(n,e){return n.composing?!0:we&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Em=ot?5e3:-1;Ce.compositionstart=Ce.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof I&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Se&&bu&&Cm(n)))n.markCursor=n.state.storedMarks||t.marks(),wt(n,!0),n.markCursor=null;else if(wt(n,!e.selection.empty),Ie&&n.domSel.active&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:o}=n.domSel.range;r&&H(r)&&o!=0;){let i=o<0?r.lastChild:r.childNodes[o-1];if(!i)break;if(de(i)){let s=n.domSelection();s&&s.collapse(i,i.nodeValue.length);break}else r=i,o=-1}n.input.composing=!0}_u(n,Em)};function Cm(n){let{focusNode:e,focusOffset:t}=n.domSel.range;if(!e||!H(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return H(r)&&r.contentEditable=="false"}Ce.compositionend=(n,e)=>{n.composing&&zu(n)};function zu(n,e=!1){n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,e?wt(n):_u(n,20)}function _u(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>wt(n),e))}function $u(n){n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());for(let e;e=n.input.compositionNodes.pop();)e.markParentDamage()}function Am(n){let e=n.domSel.range;if(!n.domSel.active||!e.focusNode)return null;let t=fu(e.focusNode,e.focusOffset),r=hu(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function wt(n,e=!1){if(!(ot&&n.domObserver.flushingSoon>=0)&&(n.domObserver.forceFlush(),$u(n),e||n.docView&&n.docView.damage)){let t=us(n,n.domSel.readRange()),r=n.state.selection;t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state)}}function Tm(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Xn=dn&&Th<604;Ee.copy=Ce.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=Xn?null:t.clipboardData,s=r.content(),{dom:l,text:a}=as(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Tm(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Nm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Om(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Qn(n,r.value,null,o,e):Qn(n,r.textContent,r.innerHTML,o,e)},50)}function Qn(n,e,t,r,o){let i=cs(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||D.empty)))return!0;if(!i)return!1;let s=Nm(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Vu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Ce.paste=(n,e)=>{let t=e;if(n.composing&&!ot)return;let r=Xn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Qn(n,Vu(r),r.getData("text/html"),o,t)?t.preventDefault():Om(n,t)};var Jr=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Dm=Re?"altKey":"ctrlKey";function qu(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Dm]}Ee.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Yn(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof P?o.to-1:o.to))){if(r&&typeof r.mightDrag=="object")s=P.create(n.state.doc,r.mightDrag.pos);else if(t.target&&H(t.target)){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=P.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=as(n,l);(!t.dataTransfer.files.length||!Se||gu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Xn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Xn||t.dataTransfer.setData("text/plain",c),n.dragging=new Jr(u,qu(n,t),s)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ce.dragover=Ce.dragenter=(n,e)=>e.preventDefault();Ce.drop=(n,e)=>{try{Lm(n,e,n.dragging)}finally{n.dragging=null}};function Lm(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Yn(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",f=>{i=f(i,n,!1)}):i=cs(n,Vu(e.dataTransfer),Xn?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(t&&qu(n,e));if(n.someProp("handleDrop",f=>f(n,e,i||D.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?zn(n.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=n.state.tr;if(s){let{node:f}=t;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let p=a.doc.resolve(c);if(u&&P.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new P(p));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,g,m,b)=>f=b),a.setSelection(pn(n,p,a.doc.resolve(f)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ee.focus=n=>{if(n.input.lastFocus=Date.now(),!n.focused&&(n.domObserver.stopped(()=>n.dom.classList.add("ProseMirror-focused")),n.focused=!0,n.domSel.read(),!n.domSel.synced)){let e=n.domSel.range;setTimeout(()=>{let t=n.domSel.readRange();t&&e.eq(t)&&n.domSel.sync()},20)}};Ee.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stopped(()=>n.dom.classList.remove("ProseMirror-focused")),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domSel.deactivate(),n.focused=!1)};Ee.beforeinput=(n,e)=>{if(ot&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||n.domObserver.pendingRecords().length||(n.dom.blur(),n.focus(),Mt(n,"Backspace")))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Ce)Ee[n]=Ce[n];function Zn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var er=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},Gr=class n{constructor(e,t){this.toDOM=e,this.spec=t||Vt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new ae(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Zn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},$t=class n{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ae(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},rs=class n{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new ae(i.pos-r,s.pos-r,this)}valid(e,t,r){let o=r.nodeAt(t.from);return!!o&&!o.isText&&t.from+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}destroy(){}},ae=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Gr(t,r))}static inline(e,t,r,o){return new n(e,t,new $t(r,o))}static node(e,t,r,o){return new n(e,t,new rs(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof $t}get widget(){return this.type instanceof Gr}},ln=[],Vt={},G=class n{constructor(e,t){this.local=e.length?e:ln,this.children=t.length?t:ln}static create(e,t){return t.length?Xr(t,e,0,Vt):ye}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from>t)break;l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length&&!(this.children[s]>=t);s+=3)if(this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==ye||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Vt)}mapInner(e,t,r,o,i){let s;if(this.local.length){let l=new er(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?Rm(this.children,s||[],e,t,r,o,i):s?new n(s.sort(xt),ln):ye}add(e,t){return t.length?this==ye?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=ju(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,Xr(u,l,c+1,Vt)),i+=3}});let s=Wu(i?Ku(t):t,-r).sort(xt);if(s.length){let l=new er(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(xt):this.local,o||this.children)}remove(e){return e.length==0||this==ye?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=ye?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):ye}forChild(e,t){if(this==ye)return this;if(t.isLeaf)return n.empty;let r,o,i=0,s=this.children.length/3;for(;i<s;){let c=i+s>>>1,u=c*3,d=this.children[u];if(d<e)i=c+1;else if(d>e)s=c;else{r=this.children[u+2];break}}let l=e+1,a=l+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>l&&u.type instanceof $t){let d=Math.max(l,u.from)-l,p=Math.min(a,u.to)-l;d<p&&(o||(o=[])).push(u.copy(d,p))}}if(o){let c=new n(o.sort(xt),ln);return r?new Yr([c,r]):c}return r||ye}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return fs(this.localsInner(e))}localsInner(e){if(this==ye)return ln;if(e.inlineContent||!this.local.some($t.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $t||t.push(this.local[r]);return t}forEachSet(e){e(this)}};G.empty=new G([],[]);G.removeOverlap=fs;var ye=G.empty,Yr=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(o=>o.map(e,t,Vt));return n.from(r)}forChild(e,t){if(t.isLeaf)return G.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=ye&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?fs(r?t:t.sort(xt)):ln}static from(e){switch(e.length){case 0:return ye;case 1:return e[0];default:return new n(e.every(t=>t instanceof G)?e:e.reduce((t,r)=>t.concat(r instanceof G?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Rm(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((p,f,h,g)=>{let m=g-h-(f-p);for(let b=0;b<l.length;b+=3){let k=l[b+1];if(k<0||p>k+u-d)continue;let y=l[b]+u-d;f>=y?l[b+1]=p<=y?-2:-1:p>=u&&m&&(l[b]+=m,l[b+1]+=m)}d+=m}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let p=t.map(n[c+1]+i,-1),f=p-o,{index:h,offset:g}=r.content.findIndex(d),m=r.maybeChild(h);if(m&&g==d&&g+m.nodeSize==f){let b=l[c+2].mapInner(t,m,u+1,n[c]+i+1,s);b!=ye?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Pm(l,n,e,t,o,i,s),u=Xr(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<u.children.length;d+=3){let f=u.children[d];for(;p<l.length&&l[p]<f;)p+=3;l.splice(p,0,u.children[d],u.children[d+1],u.children[d+2])}}return new G(e.sort(xt),l)}function Wu(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new ae(o.from+e,o.to+e,o.type))}return t}function Pm(n,e,t,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function ju(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function Ku(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Xr(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=ju(n,l,a+t);if(c){i=!0;let u=Xr(c,l,t+a+1,r);u!=ye&&o.push(a,a+l.nodeSize,u)}});let s=Wu(i?Ku(n):n,-t).sort(xt);if(s.length){let l=new er(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||o.length?new G(s,o):ye}function xt(n,e){return n.from-e.from||n.to-e.to}function fs(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),ou(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),ou(e,o,r.copy(i.from,r.to)));break}}}return e}function ou(n,e,t){for(;e<n.length&&xt(t,n[e])>0;)e++;n.splice(e,0,t)}function $i(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ye&&e.push(r)}),n.cursorWrapper&&e.push(G.create(n.state.doc,[n.cursorWrapper.deco])),Yr.from(e)}function Im(n,e,t,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSel.range,u,d=c.anchorNode;if(d&&cn(n.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],Qr(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Se&&n.input.lastKeyCode===8)for(let b=s;b>i;b--){let k=o.childNodes[b-1],y=k.pmViewDesc;if(k.nodeName=="BR"&&!y){s=b;break}if(!y||y.size)break}let p=n.state.doc,f=n.someProp("domParser")||Qe.fromSchema(n.state.schema),h=p.resolve(l),g=null,m=f.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Hm(r),context:h});if(u&&u[0].pos!=null){let b=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=b),g={anchor:b+l,head:k+l}}return{doc:m,sel:g,from:l,to:a}}var Hm=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(we&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||we&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Bm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Fm(n,e,t,r,o,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,v=us(n,n.domSel.range,O);if(v&&!n.state.selection.eq(v)&&n.domSel.active){if(Se&&ot&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&Mt(n,"Enter"))return;let x=n.state.tr.setSelection(v);O=="pointer"?x.setMeta("pointer",!0):O=="key"&&x.scrollIntoView(),s&&x.setMeta("composition",s),n.dispatch(x)}return}let l=n.state.doc.resolve(e),a=l.sharedDepth(t);e=l.before(a+1),t=n.state.doc.resolve(t).after(a+1);let c=n.state.selection,u=Im(n,e,t,i),d=n.state.doc,p=d.slice(u.from,u.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let g=Vm(p.content,u.doc.content,u.from,f,h);if(g&&n.input.domChangeCount++,(dn&&n.input.lastIOSEnter>Date.now()-225||ot)&&i.some(O=>H(O)&&!Bm.test(O.nodeName))&&(!g||g.endA>=g.endB)&&Mt(n,"Enter")){n.input.lastIOSEnter=0;return}if(!g)if(o&&c instanceof I&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))g={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let O=iu(n,n.state.doc,u.sel);if(O&&!O.eq(n.state.selection)){let v=n.state.tr.setSelection(O);s&&v.setMeta("composition",s),n.dispatch(v)}}return}n.state.selection.from<n.state.selection.to&&g.start==g.endB&&n.state.selection instanceof I&&(g.start>n.state.selection.from&&g.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?g.start=n.state.selection.from:g.endA<n.state.selection.to&&g.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(g.endB+=n.state.selection.to-g.endA,g.endA=n.state.selection.to));let m=u.doc.resolveNoCache(g.start-u.from),b=u.doc.resolveNoCache(g.endB-u.from),k=d.resolve(g.start),y=m.sameParent(b)&&m.parent.inlineContent&&k.end()>=g.endA;if((dn&&n.input.lastIOSEnter>Date.now()-225&&(!y||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!y&&$m(u.doc,m.pos,b.pos))&&Mt(n,"Enter")){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>g.start&&(y?g.endA>g.start&&g.endB==g.start:_m(d,g.start,g.endA,m,b))&&Mt(n,"Backspace")){ot&&Se&&n.domSel.suppressChanges();return}Se&&g.endB==g.start&&(n.input.lastChromeDelete=Date.now()),ot&&!y&&m.start()!=b.start()&&b.parentOffset==0&&m.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==g.endA&&(g.endB-=2,b=u.doc.resolveNoCache(g.endB-u.from),setTimeout(()=>Mt(n,"Enter"),20));let w=g.start,N=g.endA,L=O=>{let v=O||n.state.tr.replace(w,N,u.doc.slice(g.start-u.from,g.endB-u.from));if(u.sel){let x=iu(n,v.doc,u.sel);x&&!(Se&&n.composing&&x.empty&&(g.start!=g.endB||n.input.lastChromeDelete<Date.now()-100)&&(x.head==w||x.head==v.mapping.map(N)-1))&&v.setSelection(x)}return s&&v.setMeta("composition",s),v.scrollIntoView()},R;if(y)if(m.pos==b.pos){let O=L(n.state.tr.delete(w,N)),v=d.resolve(g.start).marksAcross(d.resolve(g.endA));v&&O.ensureMarks(v),n.dispatch(O)}else if(g.endA==g.endB&&(R=zm(m.parent.content.cut(m.parentOffset,b.parentOffset),k.parent.content.cut(k.parentOffset,g.endA-k.start())))){let O=L(n.state.tr);R.type=="add"?O.addMark(w,N,R.mark):O.removeMark(w,N,R.mark),n.dispatch(O)}else if(m.parent.child(m.index()).isText&&m.index()==b.index()-(b.textOffset?0:1)){let O=m.parent.textBetween(m.parentOffset,b.parentOffset),v=()=>L(n.state.tr.insertText(O,w,N));n.someProp("handleTextInput",x=>x(n,w,N,O,v))||n.dispatch(v())}else n.dispatch(L());else n.dispatch(L())}function iu(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:pn(n,e.resolve(t.anchor),e.resolve(t.head))}function zm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(A.from(c).eq(n))return{mark:l,type:s}}function _m(n,e,t,r,o){if(t-e<=o.pos-r.pos||Vi(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Vi(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Vi(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function $m(n,e,t){let r=0,o=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&o++}),o==0&&r==1}function Vi(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Vm(n,e,t,r,o){let i=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(o=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var qm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},is=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let r=0;r<t.length;r++)this.queue.push(t[r]);we&&e.composing&&t.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,qm),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=an(i))t.add(i);for(let i=e.anchorNode;i;i=an(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:de(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&t.domSel.read();let o=!t.domSel.suppress&&!t.domSel.synced&&!!Iu(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let u=0;u<r.length;u++){let d=this.registerMutation(r[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Se&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&r.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&H(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ie&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,p]=u;d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}else{let{focusNode:d}=t.domSel.range;for(let p of u){let f=p.parentNode;f&&f.nodeName=="LI"&&(!d||jm(t,d)!=f)&&p.remove()}}}let c=null;i<0&&o&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Qr(t.domSel.range)&&(c=us(t,t.domSel.range))&&c.eq(F.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||o)&&(i>-1&&Wm(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Km(t,a)),Fm(this.view,i,s,o,l,a),t.docView&&t.docView.damage?t.updateState(t.state):o&&t.domSel.sync())}registerMutation(e,t){var r;if(t.indexOf(e.target)>-1)return null;let o;for(let i=e.target;i&&!(o=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),de(p)&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return o.markDamage(4),{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,s=e.nextSibling,l=i&&i.parentNode==e.target?xe(i)+1:0,a=o.localPosFromDOM(e.target,l,-1),c=s&&s.parentNode==e.target?xe(s):e.target.childNodes.length,u=o.localPosFromDOM(e.target,c,1);return o.markDamage(!((r=o.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:a,to:u}}else return e.type=="attributes"?(o.markDamage(4),{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}):(this.lastChangedTextNode=e.target,o.markDamage(o instanceof Jn&&e.target==o.nodeDOM?8:4),{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},su=new WeakMap,lu=!1;function Wm(n){if(!su.has(n)&&(su.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,lu)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),lu=!0}}function jm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Km(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSel.range;for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!H(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}var Um=cs,Jm=wt,fn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Zi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(pu),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=uu(this),cu(this),this.nodeViews=du(this),this.docView=$c(this.state.doc,au(this),$i(this),this.dom,this),this.domObserver=new is(this),this.domSel=new Qi(this),this.domObserver.start(),this.domSel.read(),fm(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&es(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(pu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&($u(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=du(this);Ym(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&es(this),this.editable=uu(this),cu(this);let a=$i(this),c=au(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let p=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Dh(this);s&&this.domObserver.stopped(()=>{let f=d&&Se&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Gm(o.selection,e.selection);if(d){let h=Se?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=Am(this)),i||!this.docView.update(e.doc,c,a,this,-1)){let g=this.docView.outerDeco;this.docView.destroy(),this.docView=$c(e.doc,c,a,this.dom,this,g)}h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}this.domSel.sync(f)}),this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&Lh(p)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof P){let t=this.docView.domAfterPos(this.state.selection.from);H(t)&&Bc(this,t.getBoundingClientRect(),e)}else Bc(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Jr(e.slice,e.move,o<0?void 0:P.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&ku(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return t||document}updateRoot(){this._root=null}posAtCoords(e){return Bh(this,e)}coordsAtPos(e,t=1){return Su(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Vh(this,t||this.state,e)}pasteHTML(e,t){return Qn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Qn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return as(this,e)}destroy(){this.docView&&(hm(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$i(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Sh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return gm(this,e)}domSelection(){return this.root.getSelection()}};fn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function au(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ae.node(0,n.state.doc.content.size,e)]}function cu(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ae.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function uu(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Gm(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function du(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ym(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function pu(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var gs={};Z(gs,{keydownHandler:()=>ro,keymap:()=>Ke});var it={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},no={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Xm=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(te=0;te<10;te++)it[48+te]=it[96+te]=String(te);var te;for(te=1;te<=24;te++)it[te+111]="F"+te;var te;for(te=65;te<=90;te++)it[te]=String.fromCharCode(te+32),no[te]=String.fromCharCode(te);var te;for(to in it)no.hasOwnProperty(to)||(no[to]=it[to]);var to;function Uu(n){var e=Xm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Qm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?no:it)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var Zm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),eg=typeof navigator<"u"&&/Win/.test(navigator.platform);function tg(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Zm?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function ng(n){let e=Object.create(null);for(let t in n)e[tg(t)]=n[t];return e}function ms(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ke(n){return new z({props:{handleKeyDown:ro(n)}})}function ro(n){let e=ng(n);return function(t,r){let o=Uu(r),i,s=e[ms(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[ms(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(eg&&r.ctrlKey&&r.altKey)&&(i=it[r.keyCode])&&i!=o){let l=e[ms(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Ms={};Z(Ms,{COMMENT_ID_RE:()=>hn,COMMENT_MAX_LENGTH:()=>oo,COMMENT_NAME_MAX_LENGTH:()=>vs,createCommentStore:()=>ks,newCommentId:()=>io,sanitizeThread:()=>bs});var hn=/^[A-Za-z0-9_-]{1,64}$/,oo=5e3,vs=80;function io(n="c"){let e=new Uint8Array(9);return globalThis.crypto.getRandomValues(e),n+Array.from(e,t=>(t%36).toString(36)).join("")}function bs(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!hn.test(e.id))return null;let t=Array.isArray(e.comments)?e.comments.map(Ju).filter(o=>o!==null):[],r=e.resolved;return{id:e.id,createdAt:Number(e.createdAt)||0,comments:t,resolved:r&&typeof r=="object"?{by:ys(r.by),at:Number(r.at)||0}:null}}function ys(n){let e=n&&typeof n=="object"?n:{};return{id:String(e.id??"").slice(0,128),name:String(e.name??"").slice(0,80)}}function Ju(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!hn.test(e.id))return null;let t={id:e.id,author:ys(e.author),text:String(e.text??"").slice(0,5e3),createdAt:Number(e.createdAt)||0};if(e.editedAt&&(t.editedAt=Number(e.editedAt)||0),Array.isArray(e.mentions)){let r=e.mentions.slice(0,20).map(ys).filter(o=>/^[\w.@:+-]{1,128}$/.test(o.id)&&o.name);r.length&&(t.mentions=r)}return t}function ks(n=[],e){let t=n.map(bs).filter(s=>s!==null),r=new Set,o=s=>{t=s,e?.(t),r.forEach(l=>l())},i=(s,l)=>o(t.map(a=>a.id===s?l(a):a));return{threads:()=>t,subscribe(s){return r.add(s),()=>r.delete(s)},createThread(s){let l=bs(s);!l||t.some(a=>a.id===l.id)||o([...t,l])},reply(s,l){let a=Ju(l);a&&i(s,c=>({...c,comments:[...c.comments,a]}))},editComment(s,l,a){i(s,c=>({...c,comments:c.comments.map(u=>u.id===l?{...u,text:a.slice(0,5e3),editedAt:Date.now()}:u)}))},deleteComment(s,l){i(s,a=>({...a,comments:a.comments.filter(c=>c.id!==l)}))},setResolved(s,l){i(s,a=>({...a,resolved:l??null}))},deleteThread(s){o(t.filter(l=>l.id!==s))}}}var rg={en:{list:"People",empty:"No matches"}},xs=/^[\w.@:+-]{1,128}$/,og=80,so=n=>n.replace(/^@/,"").trim().slice(0,og);async function Ss(n,e,t=8){let r=await n(e);return Array.isArray(r)?r.filter(o=>o&&typeof o.id=="string"&&xs.test(o.id)&&o.name).slice(0,t).map(o=>({id:o.id,name:so(String(o.name)),...o.description?{description:String(o.description).slice(0,120)}:{}})):[]}var Gu={name:"mentions",nodes:{mention:{group:"inline",inline:!0,atom:!0,selectable:!1,attrs:{id:{},name:{default:""}},parseDOM:[{tag:"span[data-mention]",getAttrs:n=>{let e=n,t=e.getAttribute("data-mention")??"";return xs.test(t)?{id:t,name:so(e.textContent??"")}:!1}}],toDOM:n=>["span",{"data-mention":xs.test(n.attrs.id)?n.attrs.id:null},`@${so(String(n.attrs.name))}`],leafText:n=>`@${so(String(n.attrs.name))}`}},setup(n){let e=n.options.pluginOptions?.mentions;if(!e?.fetch){console.warn("[nova] mentions: set pluginOptions.mentions.fetch to search people");return}let t=le(n,"mentions",rg),r=e.maxResults??8,o=new Map;n.ui.registry.addAutocompleter("mentions",{trigger:"@",label:t.list,emptyText:t.empty,maxResults:r,fetch:async i=>{let s=await Ss(e.fetch,i,r);return o=new Map(s.map(l=>[l.id,l])),s.map(l=>({value:l.id,label:l.name,...l.description?{detail:l.description}:{}}))},onSelect:(i,s,l)=>{let a=o.get(i.value)??{id:i.value,name:i.label},{state:c,dispatch:u}=l.view,d=l.schema.nodes.mention.create({id:a.id,name:a.name});u(c.tr.replaceWith(s.from,s.to,[d,c.schema.text(" ")]).scrollIntoView()),e.onMention?.(a,l)}})}};var ig={en:{add:"Add comment",show:"Comments",panel:"Comments",guest:"Guest",newComment:"New comment",placeholder:"Add a comment\u2026",replyPlaceholder:"Reply\u2026",comment:"Comment",reply:"Reply",cancel:"Cancel",save:"Save",edit:"Edit",remove:"Delete",resolve:"Resolve",reopen:"Reopen",deleteThread:"Delete thread",close:"Close comments",showResolved:"Show resolved",resolvedBy:"Resolved by {name}",orphan:"The commented text was deleted",empty:"No comments yet. Select text and press \u201CAdd comment\u201D ({shortcut}).",people:"People",noPeople:"No matches",edited:"edited",you:"you",count:"{count} comments"}},Yu=S.commentAdd,Xu=S.comments,lo="Mod-Alt-m",st=new K("nova-comments"),Es=new WeakMap;function ws(n){return Es.get(n)}function Qu(n){let e=new Map;return n.descendants((t,r)=>{if(t.isInline)for(let o of t.marks){if(o.type.name!=="comment")continue;let i=o.attrs.id,s=e.get(i)??[],l=s[s.length-1];l&&l.to===r?l.to=r+t.nodeSize:s.push({from:r,to:r+t.nodeSize}),e.set(i,s)}}),e}function sg(n){let{$from:e,empty:t}=n.selection;return(t?[...e.nodeBefore?.marks??[],...e.nodeAfter?.marks??[]]:e.nodeAfter?.marks??[]).filter(o=>o.type.name==="comment").map(o=>o.attrs.id)}var Zu={name:"comments",toolbar:"addcomment showcomments",marks:{comment:{attrs:{id:{}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-comment]",getAttrs:n=>{let e=n.getAttribute("data-comment")??"";return hn.test(e)?{id:e}:!1}}],toDOM:n=>["span",{"data-comment":hn.test(n.attrs.id)?n.attrs.id:null},0]}},prosemirrorPlugins:n=>{let e=null;return[Ke({[lo]:()=>ws(n)?.startComment()??!1}),new z({key:st,state:{init:()=>({pending:null,active:null}),apply(t,r){let o=t.getMeta(st),i=r;if(t.docChanged&&i.pending){let s=t.mapping.map(i.pending.from,1),l=t.mapping.map(i.pending.to,-1);i={...i,pending:s<l?{from:s,to:l}:null}}return o&&("pending"in o||"active"in o)&&(i={...i,...o}),i}},props:{decorations(t){let r=ws(n),o=st.getState(t),i=r?.store.threads();if(e&&e.doc===t.doc&&e.threads===i&&e.state===o)return e.set;let s=new Set((i??[]).filter(c=>!c.resolved).map(c=>c.id)),l=[];for(let[c,u]of Qu(t.doc)){if(!s.has(c))continue;let d=c===o.active?"nova-comment is-active":"nova-comment";for(let{from:p,to:f}of u)l.push(ae.inline(p,f,{class:d}))}if(o.pending){let{from:c,to:u}=o.pending;l.push(ae.inline(c,u,{class:"nova-comment is-active is-pending"}))}let a=G.create(t.doc,l);return e={doc:t.doc,threads:i,state:o,set:a},a}},view:()=>({update(t,r){if(r.selection.eq(t.state.selection)||r.doc!==t.state.doc)return;let o=ws(n);if(!o||st.getState(t.state).pending)return;let i=new Set(o.store.threads().filter(l=>!l.resolved).map(l=>l.id)),s=sg(t.state).find(l=>i.has(l));s&&(s!==o.active()||!o.isPanelOpen())&&queueMicrotask(()=>{o.setActive(s),o.openPanel()})}})})]},setup(n){let e=le(n,"comments",ig),t=n.options.pluginOptions?.comments??{},r=t.store??ks(t.threads??[],t.onChange),o={id:String(t.author?.id??"guest").slice(0,128),name:String(t.author?.name||e.guest).slice(0,80)},i=()=>n.schema.marks.comment,s=t.mentions??n.options.pluginOptions?.mentions?.fetch,l=(y,w=[])=>[...new Map(w.map(L=>[L.id,L])).values()].filter(L=>y.includes(`@${L.name}`)),a=(y,w)=>{let N=l(y,w);return{id:io(),author:o,text:y,createdAt:Date.now(),...N.length?{mentions:N}:{}}},c=(y,w)=>{w.mentions?.length&&t.onMention?.({threadId:y,comment:w,users:w.mentions})},u=()=>st.getState(n.view.state),d=y=>n.view.dispatch(n.view.state.tr.setMeta(st,y)),p=null,f=!1;n.ui.registry.addSidebar("comments",{title:e.panel,button:!1,header:!1,render:async y=>{let{createCommentsPanel:w}=await import(__novaChunk("tinymce-chunks/comments-panel-37cba890.js") );return p=w(h),y.append(p.el),()=>p?.destroy()},onShow:()=>{f=!0,p&&(p.el.hidden=!1),n.root.classList.add("nova-comments-open"),p?.render()},onHide:()=>{f=!1,p&&(p.el.hidden=!0),n.root.classList.remove("nova-comments-open"),u().pending&&d({pending:null})}});let h={editor:n,store:r,author:o,labels:e,shortcut:lo,pending:()=>u().pending,active:()=>u().active,setActive(y,w=!1){u().active!==y&&d({active:y}),p?.render();let N=y?h.ranges(y)[0]:void 0;if(w&&N){let{node:L}=n.view.domAtPos(N.from);(L instanceof Element?L:L.parentElement)?.scrollIntoView({block:"nearest"})}},startComment(){let{selection:y}=n.view.state;return y.empty||!n.isEditable()?!1:(d({pending:{from:y.from,to:y.to},active:null}),h.openPanel().then(()=>{p?.render(),p?.focusComposer()}),!0)},cancelPending(){d({pending:null}),p?.render(),n.focus()},findUsers:s?y=>Ss(s,y):null,submitPending(y,w){let N=u().pending,L=y.trim().slice(0,5e3);if(!N||!L)return null;let R=io("t"),O=a(L,w);r.createThread({id:R,createdAt:O.createdAt,comments:[O],resolved:null});let{state:v}=n.view;return n.view.dispatch(v.tr.addMark(N.from,N.to,i().create({id:R})).setMeta(st,{pending:null,active:R}).setMeta("addToHistory",!1)),p?.render(),c(R,O),R},reply(y,w,N){let L=w.trim().slice(0,5e3);if(!L)return;let R=a(L,N);r.reply(y,R),c(y,R)},ranges:y=>Qu(n.view.state.doc).get(y)??[],quote(y){let{doc:w}=n.view.state;return h.ranges(y).map(({from:N,to:L})=>w.textBetween(N,L," ")).join(" \u2026 ")},positionOf:y=>h.ranges(y)[0]?.from??Number.MAX_SAFE_INTEGER,deleteThread(y){let{state:w}=n.view,N=w.tr;for(let{from:L,to:R}of h.ranges(y))N.removeMark(L,R,i().create({id:y}));u().active===y&&N.setMeta(st,{active:null}),(N.docChanged||N.getMeta(st))&&n.view.dispatch(N.setMeta("addToHistory",!1)),r.deleteThread(y)},setResolved(y,w){r.setResolved(y,w?{by:o,at:Date.now()}:null),w&&u().active===y&&d({active:null})},canEdit:y=>t.canEdit?t.canEdit(y,o):y.author.id===o.id,isPanelOpen:()=>f,openPanel:()=>n.ui.sidebar.show("comments"),closePanel(){f&&(n.ui.sidebar.hide({restoreFocus:!1}),n.focus())}};Es.set(n,h);let g=r.subscribe(()=>{n.view.isDestroyed||(d({refresh:!0}),p?.render())}),m=()=>h.startComment(),b=()=>h.isPanelOpen()?h.closePanel():void h.openPanel(),k=y=>y.isEditable()&&!y.view.state.selection.empty;return n.ui.registry.addButton("addcomment",{icon:Yu,tooltip:e.add,shortcut:lo,isEnabled:k,onAction:m}),n.ui.registry.addToggleButton("showcomments",{icon:Xu,tooltip:e.show,isActive:()=>f,onAction:b}),n.ui.registry.addMenuItem("addcomment",{text:e.add,icon:Yu,shortcut:lo,isEnabled:k,onAction:m}),n.ui.registry.addMenuItem("showcomments",{text:e.show,icon:Xu,isActive:()=>f,onAction:b}),()=>{g(),Es.delete(n)}}};var ed={en:{insert:"Insert variable",search:"Variables",empty:"No variables found",unknown:"Unknown variable"}},td=/^[\w.:-]{1,100}$/,lg=/^data-[a-z0-9-]{1,40}$/;function co(n){return n.options.pluginOptions?.mergetags??{}}function ag(n){let e=co(n).attribute??"data-mergetag";return lg.test(e)?e:(console.warn(`[nova] mergetags: attribute "${e}" must look like data-name; using data-mergetag`),"data-mergetag")}var rd=n=>Array.isArray(n.items);function ao(n){return(co(n).list??[]).flatMap(e=>rd(e)?e.items:[e])}function od(n,e){return ao(n).find(t=>t.key===e)?.label}function cg(n){let e=ag(n);return{mergetag:{group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,ignoreStyles:!0,attrs:{key:{},label:{default:""}},parseDOM:[{tag:`span[${e}]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute(e)??"";return td.test(o)?{key:o,label:od(n,o)??r.textContent?.trim()??o}:!1}}],toDOM:t=>{let r=td.test(t.attrs.key)?t.attrs.key:"",o=t.attrs.label==null||t.attrs.label===""?r:String(t.attrs.label);return["span",{[e]:r,contenteditable:"false"},o]}}}}var Cs=class{constructor(e,t,r){E(this,"node",e);E(this,"editor",t);E(this,"unknownTitle",r);E(this,"dom");this.dom=document.createElement("span"),this.dom.className="nova-mergetag",this.dom.contentEditable="false",this.render()}render(){let e=this.node.attrs.key,t=od(this.editor,e);this.dom.textContent=t??(this.node.attrs.label||e),this.dom.dataset.key=e;let o=!!co(this.editor).list?.length&&t===void 0;this.dom.classList.toggle("is-unknown",o),this.dom.title=o?`${this.unknownTitle}: ${e}`:e}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(){return!1}ignoreMutation(){return!0}};function nd(n,e,t){let{state:r,dispatch:o}=n.view,i=n.schema.nodes.mergetag.create({key:e.key,label:e.label}),s=t?r.tr.replaceWith(t.from,t.to,i):r.tr.replaceSelectionWith(i,!1);o(s.scrollIntoView()),n.focus()}var id={name:"mergetags",toolbar:"mergetags",nodes:cg,prosemirrorPlugins:n=>{let e=le(n,"mergetags",ed);return[new z({props:{nodeViews:{mergetag:(t,r)=>new Cs(t,n,e.unknown)}}})]},setup(n){let e=le(n,"mergetags",ed);n.ui.registry.addMenuButton("mergetags",{icon:S.mergeTags,tooltip:e.insert,isEnabled:t=>t.isEditable()&&ao(t).length>0,items:t=>{let r=[],o=(i,s)=>({id:s,label:i.label,onSelect:()=>nd(t,i)});return(co(t).list??[]).forEach((i,s)=>{rd(i)?(r.length&&r.push({type:"separator"}),r.push({type:"heading",label:i.title}),i.items.forEach((l,a)=>r.push(o(l,`mergetag-${s}-${a}`)))):r.push(o(i,`mergetag-${s}`))}),r}}),n.ui.registry.addAutocompleter("mergetags",{trigger:"{{",label:e.search,emptyText:e.empty,maxResults:12,fetch:(t,r)=>{let o=t.toLowerCase();return ao(r).filter(i=>i.label.toLowerCase().includes(o)||i.key.toLowerCase().includes(o)).map(i=>({value:i.key,label:i.label,detail:i.key}))},onSelect:(t,r,o)=>{let i=ao(o).find(s=>s.key===t.value);i&&nd(o,i,r)}})}};var sd=/^[A-Za-z0-9_-]{1,64}$/,Ds=/^[\w.@:+-]{1,128}$/,As={en:{toggle:"Suggest edits",review:"Review suggestions",accept:"Accept",reject:"Reject",acceptAll:"Accept all suggestions",rejectAll:"Reject all suggestions",next:"Next suggestion",previous:"Previous suggestion",inserted:"Inserted by {name}",deleted:"Deleted by {name}",toolbar:"Suggestion",guest:"Guest",none:"No suggestions"}},ld=S.suggest,ug=S.review,dg=S.check,pg=S.close,tr=new K("nova-suggestions"),Ls="nova-suggestions-own",ad=["#1a7f37","#8250df","#bf3989","#0969da","#bc4c00","#1b7c83"];function fg(n){let e=0;for(let t of String(n??""))e=e*31+t.charCodeAt(0)|0;return ad[Math.abs(e)%ad.length]}function cd(){let n=new Uint8Array(9);return globalThis.crypto.getRandomValues(n),"s"+Array.from(n,e=>(e%36).toString(36)).join("")}function ud(n){let e=n==="insert"?"ins":"del";return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0}},inclusive:!1,excludes:"",parseDOM:[{tag:`${e}[data-suggestion]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute("data-suggestion")??"";if(!sd.test(o))return!1;let i=r.getAttribute("data-author")??"";return{id:o,author:Ds.test(i)?i:"",name:(r.getAttribute("data-name")??"").slice(0,80),time:Number(r.getAttribute("data-time"))||0}}}],toDOM:t=>[e,{"data-suggestion":sd.test(t.attrs.id)?t.attrs.id:null,"data-author":Ds.test(t.attrs.author)?t.attrs.author:null,"data-name":String(t.attrs.name??"").slice(0,80)||null,"data-time":Number(t.attrs.time)||null},0]}}var Rs=n=>({insert:n.marks.suggestion_insert,delete:n.marks.suggestion_delete});function hg(n){return!n.docChanged||n.getMeta(Ls)||n.getMeta("addToHistory")===!1||n.getMeta("history$")||n.getMeta("y-sync$")?.isChangeOrigin?!1:n.steps.every(t=>t instanceof ue)}function Ts(n,e,t,r){let o=n.resolve(e);for(let i of[o.nodeBefore,o.nodeAfter]){let s=i?.marks.find(l=>l.type===t&&l.attrs.author===r);if(s)return s}return null}function pd(n,e,t){let r=[];return n.forEach(o=>{o.isInline?r.push(t&&!t.allowsMarkType(e.type)?o:o.mark(e.addToSet(o.marks))):r.push(o.copy(pd(o.content,e,o.type)))}),A.from(r)}function mg(n,e,t){if(!hg(n))return n;let r=Rs(e.schema),o=e.tr,i=Date.now(),s=c=>c,l=null,a=null;if(n.steps.forEach(c=>{let u=c,d=o.steps.length,p=s,f=p(u.from),h=Math.max(f,p(u.to));if(h>f){let b=[],k=[];if(o.doc.nodesBetween(f,h,(N,L)=>{if(!N.isInline)return!0;let R=Math.max(L,f),O=Math.min(L+N.nodeSize,h);return R>=O||(N.marks.some(x=>x.type===r.insert&&x.attrs.author===t.id)?b.push({from:R,to:O}):r.delete.isInSet(N.marks)||k.push({from:R,to:O})),!1}),k.length){let N=k[0],L=Ts(o.doc,N.from,r.delete,t.id)??Ts(o.doc,k[k.length-1].to,r.delete,t.id)??r.delete.create({id:cd(),author:t.id,name:t.name,time:i});for(let R of k)o.addMark(R.from,R.to,L)}for(let N of b.reverse())o.delete(N.from,N.to);let y=o.mapping.slice(d);f=y.map(f,1),h=y.map(h,-1);let w=e.selection;n.steps.length===1&&u.slice.size===0&&w.empty&&w.from===u.from&&n.selection.head===u.from&&(l=h)}if(u.slice.size>0){let b=h;if(!u.slice.openStart)for(let N=o.doc.resolve(b).nodeAfter;N&&r.delete.isInSet(N.marks);)b+=N.nodeSize,N=o.doc.resolve(b).nodeAfter;let k=Ts(o.doc,b,r.insert,t.id)??r.insert.create({id:cd(),author:t.id,name:t.name,time:i}),y=o.doc.resolve(b),w=pd(u.slice.content,k,u.slice.openStart?null:y.parent.type);o.replace(b,b,new D(w,u.slice.openStart,u.slice.openEnd)),n.steps.length===1&&(a=b+u.slice.size)}let g=u.getMap().invert(),m=o.mapping.slice(d);s=b=>m.map(p(g.map(b,-1)),1)}),l!==null)o.setSelection(I.create(o.doc,l));else if(a!==null&&n.selection.empty)o.setSelection(I.create(o.doc,a));else{let c=s(n.selection.anchor),u=s(n.selection.head);try{o.setSelection(I.create(o.doc,c,u))}catch{}}for(let c of["addToHistory","uiEvent","paste","scrollIntoView"]){let u=n.getMeta(c);u!==void 0&&o.setMeta(c,u)}return n.scrolledIntoView&&o.scrollIntoView(),o}function nr(n){let e=Rs(n.type.schema),t=[];return n.descendants((r,o)=>{if(!r.isInline)return!0;for(let i of r.marks){let s=i.type===e.insert?"insert":i.type===e.delete?"delete":null;if(!s)continue;let l=t[t.length-1],a=r.isText?r.text:"";l&&l.id===i.attrs.id&&l.kind===s&&l.to===o?(l.to=o+r.nodeSize,l.text+=a):t.push({id:i.attrs.id,kind:s,author:{id:i.attrs.author,name:i.attrs.name},time:Number(i.attrs.time)||0,from:o,to:o+r.nodeSize,text:a})}return!1}),t}function Ns(n,e,t){let r=Rs(n.schema),o=n.tr.setMeta(Ls,!0),i=nr(n.doc).filter(s=>!t||t.includes(s.id));for(let s of[...i].sort((l,a)=>a.from-l.from))s.kind==="insert"==(e==="reject")?o.delete(s.from,s.to):o.removeMark(s.from,s.to,s.kind==="insert"?r.insert:r.delete);return o}function dd(n){let{from:e}=n.selection;return nr(n.doc).find(t=>e>=t.from&&e<=t.to&&(t.to>e||t.from<e))??null}function mn(n){return tr.getState(n)?.enabled??!1}function Os(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.setMeta(tr,{enabled:e}).setMeta(Ls,!0)),n.updateUI()}var fd={name:"suggestions",toolbar:"suggestions reviewsuggestions",marks:{suggestion_insert:ud("insert"),suggestion_delete:ud("delete")},prosemirrorPlugins:n=>{let e=n.options.pluginOptions?.suggestions??{},t=null;return[new z({key:tr,state:{init:()=>({enabled:!!(e.enabled||e.force)}),apply(r,o){let i=r.getMeta(tr);return i?{enabled:e.force?!0:i.enabled}:o}},props:{attributes:r=>tr.getState(r)?.enabled?{class:"nova-suggesting"}:{},decorations(r){if(t?.doc===r.doc)return t.set;let o=le(n,"suggestions",As),i=new Intl.DateTimeFormat(n.options.language??"en",{dateStyle:"medium",timeStyle:"short"}),s=G.create(r.doc,nr(r.doc).map(l=>ae.inline(l.from,l.to,{title:(l.kind==="insert"?o.inserted:o.deleted).replace("{name}",l.author.name||o.guest)+(l.time?` \xB7 ${i.format(l.time)}`:""),class:l.kind==="insert"?"nova-sugg-insert":"nova-sugg-delete",style:`--nova-suggestion: ${fg(l.author.id||l.author.name)}`})));return t={doc:r.doc,set:s},s}}}),Ke({"Mod-Alt-Shift-e":()=>e.force?!1:(Os(n,!mn(n.view.state)),!0)})]},transformTransaction(n,e,t){if(!mn(e))return n;let r=t.options.pluginOptions?.suggestions??{},o=le(t,"suggestions",As),i={id:Ds.test(r.author?.id??"")?r.author.id:"guest",name:String(r.author?.name||o.guest).slice(0,80)};return mg(n,e,i)},setup(n){let e=n.options.pluginOptions?.suggestions??{},t=le(n,"suggestions",As),r=e.canReview!==!1,o=c=>n.view.dispatch(c),i=()=>dd(n.view.state),s=c=>{let u=i();u&&o(Ns(n.view.state,c,[u.id])),n.focus()},l=c=>{let{state:u}=n.view,d=nr(u.doc),p=u.selection.from,f=c===1?d.find(h=>h.from>p)??d[0]:[...d].reverse().find(h=>h.to<p)??d[d.length-1];if(!f){n.ui.notify(t.none);return}o(u.tr.setSelection(I.create(u.doc,f.from)).scrollIntoView()),n.focus()},a=()=>nr(n.view.state.doc).length>0;n.ui.registry.addToggleButton("suggestions",{icon:ld,tooltip:t.toggle,shortcut:"Mod-Alt-Shift-e",isActive:c=>mn(c.view.state),isEnabled:()=>!e.force,onAction:c=>Os(c,!mn(c.view.state))}),n.ui.registry.addMenuButton("reviewsuggestions",{icon:ug,tooltip:t.review,isEnabled:a,items:()=>[{id:"next",label:t.next,onSelect:()=>l(1)},{id:"previous",label:t.previous,onSelect:()=>l(-1)},...r?[{type:"separator"},{id:"accept-all",label:t.acceptAll,onSelect:()=>o(Ns(n.view.state,"accept"))},{id:"reject-all",label:t.rejectAll,onSelect:()=>o(Ns(n.view.state,"reject"))}]:[]]}),r&&(n.ui.registry.addButton("acceptsuggestion",{icon:dg,text:t.accept,tooltip:t.accept,onAction:()=>s("accept")}),n.ui.registry.addButton("rejectsuggestion",{icon:pg,text:t.reject,tooltip:t.reject,onAction:()=>s("reject")}),n.ui.registry.addContextToolbar("suggestion",{label:t.toolbar,predicate:c=>dd(c.view.state)!==null,items:"acceptsuggestion rejectsuggestion",position:"selection",placement:"bottom-start",priority:20})),n.ui.registry.addMenuItem("suggestions",{text:t.toggle,icon:ld,isActive:c=>mn(c.view.state),isEnabled:()=>!e.force,onAction:c=>Os(c,!mn(c.view.state))})}};function gn(n,e,t,r){let{filePicker:o,filePickerTypes:i}=n.options;if(!o||i&&!i.includes(t))return;let{input:s}=e,l=M("button",{type:"button",className:"nova-btn nova-input-action","aria-label":n.ui.t("dialog.browse"),title:n.ui.t("dialog.browse")},V(S.browse)),a=M("div",{className:"nova-input-group"});s.replaceWith(a),a.append(s,l),l.addEventListener("click",async()=>{l.disabled=!0;try{let c=await o({type:t,value:s.value});if(!c?.url)return;s.value=c.url,s.removeAttribute("aria-invalid"),r?.(c)}catch(c){console.error("[nova] filePicker failed:",c)}finally{l.disabled=!1,s.isConnected&&s.focus()}})}var qs={};Z(qs,{ALIGNMENTS:()=>ir,BULLET_STYLES:()=>Is,CELL_VALIGN:()=>Fs,IMAGE_ALIGN_STYLES:()=>Bs,INDENT_STEP:()=>$s,MAX_INDENT:()=>xd,ORDERED_STYLES:()=>Hs,classAttr:()=>He,createSchema:()=>po,cssValue:()=>q,imageSize:()=>ne,indentLevel:()=>bn,schema:()=>At,tableStyle:()=>Sd});function gg(n,e){if(typeof n=="string")return{};let t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length===o?r:null};for(let[s,l]of Object.entries(e)){let a=l.getFromDOM?.(n);a!=null&&(i[s]=a)}return i}function bg(n,e){let t={};n.attrs.colspan!==1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!==1&&(t.rowspan=n.attrs.rowspan),Array.isArray(n.attrs.colwidth)&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(let[r,o]of Object.entries(e))o.setDOMAttr?.(n.attrs[r],t);return t}function yg(n){if(n!==null&&(!Array.isArray(n)||n.some(e=>typeof e!="number")))throw new TypeError("colwidth must be null or an array of numbers")}function hd(n){let e=n.cellAttributes,t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:yg}};for(let[o,i]of Object.entries(e))t[o]={default:i.default};let r=(o,i)=>({content:n.cellContent,attrs:t,tableRole:i,isolating:!0,parseDOM:[{tag:o,getAttrs:s=>gg(s,e)}],toDOM:s=>[o,bg(s,e),0]});return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:r("td","cell"),table_header:r("th","header_cell")}}function Et(n){let{$head:e}=n.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="row")return!0;return!1}var Ps={};Z(Ps,{isSafeImageUrl:()=>ce,isSafeLinkUrl:()=>Oe});var vg=new Set(["http:","https:","mailto:","tel:"]),kg=new Set(["http:","https:","blob:"]),Mg=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;function md(n){if(typeof n!="string")return null;let t=n.replace(/[\u0000- \u007f-\u009f]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);return t?`${t[1].toLowerCase()}:`:null}function Oe(n){if(typeof n!="string")return!1;let e=md(n);return e===null||vg.has(e)}function ce(n){if(typeof n!="string")return!1;if(Mg.test(n.trim()))return!0;let e=md(n);return e===null||kg.has(e)}var ir=["left","center","right","justify"],xg=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i,Sg=/^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/,wg=/^\d{1,2}(\.\d{1,3})?(px|em|%)?$/,Eg=/^[\w\s,'"-]{1,200}$/;function Cg(n){let e=n.trim().toLowerCase(),t=e.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0+)\s*)?\)$/);if(t)return"#"+t.slice(1,4).map(o=>Math.min(255,Number(o)).toString(16).padStart(2,"0")).join("");let r=e.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);return r?`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`:e}var q={color:n=>typeof n=="string"&&xg.test(n.trim())&&!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(n.trim())?Cg(n):null,length:n=>typeof n=="string"&&Sg.test(n.trim())?n.trim():null,lineHeight:n=>typeof n=="string"&&wg.test(n.trim())&&n.trim()!=="normal"?n.trim():null,fontFamily:n=>typeof n=="string"&&Eg.test(n.trim())?n.trim():null},$s=40,xd=10;function bn(n){let e=Math.trunc(Number(n));return Number.isFinite(e)?Math.min(xd,Math.max(0,e)):0}var Ag=/^(\d+(?:\.\d+)?)(px|pt|em|rem)$/,Tg={px:1,pt:4/3,em:16,rem:16};function Ng(n,e){if(n.parentElement?.tagName==="LI")return 0;let t=n.style,r=e==="rtl"?t.marginRight||t.paddingRight:t.marginLeft||t.paddingLeft,o=Ag.exec(r?.trim()??"");return o?bn(Math.round(Number(o[1])*Tg[o[2]]/$s)):0}function Og(n){let e=n.getAttribute("dir")?.toLowerCase();return e==="rtl"||e==="ltr"?e:null}function gd(n,e=!1){let t=n.style.textAlign,r=Og(n);return{align:ir.includes(t)?t:null,lineHeight:q.lineHeight(n.style.lineHeight),dir:r,indent:Ng(n,r??(e?"rtl":null))}}function bd(n,e=!1){let t={};(n.dir==="rtl"||n.dir==="ltr")&&(t.dir=n.dir);let r=n.dir==="rtl"||e&&n.dir!=="ltr",o=[],i=n.align;i&&ir.includes(i)&&o.push(`text-align: ${i};`);let s=q.lineHeight(n.lineHeight);s&&o.push(`line-height: ${s};`);let l=bn(n.indent);return l&&o.push(`margin-${r?"right":"left"}: ${l*$s}px;`),o.length&&(t.style=o.join(" ")),t}var yd={align:{default:null},lineHeight:{default:null},dir:{default:null},indent:{default:0}},Is=["disc","circle","square"],Hs=["decimal","lower-alpha","upper-alpha","lower-roman","upper-roman","lower-greek"],Dg={1:"decimal",a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};function vd(n,e,t){let r=n.style.listStyleType.toLowerCase(),o=Dg[n.getAttribute("type")??""]??"",i=e.includes(r)?r:e.includes(o)?o:null;return i===t?null:i}function kd(n,e){return typeof n=="string"&&e.includes(n)?{style:`list-style-type: ${n};`}:{}}var Bs={left:"float: left; margin: 0 1em 1em 0;",right:"float: right; margin: 0 0 1em 1em;",center:"display: block; margin-left: auto; margin-right: auto;"};function Md(n){let e=n.style.float||n.getAttribute("align");return e==="left"||e==="right"?e:n.style.display==="block"&&n.style.marginLeft==="auto"&&n.style.marginRight==="auto"?"center":null}function ne(n){if(n==null||n==="")return null;let e=String(n).trim().match(/^(\d{1,5})(px)?$/);if(!e)return null;let t=Number(e[1]);return t>=1&&t<=1e4?t:null}var Fs=["top","middle","bottom"];function Sd(n){let e=[],t=q.length(n.width);return t&&e.push(`width: ${t};`),n.align==="center"?e.push("margin-left: auto; margin-right: auto;"):n.align==="right"&&e.push("margin-left: auto;"),e.join(" ")}var Lg=100;function Rg(n){let e=hd({tableGroup:"block",cellContent:"block+",cellAttributes:{class:{default:null,getFromDOM:t=>Ct(t,n),setDOMAttr:(t,r)=>{let o=He(t).class;o&&(r.class=o)}},background:{default:null,getFromDOM:t=>q.color(t.getAttribute("data-nova-cell-bg")??t.style?.backgroundColor),setDOMAttr:(t,r)=>{let o=q.color(t);o&&(r.style=`${r.style??""}background-color: ${o};`)}},valign:{default:null,getFromDOM:t=>{let r=t,o=(r.style.verticalAlign||r.getAttribute("valign")||"").toLowerCase();return Fs.includes(o)?o:null},setDOMAttr:(t,r)=>{Fs.includes(t)&&(r.style=`${r.style??""}vertical-align: ${t};`)}}}});e.table.attrs={width:{default:null},align:{default:null},class:{default:null}},e.table.parseDOM=[{tag:"table",getAttrs:t=>{let r=t,o=q.length(r.style.width)??q.length(`${r.getAttribute("width")??""}px`),i=l=>l==="auto",s=r.getAttribute("align")==="center"||i(r.style.marginLeft)&&i(r.style.marginRight)?"center":r.getAttribute("align")==="right"||i(r.style.marginLeft)?"right":null;return{width:o,align:s,class:Ct(r,n)}}}],e.table.toDOM=t=>{let r=Sd(t.attrs);return["table",{...He(t.attrs.class),...r?{style:r}:{}},["tbody",0]]};for(let t of["table_cell","table_header"]){let r=e[t],o=r.parseDOM[0],i=o.getAttrs;o.getAttrs=l=>{let a=i(l);if(!a)return a;let c=u=>Math.min(Lg,Math.max(1,Number.isFinite(u)?Math.floor(u):1));return{...a,colspan:c(a.colspan),rowspan:c(a.rowspan)}};let s=r.toDOM;r.toDOM=l=>{let a=s(l),c=l.attrs.colwidth;if(c?.every(u=>u>0)){let u=c.reduce((p,f)=>p+f,0),d=a[1].style?` ${a[1].style}`:"";a[1]={...a[1],style:`width: ${u}px;${d}`}}return a}}return e}var Vs=()=>!1,wd=/^-?[_a-zA-Z][\w-]*$/;function Pg(n){let e=Math.trunc(Number(n));return e>=1&&e<=6?e:1}function Ct(n,e){let t=[...n.classList].filter(r=>wd.test(r)&&e(r));return t.length?t.join(" "):null}function He(n){if(typeof n!="string")return{};let e=n.split(/\s+/).filter(t=>wd.test(t));return e.length?{class:e.join(" ")}:{}}var rr={class:{default:null}},Ed=(n,e=!1)=>({doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...yd,...rr},parseDOM:[{tag:"p",getAttrs:t=>({...gd(t,e),class:Ct(t,n)})}],toDOM:t=>["p",{...He(t.attrs.class),...bd(t.attrs,e)},0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{level:{default:1},...yd,...rr},parseDOM:[1,2,3,4,5,6].map(t=>({tag:`h${t}`,getAttrs:r=>({level:t,...gd(r,e),class:Ct(r,n)})})),toDOM:t=>[`h${Pg(t.attrs.level)}`,{...He(t.attrs.class),...bd(t.attrs,e)},0]},blockquote:{group:"block",content:"block+",defining:!0,attrs:{...rr},parseDOM:[{tag:"blockquote",getAttrs:t=>({class:Ct(t,n)})}],toDOM:t=>["blockquote",He(t.attrs.class),0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{language:{default:null}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({language:t.querySelector("code")?.className.match(/language-([\w-]+)/)?.[1]??null})}],toDOM:t=>["pre",["code",t.attrs.language?{class:`language-${t.attrs.language}`}:{},0]]},bullet_list:{group:"block",content:"list_item+",attrs:{listStyle:{default:null}},parseDOM:[{tag:"ul",getAttrs:t=>({listStyle:vd(t,Is,"disc")})}],toDOM:t=>["ul",kd(t.attrs.listStyle,Is),0]},ordered_list:{group:"block",content:"list_item+",attrs:{start:{default:1},listStyle:{default:null}},parseDOM:[{tag:"ol",getAttrs:t=>{let r=t.getAttribute("start");return{start:r?Number(r):1,listStyle:vd(t,Hs,"decimal")}}}],toDOM:t=>["ol",{...t.attrs.start===1?{}:{start:t.attrs.start},...kd(t.attrs.listStyle,Hs)},0]},list_item:{content:"paragraph block*",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["li",0]},text:{group:"inline"},figure:{group:"block",content:"figure_image figcaption",draggable:!0,isolating:!0,attrs:{align:{default:null},...rr},parseDOM:[{tag:"figure",getAttrs:t=>{let r=t,o=r.querySelector("img");return!o||!ce(o.getAttribute("src")??"")?!1:{align:Md(r),class:Ct(r,n)}}}],toDOM:t=>{let r=ne(t.firstChild?.attrs.width),o=Bs[t.attrs.align]??"",i=`${o}${r?`${o?" ":""}width: ${r}px;`:""}`;return["figure",{...He(t.attrs.class),...i?{style:i}:{}},0]}},figure_image:{atom:!0,selectable:!1,attrs:{src:{default:""},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}},parseDOM:[{tag:"img[src]",context:"figure/",priority:60,getAttrs:t=>{let r=t;return ce(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=ce(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height);return["img",{src:i,...r?{alt:r}:{},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{}}]}},figcaption:{content:"inline*",parseDOM:[{tag:"figcaption",context:"figure/"}],toDOM:()=>["figcaption",0]},image:{group:"inline",inline:!0,draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},align:{default:null},...rr},parseDOM:[{tag:"img[src]",getAttrs:t=>{let r=t;return ce(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height),align:Md(r),class:Ct(r,n)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=ce(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height),a=Bs[t.attrs.align];return["img",{src:i,...He(t.attrs.class),...r?{alt:r}:{},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{},...a?{style:a}:{}}]}},hard_break:{group:"inline",inline:!0,selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},...Rg(n)}),zs=Ed(Vs),Cd=n=>({link:{attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return Oe(t.getAttribute("href")??"")?{href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")}:!1}}],toDOM:e=>{let{title:t,target:r}=e.attrs;return["a",{href:Oe(e.attrs.href)?e.attrs.href:"#",...t?{title:t}:{},...r?{target:r,rel:"noopener noreferrer"}:{}},0]}},bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>e.style?.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>["strong",0]},italic:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},underline:{parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:()=>["u",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},code:{parseDOM:[{tag:"code"}],toDOM:()=>["code",0]},subscript:{excludes:"superscript",parseDOM:[{tag:"sub"},{style:"vertical-align=sub"}],toDOM:()=>["sub",0]},superscript:{excludes:"subscript",parseDOM:[{tag:"sup"},{style:"vertical-align=super"}],toDOM:()=>["sup",0]},color:{attrs:{value:{}},parseDOM:[{style:"color",getAttrs:e=>or(q.color(e))},{tag:"font[color]",getAttrs:e=>or(q.color(e.getAttribute("color")))}],toDOM:e=>uo("color",q.color(e.attrs.value))},background:{attrs:{value:{}},parseDOM:[{style:"background-color",getAttrs:e=>or(q.color(e))},{tag:"mark",getAttrs:()=>({value:"yellow"})}],toDOM:e=>uo("background-color",q.color(e.attrs.value))},font_family:{attrs:{value:{}},parseDOM:[{style:"font-family",getAttrs:e=>or(q.fontFamily(e))}],toDOM:e=>uo("font-family",q.fontFamily(e.attrs.value))},font_size:{attrs:{value:{}},parseDOM:[{style:"font-size",getAttrs:e=>or(q.length(e))}],toDOM:e=>uo("font-size",q.length(e.attrs.value))},span_class:{attrs:{class:{}},parseDOM:[{tag:"span[class]",consuming:!1,getAttrs:e=>{let t=Ct(e,n);return t?{class:t}:!1}}],toDOM:e=>["span",He(e.attrs.class),0]}}),_s=Cd(Vs);function or(n){return n?{value:n}:!1}function uo(n,e){return e?["span",{style:`${n}: ${e};`},0]:["span",0]}var At=new Xt({nodes:zs,marks:_s});function po(n={},e,t,r="ltr"){let o=r==="rtl",i=Object.entries(n.nodes??{}),s=Object.entries(n.marks??{});if(!i.length&&!s.length&&!e&&!t&&!o)return At;let l=e||o?Ed(e??Vs,o):zs,a=e?Cd(e):_s,c={};t&&({nodes:l,marks:a}=t.apply({nodes:l,marks:a},c));for(let[u]of i)if(u in zs)throw new Error(`[nova] node "${u}" already exists in the base schema`);for(let[u]of s)if(u in _s)throw new Error(`[nova] mark "${u}" already exists in the base schema`);return c.schema=new Xt({nodes:{...l,...Object.fromEntries(i)},marks:{...a,...Object.fromEntries(s)}}),c.schema}var Ig=/^https?:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/)([\w-]{11})(?:[?&#]|$)/i,Hg=/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{1,12})(?:[/?#]|$)/i,Bg=/^https:\/\/[^\s"'<>]+\.(?:mp4|webm|ogv|ogg)(?:\?[^\s"'<>#]*)?$/i;function fo(n){if(typeof n!="string")return null;let e=n.trim(),t=e.match(Ig);if(t)return{kind:"youtube",src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let r=e.match(Hg);return r?{kind:"vimeo",src:`https://player.vimeo.com/video/${r[1]}`}:Bg.test(e)?{kind:"video",src:e}:null}var Ad=S.media,Fg={en:{title:"Video",url:"Video URL",hint:"YouTube, Vimeo or a link to an .mp4 / .webm file",name:"Title (for screen readers)",invalid:"This video address is not supported",save:"Insert"}};function Td(n,e){let t=e?fo(e):null;return t?{...t,width:ne(n.getAttribute("width"))??560,height:ne(n.getAttribute("height"))??315,title:n.getAttribute("title")??""}:!1}function zg(n){let e=fo(n.attrs.src);if(!e)return null;let t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e.kind==="video"?M("video",{src:e.src,controls:!0,width:t,height:r,preload:"metadata"}):M("iframe",{src:e.src,width:t,height:r,title:n.attrs.title||"Video",allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:!0,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})}var Nd={name:"media",toolbar:"media",nodes:{media:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{kind:{default:"youtube"},src:{},width:{default:560},height:{default:315},title:{default:""}},parseDOM:[{tag:"iframe[src]",getAttrs:n=>Td(n,n.getAttribute("src"))},{tag:"video",getAttrs:n=>{let e=n,t=e.getAttribute("src")??e.querySelector("source[src]")?.getAttribute("src")??null;return Td(e,t)}}],toDOM:n=>{let e=fo(n.attrs.src),t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e?e.kind==="video"?["video",{src:e.src,controls:"",width:t,height:r}]:["iframe",{src:e.src,width:t,height:r,title:n.attrs.title||null,allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"}]:["p"]}}},prosemirrorPlugins:()=>[new z({props:{nodeViews:{media:n=>{let e=zg(n);return{dom:M("div",{className:"nova-media",contenteditable:"false"},e,M("div",{className:"nova-media-overlay","aria-hidden":"true"})),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}})],setup(n){let e=le(n,"media",Fg),t=()=>{let{selection:o}=n.view.state;return o instanceof P&&o.node.type.name==="media"?o:null},r=()=>{let o=t(),i=ee({label:e.url,type:"url",placeholder:"https://",hint:e.hint,value:o?.node.attrs.src??""}),s=ee({label:e.name,value:o?.node.attrs.title??""});gn(n,i,"media",l=>{l.title&&(s.input.value=l.title)}),n.ui.openDialog({title:e.title,body:M("div",{className:"nova-form"},i.el,s.el),submitLabel:e.save,onSubmit:()=>{let l=fo(i.input.value);if(!l)return e.invalid;let{state:a,dispatch:c}=n.view,u={...l,title:s.input.value.trim()},d=t();return c(d?a.tr.setNodeMarkup(d.from,void 0,{...d.node.attrs,...u}):a.tr.replaceSelectionWith(n.schema.nodes.media.create(u)).scrollIntoView()),!0}})};n.ui.registry.addToggleButton("media",{icon:Ad,tooltip:e.title,isActive:()=>t()!==null,isEnabled:o=>o.isEditable(),onAction:r}),n.ui.registry.addMenuItem("media",{text:e.title,icon:Ad,onAction:r})}};var Od=S.pageBreak,_g={en:{title:"Page break"}},Dd={name:"pagebreak",toolbar:"pagebreak",nodes:{pagebreak:{group:"block",atom:!0,selectable:!0,parseDOM:[{tag:"div.nova-pagebreak"},{tag:"div",getAttrs:n=>{let e=n;return(e.style.breakAfter==="page"||e.style.pageBreakAfter==="always")&&!e.textContent?.trim()?null:!1}}],toDOM:()=>["div",{class:"nova-pagebreak",style:"break-after: page;"}]}},setup(n){let{title:e}=le(n,"pagebreak",_g),t=()=>{let{state:r,dispatch:o}=n.view,i=n.schema.nodes.pagebreak;o(r.tr.replaceSelectionWith(i.create()).scrollIntoView()),n.focus()};n.ui.registry.addButton("pagebreak",{icon:Od,tooltip:e,isEnabled:r=>r.isEditable(),onAction:t}),n.ui.registry.addMenuItem("pagebreak",{text:e,icon:Od,onAction:t})}};U("insertdatetime",()=>import(__novaChunk("tinymce-chunks/insertdatetime-e0dbcf63.js") ));U("quickbars",()=>import(__novaChunk("tinymce-chunks/quickbars-d937e10a.js") ));U("charmap",()=>import(__novaChunk("tinymce-chunks/charmap-4b14307a.js") ));U("emoticons",()=>import(__novaChunk("tinymce-chunks/emoticons-7e6da0b6.js") ));U("nonbreaking",()=>import(__novaChunk("tinymce-chunks/nonbreaking-49bdb0d2.js") ));U("autolink",()=>import(__novaChunk("tinymce-chunks/autolink-7e2e7be2.js") ));U("autosave",()=>import(__novaChunk("tinymce-chunks/autosave-4fd46720.js") ));U("autoresize",()=>import(__novaChunk("tinymce-chunks/autoresize-d6c9537b.js") ));U("visualblocks",()=>import(__novaChunk("tinymce-chunks/visualblocks-58c88e5d.js") ));U("anchor",Rc);U("pagebreak",Dd);U("media",Nd);U("comments",Zu);U("mentions",Gu);U("mergetags",id);U("suggestions",fd);U("directionality",()=>import(__novaChunk("tinymce-chunks/directionality-60dba768.js") ));U("advlist",()=>import(__novaChunk("tinymce-chunks/advlist-7a360f16.js") ));U("revisionhistory",()=>import(__novaChunk("tinymce-chunks/revisionhistory-d6306426.js") ));var ma={};Z(ma,{API_CHANGE_META:()=>vr,Editor:()=>kr,REMOTE_CHANGE_META:()=>ha,createEditor:()=>ti,parseContent:()=>fa});var Rd=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function $g(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Vg=(n,e,t)=>{let r=$g(n,t);if(!r)return!1;let o=Pd(r);if(!o){let s=r.blockRange(),l=s&&gt(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Hd(n,o,e,-1))return!0;if(r.parent.content.size==0&&(yn(i,"end")||P.isSelectable(i)))for(let s=r.depth;;s--){let l=_n(n.doc,r.before(s),r.after(s),D.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(yn(i,"end")?F.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):P.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function yn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var qg=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=Pd(r)}let s=i&&i.nodeBefore;return!s||!P.isSelectable(s)?!1:(e&&e(n.tr.setSelection(P.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Pd(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Wg(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var jg=(n,e,t)=>{let r=Wg(n,t);if(!r)return!1;let o=Id(r);if(!o)return!1;let i=o.nodeAfter;if(Hd(n,o,e,1))return!0;if(r.parent.content.size==0&&(yn(i,"start")||P.isSelectable(i))){let s=_n(n.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(yn(i,"start")?F.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):P.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Kg=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=Id(r)}let s=i&&i.nodeAfter;return!s||!P.isSelectable(s)?!1:(e&&e(n.tr.setSelection(P.create(n.doc,i.pos)).scrollIntoView()),!0)};function Id(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var ho=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&gt(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},Ug=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
11
- `).scrollIntoView()),!0)};function js(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Ks=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=js(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(F.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Jg=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof se||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=js(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(I.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Gg=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(et(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&gt(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Yg(n){return(e,t)=>{if(e.selection instanceof P&&e.selection.node.isBlock){let{$from:f}=e.selection;return!f.parentOffset||!et(e.doc,f.pos)?!1:(t&&t(e.tr.split(f.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof I||e.selection instanceof se)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let f=o.depth;;f--)if(o.node(f).isBlock){c=o.end(f)==o.pos+(o.depth-f),u=o.start(f)==o.pos-(o.depth-f),a=js(o.node(f-1).contentMatchAt(o.indexAfter(f-1)));let g=n&&n(o.parent,c,o);s.unshift(g||(c&&a?{type:a}:null)),l=f;break}else{if(f==1)return!1;s.unshift(null)}let d=o.pos,p=et(r.doc,d,s.length,s);if(p||(s[0]=a?{type:a}:null,p=et(r.doc,d,s.length,s)),!p)return!1;if(r.split(d,s.length,s),!c&&u&&o.node(l).type!=a){let f=r.mapping.slice(i),h=f.map(o.before(l)),g=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(g.index(),g.index()+1,a)&&r.setNodeMarkup(f.map(o.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var Xg=Yg();var Qg=(n,e)=>(e&&e(n.tr.setSelection(new se(n.doc))),!0);function Zg(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||bt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Hd(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Zg(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,h=A.empty;for(let b=s.length-1;b>=0;b--)h=A.from(s[b].create(null,h));h=A.from(o.copy(h));let g=n.tr.step(new ie(e.pos-1,f,e.pos,f,new D(h,1,0),s.length,!0)),m=g.doc.resolve(f+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&bt(g.doc,m.pos)&&g.join(m.pos),t(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:F.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),p=d&&gt(d);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(d,p).scrollIntoView()),!0;if(c&&yn(i,"start",!0)&&yn(o,"end")){let f=o,h=[];for(;h.push(f),!f.isTextblock;)f=f.lastChild;let g=i,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(t){let b=A.empty;for(let y=h.length-1;y>=0;y--)b=A.from(h[y].copy(b));let k=n.tr.step(new ie(e.pos-h.length,e.pos+i.nodeSize,e.pos+m,e.pos+i.nodeSize-m,new D(b,h.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function Bd(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(I.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var eb=Bd(-1),tb=Bd(1);function mo(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&It(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Us(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function nb(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:i,$to:s}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function rb(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:o}=n[t];r.doc.nodesBetween(r.pos,o.pos,(i,s)=>{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new Bt(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.pos<o.pos&&e.push(new Bt(r,o))}return e}function Tt(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,o=(t&&t.enterInlineAtoms)!==!1,i=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!nb(s.doc,u,n,o))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let d,p=s.tr;o||(u=rb(u)),r?d=!u.some(f=>s.doc.rangeHasMark(f.$from.pos,f.$to.pos,n)):d=!u.every(f=>{let h=!1;return p.doc.nodesBetween(f.$from.pos,f.$to.pos,(g,m,b)=>{if(h)return!1;h=!n.isInSet(g.marks)&&!!b&&b.type.allowsMarkType(n)&&!(g.isText&&/^\s*$/.test(g.textBetween(Math.max(0,f.$from.pos-m),Math.min(g.nodeSize,f.$to.pos-m))))}),!h});for(let f=0;f<u.length;f++){let{$from:h,$to:g}=u[f];if(!d)p.removeMark(h.pos,g.pos,n);else{let m=h.pos,b=g.pos,k=h.nodeAfter,y=g.nodeBefore,w=i&&k&&k.isText?/^\s*/.exec(k.text)[0].length:0,N=i&&y&&y.isText?/\s*$/.exec(y.text)[0].length:0;m+w<b&&(m+=w,b-=N),p.addMark(m,b,n.create(e))}}l(p.scrollIntoView())}return!0}}function vn(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}var Ws=vn(Rd,Vg,qg),Ld=vn(Rd,jg,Kg),lt={Enter:vn(Ug,Jg,Gg,Xg),"Mod-Enter":Ks,Backspace:Ws,"Mod-Backspace":Ws,"Shift-Backspace":Ws,Delete:Ld,"Mod-Delete":Ld,"Mod-a":Qg},Fd={"Ctrl-h":lt.Backspace,"Alt-Backspace":lt["Mod-Backspace"],"Ctrl-d":lt.Delete,"Ctrl-Alt-Backspace":lt["Mod-Delete"],"Alt-Delete":lt["Mod-Delete"],"Alt-d":lt["Mod-Delete"],"Ctrl-a":eb,"Ctrl-e":tb};for(let n in lt)Fd[n]=lt[n];var ob=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,zd=ob?Fd:lt;var ol={};Z(ol,{commands:()=>W,getActiveAlign:()=>Nt,getLinkAt:()=>Kt,insertImage:()=>nl,isCommandActive:()=>rl,isMarkActive:()=>xn,isNodeActive:()=>Be,listIndent:()=>el,listOutdent:()=>tl,markRange:()=>Ut,marksOf:()=>Y,nodesOf:()=>$,setLink:()=>Tb});var Qs={};Z(Qs,{closeHistory:()=>fb,history:()=>Xs,isHistoryTransaction:()=>yb,redo:()=>ko,redoDepth:()=>bb,redoNoScroll:()=>mb,undo:()=>vo,undoDepth:()=>gb,undoNoScroll:()=>hb});var go=200,pe=function(){};pe.prototype.append=function(e){return e.length?(e=pe.from(e),!this.length&&e||e.length<go&&this.leafAppend(e)||this.length<go&&e.leafPrepend(this)||this.appendInner(e)):this};pe.prototype.prepend=function(e){return e.length?pe.from(e).append(this):this};pe.prototype.appendInner=function(e){return new ib(this,e)};pe.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?pe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};pe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};pe.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};pe.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};pe.from=function(e){return e instanceof pe?e:e&&e.length?new _d(e):pe.empty};var _d=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=go)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=go)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(pe);pe.empty=new _d([]);var ib=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(pe),Js=pe;var sb=500,Wt=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){o||(o=this.remapping(r,p+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new Ue(d.map));let f=d.step.map(o.slice(i)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ue(h,void 0,void 0,c.length+u.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new Ue(e.mapping.maps[u],d,t),f;(f=a&&a.merge(p))&&(p=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(p),t&&(s++,t=void 0),o||(a=p)}let c=s-r.depth;return c>ab&&(l=lb(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new Zt;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new Ue(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],o=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},o);let a=t;this.items.forEach(p=>{let f=i.getMirror(--a);if(f==null)return;s=Math.min(s,f);let h=i.maps[f];if(p.step){let g=e.steps[f].invert(e.docs[f]),m=p.selection&&p.selection.map(i.slice(a+1,f));m&&l++,r.push(new Ue(h,g,m))}else r.push(new Ue(h))},o);let c=[];for(let p=t;p<s;p++)c.push(new Ue(i.maps[p]));let u=this.items.slice(0,o).append(c).append(r),d=new n(u,l);return d.emptyItemCount()>sb&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&i++;let d=new Ue(c.invert(),a,u),p,f=o.length-1;(p=o.length&&o[f].merge(d))?o[f]=p:o.push(d)}}else s.map&&r--},this.items.length,0),new n(Js.from(o.reverse()),i)}};Wt.empty=new Wt(Js.empty,0);function lb(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var Ue=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},Je=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},ab=20;function cb(n,e,t,r){let o=t.getMeta(Ge),i;if(o)return o.historyState;t.getMeta(qd)&&(n=new Je(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Ge))return s.getMeta(Ge).redo?new Je(n.done.addTransform(t,void 0,r,bo(e)),n.undone,$d(t.mapping.maps),n.prevTime,n.prevComposition):new Je(n.done,n.undone.addTransform(t,void 0,r,bo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ub(t,n.prevRanges)),c=s?Gs(n.prevRanges,t.mapping):$d(t.mapping.maps);return new Je(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,bo(e)),Wt.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Je(n.done.rebased(t,i),n.undone.rebased(t,i),Gs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Je(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Gs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ub(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function $d(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function Gs(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function db(n,e){for(let t=0;t<e.steps.length;t++){let r=e.mapping.maps[t],o=-1;if(r.forEach((i,s)=>o=s),o<0){let i=e.steps[t];(i instanceof mt||i instanceof Ze)&&(o=i.to)}if(o>-1)return F.near(n.doc.resolve(o))}return n.selection}function pb(n,e,t){let r=bo(e),o=Ge.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,db(e,i.transform).getBookmark(),o,r),a=new Je(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Ge,{redo:t,historyState:a})}var Ys=!1,Vd=null;function bo(n){let e=n.plugins;if(Vd!=e){Ys=!1,Vd=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ys=!0;break}}return Ys}function fb(n){return n.setMeta(qd,!0)}var Ge=new K("history"),qd=new K("closeHistory");function Xs(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new z({key:Ge,state:{init(){return new Je(Wt.empty,Wt.empty,null,0,-1)},apply(e,t,r){return cb(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?vo:r=="historyRedo"?ko:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function yo(n,e){return(t,r)=>{let o=Ge.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=pb(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var vo=yo(!1,!0),ko=yo(!0,!0),hb=yo(!1,!1),mb=yo(!0,!1);function gb(n){let e=Ge.getState(n);return e?e.done.eventCount:0}function bb(n){let e=Ge.getState(n);return e?e.undone.eventCount:0}function yb(n){return n.getMeta(Ge)!=null}function Wd(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return vb(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function vb(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new ft(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ft(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=It(i,t,r,e);return l?(n&&kb(n,e,l,o,t),!0):!1}function kb(n,e,t,r,o){let i=A.empty;for(let u=t.length-1;u>=0;u--)i=A.from(t[u].type.create(t[u].attrs,i));n.step(new ie(e.start-(r?2:0),e.end,e.start,e.end,new D(i,0,0),t.length,!0));let s=0;for(let u=0;u<t.length;u++)t[u].type==o&&(s=u+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,p=!0;u<d;u++,p=!1)!p&&l&&et(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function kn(n,e){return n instanceof qe?e==n:n.indexOf(e)>-1}function jd(n,e){return function(t,r){let{$from:o,$to:i,node:s}=t.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(!kn(n,l.type))return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||!kn(n,o.node(-3).type)||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let d=A.empty,p=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-p;b>=o.depth-3;b--)d=A.from(o.node(b).copy(d));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;d=d.append(A.from(o.node(-3).type.createAndFill()));let h=o.before(o.depth-(p-1)),g=t.tr.replace(h,o.after(-f),new D(d,4-p,0)),m=-1;g.doc.nodesBetween(h,g.doc.content.size,(b,k)=>{if(m>-1)return!1;b.isTextblock&&b.content.size==0&&(m=k+1)}),m>-1&&g.setSelection(F.near(g.doc.resolve(m))),r(g.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),u=a||e?[e?{type:l.type,attrs:e}:null,a?{type:a}:null]:void 0;return et(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Mo(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&kn(n,s.firstChild.type));return i?t?kn(n,r.node(i.depth-1).type)?Mb(e,t,i):xb(e,t,i):!0:!1}}function Mb(n,e,t){let r=n.tr,o=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;o<i&&(r.step(new ie(o-1,i,o,i,new D(A.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new ft(r.doc.resolve(t.$from.pos),r.doc.resolve(i),t.depth));let l=gt(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return bt(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function xb(n,e,t){let r=n.tr,o=t.parent;for(let f=t.end,h=t.endIndex-1,g=t.startIndex;h>g;h--)f-=o.child(h).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?A.empty:A.from(o))))return!1;let d=i.pos,p=d+s.nodeSize;return r.step(new ie(d-(l?1:0),p+(a?1:0),d+1,p-1,new D((l?A.empty:A.from(o.copy(A.empty))).append(a?A.empty:A.from(o.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Zs(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&kn(n,c.firstChild.type));if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(!kn(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=A.from(c?a.lastChild.lastChild.type.create():null),d=new D(A.from(a.type.create(null,A.from(l.type.create(null,u)))),c?3:1,0),p=i.start,f=i.end;t(e.tr.step(new ie(p-(c?3:1),f,p,f,d,1,!0)).scrollIntoView())}return!0}}var $=n=>n.schema.nodes,Y=n=>n.schema.marks,sr=(n,e)=>(t,r,o)=>e($(t)[n])(t,r,o),jt=(n,e)=>(t,r,o)=>e(Y(t)[n])(t,r,o);function xo(n){return(e,t)=>{let{from:r,to:o}=e.selection,i=e.tr,s=!1;return e.doc.nodesBetween(r,o,(l,a)=>{let c=$(e);(l.type===c.paragraph||l.type===c.heading)&&(s=!0,i=i.setNodeMarkup(a,void 0,{...l.attrs,align:n}))}),s?(t?.(i),!0):!1}}var Sb=(n,e)=>(e?.(n.tr.replaceSelectionWith($(n).horizontal_rule.create()).scrollIntoView()),!0),wb=(n,e)=>{let{from:t,to:r,empty:o,$from:i}=n.selection,s=Y(n);if(o){let l=Ut(n,s.link,i.pos);return l?(e?.(n.tr.removeMark(l.from,l.to,s.link)),!0):!1}return n.doc.rangeHasMark(t,r,s.link)?(e?.(n.tr.removeMark(t,r,s.link)),!0):!1},Eb=(n,e)=>{let{from:t,to:r,empty:o}=n.selection;if(o)return!1;if(e){let i=Y(n),s=n.tr;for(let l of Object.values(i))l!==i.link&&(s=s.removeMark(t,r,l));e(s)}return!0};function Ud(n){return(e,t)=>{let r=$(e),o=[],{from:i,to:s}=e.selection;if(e.doc.nodesBetween(i,s,(l,a,c)=>{if(l.type!==r.paragraph&&l.type!==r.heading)return!0;if(c?.type!==r.list_item){let u=bn(l.attrs.indent),d=bn(u+n);d!==u&&o.push({pos:a,attrs:{...l.attrs,indent:d}})}return!1}),!o.length)return!1;if(t){let l=e.tr;for(let{pos:a,attrs:c}of o)l.setNodeMarkup(a,void 0,c);t(l.scrollIntoView())}return!0}}var Cb=(n,e,t)=>Zs($(n).list_item)(n,e,t)||Ud(1)(n,e,t),Ab=(n,e,t)=>Mo($(n).list_item)(n,e,t)||Ud(-1)(n,e,t),el=(n,e,t)=>Zs($(n).list_item)(n,e,t),tl=(n,e,t)=>Mo($(n).list_item)(n,e,t);function Jd(n,e={}){let t=Us(n,e);return(r,o)=>{if(!t(r))return!1;if(o){let i=r.tr;for(let s of r.selection.ranges)i.setBlockType(s.$from.pos,s.$to.pos,n,l=>({...e,..."align"in n.spec.attrs&&l.attrs.align?{align:l.attrs.align}:{},..."lineHeight"in n.spec.attrs&&l.attrs.lineHeight?{lineHeight:l.attrs.lineHeight}:{},..."dir"in n.spec.attrs&&l.attrs.dir?{dir:l.attrs.dir}:{},..."indent"in n.spec.attrs&&l.attrs.indent?{indent:l.attrs.indent}:{}}));o(i.scrollIntoView())}return!0}}function Mn(n){return sr("heading",e=>Jd(e,{level:n}))}var W={bold:jt("bold",Tt),italic:jt("italic",Tt),underline:jt("underline",Tt),strike:jt("strike",Tt),code:jt("code",Tt),subscript:jt("subscript",Tt),superscript:jt("superscript",Tt),paragraph:sr("paragraph",n=>Jd(n)),h1:Mn(1),h2:Mn(2),h3:Mn(3),h4:Mn(4),h5:Mn(5),h6:Mn(6),blockquote:(n,e)=>Be(n,$(n).blockquote)?ho(n,e):mo($(n).blockquote)(n,e),codeBlock:sr("code_block",n=>Us(n)),bulletList:sr("bullet_list",Kd),orderedList:sr("ordered_list",Kd),indent:Cb,outdent:Ab,alignLeft:xo(null),alignCenter:xo("center"),alignRight:xo("right"),alignJustify:xo("justify"),horizontalRule:Sb,unlink:wb,clearFormatting:Eb,undo:vo,redo:ko};function Kd(n){return(e,t)=>Be(e,n)?Mo($(e).list_item)(e,t):Wd(n)(e,t)}function Tb(n,e={}){return(t,r)=>{if(!Oe(n))return!1;let{from:o,to:i,empty:s,$from:l}=t.selection,a=Y(t),c=a.link.create({href:n,title:e.title??null,target:e.target??null});if(s){let u=Ut(t,a.link,l.pos);return u?(r?.(t.tr.removeMark(u.from,u.to,a.link).addMark(u.from,u.to,c)),!0):(r?.(t.tr.insert(o,t.schema.text(n,[c]))),!0)}return r?.(t.tr.removeMark(o,i,a.link).addMark(o,i,c)),!0}}function nl(n,e){return(t,r)=>ce(n)?(r?.(t.tr.replaceSelectionWith($(t).image.create({src:n,alt:e??null})).scrollIntoView()),!0):!1}function xn(n,e){let{from:t,$from:r,to:o,empty:i}=n.selection;return i?!!e.isInSet(n.storedMarks??r.marks()):n.doc.rangeHasMark(t,o,e)}function Be(n,e,t){let{$from:r,to:o}=n.selection;for(let i=r.depth;i>0;i--){let s=r.node(i);if(s.type===e&&(!t||Object.entries(t).every(([l,a])=>s.attrs[l]===a)))return o<=r.end(i)}return!1}function Nt(n){return n.selection.$from.parent.attrs.align??"left"}function rl(n,e){let t=n.selection.$from.parent,r=$(n),o=Y(n);switch(e){case"bold":case"italic":case"underline":case"strike":case"code":case"subscript":case"superscript":return xn(n,o[e]);case"paragraph":return t.type===r.paragraph;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t.type===r.heading&&t.attrs.level===Number(e[1]);case"codeBlock":return t.type===r.code_block;case"blockquote":return Be(n,r.blockquote);case"bulletList":return Be(n,r.bullet_list);case"orderedList":return Be(n,r.ordered_list);case"alignLeft":return Nt(n)==="left";case"alignCenter":return Nt(n)==="center";case"alignRight":return Nt(n)==="right";case"alignJustify":return Nt(n)==="justify";default:return!1}}function Kt(n){let{$from:e}=n.selection,t=Y(n),r=t.link.isInSet(e.marks())??t.link.isInSet(e.nodeAfter?.marks??[]);return r?r.attrs:null}function Ut(n,e,t){let r=n.doc.resolve(t),o=r.start(),i=[];return r.parent.forEach((s,l)=>{if(!e.isInSet(s.marks))return;let a=o+l,c=a+s.nodeSize,u=i[i.length-1];u&&u.to===a?u.to=c:i.push({from:a,to:c})}),i.find(s=>s.from<=t&&t<=s.to)??null}var Nb={strong:"bold",b:"bold",em:"italic",i:"italic",u:"underline",s:"strike",strike:"strike",del:"strike",code:"code",sub:"subscript",sup:"superscript"},Ob={color:{mark:"color",read:q.color},"background-color":{mark:"background",read:q.color},"font-family":{mark:"font_family",read:q.fontFamily},"font-size":{mark:"font_size",read:q.length}},To={p:n=>n.type.name==="paragraph",h1:n=>n.type.name==="heading"&&n.attrs.level===1,h2:n=>n.type.name==="heading"&&n.attrs.level===2,h3:n=>n.type.name==="heading"&&n.attrs.level===3,h4:n=>n.type.name==="heading"&&n.attrs.level===4,h5:n=>n.type.name==="heading"&&n.attrs.level===5,h6:n=>n.type.name==="heading"&&n.attrs.level===6,blockquote:n=>n.type.name==="blockquote",pre:n=>n.type.name==="code_block",img:n=>n.type.name==="image"},Gd=new Set;function No(n){Gd.has(n)||(Gd.add(n),console.warn(`[nova] formats: ${n}`))}function Fe(n){return Array.isArray(n)?n.flatMap(Fe):typeof n=="string"?n.split(/\s+/).filter(Boolean):[]}function lr(n){let e=[];for(let t of n)e.push(...Fe(t.classes)),"items"in t&&t.items&&e.push(...lr(t.items));return e}var Eo=(n,e)=>{let t=Fe(n);return e.every(r=>t.includes(r))},So=(n,e)=>{let t=[...new Set([...Fe(n),...e])];return t.length?t.join(" "):null},wo=(n,e)=>{let t=Fe(n).filter(r=>!e.includes(r));return t.length?t.join(" "):null};function Co(n){let e={};for(let[t,r]of Object.entries(n.styles??{}))t==="text-align"&&ir.includes(r)?e.align=r:t==="line-height"&&q.lineHeight(r)?e.lineHeight=q.lineHeight(r):No(`style "${t}" is not supported on blocks`);return e}function ll(n,e){let t=Y(n),r=[];if(e.inline&&e.inline!=="span"){let i=t[Nb[e.inline]];i&&r.push(i.create())}let o=Fe(e.classes);o.length&&t.span_class&&r.push(t.span_class.create({class:o.join(" ")}));for(let[i,s]of Object.entries(e.styles??{})){let l=Ob[i],a=l?.read(s),c=l?t[l.mark]:void 0;c&&a?r.push(c.create({value:a})):No(`style "${i}: ${s}" is not supported on text`)}return r}var Oo=n=>(n.selector??"").split(",").map(e=>e.trim().toLowerCase()).filter(e=>To[e]?!0:(No(`selector "${e}" is not supported`),!1));function Do(n,e){let t=[],r=a=>e.some(c=>To[c](a)),{selection:o}=n;if(o instanceof P&&r(o.node))return[{node:o.node,pos:o.from}];let{$from:i,from:s,to:l}=o;for(let a=i.depth;a>0;a--){let c=i.node(a);r(c)&&t.push({node:c,pos:i.before(a)})}return n.doc.nodesBetween(s,l,(a,c)=>{r(a)&&!t.some(u=>u.pos===c)&&t.push({node:a,pos:c})}),t}function il(n){let e=[],{from:t,to:r}=n.selection;return n.doc.nodesBetween(t,r,(o,i)=>o.isTextblock?(e.push({node:o,pos:i}),!1):!0),e}function al(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.name==="blockquote")return{node:r,pos:e.before(t)}}return null}function Qd(n){return{align:n.align??null,lineHeight:n.lineHeight??null,dir:n.dir??null}}var Ao=class{constructor(e,t){E(this,"editor",e);E(this,"allowedClasses",t);E(this,"registry",new Map)}register(e,t){let r=Array.isArray(t)?t:[t];this.registry.set(e,r),lr(r).forEach(o=>this.allowedClasses.add(o))}unregister(e){this.registry.delete(e)}has(e){return this.registry.has(e)}get(e){return this.registry.get(e)}resolve(e){if(typeof e!="string")return[e];let t=this.registry.get(e);return t||No(`unknown format "${e}"`),t??[]}canApply(e){if(!this.editor.isEditable())return!1;let t=this.editor.view.state;return this.resolve(e).some(r=>Yd(t,r))}match(e){let t=this.editor.view.state;return this.resolve(e).some(r=>Db(t,r))}apply(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);if(!t.length)return!1;let r=t.find(o=>Yd(this.editor.view.state,o))??t[0];return this.run((o,i)=>Lb(o,i,r))}remove(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);return t.length?this.run((r,o)=>t.forEach(i=>Rb(r,o,i))):!1}toggle(e){return this.match(e)?this.remove(e):this.apply(e)}run(e){let{view:t}=this.editor,r=t.state.tr;return e(t.state,r)===!1?!1:((r.docChanged||r.storedMarksSet)&&t.dispatch(r.scrollIntoView()),t.focus(),!0)}};function Yd(n,e){return e.selector?Do(n,Oo(e)).length>0:!0}function Xd(n,e){return n.type.name==="image"?!0:Object.entries(Co(e)).every(([t,r])=>n.attrs[t]===r)}function Db(n,e){let t=Fe(e.classes);if(e.block){if(e.block==="blockquote"){let o=al(n);return!!o&&Eo(o.node.attrs.class,t)}let r=n.selection.$from.parent;return To[e.block](r)&&Eo(r.attrs.class,t)&&Xd(r,e)}if(e.selector){let r=Do(n,Oo(e));return r.length>0&&r.some(({node:o})=>Eo(o.attrs.class,t)&&Xd(o,e))}if(e.inline){let r=ll(n,e);if(!r.length)return!1;let{$from:o,empty:i,from:s,to:l}=n.selection;if(i){let u=n.storedMarks??o.marks();return r.every(d=>u.some(p=>sl(p,d)))}let a=!1,c=!0;return n.doc.nodesBetween(s,l,u=>{u.isText&&(a=!0,r.every(d=>u.marks.some(p=>sl(p,d)))||(c=!1))}),a&&c}return!1}function sl(n,e){return n.type!==e.type?!1:e.type.name==="span_class"?Eo(n.attrs.class,Fe(e.attrs.class)):e.attrs.value===void 0||n.attrs.value===e.attrs.value}function Lb(n,e,t){let r=Fe(t.classes),o=$(n);if(t.block==="blockquote"){let i=al(n);return i?(e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:So(i.node.attrs.class,r)}),!0):mo(o.blockquote,{class:So(null,r)})(n,s=>s.steps.forEach(l=>e.step(l)))}if(t.block==="pre"){for(let{node:i,pos:s}of il(n))i.type!==o.code_block&&e.setNodeMarkup(s,o.code_block,{language:null});return!0}if(t.block){let i=t.block==="p"?0:Number(t.block.slice(1)),s=i?o.heading:o.paragraph,l=Co(t);for(let{node:a,pos:c}of il(n)){if(a.type===o.code_block&&a.textContent.includes(`
12
- `))continue;let u=a.type===s&&(!i||a.attrs.level===i);e.setNodeMarkup(c,s,{...Qd(a.attrs),...i?{level:i}:{},...l,class:So(u?a.attrs.class:null,r)})}return!0}if(t.selector){let i=Co(t),s=Do(n,Oo(t));if(!s.length)return!1;for(let{node:l,pos:a}of s){let c=l.type.name==="image"?{}:i;e.setNodeMarkup(a,void 0,{...l.attrs,...c,class:So(l.attrs.class,r)})}return n.selection instanceof P&&e.setSelection(P.create(e.doc,n.selection.from)),!0}if(t.inline){let i=ll(n,t);if(!i.length)return!1;let{empty:s,ranges:l}=n.selection;if(s){let a=n.storedMarks??n.selection.$from.marks();for(let c of i)a=c.addToSet(a);return e.setStoredMarks(a),!0}for(let{$from:a,$to:c}of l)for(let u of i)e.addMark(a.pos,c.pos,u);return!0}return!1}function Rb(n,e,t){let r=Fe(t.classes),o=$(n);if(t.block==="blockquote"){let i=al(n);if(!i)return;let s=wo(i.node.attrs.class,r);if(r.length&&s!==null){e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:s});return}ho(n,l=>l.steps.forEach(a=>e.step(a)));return}if(t.block){for(let{node:i,pos:s}of il(n))To[t.block](i)&&e.setNodeMarkup(s,o.paragraph,{...Qd(i.attrs),class:t.block==="p"?wo(i.attrs.class,r):null});return}if(t.selector){let i=Co(t);for(let{node:s,pos:l}of Do(n,Oo(t))){let a={};s.type.name!=="image"&&("align"in i&&s.attrs.align===i.align&&(a.align=null),"lineHeight"in i&&s.attrs.lineHeight===i.lineHeight&&(a.lineHeight=null)),e.setNodeMarkup(l,void 0,{...s.attrs,...a,class:wo(s.attrs.class,r)})}n.selection instanceof P&&e.setSelection(P.create(e.doc,n.selection.from));return}if(t.inline){let i=ll(n,t),{empty:s,from:l,to:a,$from:c}=n.selection;if(s){let u=(n.storedMarks??c.marks()).filter(d=>!i.some(p=>sl(d,p)));e.setStoredMarks(u);return}for(let u of i){if(u.type.name!=="span_class"){e.removeMark(l,a,u.type);continue}n.doc.nodesBetween(l,a,(d,p)=>{if(!d.isText)return;let f=d.marks.find(b=>b.type===u.type);if(!f)return;let h=Math.max(p,l),g=Math.min(p+d.nodeSize,a);e.removeMark(h,g,u.type);let m=wo(f.attrs.class,Fe(u.attrs.class));m&&e.addMark(h,g,u.type.create({class:m}))})}}}var Pb=/^@(font-face|(-webkit-)?keyframes|property|counter-style|page|font-feature-values|font-palette-values)\b/i,Ib=/^@(media|supports|container|layer|document|scope)\b/i;function Hb(n){let e=[],t=0,r=0,o=0,i="";for(;t<n.length;){let s=n[t];if(s==="/"&&n[t+1]==="*"){let l=n.indexOf("*/",t+2),a=l===-1?n.length:l+2;if(o===0){n=n.slice(0,t)+n.slice(a);continue}t=a;continue}if(s==='"'||s==="'"){for(t++;t<n.length&&n[t]!==s;)t+=n[t]==="\\"?2:1;t++;continue}if(s==="{")o===0&&(i=n.slice(r,t).trim(),r=t+1),o++;else if(s==="}")o--,o===0&&(e.push({prelude:i,body:n.slice(r,t)}),r=t+1),o<0&&(o=0);else if(s===";"&&o===0){let l=n.slice(r,t).trim();l&&e.push({prelude:l,body:null}),r=t+1}t++}return e}function Bb(n){let e=[],t=0,r="",o=0;for(let i=0;i<n.length;i++){let s=n[i];r?s==="\\"?i++:s===r&&(r=""):s==='"'||s==="'"?r=s:s==="("||s==="["?t++:s===")"||s==="]"?t--:s===","&&t===0&&(e.push(n.slice(o,i)),o=i+1)}return e.push(n.slice(o)),e.map(i=>i.trim()).filter(Boolean)}function Fb(n,e){let t=n,r=!1;for(;;){let o=t.match(/^(html|body|:root)(?![\w-])\s*/i);if(!o)break;r=!0,t=t.slice(o[0].length)}if(!r)return`${e} ${n}`;if(/^[.#[:]/.test(t)){let o=t.search(/[\s>+~]/);return o===-1?`${e}${t}`:`${e}${t.slice(0,o)} ${t.slice(o).trim()}`}return t?`${e} ${t}`:e}function cl(n,e){let t=[];for(let{prelude:r,body:o}of Hb(n)){if(o===null){/^@layer\b/i.test(r)&&t.push(`${r};`);continue}if(Pb.test(r))t.push(`${r}{${o}}`);else if(Ib.test(r))t.push(`${r}{${cl(o,e)}}`);else{if(r.startsWith("@"))continue;{let i=Bb(r).map(s=>Fb(s,e));i.length&&t.push(`${i.join(", ")}{${o}}`)}}}return t.join(`
13
- `)}function zb(n,e){return n.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,(t,r,o)=>{if(/^(data:|https?:|\/\/|#)/i.test(o))return t;try{return`url(${r}${new URL(o,e).href}${r})`}catch{return t}})}var Zd=/@import\s+(?:url\(\s*)?(['"]?)([^'")\s;]+)\1\s*\)?([^;]*);/gi;async function ul(n,e=0){let t=new URL(n,document.baseURI).href,r=await fetch(t);if(!r.ok)throw new Error(`HTTP ${r.status}`);let o=zb(await r.text(),t);if(e>=3)return o.replace(Zd,"");let i=[...o.matchAll(Zd)];for(let s of i){let l=s[3].trim(),a="";try{a=await ul(new URL(s[2],t).href,e+1)}catch(c){console.warn(`[nova] contentCss: could not load ${s[2]}`,c)}o=o.replace(s[0],l?`@media ${l}{${a}}`:a)}return o}function ep(n,e){let t=n.getRootNode();if("adoptedStyleSheets"in t&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)try{let i=new CSSStyleSheet;return i.replaceSync(e),t.adoptedStyleSheets=[...t.adoptedStyleSheets,i],()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(s=>s!==i)}}catch{}let o=document.createElement("style");return o.setAttribute("data-nova-content-css",""),o.textContent=e,n.prepend(o),()=>o.remove()}function tp(n={}){return new z({view(e){return new dl(e,n)}})}var dl=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(t){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let h=f.getBoundingClientRect(),g=d?h.bottom:h.top;d&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:h.left,right:h.right,top:g-m,bottom:g+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=zn(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var ke=class n extends F{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):F.near(r)}content(){return D.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new pl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!_b(e)||!$b(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!P.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};ke.prototype.visible=!1;ke.findFrom=ke.findGapCursorFrom;F.jsonID("gapcursor",ke);var pl=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ke.valid(t)?new ke(t):F.near(t)}};function np(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function _b(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||np(o.type))return!0;if(o.inlineContent)return!1}}return!0}function $b(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||np(o.type))return!0;if(o.inlineContent)return!1}}return!0}function rp(){return new z({props:{decorations:jb,createSelectionBetween(n,e,t){return e.pos==t.pos&&ke.valid(t)?new ke(t):null},handleClick:qb,handleKeyDown:Vb,handleDOMEvents:{beforeinput:Wb}}})}var Vb=ro({ArrowLeft:Lo("horiz",-1),ArrowRight:Lo("horiz",1),ArrowUp:Lo("vert",-1),ArrowDown:Lo("vert",1)});function Lo(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof I){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ke.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new ke(c))),!0):!1}}function qb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ke.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&P.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ke(r))),!0)}function Wb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ke))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=A.empty;for(let s=r.length-1;s>=0;s--)o=A.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new D(o,0,0));return i.setSelection(I.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function jb(n){if(!(n.selection instanceof ke))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",G.create(n.doc,[ae.widget(n.selection.head,e,{key:"gapcursor"})])}var Sl={};Z(Sl,{UPLOAD_RETRY_DELAYS:()=>sp,dataUrlToFile:()=>ap,embeddedImageUploadPlugin:()=>gl,exitImageCaption:()=>kl,getSelectedImage:()=>ze,hasImageCaption:()=>yl,imageDropPastePlugin:()=>bl,isSupportedImage:()=>ar,openImageAltDialog:()=>xl,openImageDialog:()=>cr,setImageAttrs:()=>Sn,setImageWidthFraction:()=>Ml,toggleImageCaption:()=>vl,uploadEmbeddedImage:()=>ml,uploadImages:()=>Ro});var Kb=/^image\/(png|jpe?g|gif|webp|avif|bmp)$/;function ar(n){return Kb.test(n.type)}function Ub(n){return new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error??new Error("FileReader failed")),r.readAsDataURL(n)})}function fl(n,e){let t=null;return n.state.doc.descendants((r,o)=>t!==null?!1:(r.type===$(n.state).image&&r.attrs.src===e&&(t=o),!0)),t}function Ro(n,e,t){let r=e.filter(ar),o=n.view;for(let i of r){let s=URL.createObjectURL(i),l=$(o.state).image.create({src:s,alt:null}),a=o.state.tr;t!==void 0?a.insert(Math.min(t,a.doc.content.size),l):a.replaceSelectionWith(l),o.dispatch(a.scrollIntoView()),hl(n,i,s,0)}}var sp=[1e3,3e3],Po=class extends Error{};function hl(n,e,t,r){let o=n.view,{t:i}=n.ui,s=n.options.uploadImage,l=s?n.ui.notify({text:i("image.uploading"),timeout:0}):null,a=s?s(e,d=>l?.setText(`${i("image.uploading")} ${Math.round(d)}%`)):Ub(e),c=()=>URL.revokeObjectURL(t),u=()=>{let d=o.isDestroyed?null:fl(o,t);d!==null&&o.dispatch(o.state.tr.delete(d,d+1).setMeta("addToHistory",!1)),c()};a.then(d=>{if(!ce(d))throw new Po(`Unsafe image URL returned: ${d}`);let p=o.isDestroyed?null:fl(o,t);if(p!==null){let f=o.state.doc.nodeAt(p);o.dispatch(o.state.tr.setNodeMarkup(p,void 0,{...f.attrs,src:d}).setMeta("addToHistory",!1))}c()}).catch(d=>{if(o.isDestroyed||fl(o,t)===null)return c();let p=sp[r];if(s&&p!==void 0&&!(d instanceof Po)){let f=n.ui.notify({text:i("image.retrying"),timeout:0});setTimeout(()=>{if(f.close(),o.isDestroyed)return c();hl(n,e,t,r+1)},p);return}console.error("[nova] image upload failed",d),n.ui.notify({text:i("image.uploadFailed"),type:"error",actions:[{label:i("image.retry"),onAction:()=>hl(n,e,t,0)},{label:i("image.delete"),onAction:u}],onClose:u})}).finally(()=>l?.close())}var lp=/^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i;function ap(n,e="pasted-image"){let t=n.match(lp);if(!t)return null;let r=t[1].toLowerCase();try{let o=atob(t[2]),i=new Uint8Array(o.length);for(let l=0;l<o.length;l++)i[l]=o.charCodeAt(l);let s=r.split("/")[1].replace("jpeg","jpg");return new File([i],`${e}.${s}`,{type:r})}catch{return null}}function Jb(n,e,t){let r=n.state.tr;n.state.doc.descendants((o,i)=>{o.type===$(n.state).image&&o.attrs.src===e&&r.setNodeMarkup(i,void 0,{...o.attrs,src:t})}),r.docChanged&&n.dispatch(r.setMeta("addToHistory",!1))}async function ml(n,e){let t=n.options.uploadImage,r=t?ap(e):null;if(!t||!r)return;let o=n.ui.notify({text:n.ui.t("image.uploading"),timeout:0});try{let i=await t(r,s=>o.setText(`${n.ui.t("image.uploading")} ${Math.round(s)}%`));if(!ce(i))throw new Error(`Unsafe image URL returned: ${i}`);Jb(n.view,e,i)}catch(i){console.error("[nova] embedded image upload failed",i),n.ui.notify({text:n.ui.t("image.uploadFailed"),type:"error",actions:[{label:n.ui.t("image.retry"),onAction:()=>{ml(n,e)}}]})}finally{o.close()}}function op(n,e){let t=new Set;return n.descendants(r=>{r.type===e&&lp.test(r.attrs.src)&&t.add(r.attrs.src)}),t}function gl(n){return new z({key:new K("nova-embedded-image-upload"),appendTransaction(e,t,r){if(!n.options.uploadImage||!e.some(a=>["paste","drop"].includes(a.getMeta("uiEvent")))||!e.some(a=>a.docChanged))return null;let i=$(r).image,s=op(t.doc,i),l=[...op(r.doc,i)].filter(a=>!s.has(a));return l.length&&queueMicrotask(()=>l.forEach(a=>{ml(n,a)})),null}})}function bl(n){return new z({key:new K("nova-image-drop-paste"),props:{handlePaste(e,t){if(!n.isAllowed("image"))return!1;let r=t.clipboardData;if(!r||r.getData("text/html"))return!1;let o=[...r.files].filter(ar);return o.length?(Ro(n,o),!0):!1},handleDrop(e,t){if(!n.isAllowed("image"))return!1;let r=[...t.dataTransfer?.files??[]].filter(ar);if(!r.length)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return Ro(n,r,o?.pos),!0}}})}function cr(n){let{t:e}=n.ui,t=M("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"nova-visually-hidden",tabindex:"-1","aria-label":e("image.drop"),"aria-hidden":"true"}),r=M("button",{type:"button",className:"nova-dropzone"},V(S.upload),M("span",{},e("image.drop"))),o=ee({label:e("image.url"),type:"url",placeholder:"https://"}),i=ee({label:e("image.alt"),hint:e("image.altHint")});gn(n,o,"image",c=>{c.alt&&(i.input.value=c.alt)});let s=M("div",{className:"nova-form"},r,t,M("div",{className:"nova-divider"},M("span",{},e("image.or"))),o.el,i.el),l=n.ui.openDialog({title:e("image.title"),body:s,submitLabel:e("dialog.insert"),initialFocus:o.input,onSubmit:()=>{let c=o.input.value.trim();return!c||!ce(c)?(o.input.setAttribute("aria-invalid","true"),o.input.focus(),e("image.invalid")):(n.exec(nl(c,i.input.value.trim()||void 0)),!0)}}),a=c=>{let u=c.filter(ar);u.length&&(l.close(),Ro(n,u))};r.addEventListener("click",()=>t.click()),t.addEventListener("change",()=>a([...t.files??[]])),r.addEventListener("dragover",c=>{c.preventDefault(),r.classList.add("is-dragover")}),r.addEventListener("dragleave",()=>r.classList.remove("is-dragover")),r.addEventListener("drop",c=>{c.preventDefault(),r.classList.remove("is-dragover"),a([...c.dataTransfer?.files??[]])})}function ze(n){let{selection:e}=n,t=$(n),r=(i,s)=>i.type===t.figure?{node:i,pos:s,attrs:{...i.firstChild?.attrs,align:i.attrs.align}}:{node:i,pos:s,attrs:i.attrs};if(e instanceof P&&(e.node.type===t.image||e.node.type===t.figure))return r(e.node,e.from);let{$from:o}=e;for(let i=o.depth;i>0;i--)if(o.node(i).type===t.figure)return r(o.node(i),o.before(i));return null}function yl(n){return ze(n)?.node.type===$(n).figure}var Gb=["src","alt","title","width","height"],ip=n=>Object.fromEntries(Gb.map(e=>[e,n[e]??null])),vl=(n,e)=>{let t=ze(n);if(!t)return!1;let r=$(n),{pos:o,node:i,attrs:s}=t;if(!e)return!0;let l=n.tr;if(i.type===r.figure){let f=r.image.create({...ip(s),align:s.align??null}),h=[r.paragraph.create(null,f)],g=i.child(1);return g.content.size&&h.push(r.paragraph.create(null,g.content)),l.replaceWith(o,o+i.nodeSize,h),l.setSelection(P.create(l.doc,o+1)),e(l.scrollIntoView()),!0}let a=n.doc.resolve(o),c=a.before(a.depth),u=a.after(a.depth),d=r.figure.create({align:s.align??null},[r.figure_image.create(ip(s)),r.figcaption.create()]),p=3;return a.parent.childCount===1?(l.replaceWith(c,u,d),l.setSelection(I.create(l.doc,c+p))):(l.insert(u,d),l.delete(o,o+i.nodeSize),l.setSelection(I.create(l.doc,l.mapping.map(u,-1)+p))),e(l.scrollIntoView()),!0},kl=(n,e)=>{let{$from:t}=n.selection;if(t.parent.type!==$(n).figcaption)return!1;if(e){let r=t.after(t.depth-1),o=n.tr.insert(r,$(n).paragraph.create());o.setSelection(I.create(o.doc,r+1)),e(o.scrollIntoView())}return!0};function Sn(n){return(e,t)=>{let r=ze(e);if(!r)return!1;if(t){let o=e.tr;if(r.node.type===$(e).figure){let{align:i,...s}=n;if(i!==void 0&&o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,align:i}),Object.keys(s).length){let l=r.node.firstChild;o.setNodeMarkup(r.pos+1,void 0,{...l.attrs,...s})}}else o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,...n}),o.setSelection(P.create(o.doc,r.pos));t(o)}return!0}}function Ml(n,e){let t=ze(n.view.state);if(!t)return!1;if(e===null)return n.exec(Sn({width:null,height:null}));let o=n.view.nodeDOM(t.pos)?.querySelector("img")??null,i=getComputedStyle(n.view.dom),s=n.view.dom.clientWidth-parseFloat(i.paddingLeft||"0")-parseFloat(i.paddingRight||"0"),l=Math.max(24,Math.round(s*e)),a=o&&o.naturalWidth?o.naturalHeight/o.naturalWidth:null;return n.exec(Sn({width:l,height:a?Math.round(l*a):null}))}function xl(n){let e=ze(n.view.state);if(!e)return;let{t}=n.ui,r=ee({label:t("image.alt"),value:String(e.attrs.alt??""),hint:t("image.altHint")}),o=ee({label:t("link.tooltip"),value:String(e.attrs.title??"")});n.ui.openDialog({title:t("image.editAlt"),body:M("div",{className:"nova-form"},r.el,o.el),submitLabel:t("dialog.save"),initialFocus:r.input,onSubmit:()=>(n.exec(Sn({alt:r.input.value.trim()||null,title:o.input.value.trim()||null})),!0)})}var Al={};Z(Al,{InputRule:()=>_e,closeDoubleQuote:()=>dp,closeSingleQuote:()=>fp,ellipsis:()=>Cl,emDash:()=>El,inputRules:()=>wl,openDoubleQuote:()=>up,openSingleQuote:()=>pp,smartQuotes:()=>Zb,textblockTypeInputRule:()=>Io,undoInputRule:()=>Qb,wrappingInputRule:()=>ur});var _e=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Yb(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function Yb(n){return function(e,t,r,o){let i=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);i+=t[0].slice(s+t[1].length),r+=s;let l=r-o;l>0&&(i=t[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}var Xb=500;function wl({rules:n}){let e=new z({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,i){return cp(t,r,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&cp(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function cp(n,e,t,r,o,i){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=n.state.selection,c=l.parent.textBetween(Math.max(0,l.parentOffset-Xb),l.parentOffset,null,"\uFFFC")+r,u=e==a.from&&t==a.to&&n.state.storedMarks||(e==t?l.marks():l.marksAcross(s.doc.resolve(t))||[]);for(let d=0;d<o.length;d++){let p=o[d];if(!p.inCodeMark&&u.some(m=>m.type.spec.code))continue;if(l.parent.type.spec.code){if(!p.inCode)continue}else if(p.inCode==="only")continue;let f=p.match.exec(c);if(!f||f[0].length<r.length)continue;let h=e-(f[0].length-r.length);if(!p.inCodeMark){let m=!1;if(s.doc.nodesBetween(h,l.pos,b=>{b.isInline&&b.marks.some(k=>k.type.spec.code)&&(m=!0)}),m)continue}let g=p.handler(s,f,h,t,r);if(g)return p.undoable&&g.setMeta(i,{transform:g,from:e,to:t,text:r}),n.dispatch(g),!0}return!1}var Qb=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){let s=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1},El=new _e(/--$/,"\u2014",{inCodeMark:!1}),Cl=new _e(/\.\.\.$/,"\u2026",{inCodeMark:!1}),up=new _e(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),dp=new _e(/"$/,"\u201D",{inCodeMark:!1}),pp=new _e(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),fp=new _e(/'$/,"\u2019",{inCodeMark:!1}),Zb=[up,dp,pp,fp];function ur(n,e,t,r){let o,i;return e instanceof qe?i=e:(o=e,i=e.nodeType,t=e.getAttrs,r=e.joinPredicate),new _e(n,(s,l,a,c)=>{let u=t instanceof Function?t(l):t,d=s.tr.delete(a,c),p=d.doc.resolve(a),f=p.blockRange(),h=f&&It(f,i,u);if(!h)return null;d.wrap(f,h);let g=d.doc.resolve(a-1).nodeBefore;return g&&g.type==i&&bt(d.doc,a-1)&&(!r||r(l,g))&&d.join(a-1),d},o)}function Io(n,e,t){let r,o;return e instanceof qe?o=e:(r=e,o=e.nodeType,t=e.getAttrs),new _e(n,(i,s,l,a)=>{let c=i.doc.resolve(l),u=t instanceof Function?t(s):t;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),o)?i.tr.delete(l,a).setBlockType(l,l,o,u):null},r)}function hp(n=()=>!0,e=At){let{nodes:t}=e,r=[Cl,El];n("blockquote")&&r.push(ur(/^\s*>\s$/,t.blockquote)),n("numlist")&&r.push(ur(/^(\d+)\.\s$/,t.ordered_list,o=>({start:Number(o[1])}),(o,i)=>i.childCount+i.attrs.start===Number(o[1]))),n("bullist")&&r.push(ur(/^\s*([-+*])\s$/,t.bullet_list)),n("codeblock")&&r.push(Io(/^```$/,t.code_block));for(let o=1;o<=6;o++)n(`h${o}`)&&r.push(Io(new RegExp(`^(#{${o}})\\s$`),t.heading,{level:o}));return wl({rules:r})}var ey=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ty=vn(Ks,(n,e)=>(e?.(n.tr.replaceSelectionWith($(n).hard_break.create()).scrollIntoView()),!0)),Tl=(n,e)=>(t,r,o)=>n(e)(t,r,o);function mp(n=e=>W[e]){let e={"Mod-z":Tl(n,"undo"),"Shift-Mod-z":Tl(n,"redo"),"Mod-b":W.bold,"Mod-i":W.italic,"Mod-u":W.underline,"Mod-Shift-x":W.strike,"Mod-e":W.code,"Mod-,":W.subscript,"Mod-.":W.superscript,"Mod-Alt-0":W.paragraph,"Mod-Alt-1":W.h1,"Mod-Alt-2":W.h2,"Mod-Alt-3":W.h3,"Mod-Alt-4":W.h4,"Mod-Alt-5":W.h5,"Mod-Alt-6":W.h6,"Mod-Shift-7":W.orderedList,"Mod-Shift-8":W.bulletList,"Mod-Shift-l":W.alignLeft,"Mod-Shift-e":W.alignCenter,"Mod-Shift-r":W.alignRight,"Mod-Shift-j":W.alignJustify,"Mod-\\":W.clearFormatting,"Shift-Enter":ty,Enter:vn(kl,(t,r)=>jd($(t).list_item)(t,r)),Tab:el,"Shift-Tab":tl,"Mod-]":W.indent,"Mod-[":W.outdent};return ey||(e["Mod-y"]=Tl(n,"redo")),[Ke(e),Ke(zd)]}var Dl={};Z(Dl,{applyLink:()=>gp,normalizeUrl:()=>Nl,openLinkDialog:()=>at,removeLink:()=>wn});function Nl(n){let e=n.trim();return e?/^[a-z][a-z0-9+.-]*:/i.test(e)||/^[/#?.]/.test(e)?e:/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e)?`mailto:${e}`:/^(www\.)?[^\s/]+\.[a-z]{2,}([/:?#].*)?$/i.test(e)?`https://${e}`:e:""}function Ol(n){let{from:e,to:t,empty:r,$from:o}=n.selection;return r?Ut(n,Y(n).link,o.pos)??{from:e,to:t}:{from:e,to:t}}function gp(n){return(e,t)=>{let r=Nl(n.href);if(!r||!Oe(r))return!1;if(!t)return!0;let{from:o,to:i}=Ol(e),s=Y(e).link.create({href:r,title:n.title||null,target:n.target||null}),l=e.doc.textBetween(o,i),a=n.text?.trim()?n.text:null,c=e.tr;if(o===i||a!==null&&a!==l){let u=Y(e).link.removeFromSet(e.doc.resolve(o).marks()),d=e.schema.text(a??(l||r),s.addToSet(u));c.replaceWith(o,i,d)}else c.removeMark(o,i,Y(e).link).addMark(o,i,s);return t(c.scrollIntoView()),!0}}function wn(){return(n,e)=>{let{from:t,to:r}=Ol(n);return t===r||!n.doc.rangeHasMark(t,r,Y(n).link)?!1:(e?.(n.tr.removeMark(t,r,Y(n).link)),!0)}}function at(n){let{t:e}=n.ui,t=n.view.state,r=Kt(t),o=Ol(t),i=t.doc.textBetween(o.from,o.to),s=!i.includes(`
14
- `)&&t.selection.$from.sameParent(t.doc.resolve(o.to)),l=ee({label:e("link.url"),type:"url",value:r?.href??"",placeholder:"https://",required:!0}),a=ee({label:e("link.text"),value:i}),c=ee({label:e("link.tooltip"),value:r?.title??""}),u=Ac(e("link.newTab"),r?.target==="_blank");gn(n,l,"file",p=>{p.text&&!a.input.value.trim()&&(a.input.value=p.text),p.title&&(c.input.value=p.title)});let d=M("div",{className:"nova-form"},l.el,s?a.el:null,c.el,u.el);n.ui.openDialog({title:e(r?"link.editTitle":"link.title"),body:d,submitLabel:e(r?"dialog.save":"dialog.insert"),initialFocus:l.input,onSubmit:()=>{let p=Nl(l.input.value);return!p||!Oe(p)?(l.input.setAttribute("aria-invalid","true"),l.input.focus(),e("link.invalid")):(n.exec(gp({href:p,...s?{text:a.input.value}:{},title:c.input.value.trim()||null,target:u.input.checked?"_blank":null})),!0)}})}function ny(n,e){let t=0;for(let r=e;r<n.length;r++){let o=n[r];if(o==="\\"){r++;continue}if(o==="{")t++;else if(o==="}"&&(t--,t===0))return r}return-1}function ry(n){let e="",t=0;for(let r=0;r<n.length;r++){let o=n[r];if(o==="\\"){t===0&&(e+=o+(n[r+1]??"")),r++;continue}o==="{"?t++:o==="}"?t--:t===0&&(e+=o)}return e}var oy=20*1024*1024;function iy(n){if(n.length%2!==0||n.length/2>oy||!/^[0-9a-f]+$/i.test(n))return null;let e="";for(let t=0;t<n.length;t+=2)e+=String.fromCharCode(parseInt(n.slice(t,t+2),16));return btoa(e)}function Ll(n){let e=[],t=0;for(;;){let r=n.indexOf("{\\pict",t);if(r<0)break;let o=ny(n,r);if(o<0)break;if(t=o+1,/\\nonshppict\s*$/.test(n.slice(Math.max(0,r-16),r)))continue;let i=ry(n.slice(r+1,o)),s=/\\pngblip(?![a-z])/.test(i)?"image/png":/\\jpegblip(?![a-z])/.test(i)?"image/jpeg":null;if(!s)continue;let l=i.replace(/\\[a-z]+-?\d* ?/gi,"").replace(/\s+/g,""),a=iy(l);if(!a)continue;let c=atob(a.slice(0,12));(s==="image/png"?c.startsWith("\x89PNG"):c.charCodeAt(0)===255&&c.charCodeAt(1)===216)&&e.push({type:s,base64:a})}return e}function Rl(n){return/<img[^>]+src=["']?file:/i.test(n)}function Pl(n,e){let t=document.createElement("template");t.innerHTML=n;let r=[...t.content.querySelectorAll("img")].filter(o=>/^file:/i.test(o.getAttribute("src")??""));return!r.length||r.length!==e.length?n:(r.forEach((o,i)=>{let s=e[i];o.setAttribute("src",`data:${s.type};base64,${s.base64}`)}),t.innerHTML)}var Ho=null,Il=null;function Hl(){return Il??(Il=import(__novaChunk("tinymce-chunks/paste-office-a38659d6.js") ).then(n=>Ho=n,()=>(Il=null,null))),Il}var sy=new K("nova-paste");function ly(n){let e=document.createElement("template");e.innerHTML=n;let t=/^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/,r="",o=i=>{if(i.nodeType===Node.TEXT_NODE){r+=(i.textContent??"").replace(/\s+/g," ");return}if(!(i instanceof Element)){i.childNodes.forEach(o);return}if(/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(i.tagName))return;if(i.tagName==="BR"){r+=`
9
+ `);return{dom:a,text:p,slice:e}}function Ul(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,i||r,n)}),i)return l=new D(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
10
+ `))),0,0),n.someProp("transformPasted",p=>{l=p(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",p=>p(e,o,r,n));if(d)l=d;else{let p=o.marks(),{schema:f}=n.state,h=qe.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(f.text(m,p)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),s=Sk(t),ei&&Mk(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let p=s.firstChild;for(;p&&!W(p);)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Mt.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!vk.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ek(of(l,+u[1],+u[2]),u[4]);else if(l=D.maxOpen(xk(l.content,o),!0),l.openStart||l.openEnd){let d=0,p=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;p<l.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);l=of(l,d,p)}return n.someProp("transformPasted",d=>{l=d(l,n,r)}),l}var vk=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function xk(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&zf(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=$f(s[s.length-1],i.length));let u=Ff(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return T.from(s)}return n}function Ff(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function zf(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=zf(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(T.from(Ff(t,n,o+1))))}}function $f(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,$f(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(r))}function Il(n,e,t,r,o,i){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(i=0),o<r-1&&(l=Il(l,e,t,r,o+1,i)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function of(n,e,t){return e<n.openStart&&(n=new D(Il(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new D(Il(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Vf={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function qf(){return document.implementation.createHTMLDocument("title")}var Dr=null;function wk(n){let e=window.trustedTypes;if(!e)return n;if(!Dr){if(Dr=e.defaultPolicy)try{return Dr.createHTML(n)}catch{}Dr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Dr.createHTML(n)}function Sk(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=qf(),r=t.body,o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&Vf[o[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=wk(n),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Mk(n){let e=n.querySelectorAll(Pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Ek(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs()||!a.createAndFill(null,o))break;try{o=T.from(a.create(r[l+1],o))}catch{break}i++,s++}return new D(o,i,s)}var Be=class n{constructor(e,t,r,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=o}static from(e){return e instanceof n?e:new n(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};Be.null=new Be(null,0,null,0);var Hl=class{constructor(e){this.view=e,this.range=Be.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=Be.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?Re&&e.root.nodeType===11&&Kb(e.dom.ownerDocument)==e.dom?Be.from(Ck(e,t)||t):Be.from(t):Be.null}read(){this.ensureListener();let e=Kf(this.view);if(!e){this.active=!1,this.range=Be.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{Lk(t,t.state.selection);let r=t.state.selection;if(t.input.mouseDown||jf(t)){let{desc:o,start:i}=Wf(t.docView,r.from,r.to,0);t.cursorWrapper?Ok(t):o instanceof Uo&&o.spec.setSelection?o.spec.setSelection(r.anchor-i,r.head-i,t.root):Ak(t,e,o,i),this.synced=this.active=!0}r.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),Nk(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=Be.from(e),this.synced=!0}deactivate(){this.range=Be.null,this.active=this.synced=!1}};function Ck(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return sf(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?sf(n,t):null}function sf(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return qo(s.node,s.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),new Be(t,r,o,i)}function Jl(n,e,t=null){let r=n.state.doc;if(!e.focusNode)return null;let o=n.docView.nearestDesc(e.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Qo(e)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&R.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&jb(e.focusNode,e.focusOffset,o.dom))){let d=o.posBefore;c=new R(s==d?l:r.resolve(d))}else if(Ye&&t=="key"&&s>n.state.selection.to&&W(e.focusNode)&&e.focusOffset==e.focusNode.childNodes.length&&o&&o.posAtStart>n.state.selection.to)for(let d=e.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=U.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!W(d.parentNode))break}}else{if(e instanceof n.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let d=s,p=s;for(let f=0;f<e.rangeCount;f++){let h=e.getRangeAt(f);d=Math.min(d,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(d<0)return null;[a,s]=p==n.state.selection.anchor?[p,d]:[d,p],l=r.resolve(s)}else a=n.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=t=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=Xn(n,u,l,d)}return c}function jf(n){return n.editable?n.hasFocus():Uf(n,n.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(n.dom))}function Ak(n,e,t,r){let o=n.state.selection,{anchor:i,head:s}=o,l,a;lf&&!(o instanceof F)&&(o.$from.parent.inlineContent||(l=af(n,o.from)),!o.empty&&!o.$from.parent.inlineContent&&(a=af(n,o.to)));let c=t.domFromPos(i-r,i>r?-1:1),u=s==i?c:t.domFromPos(s-r,s>r?-1:1);Tk(i,s,c,u,n,e),lf&&(l&&cf(l),a&&cf(a))}function Wf(n,e,t,r=0){for(let o=0,i=r;o<n.children.length;o++){let s=n.children[o],l=i+s.size;if(e>i&&t<l)return Wf(s,e,t,i+s.border);i=l}return{desc:n,start:r}}function Tk(n,e,t,r,o,i){let s=!1;if((Ye||Re)&&n==e){let{node:a,offset:c}=t;if(ke(a)){if(s=!!(c&&a.nodeValue[c-1]==`
11
+ `),s&&c==a.nodeValue.length)for(let u=a,d;u;u=u.parentNode){if(d=u.nextSibling){d.nodeName=="BR"&&(t=r={node:d.parentNode,offset:Le(d)+1});break}let p=u.pmViewDesc;if(p&&p.node&&p.node.isBlock)break}}else{let u=a.childNodes[c-1];s=u&&(u.nodeName=="BR"||u.contentEditable=="false")}}let l=o.domSel.readRange();if(Ye&&l.focusNode&&l.focusNode!=r.node&&W(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(i=!0)}!(i||s&&Re)&&qo(t.node,t.offset,l.anchorNode,l.anchorOffset)&&qo(r.node,r.offset,l.focusNode,l.focusOffset)||Cf(o.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:t.node,anchorOffset:t.offset})}var lf=Re||Pe&&Af<63;function af(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Re&&o&&o.contentEditable=="false")return El(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return El(o);if(i)return El(i)}}function El(n){return n.contentEditable="true",Re&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function cf(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Nk(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSel.readRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!jf(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ok(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom;t.nodeName=="IMG"?e.collapse(t.parentNode,Le(t)+1):e.collapse(t,0)}function Lk(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(uf(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else uf(n)}function uf(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Xn(n,e,t,r){let o=n.someProp("createSelectionBetween",i=>i(n,e,t))||F.between(e,t,r);return n.someProp("adjustSelectionFromDOM",i=>{o=i(n,o)}),o}function Kf(n){if(n.editable&&!n.hasFocus())return null;let e=n.domSel.readRange();return e&&Uf(n,e)?e:null}function Uf(n,e){if(!e.anchorNode)return!1;try{return Jn(n.dom,e.anchorNode)&&(n.editable||Jn(n.dom,e.focusNode))}catch{return!1}}var De={},_e={},Pk={touchstart:!0,touchmove:!0},Bl=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Rk(n){for(let e in De){let t=De[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{_k(n,r)&&(n.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&Yf(n,!0),!Gl(n,r)&&(n.editable||!(r.type in _e))&&t(n,r))},Pk[e]?{passive:!0}:void 0)}Re&&n.dom.addEventListener("input",()=>null),Fl(n)}function ti(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Dk(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Fl(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Gl(n,r))})}function Gl(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function _k(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ik(n,e){!Gl(n,e)&&De[e.type]&&(n.editable||!(e.type in _e))&&De[e.type](n,e)}function Wt(n,e){let{input:t}=n;return t.lastKeyDispatched||n.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=Wb(e=="Backspace"?8:13,e)),n.someProp("handleKeyDown",r=>r(n,e)))}_e.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),n.input.lastKeyDispatched=!1,!(Ot&&Pe&&t.keyCode==13)){if(Yn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(Wt(n,"Enter"),n.input.lastIOSEnter=0)},200);return}t.keyCode!=229&&n.domObserver.forceFlush(!0),Wt(n,t)||kk(n,t)?t.preventDefault():ti(n,"key")}};_e.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};_e.keypress=(n,e)=>{let t=e;if(jk(n)||!t.charCode||t.ctrlKey&&!t.altKey||We&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};function Fr(n){return{left:n.clientX,top:n.clientY}}function Hk(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Yl(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function Jf(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Bk(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(Jf(n,new R(t)),!0):!1}function Fk(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof R&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(R.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(Jf(n,R.create(n.state.doc,o)),!0):!1}function zk(n,e,t,r,o){return Yl(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?Fk(n,t):Bk(n,t))}function $k(n,e,t,r){return Yl(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Vk(n,e,t,r){return Yl(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))}function df(n,e,t){if(e==-1)return n.inlineContent?F.create(n,0,n.content.size):null;let r=n.resolve(e);for(let o=r.depth+1;o>0;o--){let i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)return F.create(n,s+1,s+1+i.content.size);if(t&&R.isSelectable(i))return R.create(n,s)}return null}var zl=/[\w_\u00a1-\uffff]+/g;try{zl=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function pf(n,e){let t=n.resolve(e),r=t.node(),o="",i=e,s=e;for(let m=t.indexAfter(),g=!1;m>0;m--){let k=r.child(m-1);if(!k.text)break;let x=i==e?e-t.posAtIndex(m-1):k.text.length,M=x;for(;M>0;M--)if(/\S/.test(k.text[M-1]))g=!0;else if(g)break;if(o=k.text.slice(M,x)+o,i-=x-M,M||i<e-50)break}for(let m=t.index(),g=!1;m<r.childCount;m++){let k=r.child(m);if(!k.text)break;let x=s==e?e-t.posAtIndex(m):0,M=x;for(;M<k.text.length;M++)if(/\S/.test(k.text[M]))g=!0;else if(g)break;if(o+=k.text.slice(x,M),s+=M-x,M<k.text.length||s>e+50)break}let l=i,a=s;if(Intl.Segmenter){for(let m of new Intl.Segmenter(void 0,{granularity:"word"}).segment(o))if(m.isWordLike){let g=m.index+i,k=g+m.segment.length;if(k<e)l=k;else if(g>e){a=g;break}else return F.create(n,g,k)}}else{zl.lastIndex=0;for(let m;m=zl.exec(o);){let g=m.index+i,k=g+m[0].length;if(k<e)l=k;else if(g>e){a=g;break}else return F.create(n,g,k)}}let c=o.slice(l-i,e-i),u=o.slice(e-i,a-i),d=/\S*$/.exec(c)[0].length,p=/^\S*/.exec(u)[0].length;if(d||p)return F.create(n,e-d,e+p);let f=/\s*$/.exec(c)[0].length,h=/^\s*/.exec(u)[0].length;return F.create(n,e-f,e+h)}var Gf=We?"metaKey":"ctrlKey";De.mousedown=(n,e)=>{let t=e,r=Date.now();if(n.input.shiftKey=t.shiftKey,n.input.lastTouch>r-500)return!1;Jt(n);let o="singleClick";r-n.input.lastClick.time<500&&Hk(t,n.input.lastClick)&&!t[Gf]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let i=n.posAtCoords(Fr(t));if(i)if(t.button==0){if(!n.hasFocus()){Lf(n.dom);let l=n.root.activeElement;l&&!l.contains(n.dom)&&l.blur()}(n.input.mouseDown=new $l(n,i,t,o)).mightDrag||t.preventDefault()}else ti(n,"pointer")};var $l=class{constructor(e,t,r,o){var i;this.view=e,this.startPos=t,this.event=r,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[Gf],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let s=ff(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof R?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof R?e.nodeDOM(l.from).getBoundingClientRect():e.coordsAtPos(l.anchor);this.anchorOffset={x:(a.left+a.right)/2-s.x,y:(a.top+a.bottom)/2-s.y}}else this.anchorOffset={x:r.clientX-s.x,y:r.clientY-s.y};if(o=="singleClick"){let{selection:l}=e.state,a,c,u=!1;if(l instanceof R&&l.from<=t.pos&&l.to>=t.pos)c=l.from,a=l.node,u=!0;else if(t.inside>-1)a=e.state.doc.nodeAt(t.inside),c=t.inside;else{let d=e.state.doc.resolve(t.pos);a=d.parent,c=d.depth?d.before():-1}if(u||c>-1&&a.type.spec.draggable&&a.type.spec.selectable!==!1){let d=(i=e.docView.descAt(c))===null||i===void 0?void 0:i.nodeDOM;this.mightDrag={node:a,elt:d,pos:c,addAttr:!1},d&&!d.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>d.draggable=!0))}else this.mightDrag=qk(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,t){return(this.type=="singleClick"?zk:this.type=="doubleClick"?$k:Vk)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Fr(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(Fr(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:o}=r.state,i=this.type=="singleClick"?hf(r,o,e):this.type=="doubleClick"?pf(o,e.pos):df(o,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=Xn(r,o.resolve(this.anchorRange.from),o.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=Xn(r,o.resolve(this.anchorRange.to),o.resolve(i.from)))),i.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()))}restoreAnchor(){let e=ff(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?hf(this.view,r,t):this.type=="doubleClick"?pf(r,t.pos):df(r,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function ff(n){let e=n.dom.getBoundingClientRect();return{x:e.left-n.dom.scrollLeft,y:e.top-n.dom.scrollTop}}function hf(n,e,t){if(t.inside>-1){let o=e.nodeAt(t.inside);if(o.isAtom&&R.isSelectable(o))return R.create(e,t.inside)}let r=e.resolve(t.pos);return Xn(n,r,r)}function qk(n,e){let{selection:t}=n.state;if(t.empty)return!1;let r=n.domSelection();if(!r||r.rangeCount==0)return!0;let o=r.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}De.touchstart=n=>{n.input.lastTouch=Date.now(),Jt(n),ti(n,"pointer")};De.touchmove=n=>{n.input.lastTouch=Date.now(),ti(n,"pointer")};De.contextmenu=n=>Jt(n);function jk(n,e){return n.composing?!0:Re&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Wk=Ot?5e3:-1;_e.compositionstart=_e.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Pe&&Tf&&Kk(n)))n.markCursor=n.state.storedMarks||t.marks(),Jt(n,!0),n.markCursor=null;else if(Jt(n,!e.selection.empty),Ye&&n.domSel.active&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:o}=n.domSel.range;r&&W(r)&&o!=0;){let i=o<0?r.lastChild:r.childNodes[o-1];if(!i)break;if(ke(i)){let s=n.domSelection();s&&s.collapse(i,i.nodeValue.length);break}else r=i,o=-1}n.input.composing=!0}Xf(n,Wk)};function Kk(n){let{focusNode:e,focusOffset:t}=n.domSel.range;if(!e||!W(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return W(r)&&r.contentEditable=="false"}_e.compositionend=(n,e)=>{n.composing&&Yf(n)};function Yf(n,e=!1){n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,e?Jt(n):Xf(n,20)}function Xf(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jt(n),e))}function Zf(n){n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());for(let e;e=n.input.compositionNodes.pop();)e.markParentDamage()}function Uk(n){let e=n.domSel.range;if(!n.domSel.active||!e.focusNode)return null;let t=Mf(e.focusNode,e.focusOffset),r=Ef(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Jt(n,e=!1){if(!(Ot&&n.domObserver.flushingSoon>=0)&&(n.domObserver.forceFlush(),Zf(n),e||n.docView&&n.docView.damage)){let t=Jl(n,n.domSel.readRange()),r=n.state.selection;t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state)}}function Jk(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var zr=Yn&&Jb<604;De.copy=_e.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=zr?null:t.clipboardData,s=r.content(),{dom:l,text:a}=Kl(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Jk(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Gk(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Yk(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?$r(n,r.value,null,o,e):$r(n,r.textContent,r.innerHTML,o,e)},50)}function $r(n,e,t,r,o){let i=Ul(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||D.empty)))return!0;if(!i)return!1;let s=Gk(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Qf(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}_e.paste=(n,e)=>{let t=e;if(n.composing&&!Ot)return;let r=zr?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&$r(n,Qf(r),r.getData("text/html"),o,t)?t.preventDefault():Yk(n,t)};var Go=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Xk=We?"altKey":"ctrlKey";function eh(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Xk]}De.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Fr(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof R?o.to-1:o.to))){if(r&&typeof r.mightDrag=="object")s=R.create(n.state.doc,r.mightDrag.pos);else if(t.target&&W(t.target)){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=R.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=Kl(n,l);(!t.dataTransfer.files.length||!Pe||Af>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(zr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",zr||t.dataTransfer.setData("text/plain",c),n.dragging=new Go(u,eh(n,t),s)};De.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};_e.dragover=_e.dragenter=(n,e)=>e.preventDefault();_e.drop=(n,e)=>{try{Zk(n,e,n.dragging)}finally{n.dragging=null}};function Zk(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Fr(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",f=>{i=f(i,n,!1)}):i=Ul(n,Qf(e.dataTransfer),zr?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(t&&eh(n,e));if(n.someProp("handleDrop",f=>f(n,e,i||D.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Nr(n.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=n.state.tr;if(s){let{node:f}=t;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let p=a.doc.resolve(c);if(u&&R.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new R(p));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,m,g,k)=>f=k),a.setSelection(Xn(n,p,a.doc.resolve(f)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}De.focus=n=>{if(n.input.lastFocus=Date.now(),!n.focused&&(n.domObserver.stopped(()=>n.dom.classList.add("ProseMirror-focused")),n.focused=!0,n.domSel.read(),!n.domSel.synced)){let e=n.domSel.range;setTimeout(()=>{let t=n.domSel.readRange();t&&e.eq(t)&&n.domSel.sync()},20)}};De.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stopped(()=>n.dom.classList.remove("ProseMirror-focused")),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domSel.deactivate(),n.focused=!1)};De.beforeinput=(n,e)=>{if(Ot&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||n.domObserver.pendingRecords().length||(n.dom.blur(),n.focus(),Wt(n,"Backspace")))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in _e)De[n]=_e[n];function Vr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var qr=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},Yo=class n{constructor(e,t){this.toDOM=e,this.spec=t||mn,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new ge(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},hn=class n{constructor(e,t){this.attrs=e,this.spec=t||mn}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ge(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Vl=class n{constructor(e,t){this.attrs=e,this.spec=t||mn}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new ge(i.pos-r,s.pos-r,this)}valid(e,t,r){let o=r.nodeAt(t.from);return!!o&&!o.isText&&t.from+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}destroy(){}},ge=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Yo(t,r))}static inline(e,t,r,o){return new n(e,t,new hn(r,o))}static node(e,t,r,o){return new n(e,t,new Vl(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof hn}get widget(){return this.type instanceof Yo}},Kn=[],mn={},ae=class n{constructor(e,t){this.local=e.length?e:Kn,this.children=t.length?t:Kn}static create(e,t){return t.length?Zo(t,e,0,mn):Se}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from>t)break;l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length&&!(this.children[s]>=t);s+=3)if(this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==Se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||mn)}mapInner(e,t,r,o,i){let s;if(this.local.length){let l=new qr(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?Qk(this.children,s||[],e,t,r,o,i):s?new n(s.sort(Kt),Kn):Se}add(e,t){return t.length?this==Se?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=nh(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,Zo(u,l,c+1,mn)),i+=3}});let s=th(i?rh(t):t,-r).sort(Kt);if(s.length){let l=new qr(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(Kt):this.local,o||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Se?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):Se}forChild(e,t){if(this==Se)return this;if(t.isLeaf)return n.empty;let r,o,i=0,s=this.children.length/3;for(;i<s;){let c=i+s>>>1,u=c*3,d=this.children[u];if(d<e)i=c+1;else if(d>e)s=c;else{r=this.children[u+2];break}}let l=e+1,a=l+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>l&&u.type instanceof hn){let d=Math.max(l,u.from)-l,p=Math.min(a,u.to)-l;d<p&&(o||(o=[])).push(u.copy(d,p))}}if(o){let c=new n(o.sort(Kt),Kn);return r?new Xo([c,r]):c}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Xl(this.localsInner(e))}localsInner(e){if(this==Se)return Kn;if(e.inlineContent||!this.local.some(hn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof hn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};ae.empty=new ae([],[]);ae.removeOverlap=Xl;var Se=ae.empty,Xo=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(o=>o.map(e,t,mn));return n.from(r)}forChild(e,t){if(t.isLeaf)return ae.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Se&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?Xl(r?t:t.sort(Kt)):Kn}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new n(e.every(t=>t instanceof ae)?e:e.reduce((t,r)=>t.concat(r instanceof ae?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Qk(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((p,f,h,m)=>{let g=m-h-(f-p);for(let k=0;k<l.length;k+=3){let x=l[k+1];if(x<0||p>x+u-d)continue;let M=l[k]+u-d;f>=M?l[k+1]=p<=M?-2:-1:p>=u&&g&&(l[k]+=g,l[k+1]+=g)}d+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let p=t.map(n[c+1]+i,-1),f=p-o,{index:h,offset:m}=r.content.findIndex(d),g=r.maybeChild(h);if(g&&m==d&&m+g.nodeSize==f){let k=l[c+2].mapInner(t,g,u+1,n[c]+i+1,s);k!=Se?(l[c]=d,l[c+1]=f,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ev(l,n,e,t,o,i,s),u=Zo(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<u.children.length;d+=3){let f=u.children[d];for(;p<l.length&&l[p]<f;)p+=3;l.splice(p,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ae(e.sort(Kt),l)}function th(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new ge(o.from+e,o.to+e,o.type))}return t}function ev(n,e,t,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function nh(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function rh(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Zo(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=nh(n,l,a+t);if(c){i=!0;let u=Zo(c,l,t+a+1,r);u!=Se&&o.push(a,a+l.nodeSize,u)}});let s=th(i?rh(n):n,-t).sort(Kt);if(s.length){let l=new qr(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||o.length?new ae(s,o):Se}function Kt(n,e){return n.from-e.from||n.to-e.to}function Xl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),mf(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),mf(e,o,r.copy(i.from,r.to)));break}}}return e}function mf(n,e,t){for(;e<n.length&&Kt(t,n[e])>0;)e++;n.splice(e,0,t)}function Cl(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Se&&e.push(r)}),n.cursorWrapper&&e.push(ae.create(n.state.doc,[n.cursorWrapper.deco])),Xo.from(e)}function tv(n,e,t,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSel.range,u,d=c.anchorNode;if(d&&Jn(n.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],Qo(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Pe&&n.input.lastKeyCode===8)for(let k=s;k>i;k--){let x=o.childNodes[k-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){s=k;break}if(!M||M.size)break}let p=n.state.doc,f=n.someProp("domParser")||Mt.fromSchema(n.state.schema),h=p.resolve(l),m=null,g=f.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:nv(r),context:h});if(u&&u[0].pos!=null){let k=u[0].pos,x=u[1]&&u[1].pos;x==null&&(x=k),m={anchor:k+l,head:x+l}}return{doc:g,sel:m,from:l,to:a}}var nv=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(Re&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Re&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},rv=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function ov(n,e,t,r,o,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let P=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,G=Jl(n,n.domSel.range,P);if(G&&!n.state.selection.eq(G)&&n.domSel.active){if(Pe&&Ot&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&Wt(n,"Enter"))return;let y=n.state.tr.setSelection(G);P=="pointer"?y.setMeta("pointer",!0):P=="key"&&y.scrollIntoView(),s&&y.setMeta("composition",s),n.dispatch(y)}return}let l=n.state.doc.resolve(e),a=l.sharedDepth(t);e=l.before(a+1),t=n.state.doc.resolve(t).after(a+1);let c=n.state.selection,u=tv(n,e,t,i),d=n.state.doc,p=d.slice(u.from,u.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=av(p.content,u.doc.content,u.from,f,h);if(m&&n.input.domChangeCount++,(Yn&&n.input.lastIOSEnter>Date.now()-225||Ot)&&i.some(P=>W(P)&&!rv.test(P.nodeName))&&(!m||m.endA>=m.endB)&&Wt(n,"Enter")){n.input.lastIOSEnter=0;return}if(!m)if(o&&c instanceof F&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let P=gf(n,n.state.doc,u.sel);if(P&&!P.eq(n.state.selection)){let G=n.state.tr.setSelection(P);s&&G.setMeta("composition",s),n.dispatch(G)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof F&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to));let g=u.doc.resolveNoCache(m.start-u.from),k=u.doc.resolveNoCache(m.endB-u.from),x=d.resolve(m.start),M=g.sameParent(k)&&g.parent.inlineContent&&x.end()>=m.endA;if((Yn&&n.input.lastIOSEnter>Date.now()-225&&(!M||i.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!M&&lv(u.doc,g.pos,k.pos))&&Wt(n,"Enter")){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&(M?m.endA>m.start&&m.endB==m.start:sv(d,m.start,m.endA,g,k))&&Wt(n,"Backspace")){Ot&&Pe&&n.domSel.suppressChanges();return}Pe&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Ot&&!M&&g.start()!=k.start()&&k.parentOffset==0&&g.depth==k.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,k=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>Wt(n,"Enter"),20));let L=m.start,O=m.endA,B=P=>{let G=P||n.state.tr.replace(L,O,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let y=gf(n,G.doc,u.sel);y&&!(Pe&&n.composing&&y.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(y.head==L||y.head==G.mapping.map(O)-1))&&G.setSelection(y)}return s&&G.setMeta("composition",s),G.scrollIntoView()},J;if(M)if(g.pos==k.pos){let P=B(n.state.tr.delete(L,O)),G=d.resolve(m.start).marksAcross(d.resolve(m.endA));G&&P.ensureMarks(G),n.dispatch(P)}else if(m.endA==m.endB&&(J=iv(g.parent.content.cut(g.parentOffset,k.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let P=B(n.state.tr);J.type=="add"?P.addMark(L,O,J.mark):P.removeMark(L,O,J.mark),n.dispatch(P)}else if(g.parent.child(g.index()).isText&&g.index()==k.index()-(k.textOffset?0:1)){let P=g.parent.textBetween(g.parentOffset,k.parentOffset),G=()=>B(n.state.tr.insertText(P,L,O));n.someProp("handleTextInput",y=>y(n,L,O,P,G))||n.dispatch(G())}else n.dispatch(B());else n.dispatch(B())}function gf(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Xn(n,e.resolve(t.anchor),e.resolve(t.head))}function iv(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(T.from(c).eq(n))return{mark:l,type:s}}function sv(n,e,t,r,o){if(t-e<=o.pos-r.pos||Al(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Al(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Al(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function lv(n,e,t){let r=0,o=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&o++}),o==0&&r==1}function Al(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function av(n,e,t,r,o){let i=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(o=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var cv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ql=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let r=0;r<t.length;r++)this.queue.push(t[r]);Re&&e.composing&&t.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,cv),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=Un(i))t.add(i);for(let i=e.anchorNode;i;i=Un(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:ke(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&t.domSel.read();let o=!t.domSel.suppress&&!t.domSel.synced&&!!Kf(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let u=0;u<r.length;u++){let d=this.registerMutation(r[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Pe&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&r.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&W(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ye&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,p]=u;d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}else{let{focusNode:d}=t.domSel.range;for(let p of u){let f=p.parentNode;f&&f.nodeName=="LI"&&(!d||dv(t,d)!=f)&&p.remove()}}}let c=null;i<0&&o&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Qo(t.domSel.range)&&(c=Jl(t,t.domSel.range))&&c.eq(U.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||o)&&(i>-1&&uv(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,pv(t,a)),ov(this.view,i,s,o,l,a),t.docView&&t.docView.damage?t.updateState(t.state):o&&t.domSel.sync())}registerMutation(e,t){var r;if(t.indexOf(e.target)>-1)return null;let o;for(let i=e.target;i&&!(o=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),ke(p)&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return o.markDamage(4),{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,s=e.nextSibling,l=i&&i.parentNode==e.target?Le(i)+1:0,a=o.localPosFromDOM(e.target,l,-1),c=s&&s.parentNode==e.target?Le(s):e.target.childNodes.length,u=o.localPosFromDOM(e.target,c,1);return o.markDamage(!((r=o.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:a,to:u}}else return e.type=="attributes"?(o.markDamage(4),{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}):(this.lastChangedTextNode=e.target,o.markDamage(o instanceof Hr&&e.target==o.nodeDOM?8:4),{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},yf=new WeakMap,bf=!1;function uv(n){if(!yf.has(n)&&(yf.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ye,bf)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),bf=!0}}function dv(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function pv(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSel.range;for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!W(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}var fv=Ul,hv=Jt,Zn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Bl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Sf),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=xf(this),vf(this),this.nodeViews=wf(this),this.docView=Xp(this.state.doc,kf(this),Cl(this),this.dom,this),this.domObserver=new ql(this),this.domSel=new Hl(this),this.domObserver.start(),this.domSel.read(),Rk(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Fl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Sf),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Zf(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=wf(this);gv(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Fl(this),this.editable=xf(this),vf(this);let a=Cl(this),c=kf(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let p=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Xb(this);s&&this.domObserver.stopped(()=>{let f=d&&Pe&&!this.composing&&!o.selection.empty&&!e.selection.empty&&mv(o.selection,e.selection);if(d){let h=Pe?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=Uk(this)),i||!this.docView.update(e.doc,c,a,this,-1)){let m=this.docView.outerDeco;this.docView.destroy(),this.docView=Xp(e.doc,c,a,this.dom,this,m)}h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}this.domSel.sync(f)}),this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&Zb(p)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);W(t)&&Up(this,t.getBoundingClientRect(),e)}else Up(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Go(e.slice,e.move,o<0?void 0:R.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&Lf(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return t||document}updateRoot(){this._root=null}posAtCoords(e){return rk(this,e)}coordsAtPos(e,t=1){return Df(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return ak(this,t||this.state,e)}pasteHTML(e,t){return $r(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return $r(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Kl(this,e)}destroy(){this.docView&&(Dk(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Cl(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,qb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ik(this,e)}domSelection(){return this.root.getSelection()}};Zn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function kf(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ge.node(0,n.state.doc.content.size,e)]}function vf(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ge.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function xf(n){return!n.someProp("editable",e=>e(n.state)===!1)}function mv(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function wf(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function gv(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Sf(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var na={};q(na,{keydownHandler:()=>ri,keymap:()=>Ke});var ea={};q(ea,{base:()=>pt,keyName:()=>Ql,shift:()=>jr});var pt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},jr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yv=typeof navigator<"u"&&/Mac/.test(navigator.platform),bv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(pe=0;pe<10;pe++)pt[48+pe]=pt[96+pe]=String(pe);var pe;for(pe=1;pe<=24;pe++)pt[pe+111]="F"+pe;var pe;for(pe=65;pe<=90;pe++)pt[pe]=String.fromCharCode(pe+32),jr[pe]=String.fromCharCode(pe);var pe;for(ni in pt)jr.hasOwnProperty(ni)||(jr[ni]=pt[ni]);var ni;function Ql(n){var e=yv&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||bv&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?jr:pt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var kv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),vv=typeof navigator<"u"&&/Win/.test(navigator.platform);function xv(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))kv?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function wv(n){let e=Object.create(null);for(let t in n)e[xv(t)]=n[t];return e}function ta(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ke(n){return new z({props:{handleKeyDown:ri(n)}})}function ri(n){let e=wv(n);return function(t,r){let o=Ql(r),i,s=e[ta(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[ta(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(vv&&r.ctrlKey&&r.altKey)&&(i=pt[r.keyCode])&&i!=o){let l=e[ta(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var la={};q(la,{COMMENT_ID_RE:()=>yn,COMMENT_MAX_LENGTH:()=>oi,COMMENT_NAME_MAX_LENGTH:()=>ia,createCommentStore:()=>sa,newCommentId:()=>ii,sanitizeThread:()=>ra});var yn=/^[A-Za-z0-9_-]{1,64}$/,oi=5e3,ia=80;function ii(n="c"){let e=new Uint8Array(9);return globalThis.crypto.getRandomValues(e),n+Array.from(e,t=>(t%36).toString(36)).join("")}function ra(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!yn.test(e.id))return null;let t=Array.isArray(e.comments)?e.comments.map(oh).filter(i=>i!==null):[],r=e.resolved,o={id:e.id,createdAt:Number(e.createdAt)||0,comments:t,resolved:r&&typeof r=="object"?{by:oa(r.by),at:Number(r.at)||0}:null};return typeof e.suggestion=="string"&&yn.test(e.suggestion)&&(o.suggestion=e.suggestion),o}function oa(n){let e=n&&typeof n=="object"?n:{};return{id:String(e.id??"").slice(0,128),name:String(e.name??"").slice(0,80)}}function oh(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!yn.test(e.id))return null;let t={id:e.id,author:oa(e.author),text:String(e.text??"").slice(0,5e3),createdAt:Number(e.createdAt)||0};if(e.editedAt&&(t.editedAt=Number(e.editedAt)||0),Array.isArray(e.mentions)){let r=e.mentions.slice(0,20).map(oa).filter(o=>/^[\w.@:+-]{1,128}$/.test(o.id)&&o.name);r.length&&(t.mentions=r)}return t}function sa(n=[],e){let t=n.map(ra).filter(s=>s!==null),r=new Set,o=s=>{t=s,e?.(t),r.forEach(l=>l())},i=(s,l)=>o(t.map(a=>a.id===s?l(a):a));return{threads:()=>t,subscribe(s){return r.add(s),()=>r.delete(s)},createThread(s){let l=ra(s);!l||t.some(a=>a.id===l.id)||o([...t,l])},reply(s,l){let a=oh(l);a&&i(s,c=>({...c,comments:[...c.comments,a]}))},editComment(s,l,a){i(s,c=>({...c,comments:c.comments.map(u=>u.id===l?{...u,text:a.slice(0,5e3),editedAt:Date.now()}:u)}))},deleteComment(s,l){i(s,a=>({...a,comments:a.comments.filter(c=>c.id!==l)}))},setResolved(s,l){i(s,a=>({...a,resolved:l??null}))},deleteThread(s){o(t.filter(l=>l.id!==s))}}}var ua={};q(ua,{MENTION_ID_RE:()=>li,default:()=>ca,findMentionUsers:()=>aa,getMentions:()=>Mv});var li=/^[\w.@:+-]{1,128}$/,Sv=80,si=n=>n.replace(/^@/,"").trim().slice(0,Sv);async function aa(n,e,t=8){let r=await n(e);return Array.isArray(r)?r.filter(o=>o&&typeof o.id=="string"&&li.test(o.id)&&o.name).slice(0,t).map(o=>({id:o.id,name:si(String(o.name)),...o.description?{description:String(o.description).slice(0,120)}:{}})):[]}function Mv(n){let e="view"in n?n.view.state.doc:n,t=new Map;return e.descendants(r=>{r.type.name==="mention"&&!t.has(r.attrs.id)&&t.set(r.attrs.id,{id:r.attrs.id,name:r.attrs.name})}),[...t.values()]}var ca={name:"mentions",nodes:{mention:{group:"inline",inline:!0,atom:!0,selectable:!1,attrs:{id:{},name:{default:""}},parseDOM:[{tag:"span[data-mention]",getAttrs:n=>{let e=n,t=e.getAttribute("data-mention")??"";return li.test(t)?{id:t,name:si(e.textContent??"")}:!1}}],toDOM:n=>["span",{"data-mention":li.test(n.attrs.id)?n.attrs.id:null},`@${si(String(n.attrs.name))}`],leafText:n=>`@${si(String(n.attrs.name))}`}},load:()=>import(__novaChunk("tinymce-chunks/mentions-ui-b1bb2d15.js") )};var ah={en:{add:"Add comment",show:"Comments",panel:"Comments",guest:"Guest",newComment:"New comment",placeholder:"Add a comment\u2026",replyPlaceholder:"Reply\u2026",comment:"Comment",reply:"Reply",cancel:"Cancel",save:"Save",edit:"Edit",remove:"Delete",resolve:"Resolve",reopen:"Reopen",deleteThread:"Delete thread",close:"Close comments",showResolved:"Show resolved",resolvedBy:"Resolved by {name}",orphan:"The commented text was deleted",empty:"No comments yet. Select text and press \u201CAdd comment\u201D ({shortcut}).",people:"People",noPeople:"No matches",edited:"edited",you:"you",count:"{count} comments"}},ih=C.commentAdd,sh=C.comments,ai="Mod-Alt-m",ft=new X("nova-comments"),da=new WeakMap;function ci(n){return da.get(n)}function lh(n){let e=new Map;return n.descendants((t,r)=>{if(t.isInline)for(let o of t.marks){if(o.type.name!=="comment")continue;let i=o.attrs.id,s=e.get(i)??[],l=s[s.length-1];l&&l.to===r?l.to=r+t.nodeSize:s.push({from:r,to:r+t.nodeSize}),e.set(i,s)}}),e}function Ev(n){let{$from:e,empty:t}=n.selection;return(t?[...e.nodeBefore?.marks??[],...e.nodeAfter?.marks??[]]:e.nodeAfter?.marks??[]).filter(o=>o.type.name==="comment").map(o=>o.attrs.id)}var pa={name:"comments",toolbar:"addcomment showcomments",marks:{comment:{attrs:{id:{}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-comment]",getAttrs:n=>{let e=n.getAttribute("data-comment")??"";return yn.test(e)?{id:e}:!1}}],toDOM:n=>["span",{"data-comment":yn.test(n.attrs.id)?n.attrs.id:null},0]}},prosemirrorPlugins:n=>{let e=null;return[Ke({[ai]:()=>ci(n)?.startComment()??!1}),new z({key:ft,state:{init:()=>({pending:null,active:null}),apply(t,r){let o=t.getMeta(ft),i=r;if(t.docChanged&&i.pending){let s=t.mapping.map(i.pending.from,1),l=t.mapping.map(i.pending.to,-1);i={...i,pending:s<l?{from:s,to:l}:null}}return o&&("pending"in o||"active"in o)&&(i={...i,...o}),i}},props:{decorations(t){let r=ci(n),o=ft.getState(t),i=r?.store.threads();if(e&&e.doc===t.doc&&e.threads===i&&e.state===o)return e.set;let s=new Set((i??[]).filter(c=>!c.resolved).map(c=>c.id)),l=[];for(let[c,u]of lh(t.doc)){if(!s.has(c))continue;let d=c===o.active?"nova-comment is-active":"nova-comment";for(let{from:p,to:f}of u)l.push(ge.inline(p,f,{class:d}))}if(o.pending){let{from:c,to:u}=o.pending;l.push(ge.inline(c,u,{class:"nova-comment is-active is-pending"}))}let a=ae.create(t.doc,l);return e={doc:t.doc,threads:i,state:o,set:a},a}},view:()=>({update(t,r){if(r.selection.eq(t.state.selection)||r.doc!==t.state.doc)return;let o=ci(n);if(!o||ft.getState(t.state).pending)return;let i=new Set(o.store.threads().filter(l=>!l.resolved).map(l=>l.id)),s=Ev(t.state).find(l=>i.has(l));s&&(s!==o.active()||!o.isPanelOpen())&&queueMicrotask(()=>{o.setActive(s),o.openPanel()})}})})]},setup(n){let e=Oe(n,"comments",ah),t=n.options.pluginOptions?.comments??{},r=t.store??sa(t.threads??[],t.onChange),o={id:String(t.author?.id??"guest").slice(0,128),name:String(t.author?.name||e.guest).slice(0,80)},i=()=>n.schema.marks.comment,s=t.mentions??n.options.pluginOptions?.mentions?.fetch,l=(M,L=[])=>[...new Map(L.map(B=>[B.id,B])).values()].filter(B=>M.includes(`@${B.name}`)),a=(M,L)=>{let O=l(M,L);return{id:ii(),author:o,text:M,createdAt:Date.now(),...O.length?{mentions:O}:{}}},c=(M,L)=>{L.mentions?.length&&t.onMention?.({threadId:M,comment:L,users:L.mentions})},u=()=>ft.getState(n.view.state),d=M=>n.view.dispatch(n.view.state.tr.setMeta(ft,M)),p=null,f=!1;n.ui.registry.addSidebar("comments",{title:e.panel,button:!1,header:!1,render:async M=>{let{createCommentsPanel:L}=await import(__novaChunk("tinymce-chunks/comments-panel-152e9cbe.js") );return p=L(h),M.append(p.el),()=>p?.destroy()},onShow:()=>{f=!0,p&&(p.el.hidden=!1),n.root.classList.add("nova-comments-open"),p?.render()},onHide:()=>{f=!1,p&&(p.el.hidden=!0),n.root.classList.remove("nova-comments-open"),u().pending&&d({pending:null})}});let h={editor:n,store:r,author:o,labels:e,shortcut:ai,pending:()=>u().pending,active:()=>u().active,setActive(M,L=!1){u().active!==M&&d({active:M}),p?.render();let O=M?h.ranges(M)[0]:void 0;if(L&&O){let{node:B}=n.view.domAtPos(O.from);(B instanceof Element?B:B.parentElement)?.scrollIntoView({block:"nearest"})}},startComment(){let{selection:M}=n.view.state;return M.empty||!n.isEditable()?!1:(d({pending:{from:M.from,to:M.to},active:null}),h.openPanel().then(()=>{p?.render(),p?.focusComposer()}),!0)},cancelPending(){d({pending:null}),p?.render(),n.focus()},findUsers:s?M=>aa(s,M):null,submitPending(M,L){let O=u().pending,B=M.trim().slice(0,5e3);if(!O||!B)return null;let J=ii("t"),P=a(B,L);r.createThread({id:J,createdAt:P.createdAt,comments:[P],resolved:null});let{state:G}=n.view;return n.view.dispatch(G.tr.addMark(O.from,O.to,i().create({id:J})).setMeta(ft,{pending:null,active:J}).setMeta("addToHistory",!1)),p?.render(),c(J,P),J},reply(M,L,O){let B=L.trim().slice(0,5e3);if(!B)return;let J=a(B,O);r.reply(M,J),c(M,J)},ranges:M=>lh(n.view.state.doc).get(M)??[],quote(M){let{doc:L}=n.view.state;return h.ranges(M).map(({from:O,to:B})=>L.textBetween(O,B," ")).join(" \u2026 ")},positionOf:M=>h.ranges(M)[0]?.from??Number.MAX_SAFE_INTEGER,deleteThread(M){let{state:L}=n.view,O=L.tr;for(let{from:B,to:J}of h.ranges(M))O.removeMark(B,J,i().create({id:M}));u().active===M&&O.setMeta(ft,{active:null}),(O.docChanged||O.getMeta(ft))&&n.view.dispatch(O.setMeta("addToHistory",!1)),r.deleteThread(M)},setResolved(M,L){r.setResolved(M,L?{by:o,at:Date.now()}:null),L&&u().active===M&&d({active:null})},canEdit:M=>t.canEdit?t.canEdit(M,o):M.author.id===o.id,isPanelOpen:()=>f,openPanel:()=>n.ui.sidebar.show("comments"),closePanel(){f&&(n.ui.sidebar.hide({restoreFocus:!1}),n.focus())}};da.set(n,h);let m=r.subscribe(()=>{n.view.isDestroyed||(d({refresh:!0}),p?.render())}),g=()=>h.startComment(),k=()=>h.isPanelOpen()?h.closePanel():void h.openPanel(),x=M=>M.isEditable()&&!M.view.state.selection.empty;return n.ui.registry.addButton("addcomment",{icon:ih,tooltip:e.add,shortcut:ai,isEnabled:x,onAction:g}),n.ui.registry.addToggleButton("showcomments",{icon:sh,tooltip:e.show,isActive:()=>f,onAction:k}),n.ui.registry.addMenuItem("addcomment",{text:e.add,icon:ih,shortcut:ai,isEnabled:x,onAction:g}),n.ui.registry.addMenuItem("showcomments",{text:e.show,icon:sh,isActive:()=>f,onAction:k}),()=>{m(),da.delete(n)}}};var ga={};q(ga,{LABELS:()=>uh,default:()=>ma,flatList:()=>ph,isGroup:()=>dh,optionsOf:()=>ui});var uh={en:{insert:"Insert variable",search:"Variables",empty:"No variables found",unknown:"Unknown variable"}},ch=/^[\w.:-]{1,100}$/,Cv=/^data-[a-z0-9-]{1,40}$/;function ui(n){return n.options.pluginOptions?.mergetags??{}}function Av(n){let e=ui(n).attribute??"data-mergetag";return Cv.test(e)?e:(console.warn(`[nova] mergetags: attribute "${e}" must look like data-name; using data-mergetag`),"data-mergetag")}var dh=n=>Array.isArray(n.items);function ph(n){return(ui(n).list??[]).flatMap(e=>dh(e)?e.items:[e])}function fh(n,e){return ph(n).find(t=>t.key===e)?.label}function Tv(n){let e=Av(n);return{mergetag:{group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,ignoreStyles:!0,attrs:{key:{},label:{default:""}},parseDOM:[{tag:`span[${e}]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute(e)??"";return ch.test(o)?{key:o,label:fh(n,o)??r.textContent?.trim()??o}:!1}}],toDOM:t=>{let r=ch.test(t.attrs.key)?t.attrs.key:"",o=t.attrs.label==null||t.attrs.label===""?r:String(t.attrs.label);return["span",{[e]:r,contenteditable:"false"},o]}}}}var ha=class{constructor(e,t,r){S(this,"node",e);S(this,"editor",t);S(this,"unknownTitle",r);S(this,"dom");this.dom=document.createElement("span"),this.dom.className="nova-mergetag",this.dom.contentEditable="false",this.render()}render(){let e=this.node.attrs.key,t=fh(this.editor,e);this.dom.textContent=t??(this.node.attrs.label||e),this.dom.dataset.key=e;let o=!!ui(this.editor).list?.length&&t===void 0;this.dom.classList.toggle("is-unknown",o),this.dom.title=o?`${this.unknownTitle}: ${e}`:e}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(){return!1}ignoreMutation(){return!0}},ma={name:"mergetags",toolbar:"mergetags",nodes:Tv,prosemirrorPlugins:n=>{let e=Oe(n,"mergetags",uh);return[new z({props:{nodeViews:{mergetag:(t,r)=>new ha(t,n,e.unknown)}}})]},load:()=>import(__novaChunk("tinymce-chunks/mergetags-ui-f5bdd1f9.js") )};var La={};q(La,{LABELS:()=>wa,OWN:()=>ki,RESOLVED:()=>Ch,around:()=>bi,attrValue:()=>Ea,blockSuggestion:()=>Ee,cleanFormat:()=>Kr,default:()=>Oa,formatMarks:()=>vi,hasInline:()=>mi,isSuggesting:()=>Aa,listSuggestions:()=>Na,markup:()=>Ma,resolveSuggestions:()=>Ph,setStructureTrackers:()=>Bv,setSuggesting:()=>Dh,suggestTransaction:()=>Lh,suggestionColor:()=>Ah,suggestionsKey:()=>er,suggestionsResult:()=>Xv});var ka={};q(ka,{addListNodes:()=>Pv,bulletList:()=>mh,liftListItem:()=>bn,listItem:()=>gh,orderedList:()=>hh,sinkListItem:()=>pi,splitListItem:()=>di,splitListItemKeepMarks:()=>Dv,wrapInList:()=>ba,wrapRangeInList:()=>yh});var Nv=["ol",0],Ov=["ul",0],Lv=["li",0],hh={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?Nv:["ol",{start:n.attrs.order},0]}},mh={parseDOM:[{tag:"ul"}],toDOM(){return Ov}},gh={parseDOM:[{tag:"li"}],toDOM(){return Lv},defining:!0};function ya(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function Pv(n,e,t){return n.append({ordered_list:ya(hh,{content:"list_item+",group:t}),bullet_list:ya(mh,{content:"list_item+",group:t}),list_item:ya(gh,{content:e})})}function ba(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return yh(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function yh(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Ft(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Ft(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=ln(i,t,r,e);return l?(n&&Rv(n,e,l,o,t),!0):!1}function Rv(n,e,t,r,o){let i=T.empty;for(let u=t.length-1;u>=0;u--)i=T.from(t[u].type.create(t[u].attrs,i));n.step(new re(e.start-(r?2:0),e.end,e.start,e.end,new D(i,0,0),t.length,!0));let s=0;for(let u=0;u<t.length;u++)t[u].type==o&&(s=u+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,p=!0;u<d;u++,p=!1)!p&&l&&Ct(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Qn(n,e){return n instanceof st?e==n:n.indexOf(e)>-1}function di(n,e){return function(t,r){let{$from:o,$to:i,node:s}=t.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(!Qn(n,l.type))return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||!Qn(n,o.node(-3).type)||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let d=T.empty,p=o.index(-1)?1:o.index(-2)?2:3;for(let k=o.depth-p;k>=o.depth-3;k--)d=T.from(o.node(k).copy(d));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;d=d.append(T.from(o.node(-3).type.createAndFill()));let h=o.before(o.depth-(p-1)),m=t.tr.replace(h,o.after(-f),new D(d,4-p,0)),g=-1;m.doc.nodesBetween(h,m.doc.content.size,(k,x)=>{if(g>-1)return!1;k.isTextblock&&k.content.size==0&&(g=x+1)}),g>-1&&m.setSelection(U.near(m.doc.resolve(g))),r(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),u=a||e?[e?{type:l.type,attrs:e}:null,a?{type:a}:null]:void 0;return Ct(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Dv(n,e){let t=di(n,e);return(r,o)=>t(r,o&&(i=>{let s=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();s&&i.ensureMarks(s),o(i)}))}function bn(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&Qn(n,s.firstChild.type));return i?t?Qn(n,r.node(i.depth-1).type)?_v(e,t,i):Iv(e,t,i):!0:!1}}function _v(n,e,t){let r=n.tr,o=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;o<i&&(r.step(new re(o-1,i,o,i,new D(T.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new Ft(r.doc.resolve(t.$from.pos),r.doc.resolve(i),t.depth));let l=at(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return ct(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Iv(n,e,t){let r=n.tr,o=t.parent;for(let f=t.end,h=t.endIndex-1,m=t.startIndex;h>m;h--)f-=o.child(h).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?T.empty:T.from(o))))return!1;let d=i.pos,p=d+s.nodeSize;return r.step(new re(d-(l?1:0),p+(a?1:0),d+1,p-1,new D((l?T.empty:T.from(o.copy(T.empty))).append(a?T.empty:T.from(o.copy(T.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function pi(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&Qn(n,c.firstChild.type));if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(!Qn(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=T.from(c?a.lastChild.lastChild.type.create():null),d=new D(T.from(a.type.create(null,T.from(l.type.create(null,u)))),c?3:1,0),p=i.start,f=i.end;t(e.tr.step(new re(p-(c?3:1),f,p,f,d,1,!0)).scrollIntoView())}return!0}}var fi="nova:set-content";var Wr=/^[A-Za-z0-9_-]{1,64}$/,nr=/^[\w.@:+-]{1,128}$/,wa={en:{toggle:"Suggest edits",review:"Review suggestions",accept:"Accept",reject:"Reject",acceptAll:"Accept all suggestions",rejectAll:"Reject all suggestions",next:"Next suggestion",previous:"Previous suggestion",inserted:"Inserted by {name}",deleted:"Deleted by {name}",formatted:"Formatted by {name}",toolbar:"Suggestion",guest:"Guest",none:"No suggestions",unsupported:"This change can\u2019t be a suggestion",unsupportedDirect:"This change can\u2019t be a suggestion. To make it, turn off Suggest edits."}},er=new X("nova-suggestions"),ki="nova-suggestions-own",Ch="nova-suggestions-resolved",bh=["#116329","#6639ba","#99286e","#0550ae","#953800","#0e5b5e"];function Ah(n){let e=0;for(let t of String(n??""))e=e*31+t.charCodeAt(0)|0;return bh[Math.abs(e)%bh.length]}function hi(){let n=new Uint8Array(9);return globalThis.crypto.getRandomValues(n),"s"+Array.from(n,e=>(e%36).toString(36)).join("")}function kh(n){let e=n==="insert"?"ins":"del";return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0}},inclusive:!1,excludes:"",parseDOM:[{tag:`${e}[data-suggestion]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute("data-suggestion")??"";if(!Wr.test(o))return!1;let i=r.getAttribute("data-author")??"";return{id:o,author:nr.test(i)?i:"",name:(r.getAttribute("data-name")??"").slice(0,80),time:Number(r.getAttribute("data-time"))||0}}}],toDOM:t=>[e,{"data-suggestion":Wr.test(t.attrs.id)?t.attrs.id:null,"data-author":nr.test(t.attrs.author)?t.attrs.author:null,"data-name":String(t.attrs.name??"").slice(0,80)||null,"data-time":Number(t.attrs.time)||null},0]}}function Kr(n){let e;try{e=typeof n=="string"?JSON.parse(n):n}catch{return"[]"}if(!Array.isArray(e))return"[]";let t=[];for(let r of e.slice(0,16)){let o=r?.type;if(typeof o!="string"||!/^[a-z][a-z0-9_]{0,39}$/.test(o))continue;let i=Th(r.attrs,8);t.push(Object.keys(i).length?{type:o,attrs:i}:{type:o})}return JSON.stringify(t)}function Th(n,e){let t={};if(n&&typeof n=="object"&&!Array.isArray(n))for(let[r,o]of Object.entries(n).slice(0,e))!/^[A-Za-z][\w-]{0,39}$/.test(r)||r==="suggestion"||(typeof o=="string"?t[r]=o.slice(0,2e3):(typeof o=="number"||typeof o=="boolean"||o===null)&&(t[r]=o));return t}function Ee(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!Wr.test(e.id))return null;let t=String(e.author??""),r={id:e.id,author:nr.test(t)?t:"",name:String(e.name??"").slice(0,80),time:Number(e.time)||0};if(e.change==="split"||e.change==="join"){let i=e.change==="join"&&e.before!=null?vh(e.before):null;return{...r,change:e.change,depth:Math.min(4,Math.max(1,Math.trunc(Number(e.depth))||1)),...i?{before:i}:{}}}if(e.change==="insert"||e.change==="delete")return{...r,change:e.change};if(e.change==="wrap"||e.change==="unwrap")return{...r,change:e.change,depth:Math.min(9,Math.max(1,Math.trunc(Number(e.depth))||1))};let o=vh(e.before);return o?{...r,change:"block",before:o}:null}function vh(n){let e=n;try{typeof e=="string"&&(e=JSON.parse(e))}catch{return null}let t=e?.type;return typeof t!="string"||!/^[a-z][a-z0-9_]{0,39}$/.test(t)?null:{type:t,attrs:Th(e.attrs,12)}}var Hv={nodes:"all",default:null,parse:n=>n.hasAttribute("data-before")||n.hasAttribute("data-change")?Ee({id:n.getAttribute("data-suggestion"),author:n.getAttribute("data-author"),name:n.getAttribute("data-name"),time:n.getAttribute("data-time"),before:n.getAttribute("data-before"),change:n.getAttribute("data-change"),depth:n.getAttribute("data-depth")}):null,render(n){let e=Ee(n);if(!e)return{};let t={"data-suggestion":e.id};return e.change!=="block"&&(t["data-change"]=e.change),e.before&&(t["data-before"]=JSON.stringify(e.before)),(e.depth??1)>1&&(t["data-depth"]=String(e.depth)),e.author&&(t["data-author"]=e.author),e.name&&(t["data-name"]=e.name),e.time&&(t["data-time"]=String(e.time)),t}},gi=null;function Bv(n){gi=n}function Fv(){return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0},before:{default:"[]"}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-suggestion][data-format]",priority:60,getAttrs:n=>{let e=n,t=e.getAttribute("data-suggestion")??"";if(!Wr.test(t))return!1;let r=e.getAttribute("data-author")??"";return{id:t,author:nr.test(r)?r:"",name:(e.getAttribute("data-name")??"").slice(0,80),time:Number(e.getAttribute("data-time"))||0,before:Kr(e.getAttribute("data-format"))}}}],toDOM:n=>["span",{"data-suggestion":Wr.test(n.attrs.id)?n.attrs.id:null,"data-format":Kr(n.attrs.before),"data-author":nr.test(n.attrs.author)?n.attrs.author:null,"data-name":String(n.attrs.name??"").slice(0,80)||null,"data-time":Number(n.attrs.time)||null},0]}}var Ur=n=>({insert:n.marks.suggestion_insert,delete:n.marks.suggestion_delete,format:n.marks.suggestion_format}),Ta=new Set(["suggestion_insert","suggestion_delete","suggestion_format","comment"]),yi=n=>n.filter(e=>!Ta.has(e.type.name));function vi(n,e){let t=[];for(let r of JSON.parse(Kr(e)))if(!(Ta.has(r.type)||!n.marks[r.type]))try{let o=n.markFromJSON(r);o.isInSet(t)||t.push(o)}catch{}return t}var Sa=(n,e)=>n.length===e.length&&n.every(t=>t.isInSet(e));function zv(n){return!n.docChanged||n.getMeta(ki)||n.getMeta("addToHistory")===!1||n.getMeta(fi)||n.getMeta("history$")?!1:!n.getMeta("y-sync$")?.isChangeOrigin}var tr=n=>!!n.type.spec.attrs&&"suggestion"in n.type.spec.attrs;function kn(n,e,t,r,o=1){return{id:e,author:t.id,name:t.name,time:r,change:n,...o>1?{depth:o}:{}}}function bi(n,e,t){let r=n.resolve(e),o={own:!1,deleted:!1};for(let i=r.depth;i>0;i--){let s=Ee(r.node(i).attrs.suggestion);s?.change==="insert"&&s.author===t&&(o.own=!0),s?.change==="delete"&&(o.deleted=!0)}return o}function mi(n){let e=!1;return n.descendants(t=>(t.isInline&&(e=!0),!e)),e}function Ma(n){let e={};for(let[t,r]of Object.entries(n.attrs))t!=="suggestion"&&(r===null||["string","number","boolean"].includes(typeof r))&&(e[t]=r);return{type:n.type.name,attrs:e}}function Ea(n,e,t){return e.attrs[t]??n.nodes[e.type]?.spec.attrs?.[t]?.default??null}function xh(n,e,t){return[...new Set([...Object.keys(e.attrs),...Object.keys(t.attrs)])].filter(r=>Ea(n,e,r)!==Ea(n,t,r))}function $v(n,e){if(n instanceof on)return e.nodeAt(n.pos)?n.pos:null;if(n instanceof re){let t=e.nodeAt(n.from),r=n.slice.content.firstChild;return!!t&&!!r&&!r.isLeaf&&n.slice.content.childCount===1&&n.slice.openStart===0&&n.slice.openEnd===0&&n.insert===1&&n.to===n.from+t.nodeSize&&n.gapFrom===n.from+1&&n.gapTo===n.to-1&&r.content.size===0?n.from:null}if(n instanceof le){let{from:t,to:r,slice:o}=n,i=e.nodeAt(t),s=o.content.firstChild;return i?.isLeaf&&!i.isText&&s?.isLeaf&&i.type===s.type&&r===t+i.nodeSize&&o.content.childCount===1&&o.openStart===0&&o.openEnd===0&&Sa(i.marks,s.marks)&&!i.eq(s)?t:null}return null}var Vv=new Set(["colwidth"]);function qv(n,e,t,r,o,i){let s=n.doc.nodeAt(e);if(!s||!tr(s)||!tr(t))return!1;let l=n.doc.type.schema,a=m=>n.setNodeMarkup(e,t.type,{...t.attrs,suggestion:m},t.marks),c=Ee(s.attrs.suggestion),u=Ma(s),d=Ma(t);if(s.marks.some(m=>m.type.name==="suggestion_insert"&&m.attrs.author===r.id)||(c?.change==="insert"||c?.change==="split")&&c.author===r.id||bi(n.doc,e,r.id).own||u.type===d.type&&xh(l,u,d).every(m=>Vv.has(m)))return a(s.attrs.suggestion),!0;if(c&&c.change!=="block")return!1;let f=c?.before??u,h=f.type===d.type&&xh(l,f,d).length===0;return a(h?null:{id:c?.id??o(),author:r.id,name:r.name,time:i,change:"block",before:f}),!0}function Ca(n,e){let t=n.doc.nodeAt(e);if(!t||t.isLeaf)return null;let r=n.steps.length,o=n.doc.type.schema.nodes.list_item;if(t.type===o&&o){let i=un.create({doc:n.doc,selection:F.near(n.doc.resolve(e+1))}),s=!1;if(bn(o)(i,l=>{for(let a of l.steps)n.step(a);s=!0}),!s)return null}else{let i=n.doc.resolve(e+1).blockRange(n.doc.resolve(e+t.nodeSize-1)),s=i&&at(i);if(s==null)return null;n.lift(i,s)}return n.mapping.slice(r).map(e+1,1)}function Nh(n,e){let t=n.resolve(e);return t.depth>0&&e===t.start()?t.before():null}function wh(n,e){return[...e].sort((t,r)=>r-t).every(t=>Ca(n,t)!==null)}function jv(n,e,t,r,o,i,s){let l=gi?.structure(t,n.doc);if(!l?.nodes.length)return null;let a=(h,...m)=>!!h&&h.author===o.id&&m.includes(h.change);if(l.change==="wrap"){let h=new Et(n.doc);if(!wh(h,l.nodes)||!h.doc.eq(t))return null;for(let m of l.nodes){let g=Ee(n.doc.nodeAt(m).attrs.suggestion);if(!a(g,"insert")){if(g&&!a(g,"wrap"))return null;n.setNodeAttribute(m,"suggestion",kn("wrap",g?.id??i(),o,s,(g?.depth??0)+1))}}return n}let c=new Et(t);if(!wh(c,l.nodes)||!c.doc.eq(n.doc))return null;let u=l.nodes.map(h=>({pos:h,node:t.nodeAt(h)})),d=({node:h})=>{let m=h.childCount===1?h.firstChild:null,g=Ee(h.attrs.suggestion)??Ee(m?.attrs.suggestion),k=!0;return m?.descendants(x=>(x.isInline&&!x.marks.some(M=>M.type.name==="suggestion_insert"&&M.attrs.author===o.id)&&(k=!1),k)),!!m?.isTextblock&&a(g,"split","insert")&&k},p=({node:h})=>a(Ee(h.attrs.suggestion),"wrap");if(u.every(h=>d(h)||p(h))){let h=n.mapping.slice(e);for(let m of u){let g=h.map(m.pos+1,1),k=Nh(n.doc,g),x=k===null?null:n.doc.nodeAt(k);if(p(m)){let O=Ee(m.node.attrs.suggestion);x?.type===m.node.type&&n.setNodeAttribute(k,"suggestion",(O.depth??1)>1?kn("wrap",O.id,o,O.time,O.depth-1):null);continue}let M=n.doc.nodeAt(g),L=Ee(m.node.attrs.suggestion)??Ee(m.node.firstChild.attrs.suggestion);M?.isTextblock&&x?.type.name!=="list_item"&&n.setNodeAttribute(g,"suggestion",kn("insert",L.id,o,L.time))}return n}let f=r.tr;for(let h of n.steps.slice(0,e))f.step(h);if(!f.doc.eq(t))return null;for(let{pos:h,node:m}of u){let g=Ee(m.attrs.suggestion);if(g&&!a(g,"unwrap"))return null;f.setNodeAttribute(h,"suggestion",kn("unwrap",g?.id??i(),o,s,(g?.depth??0)+1))}return f}function Wv(n,e,t,r,o,i,s){let l=Ur(n.doc.type.schema),a=(d,p)=>r==="add"?n.addMark(d,p,o):n.removeMark(d,p,o);if(Ta.has(o.type.name)||!l.format){a(e,t);return}let c=[];n.doc.nodesBetween(e,t,(d,p,f)=>{if(!d.isInline)return!0;let h=Math.max(p,e),m=Math.min(p+d.nodeSize,t);return h<m&&f?.type.allowsMarkType(o.type)&&c.push({from:h,to:m,node:d}),!1});let u=null;for(let{from:d,to:p,node:f}of c){let h=r==="add"?o.addToSet(f.marks):o.removeFromSet(f.marks);if(Sa(h,f.marks)||(a(d,p),f.marks.some(x=>x.type===l.insert&&x.attrs.author===i.id)||l.delete.isInSet(f.marks)))continue;let g=f.marks.find(x=>x.type===l.format);if(g){let x=vi(n.doc.type.schema,g.attrs.before);Sa(yi(h),x)&&n.removeMark(d,p,g);continue}u??(u=hi());let k=Kr(yi(f.marks).map(x=>x.toJSON()));n.addMark(d,p,l.format.create({id:u,author:i.id,name:i.name,time:s,before:k}))}}function va(n,e,t,r){let o=n.resolve(e);for(let i of[o.nodeBefore,o.nodeAfter]){let s=i?.marks.find(l=>l.type===t&&l.attrs.author===r);if(s)return s}return null}function Oh(n,e,t,r,o,i){let s=[];return n.forEach((l,a,c)=>{if(l.isInline){s.push(t&&!t.allowsMarkType(e.type)?l:l.mark(e.addToSet(l.marks)));return}let u=c===0&&r>0,d=c===n.childCount-1&&o>0;if(!u&&!d&&tr(l)){s.push(l.type.create({...l.attrs,suggestion:i()},l.content,l.marks));return}s.push(l.copy(Oh(l.content,e,l.type,u?r-1:0,d?o-1:0,i)))}),T.from(s)}function Sh(n,e,t){n.maybeStep(new le(e,e,t)).failed&&n.replace(e,e,t)}function xa(n,e,t){if(n instanceof R){let r=t(n.from),o=e.nodeAt(r);if(o&&R.isSelectable(o))return R.create(e,r)}return F.between(e.resolve(t(n.anchor)),e.resolve(t(n.head)))}function Lh(n,e,t,r){if(!zv(n))return n;let o=()=>(r?.(),e.tr),i=gi?.breaks(n,e,t);if(i)return i;let s=Ur(e.schema),l=e.tr,a=Date.now(),c=null,u=()=>c??(c=hi()),d=L=>L,p=null,f=null,h=null,m=!1,g=!1,k=!1,x=null,M=null;for(let L=0;L<n.steps.length;L++){let O=n.steps[L],B=n.docs[L];if(O instanceof Je||O instanceof Ge){if(x!==null)return o();let K=O instanceof Je?"add":"remove";Wv(l,d(O.from),d(O.to),K,O.mark,t,a);continue}let J=$v(O,B);if(J!==null){if(x!==null||g)return o();k=!0;let K=(n.docs[L+1]??n.doc).nodeAt(J);if(!K||!qv(l,d(J),K,t,u,a))return o();continue}if(O instanceof re||x!==null){let K=O instanceof le&&(mi(B.slice(O.from,O.to).content)||mi(O.slice.content));if(!gi||K||!(O instanceof re||O instanceof le))return o();if(x===null){if(!l.doc.eq(B))return o();x=l.steps.length,M=l.doc}if(l.maybeStep(O).failed)return o();continue}if(!(O instanceof le))return o();m=!0;let P=O,G=l.steps.length,y=d,v=y(P.from),b=Math.max(v,y(P.to)),E=!1;if(b>v){let K=[],se=[],Ae=[];l.doc.nodesBetween(v,b,(ue,he)=>{let be=Math.max(he,v),Is=Math.min(he+ue.nodeSize,b);if(be>=Is)return!1;if(!ue.isInline){if(he<v||he+ue.nodeSize>b)return!0;let en=Ee(ue.attrs.suggestion);return en?.change==="insert"&&en.author===t.id?(K.push({from:he,to:he+ue.nodeSize}),!1):en?.change==="delete"?!1:!tr(ue)||en?!0:(Ae.push(he),!1)}let wd=bi(l.doc,he,t.id);return wd.deleted||(wd.own||ue.marks.some(en=>en.type===s.insert&&en.attrs.author===t.id)?K.push({from:be,to:Is}):s.delete.isInSet(ue.marks)||se.push({from:be,to:Is})),!1});let ot=null;if(se.length){let ue=se[0],he=va(l.doc,ue.from,s.delete,t.id)??va(l.doc,se[se.length-1].to,s.delete,t.id)??s.delete.create({id:hi(),author:t.id,name:t.name,time:a});for(let be of se)l.addMark(be.from,be.to,he);ot=he.attrs.id}for(let ue of Ae)l.setNodeAttribute(ue,"suggestion",kn("delete",ot??u(),t,a));let Ve=l.doc.resolve(v),wt=l.doc.resolve(b),it=wt.parent;if(Ve.parent!==it&&Ve.parent.isTextblock&&it.isTextblock&&Ve.depth===wt.depth&&wt.start()>v&&tr(it)&&!it.attrs.suggestion&&!Ae.includes(wt.before())&&l.setNodeAttribute(wt.before(),"suggestion",{id:ot??u(),author:t.id,name:t.name,time:a,change:"join",depth:wt.depth-Ve.sharedDepth(b)}),(se.length||Ae.length)&&(g=!0,k))return o();E=Ae.length>0;for(let ue of K.sort((he,be)=>be.from-he.from))l.delete(ue.from,ue.to);let ye=l.mapping.slice(G);v=ye.map(v,1),b=ye.map(b,-1);let He=e.selection;n.steps.length===1&&P.slice.size===0&&(He.empty&&He.from===P.from&&n.selection.head===P.from&&(p=b),He instanceof R&&Ae.includes(y(He.from))&&(f=ye.map(y(He.to),1)))}let _=E&&P.slice.content.childCount===1&&!P.slice.openStart&&!!P.slice.content.firstChild.isTextblock&&!P.slice.content.firstChild.content.size;if(P.slice.size>0&&!_){let K=b;if(bi(l.doc,K,t.id).own){let ye=l.doc.resolve(K),He=ye.parent.isTextblock?Ee(ye.parent.attrs.suggestion):null;if(Sh(l,K,P.slice),He?.change==="insert"&&P.slice.openEnd>0){let be=l.doc.resolve(K+P.slice.size);be.parent.isTextblock&&!be.parent.attrs.suggestion&&l.setNodeAttribute(be.before(),"suggestion",He)}n.steps.length===1&&(h={at:K,from:P.from,size:P.slice.size});let ue=P.getMap().invert(),he=l.mapping.slice(G);d=be=>he.map(y(ue.map(be,-1)),1);continue}if(!P.slice.openStart)for(let ye=l.doc.resolve(K).nodeAfter;ye&&s.delete.isInSet(ye.marks);)K+=ye.nodeSize,ye=l.doc.resolve(K).nodeAfter;let se=va(l.doc,K,s.insert,t.id)??s.insert.create({id:hi(),author:t.id,name:t.name,time:a}),Ae=l.doc.resolve(K),ot=()=>kn("insert",mi(P.slice.content)?se.attrs.id:u(),t,a),Ve=Oh(P.slice.content,se,P.slice.openStart?null:Ae.parent.type,P.slice.openStart,P.slice.openEnd,ot);Sh(l,K,new D(Ve,P.slice.openStart,P.slice.openEnd)),n.steps.length===1&&(h={at:K,from:P.from,size:P.slice.size});let{openStart:wt,openEnd:it}=P.slice;if(wt>0&&wt===it&&Ae.parent.isTextblock){let ye=l.doc.resolve(K+P.slice.size),He=ye.depth>=it?ye.before(ye.depth-it+1):-1,ue=Ae.parentOffset===Ae.parent.content.size&&He>=0&&He+l.doc.nodeAt(He).nodeSize===K+P.slice.size+it,he=ue?He:ye.depth>0?ye.before():-1,be=he>=0?l.doc.nodeAt(he):null;ye.parent.isTextblock&&be&&tr(be)&&l.setNodeAttribute(he,"suggestion",ue?kn("insert",se.attrs.id,t,a):{id:se.attrs.id,author:t.id,name:t.name,time:a,change:"split",depth:it})}}let N=P.getMap().invert(),$=l.mapping.slice(G);d=K=>$.map(y(N.map(K,-1)),1)}if(x!==null){let L=jv(l,x,M,e,t,u,a);if(!L)return o();L===l?l.setSelection(n.selection.map(l.doc,l.mapping.slice(l.steps.length))):(l=L,l.setSelection(e.selection.map(l.doc,l.mapping)))}else if(!m)l.setSelection(n.selection.map(l.doc,l.mapping.slice(l.steps.length)));else if(p!==null)l.setSelection(F.create(l.doc,p));else if(f!==null)l.setSelection(U.near(l.doc.resolve(f),1));else if(h){let{at:L,from:O,size:B}=h,{anchor:J,head:P,empty:G}=n.selection,y=v=>v>=O&&v<=O+B;if(G&&P===O+B)l.setSelection(F.create(l.doc,L+B));else if(y(J)&&y(P))l.setSelection(xa(n.selection,l.doc,v=>v-O+L));else if(G){let v=l.doc.resolve(L+B);l.setSelection(F.between(v,v))}else l.setSelection(xa(n.selection,l.doc,d))}else l.setSelection(xa(n.selection,l.doc,d));for(let L of["addToHistory","uiEvent","paste","scrollIntoView"]){let O=n.getMeta(L);O!==void 0&&l.setMeta(L,O)}return n.scrolledIntoView&&l.scrollIntoView(),l}function Kv(n,e){let t=vi(n.type.schema,e.attrs.before),r=yi(n.marks),o=r.filter(s=>!s.isInSet(t)).map(s=>s.type.name),i=t.filter(s=>!s.isInSet(r)&&!o.includes(s.type.name)).map(s=>s.type.name);return{added:o,removed:i}}var Mh=(n,e)=>{for(let t of e)n.includes(t)||n.push(t)};function Na(n){let e=Ur(n.type.schema),t=[];return n.descendants((r,o)=>{if(!r.isText){let i=Ee(r.attrs.suggestion);if(i&&t.push({id:i.id,kind:i.change,author:{id:i.author,name:i.name},time:i.time,from:o,to:o+r.nodeSize,text:r.isLeaf?r.type.spec.leafText?.(r)??"":r.textContent,node:r.type.name,...i.before?{before:i.before}:{},...i.depth?{depth:i.depth}:{}}),!r.isInline)return!0}for(let i of r.marks){let s=i.type===e.insert?"insert":i.type===e.delete?"delete":i.type===e.format?"format":null;if(!s)continue;let l=t[t.length-1],a=r.isText?r.text:r.type.spec.leafText?.(r)??"",c=s==="format"?Kv(r,i):null;l&&l.id===i.attrs.id&&l.kind===s&&l.to===o?(l.to=o+r.nodeSize,l.text+=a,c&&(Mh(l.added,c.added),Mh(l.removed,c.removed))):t.push({id:i.attrs.id,kind:s,author:{id:i.attrs.author,name:i.attrs.name},time:Number(i.attrs.time)||0,from:o,to:o+r.nodeSize,text:a,...c??{}})}return!1}),t}function Uv(n,e,t){let r=Ur(n.doc.type.schema).format,o=[];n.doc.nodesBetween(e.from,e.to,(i,s)=>{if(!i.isInline)return!0;let l=i.marks.find(a=>a.type===r&&a.attrs.id===e.id);return l&&o.push({from:Math.max(s,e.from),to:Math.min(s+i.nodeSize,e.to),node:i,mark:l}),!1});for(let{from:i,to:s,node:l,mark:a}of o){if(t==="reject"){let c=vi(n.doc.type.schema,a.attrs.before);for(let u of yi(l.marks))u.isInSet(c)||n.removeMark(i,s,u);for(let u of c)u.isInSet(l.marks)||n.addMark(i,s,u)}n.removeMark(i,s,a)}}function Jv(n,e,t){let r=e.from,o=n.doc.nodeAt(r);if(!o)return;let i=t==="reject"?n.doc.type.schema.nodes[e.before.type]:void 0,s=n.doc.resolve(r);if(i?.spec.attrs&&"suggestion"in i.spec.attrs&&s.parent.canReplaceWith(s.index(),s.index()+1,i)&&(o.isLeaf?i.isLeaf:!i.isLeaf&&i.validContent(o.content))){let l=Object.fromEntries(Object.entries(e.before.attrs).filter(([a])=>a in i.spec.attrs));try{n.setNodeMarkup(r,i,{...o.attrs,...l,suggestion:null},o.marks);return}catch{}}n.setNodeAttribute(r,"suggestion",null)}function Gv(n,e){let t=n.doc.nodeAt(e);if(!t)return;let r=n.doc.resolve(e),o=e,i=e+t.nodeSize;for(let s=r.depth;;s--){let l=r.node(s),a=r.index(s);if(l.canReplace(a,a+1)){n.delete(o,i);return}if(s===0||l.childCount>1||l.type.spec.isolating){let c=l.type.contentMatch.defaultType?.createAndFill();c&&l.canReplace(a,a+1,T.from(c))&&n.replaceWith(o,i,c);return}o=r.before(s),i=r.after(s)}}function Ph(n,e,t){let r=Ur(n.schema),o=n.tr.setMeta(ki,!0),i=Na(n.doc).filter(p=>!t||t.includes(p.id));o.setMeta(Ch,{action:e,ids:[...new Set(i.map(p=>p.id))]});for(let p of i)p.kind==="format"&&Uv(o,p,e);let s=[],l=[];for(let p of i){if(!p.node)continue;let f=e==="reject",h=p.kind==="block"?f&&"style":p.kind==="join"?f?!!p.before&&"style":"join":p.kind==="split"?f&&"join":p.kind==="insert"?f&&"remove":p.kind==="delete"?!f&&"remove":p.kind==="wrap"?f&&"lift":!f&&"lift";h?h==="remove"?s.push(p):l.push({s:p,op:h}):o.setNodeAttribute(p.from,"suggestion",null)}for(let p of[...i].sort((f,h)=>h.from-f.from))p.kind!=="insert"&&p.kind!=="delete"||p.node||(p.kind==="insert"==(e==="reject")?o.delete(p.from,p.to):o.removeMark(p.from,p.to,p.kind==="insert"?r.insert:r.delete));let a=p=>{let f=o.mapping.mapResult(p.from,1);return(f.deleted?null:o.doc.nodeAt(f.pos))?.type.name===p.node?f.pos:null};for(let p of s.sort((f,h)=>h.from-f.from)){let f=a(p);f!==null&&Gv(o,f)}let c=({s:p,op:f},h)=>{let m=a(p);if(m===null)return!0;if(f==="join"){let k=m-((p.depth??1)-1);if(!ct(o.doc,k))return!1;try{o.join(k,p.depth??1)}catch{return!1}return!0}if(f==="style")return!h&&!Yv(o.doc,m,p)?!1:(Jv(o,{...p,from:m},"reject"),!0);if(Ca(new Et(o.doc),m)===null)return!1;o.setNodeAttribute(m,"suggestion",null);let g=m;for(let k=0;k<(p.depth??1)&&g!==null;k++){let x=Ca(o,g);g=x===null?null:Nh(o.doc,x)}return!0},u={join:0,style:1,lift:2},d=l.sort((p,f)=>u[p.op]-u[f.op]||f.s.from-p.s.from);for(let p=0;p>=0;)p=d.findIndex(f=>c(f,!1)),p>=0&&d.splice(p,1);for(let p of d)if(p.op==="style")c(p,!0);else{let f=a(p.s);f!==null&&o.setNodeAttribute(f,"suggestion",null)}return o}function Yv(n,e,t){let r=n.nodeAt(e),o=t.before?n.type.schema.nodes[t.before.type]:void 0;if(!r||!o)return!1;let i=n.resolve(e);return i.parent.canReplaceWith(i.index(),i.index()+1,o)&&(r.isLeaf?o.isLeaf:!o.isLeaf&&o.validContent(r.content))}function Xv(n,e){return Ph(n.view.state,e).doc}function Rh(n){let e=[];return n.forEach(t=>{let r=t.marks.filter(i=>!i.type.name.startsWith("suggestion_"));if(t.isText){e.push(t.mark(r));return}let o=t.attrs.suggestion!=null?{...t.attrs,suggestion:null}:t.attrs;e.push(t.type.create(o,Rh(t.content),r))}),T.from(e)}var Eh=new WeakMap;function Aa(n){return er.getState(n)?.enabled??!1}function Dh(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.setMeta(er,{enabled:e}).setMeta(ki,!0)),n.updateUI()}var Oa={name:"suggestions",toolbar:"suggestions reviewsuggestions suggestionspanel",marks:{suggestion_insert:kh("insert"),suggestion_delete:kh("delete"),suggestion_format:Fv()},nodeAttributes:{suggestion:Hv},prosemirrorPlugins:n=>{let e=n.options.pluginOptions?.suggestions??{},t=null;return[new z({key:er,state:{init:()=>({enabled:!!(e.enabled||e.force)}),apply(r,o){let i=r.getMeta(er);return i?{enabled:e.force?!0:i.enabled}:o}},props:{attributes:r=>er.getState(r)?.enabled?{class:"nova-suggesting"}:{},transformPasted:r=>new D(Rh(r.content),r.openStart,r.openEnd),decorations(r){if(t?.doc===r.doc)return t.set;let o=Oe(n,"suggestions",wa),i=new Intl.DateTimeFormat(n.options.language??"en",{dateStyle:"medium",timeStyle:"short"}),s=ae.create(r.doc,Na(r.doc).map(l=>(l.node?ge.node:ge.inline)(l.from,l.to,{title:(l.kind==="insert"||l.kind==="split"?o.inserted:l.kind==="delete"||l.kind==="join"?o.deleted:o.formatted).replace("{name}",l.author.name||o.guest)+(l.time?` \xB7 ${i.format(l.time)}`:""),class:l.node&&(l.kind==="insert"||l.kind==="delete")?`nova-sugg-${l.kind} nova-sugg-node`:`nova-sugg-${l.kind}`,style:`--nova-suggestion: ${Ah(l.author.id||l.author.name)}`})));return t={doc:r.doc,set:s},s}}}),Ke({"Mod-Alt-Shift-e":()=>e.force?!1:(Dh(n,!Aa(n.view.state)),!0)})]},transformTransaction(n,e,t){if(!Aa(e))return n;let r=t.options.pluginOptions?.suggestions??{},o=Oe(t,"suggestions",wa),i={id:nr.test(r.author?.id??"")?r.author.id:"guest",name:String(r.author?.name||o.guest).slice(0,80)};return Lh(n,e,i,()=>{let s=Date.now();s-(Eh.get(t)??0)<3e3||(Eh.set(t,s),t.ui.notify(r.force?o.unsupported:o.unsupportedDirect))})},load:()=>import(__novaChunk("tinymce-chunks/suggestions-ui-c5f6bad4.js") )};var Wa={};q(Wa,{default:()=>ja,embedResolvers:()=>Mx,parseMediaUrl:()=>Ai});var qa={};q(qa,{ALIGNMENTS:()=>Yr,BULLET_STYLES:()=>_a,CELL_VALIGN:()=>Ba,IMAGE_ALIGN_STYLES:()=>Ha,INDENT_STEP:()=>$a,MAX_INDENT:()=>jh,ORDERED_STYLES:()=>Ia,classAttr:()=>Xe,createSchema:()=>Ci,cssValue:()=>Y,imageSize:()=>ne,indentLevel:()=>or,preText:()=>Uh,schema:()=>Lt,tableStyle:()=>Wh});function Zv(n,e){if(typeof n=="string")return{};let t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length===o?r:null};for(let[s,l]of Object.entries(e)){let a=l.getFromDOM?.(n);a!=null&&(i[s]=a)}return i}function Qv(n,e){let t={};n.attrs.colspan!==1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!==1&&(t.rowspan=n.attrs.rowspan),Array.isArray(n.attrs.colwidth)&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(let[r,o]of Object.entries(e))o.setDOMAttr?.(n.attrs[r],t);return t}function ex(n){if(n!==null&&(!Array.isArray(n)||n.some(e=>typeof e!="number")))throw new TypeError("colwidth must be null or an array of numbers")}function _h(n){let e=n.cellAttributes,t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:ex}};for(let[o,i]of Object.entries(e))t[o]={default:i.default};let r=(o,i)=>({content:n.cellContent,attrs:t,tableRole:i,isolating:!0,parseDOM:[{tag:o,getAttrs:s=>Zv(s,e)}],toDOM:s=>[o,Qv(s,e),0]});return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:r("td","cell"),table_header:r("th","header_cell")}}function Gt(n){let{$head:e}=n.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="row")return!0;return!1}var Pa={};q(Pa,{isSafeImageUrl:()=>fe,isSafeLinkUrl:()=>Ie});var tx=new Set(["http:","https:","mailto:","tel:"]),nx=new Set(["http:","https:","blob:"]),rx=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;function Ih(n){if(typeof n!="string")return null;let t=n.replace(/[\u0000- \u007f-\u009f]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);return t?`${t[1].toLowerCase()}:`:null}function Ie(n){if(typeof n!="string")return!1;let e=Ih(n);return e===null||tx.has(e)}function fe(n){if(typeof n!="string")return!1;if(rx.test(n.trim()))return!0;let e=Ih(n);return e===null||nx.has(e)}var Ra={};q(Ra,{codeLanguage:()=>vn});function vn(n){return typeof n=="string"&&/^[A-Za-z0-9_+#.-]{1,32}$/.test(n)?n:null}var Da={};q(Da,{DEFAULT_CONTENT_LANGS:()=>Hh,contentLanguages:()=>Si,getTextLanguage:()=>Mi,languageName:()=>wi,languageTag:()=>Fe,primaryLanguage:()=>xi,setTextLanguage:()=>rr});var Hh=["ar","de","el","en","es","fr","he","hi","it","ja","ko","la","nl","pl","pt","ru","sv","tr","uk","zh"],ox=/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/;function Fe(n){if(typeof n!="string")return null;let e=n.trim();if(e.length>35||!ox.test(e))return null;try{return Intl.getCanonicalLocales(e)[0]??null}catch{return null}}var xi=n=>n.split("-")[0].toLowerCase();function wi(n,e="en"){try{return new Intl.DisplayNames([e,"en"],{type:"language"}).of(n)??n}catch{return n}}function Si(n,e="en"){let t=n??Hh.map(o=>({code:o})),r=[];for(let o of t){let i=Fe(o?.code);if(!i||r.some(l=>l.code===i))continue;let s=typeof o.title=="string"&&o.title.trim()?o.title.trim():wi(i,e);r.push({code:i,title:s})}return n||r.sort((o,i)=>o.title.localeCompare(i.title,e)),r}function Mi(n){let e=n.schema.marks.language;if(!e)return null;let{$from:t,empty:r}=n.selection,o=r?n.storedMarks??t.marks():t.nodeAfter?.marks??t.marks();return Fe(e.isInSet(o)?.attrs.lang)}function rr(n){return(e,t)=>{let r=e.schema.marks.language,o=n===null?null:Fe(n);if(!r||n!==null&&!o)return!1;let{selection:i}=e,s=!1;if(i.empty)s=i.$from.parent.type.allowsMarkType(r);else for(let{$from:a,$to:c}of i.ranges)e.doc.nodesBetween(a.pos,c.pos,(u,d,p)=>s?!1:(u.isInline&&p?.type.allowsMarkType(r)&&(s=!0),!0));if(!s)return!1;if(!t)return!0;let l=e.tr;if(i.empty)l.removeStoredMark(r),o&&l.addStoredMark(r.create({lang:o}));else for(let{$from:a,$to:c}of i.ranges)l.removeMark(a.pos,c.pos,r),o&&l.addMark(a.pos,c.pos,r.create({lang:o}));return t(l.scrollIntoView()),!0}}var Yr=["left","center","right","justify"],ix=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i,sx=/^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/,lx=/^\d{1,2}(\.\d{1,3})?(px|em|%)?$/,ax=/^[\w\s,'"-]{1,200}$/;function cx(n){let e=n.trim().toLowerCase(),t=e.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0+)\s*)?\)$/);if(t)return"#"+t.slice(1,4).map(o=>Math.min(255,Number(o)).toString(16).padStart(2,"0")).join("");let r=e.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);return r?`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`:e}var Y={color:n=>typeof n=="string"&&ix.test(n.trim())&&!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(n.trim())?cx(n):null,length:n=>typeof n=="string"&&sx.test(n.trim())?n.trim():null,lineHeight:n=>typeof n=="string"&&lx.test(n.trim())&&n.trim()!=="normal"?n.trim():null,fontFamily:n=>typeof n=="string"&&ax.test(n.trim())?n.trim():null},$a=40,jh=10;function or(n){let e=Math.trunc(Number(n));return Number.isFinite(e)?Math.min(jh,Math.max(0,e)):0}var ux=/^(\d+(?:\.\d+)?)(px|pt|em|rem)$/,dx={px:1,pt:4/3,em:16,rem:16};function px(n,e){if(n.parentElement?.tagName==="LI")return 0;let t=n.style,r=e==="rtl"?t.marginRight||t.paddingRight:t.marginLeft||t.paddingLeft,o=ux.exec(r?.trim()??"");return o?or(Math.round(Number(o[1])*dx[o[2]]/$a)):0}function fx(n){let e=n.getAttribute("dir")?.toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Bh(n,e=!1){let t=n.style.textAlign,r=fx(n);return{align:Yr.includes(t)?t:null,lineHeight:Y.lineHeight(n.style.lineHeight),dir:r,indent:px(n,r??(e?"rtl":null))}}function Fh(n,e=!1){let t={};(n.dir==="rtl"||n.dir==="ltr")&&(t.dir=n.dir);let r=n.dir==="rtl"||e&&n.dir!=="ltr",o=[],i=n.align;i&&Yr.includes(i)&&o.push(`text-align: ${i};`);let s=Y.lineHeight(n.lineHeight);s&&o.push(`line-height: ${s};`);let l=or(n.indent);return l&&o.push(`margin-${r?"right":"left"}: ${l*$a}px;`),o.length&&(t.style=o.join(" ")),t}var zh={align:{default:null},lineHeight:{default:null},dir:{default:null},indent:{default:0}},_a=["disc","circle","square"],Ia=["decimal","lower-alpha","upper-alpha","lower-roman","upper-roman","lower-greek"],hx={1:"decimal",a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};function $h(n,e,t){let r=n.style.listStyleType.toLowerCase(),o=hx[n.getAttribute("type")??""]??"",i=e.includes(r)?r:e.includes(o)?o:null;return i===t?null:i}function Vh(n,e){return typeof n=="string"&&e.includes(n)?{style:`list-style-type: ${n};`}:{}}var Ha={left:"float: left; margin: 0 1em 1em 0;",right:"float: right; margin: 0 0 1em 1em;",center:"display: block; margin-left: auto; margin-right: auto;"};function qh(n){let e=n.style.float||n.getAttribute("align");return e==="left"||e==="right"?e:n.style.display==="block"&&n.style.marginLeft==="auto"&&n.style.marginRight==="auto"?"center":null}function ne(n){if(n==null||n==="")return null;let e=String(n).trim().match(/^(\d{1,5})(px)?$/);if(!e)return null;let t=Number(e[1]);return t>=1&&t<=1e4?t:null}var Ba=["top","middle","bottom"];function Wh(n){let e=[],t=Y.length(n.width);return t&&e.push(`width: ${t};`),n.align==="center"?e.push("margin-left: auto; margin-right: auto;"):n.align==="right"&&e.push("margin-left: auto;"),e.join(" ")}var mx=100;function gx(n){let e=_h({tableGroup:"block",cellContent:"block+",cellAttributes:{class:{default:null,getFromDOM:t=>Yt(t,n),setDOMAttr:(t,r)=>{let o=Xe(t).class;o&&(r.class=o)}},background:{default:null,getFromDOM:t=>Y.color(t.getAttribute("data-nova-cell-bg")??t.style?.backgroundColor),setDOMAttr:(t,r)=>{let o=Y.color(t);o&&(r.style=`${r.style??""}background-color: ${o};`)}},valign:{default:null,getFromDOM:t=>{let r=t,o=(r.style.verticalAlign||r.getAttribute("valign")||"").toLowerCase();return Ba.includes(o)?o:null},setDOMAttr:(t,r)=>{Ba.includes(t)&&(r.style=`${r.style??""}vertical-align: ${t};`)}}}});e.table.attrs={width:{default:null},align:{default:null},class:{default:null}},e.table.parseDOM=[{tag:"table",getAttrs:t=>{let r=t,o=Y.length(r.style.width)??Y.length(`${r.getAttribute("width")??""}px`),i=l=>l==="auto",s=r.getAttribute("align")==="center"||i(r.style.marginLeft)&&i(r.style.marginRight)?"center":r.getAttribute("align")==="right"||i(r.style.marginLeft)?"right":null;return{width:o,align:s,class:Yt(r,n)}}}],e.table.toDOM=t=>{let r=Wh(t.attrs);return["table",{...Xe(t.attrs.class),...r?{style:r}:{}},["tbody",0]]};for(let t of["table_cell","table_header"]){let r=e[t],o=r.parseDOM[0],i=o.getAttrs;o.getAttrs=l=>{let a=i(l);if(!a)return a;let c=u=>Math.min(mx,Math.max(1,Number.isFinite(u)?Math.floor(u):1));return{...a,colspan:c(a.colspan),rowspan:c(a.rowspan)}};let s=r.toDOM;r.toDOM=l=>{let a=s(l),c=l.attrs.colwidth;if(c?.every(u=>u>0)){let u=c.reduce((p,f)=>p+f,0),d=a[1].style?` ${a[1].style}`:"";a[1]={...a[1],style:`width: ${u}px;${d}`}}return a}}return e}var Va=()=>!1,Kh=/^-?[_a-zA-Z][\w-]*$/,yx=/(?:^|\s)lang(?:uage)?-(\S+)/;function bx(n){for(let e of[n.querySelector("code"),n]){if(!e)continue;let t=vn(yx.exec(e.getAttribute("class")??"")?.[1])??vn(e.getAttribute("data-language"));if(t)return t}return null}var kx=/^(?:P|DIV|H[1-6]|LI|UL|OL|DL|DT|DD|TABLE|TR|BLOCKQUOTE|PRE|SECTION|ARTICLE|HEADER|FOOTER)$/;function Uh(n){let e="",t=!1,r=i=>{i&&(t&&(e+=`
12
+ `),t=!1,e+=i)},o=i=>{for(let s of i.childNodes)if(s.nodeType===3)r(s.data);else if(s.nodeType===1){let l=s.tagName;l==="BR"?(t=!1,e+=`
13
+ `):kx.test(l)?(e&&(t||!e.endsWith(`
14
+ `))&&(e+=`
15
+ `),t=!1,o(s),t=!0):o(s)}};return o(n),e}function Jh(n){return n.getAttribute("data-type")==="taskList"||n.classList.contains("tox-checklist")||n.classList.contains("contains-task-list")}function vx(n){let e=n.parentElement;if(!e||!Jh(e))return null;let t=n.getAttribute("data-checked");if(t==="true"||t==="false")return t==="true";if(n.classList.contains("tox-checklist--checked"))return!0;let r=[...n.querySelectorAll('input[type="checkbox"]')].find(o=>o.closest("li")===n);return r?r.hasAttribute("checked"):!1}function xx(n){let e=Math.trunc(Number(n));return e>=1&&e<=6?e:1}function Yt(n,e){let t=[...n.classList].filter(r=>Kh.test(r)&&e(r));return t.length?t.join(" "):null}function Xe(n){if(typeof n!="string")return{};let e=n.split(/\s+/).filter(t=>Kh.test(t));return e.length?{class:e.join(" ")}:{}}var Jr={class:{default:null}},Gh=(n,e=!1)=>({doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...zh,...Jr},parseDOM:[{tag:"p",getAttrs:t=>({...Bh(t,e),class:Yt(t,n)})}],toDOM:t=>["p",{...Xe(t.attrs.class),...Fh(t.attrs,e)},0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{level:{default:1},id:{default:null},...zh,...Jr},parseDOM:[1,2,3,4,5,6].map(t=>({tag:`h${t}`,getAttrs:r=>({level:t,id:Vn(r.getAttribute("id")),...Bh(r,e),class:Yt(r,n)})})),toDOM:t=>[`h${xx(t.attrs.level)}`,{...Vn(t.attrs.id)?{id:t.attrs.id}:{},...Xe(t.attrs.class),...Fh(t.attrs,e)},0]},blockquote:{group:"block",content:"block+",defining:!0,attrs:{...Jr},parseDOM:[{tag:"blockquote",getAttrs:t=>({class:Yt(t,n)})}],toDOM:t=>["blockquote",Xe(t.attrs.class),0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{language:{default:null}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({language:bx(t)}),getContent:(t,r)=>{let o=Uh(t);return o?T.from(r.text(o)):T.empty}}],toDOM:t=>{let r=vn(t.attrs.language);return["pre",["code",r?{class:`language-${r}`}:{},0]]}},bullet_list:{group:"block",content:"list_item+",attrs:{listStyle:{default:null},checklist:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>{let r=Jh(t);return{listStyle:r?null:$h(t,_a,"disc"),checklist:r}}}],toDOM:t=>t.attrs.checklist===!0?["ul",{"data-type":"taskList"},0]:["ul",Vh(t.attrs.listStyle,_a),0]},ordered_list:{group:"block",content:"list_item+",attrs:{start:{default:1},listStyle:{default:null}},parseDOM:[{tag:"ol",getAttrs:t=>{let r=t.getAttribute("start");return{start:r?Number(r):1,listStyle:$h(t,Ia,"decimal")}}}],toDOM:t=>["ol",{...t.attrs.start===1?{}:{start:t.attrs.start},...Vh(t.attrs.listStyle,Ia)},0]},list_item:{content:"paragraph block*",defining:!0,attrs:{checked:{default:null}},parseDOM:[{tag:"li",getAttrs:t=>({checked:vx(t)})}],toDOM:t=>typeof t.attrs.checked=="boolean"?["li",{"data-type":"taskItem","data-checked":String(t.attrs.checked)},0]:["li",0]},text:{group:"inline"},figure:{group:"block",content:"figure_image figcaption",draggable:!0,isolating:!0,attrs:{align:{default:null},...Jr},parseDOM:[{tag:"figure",getAttrs:t=>{let r=t,o=r.querySelector("img");return!o||!fe(o.getAttribute("src")??"")?!1:{align:qh(r),class:Yt(r,n)}}}],toDOM:t=>{let r=ne(t.firstChild?.attrs.width),o=Ha[t.attrs.align]??"",i=`${o}${r?`${o?" ":""}width: ${r}px;`:""}`;return["figure",{...Xe(t.attrs.class),...i?{style:i}:{}},0]}},figure_image:{atom:!0,selectable:!1,attrs:{src:{default:""},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}},parseDOM:[{tag:"img[src]",context:"figure/",priority:60,getAttrs:t=>{let r=t;return fe(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=fe(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height);return["img",{src:i,...r==null?{}:{alt:String(r)},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{}}]}},figcaption:{content:"inline*",parseDOM:[{tag:"figcaption",context:"figure/"}],toDOM:()=>["figcaption",0]},image:{group:"inline",inline:!0,draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},align:{default:null},...Jr},parseDOM:[{tag:"img[src]",getAttrs:t=>{let r=t;return fe(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height),align:qh(r),class:Yt(r,n)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=fe(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height),a=Ha[t.attrs.align];return["img",{src:i,...Xe(t.attrs.class),...r==null?{}:{alt:String(r)},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{},...a?{style:a}:{}}]}},hard_break:{group:"inline",inline:!0,selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},...gx(n)}),Fa=Gh(Va),Yh=n=>({language:{attrs:{lang:{default:null}},parseDOM:[{tag:"[lang]",priority:60,consuming:!1,getAttrs:e=>{let t=Fe(e.getAttribute("lang"));return t?{lang:t}:!1}}],toDOM:e=>{let t=Fe(e.attrs.lang);return t?["span",{lang:t},0]:["span",0]}},link:{attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return Ie(t.getAttribute("href")??"")?{href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")}:!1}}],toDOM:e=>{let{title:t,target:r}=e.attrs;return["a",{href:Ie(e.attrs.href)?e.attrs.href:"#",...t?{title:t}:{},...r?{target:r,rel:"noopener noreferrer"}:{}},0]}},bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>e.style?.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>["strong",0]},italic:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},underline:{parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:()=>["u",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code",0]},subscript:{excludes:"superscript",parseDOM:[{tag:"sub"},{style:"vertical-align=sub"}],toDOM:()=>["sub",0]},superscript:{excludes:"subscript",parseDOM:[{tag:"sup"},{style:"vertical-align=super"}],toDOM:()=>["sup",0]},color:{attrs:{value:{}},parseDOM:[{style:"color",getAttrs:e=>Gr(Y.color(e))},{tag:"font[color]",getAttrs:e=>Gr(Y.color(e.getAttribute("color")))}],toDOM:e=>Ei("color",Y.color(e.attrs.value))},background:{attrs:{value:{}},parseDOM:[{style:"background-color",getAttrs:e=>Gr(Y.color(e))},{tag:"mark",getAttrs:()=>({value:"yellow"})}],toDOM:e=>Ei("background-color",Y.color(e.attrs.value))},font_family:{attrs:{value:{}},parseDOM:[{style:"font-family",getAttrs:e=>Gr(Y.fontFamily(e))}],toDOM:e=>Ei("font-family",Y.fontFamily(e.attrs.value))},font_size:{attrs:{value:{}},parseDOM:[{style:"font-size",getAttrs:e=>Gr(Y.length(e))}],toDOM:e=>Ei("font-size",Y.length(e.attrs.value))},span_class:{attrs:{class:{}},parseDOM:[{tag:"span[class]",consuming:!1,getAttrs:e=>{let t=Yt(e,n);return t?{class:t}:!1}}],toDOM:e=>["span",Xe(e.attrs.class),0]}}),za=Yh(Va);function Gr(n){return n?{value:n}:!1}function Ei(n,e){return e?["span",{style:`${n}: ${e};`},0]:["span",0]}var Lt=new Dn({nodes:Fa,marks:za});function wx(n,e,t){let r=t.toDOM;return{...t,attrs:{...t.attrs,[n]:{default:e.default}},parseDOM:t.parseDOM?.map(o=>{if(!o.tag)return o;let i=o.getAttrs;return{...o,getAttrs:s=>{let l=i?i(s):o.attrs??null;if(l===!1)return!1;let a=e.parse(s);return a==null?l:{...l,[n]:a}}}}),...r?{toDOM:o=>{let i=r(o),s=e.render(o.attrs[n]);if(!Array.isArray(i)||typeof i[0]!="string"||!Object.keys(s).length)return i;let l=i[1],a=!!l&&typeof l=="object"&&!Array.isArray(l)&&l.nodeType===void 0;return[i[0],{...a?l:{},...s},...i.slice(a?2:1)]}}:{}}}var Sx=n=>/\b(inline|text)\b/.test(n.content??"");function Ci(n={},e,t,r="ltr"){let o=r==="rtl",i=Object.entries(n.nodes??{}),s=Object.entries(n.marks??{}),l=Object.entries(n.attributes??{});if(!i.length&&!s.length&&!l.length&&!e&&!t&&!o)return Lt;let a=e||o?Gh(e??Va,o):Fa,c=e?Yh(e):za,u={};t&&({nodes:a,marks:c}=t.apply({nodes:a,marks:c},u));for(let[f]of i)if(f in Fa)throw new Error(`[nova] node "${f}" already exists in the base schema`);for(let[f]of s)if(f in za)throw new Error(`[nova] mark "${f}" already exists in the base schema`);let d={...a,...Object.fromEntries(i)},p=(f,h,m)=>f.nodes==="all"?h!=="doc"&&h!=="text":f.nodes==="textblock"?Sx(m):f.nodes.includes(h);for(let[f,h]of l)d=Object.fromEntries(Object.entries(d).map(([m,g])=>[m,p(h,m,g)&&!g.attrs?.[f]?wx(f,h,g):g]));return u.schema=new Dn({nodes:d,marks:{...c,...Object.fromEntries(s)}}),u.schema}var Mx=new WeakMap,Ex=/^https?:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/)([\w-]{11})(?:[?&#]|$)/i,Cx=/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{1,12})(?:[/?#]|$)/i,Ax=/^https:\/\/[^\s"'<>]+\.(?:mp4|webm|ogv|ogg)(?:\?[^\s"'<>#]*)?$/i;function Ai(n){if(typeof n!="string")return null;let e=n.trim(),t=e.match(Ex);if(t)return{kind:"youtube",src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let r=e.match(Cx);return r?{kind:"vimeo",src:`https://player.vimeo.com/video/${r[1]}`}:Ax.test(e)?{kind:"video",src:e}:null}function Xh(n,e){let t=e?Ai(e):null;return t?{...t,width:ne(n.getAttribute("width"))??560,height:ne(n.getAttribute("height"))??315,title:n.getAttribute("title")??""}:!1}function Tx(n){let e=Ai(n.attrs.src);if(!e)return null;let t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e.kind==="video"?w("video",{src:e.src,controls:!0,width:t,height:r,preload:"metadata"}):w("iframe",{src:e.src,width:t,height:r,title:n.attrs.title||"Video",allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:!0,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})}var ja={name:"media",toolbar:"media",nodes:{media:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{kind:{default:"youtube"},src:{},width:{default:560},height:{default:315},title:{default:""}},parseDOM:[{tag:"iframe[src]",getAttrs:n=>Xh(n,n.getAttribute("src"))},{tag:"video",getAttrs:n=>{let e=n,t=e.getAttribute("src")??e.querySelector("source[src]")?.getAttribute("src")??null;return Xh(e,t)}}],toDOM:n=>{let e=Ai(n.attrs.src),t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e?e.kind==="video"?["video",{src:e.src,controls:"",width:t,height:r}]:["iframe",{src:e.src,width:t,height:r,title:n.attrs.title||null,allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"}]:["p"]}}},prosemirrorPlugins:()=>[new z({props:{nodeViews:{media:n=>{let e=Tx(n);return{dom:w("div",{className:"nova-media",contenteditable:"false"},e,w("div",{className:"nova-media-overlay","aria-hidden":"true"})),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}})],load:()=>import(__novaChunk("tinymce-chunks/media-ui-de819f11.js") )};var Ja={};q(Ja,{DEFAULT_SANDBOX:()=>Qh,FIXED:()=>Pt,default:()=>Ua,embeddableUrl:()=>Ti,pageEmbedOptions:()=>Ka,ratioOf:()=>Xr});var Qh="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",Nx=["21by9","16by9","4by3","1by1"].map(n=>({value:`nova-pageembed--${n}`})),Pt={width:350,height:260},Zh=/^[\w-]{1,60}$/,Ox=/--(\d{1,3})by(\d{1,3})$/;function Ka(n){let e=n.options.pluginOptions?.pageembed??{},t=Array.isArray(e.sizes)?e.sizes.filter(o=>!!o&&typeof o.value=="string"&&Zh.test(o.value)):Nx,r=e.sandbox===!1?!1:typeof e.sandbox=="string"?e.sandbox.split(/\s+/).filter(o=>/^allow-[a-z-]{1,40}$/.test(o)).join(" "):Qh;return{sizes:t,inlineStyles:e.inlineStyles!==!1,className:typeof e.className=="string"&&Zh.test(e.className)?e.className:"nova-pageembed",sandbox:r,allowUrl:typeof e.allowUrl=="function"?e.allowUrl:void 0}}function Xr(n){let e=Ox.exec(n);if(!e)return null;let t=Number(e[1]),r=Number(e[2]);return t>0&&r>0?[t,r]:null}function Ti(n,e){if(typeof n!="string")return null;let t=n.trim();if(t.length>2e3||!/^https?:\/\/[^\s/?#]/i.test(t))return null;let r;try{r=new URL(t)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password)return null;try{if(e&&!e(r.href))return null}catch{return null}return t}function em(n,e){if(typeof n=="string"&&n.trim())return n.trim().slice(0,300);try{return new URL(e).hostname}catch{return e}}function tm(n,e){return typeof n=="string"&&e.sizes.some(t=>t.value===n)?n:""}function Lx(n,e){let t=n.find(r=>e.sizes.some(o=>o.value===r));if(t)return t;for(let r of n){let o=/^(?:nova|tiny)-pageembed--/.test(r)?Xr(r):null;if(!o)continue;let i=e.sizes.find(s=>{let l=Xr(s.value);return!!l&&l[0]*o[1]===l[1]*o[0]});if(i)return i.value}return""}function Px(n,e){return n.some(t=>t===e.className||/^(?:nova|tiny)-pageembed(?:--[\w-]+)?$/.test(t)||e.sizes.some(r=>r.value===t))}function nm(n,e,t){return{src:e,title:em(n.attrs.title,e),sandbox:t.sandbox===!1?null:t.sandbox,allow:"fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin",frameborder:n.attrs.border===!0?"1":"0",scrolling:n.attrs.scrolling===!1?"no":null}}function Rx(n){let e=Ka(n);return{pageembed:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{src:{default:""},size:{default:""},width:{default:Pt.width},height:{default:Pt.height},title:{default:""},border:{default:!1},scrolling:{default:!0}},parseDOM:[{tag:"div",priority:70,getAttrs:t=>{let r=t,o=[...r.classList];if(!Px(o,e))return!1;let i=r.querySelector("iframe"),s=Ti(i?.getAttribute("src"),e.allowUrl);if(!i||!s)return!1;let l=i.getAttribute("frameborder");return{src:s,size:Lx(o,e),width:ne(i.getAttribute("width"))??Pt.width,height:ne(i.getAttribute("height"))??Pt.height,title:(i.getAttribute("title")??"").trim().slice(0,300),border:l!==null&&l!=="0"&&l.toLowerCase()!=="no",scrolling:i.getAttribute("scrolling")?.toLowerCase()!=="no"}}}],toDOM:t=>{let r=Ti(t.attrs.src,e.allowUrl);if(!r)return["div",{class:e.className}];let o=nm(t,r,e),i=tm(t.attrs.size,e);if(!i)return o.width=String(ne(t.attrs.width)??Pt.width),o.height=String(ne(t.attrs.height)??Pt.height),["div",{class:e.className},["iframe",o]];let s=e.inlineStyles?Xr(i):null;if(s){let l=Math.round(s[1]/s[0]*1e6)/1e4;return o.style=`position: absolute; top: 0; left: 0; width: 100%; height: 100%${t.attrs.border===!0?"":"; border: 0"}`,["div",{class:`${e.className} ${i}`,style:`position: relative; width: 100%; padding-top: ${l}%; overflow: hidden`},["iframe",o]]}return["div",{class:`${e.className} ${i}`},["iframe",o]]}}}}function Dx(n,e){let t=w("div",{className:"nova-media nova-pageembed-view",contenteditable:"false"}),r=w("div",{className:"nova-media-overlay","aria-hidden":"true"}),o=null,i=null,s=l=>{let a=Ti(l.attrs.src,e.allowUrl),c=tm(l.attrs.size,e),u=c?Xr(c):null;if(t.classList.toggle("is-responsive",!!c),t.classList.toggle("has-border",l.attrs.border===!0),!a){o?.remove(),o=null,i=null,t.replaceChildren(w("div",{className:"nova-pageembed-missing"},typeof l.attrs.src=="string"?l.attrs.src:""),r);return}if(!o||i!==a){let d=nm(l,a,e);o=w("iframe",{src:a,title:d.title,...d.sandbox===null?{}:{sandbox:d.sandbox},allow:"fullscreen",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin",tabindex:"-1"}),i=a,t.replaceChildren(o,r)}o.title=em(l.attrs.title,a),l.attrs.scrolling===!1?o.setAttribute("scrolling","no"):o.removeAttribute("scrolling"),c?(o.removeAttribute("width"),o.removeAttribute("height"),o.style.aspectRatio=u?`${u[0]} / ${u[1]}`:"16 / 9"):(o.style.aspectRatio="",o.setAttribute("width",String(ne(l.attrs.width)??Pt.width)),o.setAttribute("height",String(ne(l.attrs.height)??Pt.height)))};return s(n),{dom:t,update(l){return l.type!==n.type?!1:(n=l,s(l),!0)},ignoreMutation:()=>!0,stopEvent:()=>!1}}var Ua={name:"pageembed",toolbar:"pageembed",nodes:Rx,prosemirrorPlugins:n=>{let e=Ka(n);return[new z({props:{nodeViews:{pageembed:t=>Dx(t,e)}}})]},load:()=>import(__novaChunk("tinymce-chunks/pageembed-ui-da39f1ee.js") )};var Xa={};q(Xa,{default:()=>Ya,seriesName:()=>Ga});var _x=/^[a-z][\w-]{0,39}$/i;function Ga(n){return typeof n=="string"&&_x.test(n)?n:null}var Ix={nodes:["table_cell","table_header"],default:null,parse:n=>Ga(n.getAttribute("data-series")),render:n=>{let e=Ga(n);return e?{"data-series":e}:{}}},Ya={name:"advtable",nodeAttributes:{series:Ix},load:()=>import(__novaChunk("tinymce-chunks/advtable-ui-db2e667d.js") )};var oc={};q(oc,{cardFields:()=>nc,cardHref:()=>ec,cardImage:()=>tc,cardText:()=>Rt,default:()=>rc,hostOf:()=>Za,mediaEmbedOptions:()=>Qa});var Hx=/^[\w-]{1,60}$/;function Qa(n){let e=n.options.pluginOptions?.mediaembed??{},t=Number(e.maxWidth);return{className:typeof e.className=="string"&&Hx.test(e.className)?e.className:"nova-card",inlineStyles:e.inlineStyles!==!1,maxWidth:Number.isFinite(t)&&t>=200?Math.min(2e3,Math.round(t)):650}}function Rt(n,e){return typeof n=="string"?n.replace(/\s+/g," ").trim().slice(0,e):""}function ec(n){if(typeof n!="string")return null;let e=n.trim();return/^https?:\/\/[^\s/?#]/i.test(e)&&e.length<=2e3&&Ie(e)?e:null}function tc(n){if(typeof n!="string")return null;let e=n.trim();return/^https?:\/\/[^\s/?#]/i.test(e)&&e.length<=2e3&&fe(e)?e:null}function Za(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return""}}function nc(n){let e=ec(n.href);return{href:e,title:Rt(n.title,300)||(e?Za(e):""),description:Rt(n.description,500),image:tc(n.image),site:Rt(n.site,100)||(e?Za(e):""),author:Rt(n.author,100)}}function Bx(n){let e=Qa(n),t=[...new Set([e.className,"nova-card","ephox-summary-card"])],r=(o,i)=>o.querySelector(t.map(s=>`.${s}-${i}`).join(", "));return{link_card:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{href:{default:""},title:{default:""},description:{default:""},image:{default:""},site:{default:""},author:{default:""}},parseDOM:[{tag:"a, div",priority:70,getAttrs:o=>{let i=o;if(!t.some(c=>i.classList.contains(c)))return!1;let s=ec(i.getAttribute("href")??i.querySelector("a[href]")?.getAttribute("href"));if(!s)return!1;let l=r(i,"thumbnail"),a=l?.getAttribute("src")??l?.querySelector("img")?.getAttribute("src")??"";return{href:s,title:Rt(r(i,"title")?.textContent,300),description:Rt(r(i,"description")?.textContent,500),image:tc(a)??"",site:Rt(r(i,"website")?.textContent,100),author:Rt(r(i,"author")?.textContent,100)}}}],toDOM:o=>Fx(o,e)}}}var xn=(n,e)=>n.inlineStyles?e:null;function Fx(n,e){let t=nc(n.attrs),r=e.className;if(!t.href)return["div",{class:r},t.title];let o="display: block; opacity: 0.75; font-size: 0.875em",i=[["span",{class:`${r}-title`,style:xn(e,"display: block; font-weight: 600")},t.title]];return t.description&&i.push(["span",{class:`${r}-description`,style:xn(e,o)},t.description]),i.push(["span",{class:`${r}-website`,style:xn(e,o)},t.site]),t.author&&i.push(["span",{class:`${r}-author`,style:xn(e,o)},t.author]),["a",{class:r,href:t.href,rel:"noopener noreferrer",style:xn(e,`display: flex; flex-wrap: wrap; gap: 12px; max-width: ${e.maxWidth}px; margin: 0.5em 0; padding: 12px; border: 1px solid rgb(127 127 127 / 0.35); border-radius: 8px; color: inherit; text-decoration: none; overflow: hidden`)},...t.image?[["img",{class:`${r}-thumbnail`,src:t.image,alt:"",loading:"lazy",style:xn(e,"flex: none; width: 120px; height: 90px; object-fit: cover; border-radius: 4px")}]]:[],["span",{style:xn(e,"display: block; flex: 1 1 180px; min-width: 0")},...i]]}function zx(n,e){let t=w("div",{className:"nova-card-view",contenteditable:"false"});t.style.maxWidth=`${e.maxWidth}px`;let r=o=>{let i=nc(o.attrs);t.replaceChildren(...i.image?[w("img",{className:"nova-card-view-image",src:i.image,alt:""})]:[],w("div",{className:"nova-card-view-text"},w("div",{className:"nova-card-view-title"},i.title),i.description?w("div",{className:"nova-card-view-description"},i.description):null,w("div",{className:"nova-card-view-site"},[i.site,i.author].filter(Boolean).join(" \xB7 ")))),t.title=i.href??""};return r(n),{dom:t,update(o){return o.type!==n.type?!1:(n=o,r(o),!0)},ignoreMutation:()=>!0,stopEvent:()=>!1}}var rc={name:"mediaembed",nodes:Bx,prosemirrorPlugins:n=>{let e=Qa(n);return[new z({props:{nodeViews:{link_card:t=>zx(t,e)}}})]},load:()=>import(__novaChunk("tinymce-chunks/mediaembed-ui-7be11324.js") )};var dc={};q(dc,{bodyStyle:()=>ac,cleanPage:()=>cc,default:()=>uc,fullPageOptions:()=>cm});var sc={};q(sc,{HTMLSerializer:()=>Qr,escapeAttr:()=>eo,escapeText:()=>wn});var $x=new Set(["href","xlink:href","action","formaction","cite"]),Vx=new Set(["src","poster","data","background"]),qx=/url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;function Zr(n,e){let t=n.toLowerCase();return t.startsWith("on")?null:$x.has(t)?Ie(e)?e:null:Vx.has(t)?fe(e)?e:null:t==="srcset"?e.split(",").map(o=>o.trim().split(/\s+/)[0]??"").every(o=>fe(o))?e:null:t==="style"&&qx.test(e)?null:e}var jx=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),om=new RegExp("\xA0","g");function wn(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(om,"&nbsp;")}var Wx="\xA0";function Kx(n){let e=null,t=!0,r=n.childCount;for(let o=0;o<r;o++){let i=n.child(o);if(!i.isText){t=i.type.name==="hard_break"||!i.isInline;continue}let s=i.text??"";if(!s.includes(" ")){t=!1;continue}let l=o===r-1||!n.child(o+1).isInline,a="";for(let c=0;c<s.length;c++){let u=s[c];u!==" "?(a+=u,t=!1):t||l&&c===s.length-1?(a+=Wx,t=!1):(a+=" ",t=!0)}a!==s&&(e??(e=new Map)).set(o,a)}return e}function eo(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(om,"&nbsp;")}var Ux=/^[a-z][a-z0-9-]*$/i,Jx=new Set(["script","style","base","link","meta","object","embed","applet","frame","frameset","template","noscript"]),rm=new Set;function Gx(n){rm.has(n)||(rm.add(n),console.error(`[nova] toDOM produced <${n}>, which is not allowed in output; the tag was dropped`))}var Yx=/^[a-z_:][a-z0-9_.:-]*$/i;function ic(n){if(typeof n=="string")return{open:"",close:"",hole:!1,html:wn(n)};if(typeof n=="number"||typeof n=="boolean")return{open:"",close:"",hole:!1,html:wn(String(n))};if(n==null)return{open:"",close:"",hole:!1,html:""};if(!Array.isArray(n))throw new Error("[nova] serializer supports only array/string toDOM specs");let[e,...t]=n,r=e.includes(" ")?e.split(" ")[1]:e;if(!Ux.test(r))throw new Error(`[nova] invalid tag in toDOM: ${r}`);let o=Jx.has(r.toLowerCase());o&&Gx(r.toLowerCase());let i="",s=t,l=t[0];if(l&&typeof l=="object"&&!Array.isArray(l)){for(let[f,h]of Object.entries(l)){if(h==null)continue;let m=f.includes(" ")?f.split(" ")[1]:f;if(!Yx.test(m))continue;let g=Zr(m,String(h));g!==null&&(i+=` ${m}="${eo(g)}"`)}s=t.slice(1)}let a=o?"":`<${r}${i}>`;if(jx.has(r.toLowerCase()))return{open:a,close:"",hole:!1,html:a};let c="",u="",d=!1;for(let f of s){if(f===0){if(d)throw new Error("[nova] toDOM spec has more than one content hole");d=!0;continue}let h=ic(f);if(d){if(h.hole)throw new Error("[nova] toDOM spec has more than one content hole");u+=h.html}else h.hole?(c+=h.open,u+=h.close,d=!0):c+=h.html}if(o)return{open:"",close:"",hole:d,html:""};let p=`</${r}>`;return{open:a+c,close:u+p,hole:d,html:a+c+u+p}}var Qr=class{constructor(){S(this,"cache",new WeakMap)}serializeFragment(e,{pre:t=!1}={}){let r=t?null:Kx(e),o="",i=[],s=[],l=a=>{for(;i.length>a;)o+=s.pop(),i.pop()};return e.forEach((a,c,u)=>{if(!a.isInline){l(0),o+=this.serializeNode(a);return}let d=0;for(;d<i.length&&d<a.marks.length&&i[d].eq(a.marks[d]);)d++;l(d);for(let p=d;p<a.marks.length;p++){let f=a.marks[p],h=this.renderMark(f,a.isText);o+=h.open,s.push(h.close),i.push(f)}o+=a.isText?wn(r?.get(u)??a.text??""):this.serializeNode(a)}),l(0),i=[],s=[],o}serializeNode(e){let t=e.type.spec.toDOM;if(!t)throw new Error(`[nova] node "${e.type.name}" has no toDOM`);let r=ic(t(e));if(!r.hole)return r.html;let o=!!e.type.spec.code||e.type.spec.whitespace==="pre";return r.open+this.serializeFragment(e.content,{pre:o})+r.close}renderMark(e,t){let r=e.type.spec.toDOM;if(!r)throw new Error(`[nova] mark "${e.type.name}" has no toDOM`);let o=this.cache.get(e.type);o||this.cache.set(e.type,o=new Map);let i=JSON.stringify(e.attrs),s=o.get(i);return s||(s=ic(r(e,t)),o.size>500&&o.clear(),o.set(i,s)),s}};var Xx=/^[a-z]{1,8}(?:-[a-z0-9]{1,8}){0,4}$/i,im=/^[\w.:-]{1,100}$/,sm=/^<!doctype html(?:\s+(?:public|system)(?:\s+(?:"[^"<>]{0,300}"|'[^'<>]{0,300}')){1,2})?\s*>$/i,Zx=new Set(["content-type","content-language","x-ua-compatible","default-style"]),Qx=new Set(["stylesheet","icon","shortcut","apple-touch-icon","canonical","alternate","author","license","next","prev"]),e1="<!DOCTYPE html>";function Sn(n,e){return typeof n!="string"||n.length>e||/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(n)?null:n.replace(/\r\n?/g,`
16
+ `)}var Ni=n=>Xx.test(n)?n:null,lm=n=>["ltr","rtl","auto"].includes(n.toLowerCase())?n.toLowerCase():null,lc=n=>Sn(n,300),t1=n=>{let e=n.split(/\s+/).filter(Boolean);return e.length&&e.length<=20&&e.every(t=>/^[\w-]{1,60}$/.test(t))?e.join(" "):null},n1=n=>{let e=n.trim(),t=/^([a-z][a-z0-9+.-]*):/i.exec(e.replace(/[\u0000- ]/g,""))?.[1];return e&&e.length<=2e3&&(!t||/^https?$/i.test(t))?e:null},ht=n=>{let e=n.trim().split(/\s+/);return e.length<=4&&e.every(t=>t==="0"||t==="auto"||Y.length(t))?e.join(" "):null},r1={"background-color":Y.color,color:Y.color,"font-family":Y.fontFamily,"font-size":Y.length,"line-height":Y.lineHeight,"text-align":n=>["left","center","right","justify"].includes(n)?n:null,"max-width":Y.length,margin:ht,"margin-top":ht,"margin-right":ht,"margin-bottom":ht,"margin-left":ht,padding:ht,"padding-top":ht,"padding-right":ht,"padding-bottom":ht,"padding-left":ht};function ac(n){if(typeof n!="string")return"";let e=new Map;for(let t of n.slice(0,2e3).split(";")){let r=t.indexOf(":");if(r<0)continue;let o=t.slice(0,r).trim().toLowerCase();o==="background"&&(o="background-color");let i=r1[o]?.(t.slice(r+1).trim());i&&(e.delete(o),e.set(o,i))}return[...e].map(([t,r])=>`${t}: ${r}`).join("; ")}var o1={lang:Ni,dir:lm,xmlns:n=>n==="http://www.w3.org/1999/xhtml"?n:null,"xml:lang":Ni},i1={style:n=>ac(n)||null,class:t1,dir:lm,lang:Ni},am={charset:n=>/^[\w.:-]{1,40}$/.test(n)?n:null,name:n=>im.test(n)?n:null,property:n=>im.test(n)?n:null,"http-equiv":n=>Zx.has(n.toLowerCase())?n:null,content:n=>Sn(n,2e3)},s1={rel:n=>{let e=n.toLowerCase().split(/\s+/).filter(Boolean);return e.length&&e.every(t=>Qx.has(t))?e.join(" "):null},href:n1,type:n=>/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(n)?n:null,media:lc,sizes:n=>/^(?:any|\d{1,4}x\d{1,4}(?:\s+\d{1,4}x\d{1,4}){0,9})$/i.test(n)?n:null,hreflang:Ni,title:lc},l1={media:lc,type:n=>n.toLowerCase()==="text/css"?"text/css":null};function to(n,e){if(!n||typeof n!="object"||Array.isArray(n))return null;let t=n,r={};for(let[o,i]of Object.entries(e)){let s=typeof t[o]=="string"?i(t[o]):null;s!==null&&(r[o]=s)}return Object.keys(r).length?r:null}function a1(n){if(!n||typeof n!="object")return null;let{tag:e,attrs:t,text:r}=n;if(e==="title"){let o=Sn(r,1e3);return o===null?null:{tag:e,text:o.replace(/\s+/g," ").trim()}}if(e==="meta"){let o=to(t,am),i=o&&(o.name??o.property??o["http-equiv"])&&o.content!==void 0;return o&&(o.charset||i)?{tag:e,attrs:o}:null}if(e==="link"){let o=to(t,s1);return o?.rel&&o.href?{tag:e,attrs:o}:null}if(e==="style"){let o=Sn(r,2e5);return o===null?null:{tag:e,attrs:to(t,l1)??{},text:o}}return null}function cc(n){if(!n||typeof n!="object"||Array.isArray(n))return{};let e=n,t={},r=Sn(e.doctype,700)?.trim();r&&sm.test(r)&&(t.doctype=r);let o=to(e.html,o1);o&&(t.html=o);let i=Array.isArray(e.head)?e.head.slice(0,300).map(a1).filter(c=>c!==null):[],s=i.findIndex(c=>c.tag==="title"),l=i.filter((c,u)=>c.tag!=="title"||u===s);l.length&&(t.head=l);let a=to(e.body,i1);return a&&(t.body=a),t}var Oi=(n={})=>Object.entries(n).map(([e,t])=>` ${e}="${eo(t)}"`).join("");function c1(n){return n.tag==="title"?`<title>${wn(n.text)}</title>`:n.tag==="style"?`<style${Oi(n.attrs)}>${n.text.replace(/<\/(style)/gi,"<\\/$1")}</style>`:`<${n.tag}${Oi(n.attrs)}>`}function u1(n){let e=l=>l?Object.fromEntries([...l.attributes].map(a=>[a.name.toLowerCase(),a.value])):{},t=n.doctype,r=t?`<!DOCTYPE ${t.name}${t.publicId?` PUBLIC "${t.publicId}"`:""}${t.systemId?`${t.publicId?"":" SYSTEM"} "${t.systemId}"`:""}>`:void 0,o=[...n.head.children].map(l=>{let a=l.tagName.toLowerCase();return a==="title"||a==="style"?{tag:a,attrs:e(l),text:l.textContent??""}:{tag:a,attrs:e(l)}}),i=e(n.body),s=[i.bgcolor&&`background-color: ${i.bgcolor}`,i.text&&`color: ${i.text}`,i.style].filter(Boolean);return s.length&&(i.style=s.join("; ")),cc({doctype:r,html:e(n.documentElement),head:o,body:i})}var d1=/<!doctype\b|<(?:html|head|body)[\s>/]/i;function cm(n){let e=n.options.pluginOptions?.fullpagehtml??{},t=Sn(e.doctype,700)?.trim();return{doctype:t&&sm.test(t)?t:e1,title:Sn(e.title,1e3)?.replace(/\s+/g," ").trim()??"",encoding:typeof e.encoding=="string"?am.charset(e.encoding)??"":"",bodyStyle:ac(e.bodyStyle),hideInSourceView:e.hideInSourceView===!0}}function p1(n,e){let t=cc(n),r=(t.head??[]).map(c1);e.encoding&&!t.head?.some(i=>i.tag==="meta"&&i.attrs.charset)&&r.unshift(`<meta charset="${eo(e.encoding)}">`),e.title&&!t.head?.some(i=>i.tag==="title")&&r.push(`<title>${wn(e.title)}</title>`);let o={...t.body};return!o.style&&e.bodyStyle&&(o.style=e.bodyStyle),[t.doctype??e.doctype,`<html${Oi(t.html)}>`,"<head>",...r,"</head>",`<body${Oi(o)}>`].join(`
17
+ `)}function f1(n){let e=cm(n);return{inSource:!e.hideInSourceView,read(t){if(!d1.test(t))return null;let r=new DOMParser().parseFromString(t,"text/html");return{content:r.body.innerHTML,attrs:{page:u1(r)}}},write:(t,r)=>`${p1(r.page,e)}
18
+ ${t}
19
+ </body>
20
+ </html>`}}var uc={name:"fullpagehtml",toolbar:"fullpagehtml",nodeAttributes:{page:{nodes:["doc"],default:null,parse:()=>null,render:()=>({})}},page:f1,load:()=>import(__novaChunk("tinymce-chunks/fullpagehtml-ui-9dd804af.js") )};var um={name:"pagebreak",toolbar:"pagebreak",nodes:{pagebreak:{group:"block",atom:!0,selectable:!0,parseDOM:[{tag:"div.nova-pagebreak"},{tag:"div",getAttrs:n=>{let e=n;return(e.style.breakAfter==="page"||e.style.pageBreakAfter==="always")&&!e.textContent?.trim()?null:!1}}],toDOM:()=>["div",{class:"nova-pagebreak",style:"break-after: page;"}]}},load:()=>import(__novaChunk("tinymce-chunks/pagebreak-ui-7476f5c2.js") )};var yc={};q(yc,{PAGE_SIZES:()=>fc,default:()=>gc,fillBand:()=>g1,pageLayout:()=>y1,resolveBand:()=>hc,resolvePageLayout:()=>mc,setPageCount:()=>b1});var dm=".nova-pages{--nova-desk: #e6e9ed}[data-theme=dark] .nova-pages{--nova-desk: #010409}@media(prefers-color-scheme:dark){.nova-pages:not([data-theme=light] *){--nova-desk: #010409}}.nova-pages .nova-content{position:relative;padding:24px 12px 32px;background:var(--nova-desk)}.nova-pages .nova-prosemirror{box-sizing:border-box;width:var(--nova-page-width);max-width:100%;min-height:max(var(--nova-page-height),var(--nova-pages-height, 0px));margin:0 auto;padding:var(--nova-page-margins);background:var(--nova-bg);color:var(--nova-fg);box-shadow:0 1px 3px #0000002e,0 8px 24px #00000014}@media(max-width:600px){.nova-pages .nova-content{padding:0}.nova-pages .nova-prosemirror{padding:16px;box-shadow:none}}";var fc={A3:[297,420],A4:[210,297],A5:[148,210],A6:[105,148],Letter:[215.9,279.4],Legal:[215.9,355.6]},m1=20;function pc(n,e,t,r){let o=typeof n=="number"?n:typeof n=="string"?Number(n):NaN;return Number.isFinite(o)?Math.min(t,Math.max(e,Math.round(o*10)/10)):r}function Li(n){return typeof n=="string"?n.replace(/\s+/g," ").trim().slice(0,200):""}function hc(n){let e=null;if(typeof n=="string")e={left:"",center:Li(n),right:""};else if(typeof n=="object"&&n!==null){let t=n;e={left:Li(t.left),center:Li(t.center),right:Li(t.right)}}return e&&(e.left||e.center||e.right)?e:null}function g1(n,e,t){return n.replace(/\{page\}/g,String(e)).replace(/\{pages\}/g,String(t))}function mc(n={}){let e=typeof n.size=="object"&&n.size!==null,t=!e&&typeof n.size=="string"&&n.size in fc?n.size:"A4",r=n.size,[o,i]=e?[pc(r?.width,30,2e3,210),pc(r?.height,30,2e3,297)]:fc[t];if(n.orientation==="landscape"||n.orientation==="portrait"){let c=n.orientation==="landscape",u=o>i;c!==u&&([o,i]=[i,o])}let s=Math.min(o,i)/3,l=n.margins,a=c=>pc(typeof l=="object"&&l!==null?l[c]:l,0,s,Math.min(m1,s));return{size:e?"custom":t,orientation:o>i?"landscape":"portrait",width:o,height:i,margins:{top:a("top"),right:a("right"),bottom:a("bottom"),left:a("left")},header:hc(n.header),footer:hc(n.footer),differentFirstPage:n.differentFirstPage===!0}}var Pi=new WeakMap;function pm(n){for(let e of[...n.listeners])try{e()}catch(t){console.error("[nova] pagelayout: listener failed",t)}}function fm(n,e){let{style:t}=n.root,{top:r,right:o,bottom:i,left:s}=e.margins;t.setProperty("--nova-page-width",`${e.width}mm`),t.setProperty("--nova-page-height",`${e.height}mm`),t.setProperty("--nova-page-margins",`${r}mm ${o}mm ${i}mm ${s}mm`)}function y1(n){let e=Pi.get(n);if(e)return{get layout(){return e.layout},get pages(){return e.pages},set(t){e.options={...e.options,...t},e.layout=mc(e.options),fm(n,e.layout),pm(e)},onChange(t){return e.listeners.add(t),()=>e.listeners.delete(t)}}}function b1(n,e){let t=Pi.get(n);!t||t.pages===e||(t.pages=e,pm(t))}var gc={name:"pagelayout",setup(n){let e=n.options.pluginOptions?.pagelayout??{},t=mc(e);return Pi.set(n,{options:e,layout:t,pages:null,listeners:new Set}),n.ui.addStyles("nova-pagelayout",dm),n.root.classList.add("nova-pages"),fm(n,t),()=>{Pi.delete(n),n.root.classList.remove("nova-pages")}},load:()=>import(__novaChunk("tinymce-chunks/pagelayout-ui-01757669.js") )};var wc={};q(wc,{default:()=>xc,footnoteId:()=>no,footnoteNodes:()=>mm,footnoteNumber:()=>Ri});var hm=".nova-prosemirror sup.mce-footnote a{text-decoration:none}.nova-prosemirror .mce-footnotes{margin-top:2em;font-size:.9em}.nova-prosemirror .mce-footnotes hr{width:30%;margin:0 0 .5em;border:0;border-top:1px solid var(--nova-border)}.nova-prosemirror .mce-footnotes-backlink{margin-inline-end:.35em;text-decoration:none;cursor:pointer;user-select:none}@media print{.nova-prosemirror .mce-footnotes{break-inside:avoid}.nova-prosemirror .mce-footnotes-backlink{display:none}}";function no(n){let e=typeof n=="string"||typeof n=="number"?String(n):"";return/^[\w-]{1,64}$/.test(e)?e:""}function Ri(n){let e=Math.trunc(Number(n));return Number.isFinite(e)&&e>0?e:1}var bc=(n,e)=>n?.startsWith(e)?no(n.slice(e.length)):"",mm={footnote_ref:{inline:!0,group:"inline",atom:!0,selectable:!0,draggable:!0,attrs:{id:{default:""},number:{default:1}},parseDOM:[{tag:"sup.mce-footnote",priority:60,getAttrs:n=>{let e=n.querySelector("a");return{id:bc(e?.getAttribute("href"),"#footnote-")||bc(e?.getAttribute("id"),"footnote-ref-"),number:Ri((e??n).textContent)}}}],toDOM:n=>{let e=no(n.attrs.id);return["sup",{class:"mce-footnote"},["a",{href:`#footnote-${e}`,id:`footnote-ref-${e}`,role:"doc-noteref"},String(Ri(n.attrs.number))]]},leafText:n=>`[${Ri(n.attrs.number)}]`},footnotes:{group:"block",content:"footnote+",isolating:!0,selectable:!1,parseDOM:[{tag:"div.mce-footnotes",priority:60,contentElement:n=>n.querySelector("ol, ul")??n}],toDOM:()=>["div",{class:"mce-footnotes",role:"doc-endnotes"},["hr"],["ol",0]]},footnote:{content:"inline*",defining:!0,attrs:{id:{default:""}},parseDOM:[{tag:"a.mce-footnotes-backlink",priority:60,ignore:!0},{tag:"li",context:"footnotes/",priority:60,getAttrs:n=>({id:bc(n.getAttribute("id"),"footnote-")})}],toDOM:n=>{let e=no(n.attrs.id);return["li",{id:`footnote-${e}`},["a",{class:"mce-footnotes-backlink",href:`#footnote-ref-${e}`,role:"doc-backlink"},"^"],["span",{class:"mce-footnote-text"},0]]}}},kc=class{constructor(){S(this,"dom");S(this,"contentDOM");this.dom=document.createElement("div"),this.dom.className="mce-footnotes",this.dom.setAttribute("role","doc-endnotes");let e=document.createElement("hr");e.contentEditable="false",this.contentDOM=document.createElement("ol"),this.dom.append(e,this.contentDOM)}},vc=class{constructor(e){S(this,"dom");S(this,"contentDOM");let t=no(e.attrs.id);this.dom=document.createElement("li"),this.dom.id=`footnote-${t}`;let r=document.createElement("a");r.className="mce-footnotes-backlink",r.href=`#footnote-ref-${t}`,r.setAttribute("role","doc-backlink"),r.contentEditable="false",r.textContent="^",this.contentDOM=document.createElement("span"),this.contentDOM.className="mce-footnote-text",this.dom.append(r,this.contentDOM)}},xc={name:"footnotes",nodes:mm,prosemirrorPlugins:()=>[new z({key:new X("nova-footnotes-view"),props:{nodeViews:{footnotes:()=>new kc,footnote:n=>new vc(n)}}})],setup(n){n.ui.addStyles("nova-footnotes",hm)},load:()=>import(__novaChunk("tinymce-chunks/footnotes-ui-3f167c2c.js") )};j("insertdatetime",()=>import(__novaChunk("tinymce-chunks/insertdatetime-a48ee6e0.js") ));j("casechange",()=>import(__novaChunk("tinymce-chunks/casechange-8ad6a2c3.js") ));j("formatpainter",()=>import(__novaChunk("tinymce-chunks/formatpainter-cbeeffa7.js") ));j("permanentpen",()=>import(__novaChunk("tinymce-chunks/permanentpen-fc96f445.js") ));j("visualchars",()=>import(__novaChunk("tinymce-chunks/visualchars-7cda4c00.js") ));j("save",()=>import(__novaChunk("tinymce-chunks/save-a65e56cd.js") ));j("markdown",()=>import(__novaChunk("tinymce-chunks/markdown-5698ebec.js") ));j("importcss",()=>import(__novaChunk("tinymce-chunks/importcss-28610ab5.js") ));j("template",()=>import(__novaChunk("tinymce-chunks/template-b522c8ed.js") ));j("spellchecker",()=>import(__novaChunk("tinymce-chunks/spellchecker-91509fc1.js") ));j("autocorrect",()=>import(__novaChunk("tinymce-chunks/autocorrect-907e1296.js") ));j("typography",()=>import(__novaChunk("tinymce-chunks/typography-469ce11a.js") ));j("a11ychecker",()=>import(__novaChunk("tinymce-chunks/a11ychecker-fe78c552.js") ));j("linkchecker",()=>import(__novaChunk("tinymce-chunks/linkchecker-820845fd.js") ));j("advcode",()=>import(__novaChunk("tinymce-chunks/advcode-840793ca.js") ));j("editimage",()=>import(__novaChunk("tinymce-chunks/editimage-36199bc6.js") ));j("email",()=>import(__novaChunk("tinymce-chunks/email2-e9c49586.js") ));j("quickbars",()=>import(__novaChunk("tinymce-chunks/quickbars-35c87c0e.js") ));j("charmap",()=>import(__novaChunk("tinymce-chunks/charmap-5deb524c.js") ));j("emoticons",()=>import(__novaChunk("tinymce-chunks/emoticons-a5ab437d.js") ));j("nonbreaking",()=>import(__novaChunk("tinymce-chunks/nonbreaking-f15226ad.js") ));j("checklist",()=>import(__novaChunk("tinymce-chunks/checklist-5a0c95d3.js") ));j("codesample",()=>import(__novaChunk("tinymce-chunks/codesample-b91dcd91.js") ));j("draghandle",()=>import(__novaChunk("tinymce-chunks/draghandle-a1d99987.js") ));j("autolink",()=>import(__novaChunk("tinymce-chunks/autolink-897e8650.js") ));j("autosave",()=>import(__novaChunk("tinymce-chunks/autosave-60381295.js") ));j("autoresize",()=>import(__novaChunk("tinymce-chunks/autoresize-f8a4a52a.js") ));j("visualblocks",()=>import(__novaChunk("tinymce-chunks/visualblocks-8b7cba25.js") ));j("exportword",()=>import(__novaChunk("tinymce-chunks/exportword-ad95abb4.js") ));j("exportpdf",()=>import(__novaChunk("tinymce-chunks/exportpdf-1dfcbddc.js") ));j("importword",()=>import(__novaChunk("tinymce-chunks/importword-d6c2636a.js") ));j("ai",()=>import(__novaChunk("tinymce-chunks/ai2-ddf912a7.js") ));j("anchor",_p);j("accordion",ml);j("tableofcontents",wl);j("math",kl);j("pagebreak",um);j("pagelayout",gc);j("footnotes",xc);j("media",ja);j("pageembed",Ua);j("advtable",Ya);j("mediaembed",rc);j("fullpagehtml",uc);j("comments",pa);j("mentions",ca);j("mergetags",ma);j("suggestions",Oa);j("directionality",()=>import(__novaChunk("tinymce-chunks/directionality-185b3810.js") ));j("advlist",()=>import(__novaChunk("tinymce-chunks/advlist-67b98670.js") ));j("revisionhistory",()=>import(__novaChunk("tinymce-chunks/revisionhistory-741dfb24.js") ));var dd={};q(dd,{API_CHANGE_META:()=>As,Editor:()=>vo,REMOTE_CHANGE_META:()=>ud,createEditor:()=>Ts,parseContent:()=>cd});function bm(n,e){let t=null,r=()=>{if(t!==null||(t=0,queueMicrotask(()=>t=null),e.scrollHeight>e.clientHeight+1))return t;let l=getComputedStyle(n);return l.position==="sticky"&&l.display!=="none"&&(t=n.offsetHeight+(parseFloat(l.top)||0)),t},o=l=>{if(!r()||!l.hasFocus())return;let a=n.getBoundingClientRect(),c;try{c=l.coordsAtPos(l.state.selection.head)}catch{return}c.bottom<=a.top||c.top>=a.bottom||ym(n).scrollBy(0,c.top-a.bottom-5)},i=l=>{if(!l.dom.getClientRects().length)return;let a;try{a=l.coordsAtPos(l.state.selection.head)}catch{return}if(e.scrollHeight>e.clientHeight+1){let f=e.getBoundingClientRect();a.top<f.top+5?e.scrollTop-=f.top+5-a.top:a.bottom>f.bottom-5&&(e.scrollTop+=a.bottom-f.bottom+5),a=l.coordsAtPos(l.state.selection.head)}let c=ym(e),u=c instanceof HTMLElement?c.getBoundingClientRect():{top:0,bottom:c.innerHeight},d=u.top+r()+5,p=u.bottom-5;a.top<d?c.scrollBy(0,a.top-d):a.bottom>p&&c.scrollBy(0,a.bottom-p)};return{plugin:new z({key:Sc,state:{init:()=>0,apply:(l,a)=>l.scrolledIntoView?a+1:a},view:()=>{let l=0;return{update(a,c){Sc.getState(a.state)!==Sc.getState(c)&&!a.hasFocus()&&i(a),!a.state.selection.eq(c.selection)&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>o(a)))},destroy:()=>cancelAnimationFrame(l)}}}),props:{scrollThreshold:{left:0,right:0,bottom:0,get top(){return r()}},scrollMargin:{left:5,right:5,bottom:5,get top(){return r()+5}}}}}var Sc=new X("nova-scroll-requests");function ym(n){for(let e=n.parentElement;e;e=e.parentElement){let{overflowY:t}=getComputedStyle(e);if(/auto|scroll|overlay/.test(t)&&e.scrollHeight>e.clientHeight+1)return e}return n.ownerDocument.defaultView??window}var vm=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function v1(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var x1=(n,e,t)=>{let r=v1(n,t);if(!r)return!1;let o=xm(r);if(!o){let s=r.blockRange(),l=s&&at(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Sm(n,o,e,-1))return!0;if(r.parent.content.size==0&&(ir(i,"end")||R.isSelectable(i)))for(let s=r.depth;;s--){let l=Or(n.doc,r.before(s),r.after(s),D.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(ir(i,"end")?U.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):R.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function ir(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var w1=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=xm(r)}let s=i&&i.nodeBefore;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function xm(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function S1(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var M1=(n,e,t)=>{let r=S1(n,t);if(!r)return!1;let o=wm(r);if(!o)return!1;let i=o.nodeAfter;if(Sm(n,o,e,1))return!0;if(r.parent.content.size==0&&(ir(i,"start")||R.isSelectable(i))){let s=Or(n.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(ir(i,"start")?U.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):R.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},E1=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=wm(r)}let s=i&&i.nodeAfter;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos)).scrollIntoView()),!0)};function wm(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var Di=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&at(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},C1=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
21
+ `).scrollIntoView()),!0)};function Ec(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Cc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=Ec(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(U.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},A1=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof de||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ec(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(F.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},T1=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Ct(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&at(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function N1(n){return(e,t)=>{if(e.selection instanceof R&&e.selection.node.isBlock){let{$from:f}=e.selection;return!f.parentOffset||!Ct(e.doc,f.pos)?!1:(t&&t(e.tr.split(f.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof F||e.selection instanceof de)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let f=o.depth;;f--)if(o.node(f).isBlock){c=o.end(f)==o.pos+(o.depth-f),u=o.start(f)==o.pos-(o.depth-f),a=Ec(o.node(f-1).contentMatchAt(o.indexAfter(f-1)));let m=n&&n(o.parent,c,o);s.unshift(m||(c&&a?{type:a}:null)),l=f;break}else{if(f==1)return!1;s.unshift(null)}let d=o.pos,p=Ct(r.doc,d,s.length,s);if(p||(s[0]=a?{type:a}:null,p=Ct(r.doc,d,s.length,s)),!p)return!1;if(r.split(d,s.length,s),!c&&u&&o.node(l).type!=a){let f=r.mapping.slice(i),h=f.map(o.before(l)),m=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(f.map(o.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var O1=N1();var L1=(n,e)=>(e&&e(n.tr.setSelection(new de(n.doc))),!0);function P1(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||ct(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Sm(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&P1(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,h=T.empty;for(let k=s.length-1;k>=0;k--)h=T.from(s[k].create(null,h));h=T.from(o.copy(h));let m=n.tr.step(new re(e.pos-1,f,e.pos,f,new D(h,1,0),s.length,!0)),g=m.doc.resolve(f+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&ct(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:U.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),p=d&&at(d);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(d,p).scrollIntoView()),!0;if(c&&ir(i,"start",!0)&&ir(o,"end")){let f=o,h=[];for(;h.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let k=T.empty;for(let M=h.length-1;M>=0;M--)k=T.from(h[M].copy(k));let x=n.tr.step(new re(e.pos-h.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new D(k,h.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function Mm(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var R1=Mm(-1),D1=Mm(1);function _i(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&ln(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Ac(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function _1(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:i,$to:s}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function I1(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:o}=n[t];r.doc.nodesBetween(r.pos,o.pos,(i,s)=>{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new cn(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.pos<o.pos&&e.push(new cn(r,o))}return e}function Xt(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,o=(t&&t.enterInlineAtoms)!==!1,i=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!_1(s.doc,u,n,o))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let d,p=s.tr;o||(u=I1(u)),r?d=!u.some(f=>s.doc.rangeHasMark(f.$from.pos,f.$to.pos,n)):d=!u.every(f=>{let h=!1;return p.doc.nodesBetween(f.$from.pos,f.$to.pos,(m,g,k)=>{if(h)return!1;h=!n.isInSet(m.marks)&&!!k&&k.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,f.$from.pos-g),Math.min(m.nodeSize,f.$to.pos-g))))}),!h});for(let f=0;f<u.length;f++){let{$from:h,$to:m}=u[f];if(!d)p.removeMark(h.pos,m.pos,n);else{let g=h.pos,k=m.pos,x=h.nodeAfter,M=m.nodeBefore,L=i&&x&&x.isText?/^\s*/.exec(x.text)[0].length:0,O=i&&M&&M.isText?/\s*$/.exec(M.text)[0].length:0;g+L<k&&(g+=L,k-=O),p.addMark(g,k,n.create(e))}}l(p.scrollIntoView())}return!0}}function sr(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}var Mc=sr(vm,x1,w1),km=sr(vm,M1,E1),Dt={Enter:sr(C1,A1,T1,O1),"Mod-Enter":Cc,Backspace:Mc,"Mod-Backspace":Mc,"Shift-Backspace":Mc,Delete:km,"Mod-Delete":km,"Mod-a":L1},Em={"Ctrl-h":Dt.Backspace,"Alt-Backspace":Dt["Mod-Backspace"],"Ctrl-d":Dt.Delete,"Ctrl-Alt-Backspace":Dt["Mod-Delete"],"Alt-Delete":Dt["Mod-Delete"],"Alt-d":Dt["Mod-Delete"],"Ctrl-a":R1,"Ctrl-e":D1};for(let n in Dt)Em[n]=Dt[n];var H1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Cm=H1?Em:Dt;var Fc={};q(Fc,{commands:()=>Ue,convertList:()=>_m,findParentList:()=>Dm,getActiveAlign:()=>Zt,getLinkAt:()=>Cn,insertImage:()=>Bc,isCommandActive:()=>cr,isMarkActive:()=>ar,isNodeActive:()=>Ze,listIndent:()=>Ic,listOutdent:()=>Hc,markRange:()=>An,marksOf:()=>ce,nodesOf:()=>Z,replaceSelectionWithBlock:()=>qi,setLink:()=>s0});var Pc={};q(Pc,{closeHistory:()=>K1,history:()=>Lc,isHistoryTransaction:()=>X1,redo:()=>zi,redoDepth:()=>Y1,redoNoScroll:()=>J1,undo:()=>Fi,undoDepth:()=>G1,undoNoScroll:()=>U1});var Ii=200,ve=function(){};ve.prototype.append=function(e){return e.length?(e=ve.from(e),!this.length&&e||e.length<Ii&&this.leafAppend(e)||this.length<Ii&&e.leafPrepend(this)||this.appendInner(e)):this};ve.prototype.prepend=function(e){return e.length?ve.from(e).append(this):this};ve.prototype.appendInner=function(e){return new B1(this,e)};ve.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ve.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ve.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ve.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ve.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};ve.from=function(e){return e instanceof ve?e:e&&e.length?new Am(e):ve.empty};var Am=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Ii)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Ii)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ve);ve.empty=new Am([]);var B1=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(ve),Tc=ve;var F1=500,Mn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){o||(o=this.remapping(r,p+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new mt(d.map));let f=d.step.map(o.slice(i)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new mt(h,void 0,void 0,c.length+u.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new mt(e.mapping.maps[u],d,t),f;(f=a&&a.merge(p))&&(p=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(p),t&&(s++,t=void 0),o||(a=p)}let c=s-r.depth;return c>$1&&(l=z1(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new In;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new mt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],o=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},o);let a=t;this.items.forEach(p=>{let f=i.getMirror(--a);if(f==null)return;s=Math.min(s,f);let h=i.maps[f];if(p.step){let m=e.steps[f].invert(e.docs[f]),g=p.selection&&p.selection.map(i.slice(a+1,f));g&&l++,r.push(new mt(h,m,g))}else r.push(new mt(h))},o);let c=[];for(let p=t;p<s;p++)c.push(new mt(i.maps[p]));let u=this.items.slice(0,o).append(c).append(r),d=new n(u,l);return d.emptyItemCount()>F1&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&i++;let d=new mt(c.invert(),a,u),p,f=o.length-1;(p=o.length&&o[f].merge(d))?o[f]=p:o.push(d)}}else s.map&&r--},this.items.length,0),new n(Tc.from(o.reverse()),i)}};Mn.empty=new Mn(Tc.empty,0);function z1(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var mt=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},gt=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},$1=20;function V1(n,e,t,r){let o=t.getMeta(yt),i;if(o)return o.historyState;t.getMeta(Om)&&(n=new gt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(yt))return s.getMeta(yt).redo?new gt(n.done.addTransform(t,void 0,r,Hi(e)),n.undone,Tm(t.mapping.maps),n.prevTime,n.prevComposition):new gt(n.done,n.undone.addTransform(t,void 0,r,Hi(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!q1(t,n.prevRanges)),c=s?Nc(n.prevRanges,t.mapping):Tm(t.mapping.maps);return new gt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Hi(e)),Mn.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new gt(n.done.rebased(t,i),n.undone.rebased(t,i),Nc(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new gt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Nc(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function q1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function Tm(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function Nc(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function j1(n,e){for(let t=0;t<e.steps.length;t++){let r=e.mapping.maps[t],o=-1;if(r.forEach((i,s)=>o=s),o<0){let i=e.steps[t];(i instanceof Je||i instanceof Ge)&&(o=i.to)}if(o>-1)return U.near(n.doc.resolve(o))}return n.selection}function W1(n,e,t){let r=Hi(e),o=yt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,j1(e,i.transform).getBookmark(),o,r),a=new gt(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(yt,{redo:t,historyState:a})}var Oc=!1,Nm=null;function Hi(n){let e=n.plugins;if(Nm!=e){Oc=!1,Nm=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Oc=!0;break}}return Oc}function K1(n){return n.setMeta(Om,!0)}var yt=new X("history"),Om=new X("closeHistory");function Lc(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new z({key:yt,state:{init(){return new gt(Mn.empty,Mn.empty,null,0,-1)},apply(e,t,r){return V1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Fi:r=="historyRedo"?zi:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Bi(n,e){return(t,r)=>{let o=yt.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=W1(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var Fi=Bi(!1,!0),zi=Bi(!0,!0),U1=Bi(!1,!1),J1=Bi(!0,!1);function G1(n){let e=yt.getState(n);return e?e.done.eventCount:0}function Y1(n){let e=yt.getState(n);return e?e.undone.eventCount:0}function X1(n){return n.getMeta(yt)!=null}var _c={};q(_c,{blockUnitAt:()=>Rc,duplicateBlock:()=>e0,moveBlock:()=>$i,selectedBlockUnit:()=>Dc});function Rc(n){for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name==="list_item")return{node:t,pos:n.before(e),depth:e}}if(n.depth===0){let e=n.nodeAfter;return e?{node:e,pos:n.pos,depth:1}:null}return{node:n.node(1),pos:n.before(1),depth:1}}function Dc(n){let{selection:e}=n;return e instanceof R?{node:e.node,pos:e.from,depth:e.$from.depth+1}:e instanceof F?Rc(e.$from):null}function Z1(n){let e=Dc(n);if(!e)return null;let{selection:t}=n;if(!(t instanceof R)&&e.node.type.spec.tableRole==="table")return null;let r=n.doc.resolve(e.pos),o=r.parent,i=r.index(),s=i;if(!t.empty&&!(t instanceof R)){let a=Rc(t.$to);if(a&&a.depth===e.depth){let c=n.doc.resolve(a.pos);c.start()===r.start()&&(s=Math.max(i,c.index()))}}let l=e.pos;for(let a=i;a<=s;a++)l+=o.child(a).nodeSize;return{parent:o,startIndex:i,endIndex:s,from:e.pos,to:l}}function Q1(n,e,t){let{selection:r}=e;n.setSelection(r instanceof R?R.create(n.doc,r.from+t):F.create(n.doc,r.anchor+t,r.head+t))}function $i(n){return(e,t)=>{let r=Z1(e);if(!r)return!1;let{parent:o,startIndex:i,endIndex:s,from:l,to:a}=r,c=n<0?i-1:s+1;if(c<0||c>=o.childCount)return!1;let u=o.child(c),d=[];for(let g=i;g<=s;g++)d.push(o.child(g));let p=T.fromArray(d),f=n<0?p.append(T.from(u)):T.from(u).append(p),h=Math.min(i,c),m=Math.max(s,c);if(!o.canReplace(h,m+1,f))return!1;if(t){let g=n<0?e.tr.replaceWith(l-u.nodeSize,a,f):e.tr.replaceWith(l,a+u.nodeSize,f);Q1(g,e,n*u.nodeSize),t(g.scrollIntoView())}return!0}}var e0=(n,e)=>{let t=Dc(n);if(!t||t.node.type.spec.tableRole==="table"&&!(n.selection instanceof R))return!1;let r=t.pos+t.node.nodeSize,o=n.doc.resolve(r);if(!o.parent.canReplaceWith(o.index(),o.index(),t.node.type))return!1;if(e){let i=n.tr.insert(r,t.node);i.setSelection(R.create(i.doc,r)),e(i.scrollIntoView())}return!0};var Z=n=>n.schema.nodes,ce=n=>n.schema.marks,ro=(n,e)=>(t,r,o)=>e(Z(t)[n])(t,r,o),En=(n,e)=>(t,r,o)=>e(ce(t)[n])(t,r,o);function Vi(n){return(e,t)=>{let{from:r,to:o}=e.selection,i=e.tr,s=!1;return e.doc.nodesBetween(r,o,(l,a)=>{let c=Z(e);(l.type===c.paragraph||l.type===c.heading)&&(s=!0,i=i.setNodeMarkup(a,void 0,{...l.attrs,align:n}))}),s?(t?.(i),!0):!1}}function qi(n,e){let{$from:t}=n.selection;if(e.isBlock)for(let r=t.depth-1;r>0;r--){let o=t.node(r);if(!o.type.spec.isolating)continue;let i=!1;for(let l=0;l<=o.childCount&&!i;l++)i=o.canReplaceWith(l,l,e.type);if(i)break;let s=t.after(r);return n.insert(s,e),n.setSelection(U.near(n.doc.resolve(s+e.nodeSize)))}return n.replaceSelectionWith(e)}var t0=(n,e)=>(e?.(qi(n.tr,Z(n).horizontal_rule.create()).scrollIntoView()),!0),n0=(n,e)=>{let{from:t,to:r,empty:o,$from:i}=n.selection,s=ce(n);if(o){let l=An(n,s.link,i.pos);return l?(e?.(n.tr.removeMark(l.from,l.to,s.link)),!0):!1}return n.doc.rangeHasMark(t,r,s.link)?(e?.(n.tr.removeMark(t,r,s.link)),!0):!1},r0=(n,e)=>{let{from:t,to:r,empty:o}=n.selection;if(o)return!1;if(e){let i=ce(n),s=n.tr;for(let l of Object.values(i))l!==i.link&&(s=s.removeMark(t,r,l));e(s)}return!0};function Pm(n){return(e,t)=>{let r=Z(e),o=[],{from:i,to:s}=e.selection;if(e.doc.nodesBetween(i,s,(l,a,c)=>{if(l.type!==r.paragraph&&l.type!==r.heading)return!0;if(c?.type!==r.list_item){let u=or(l.attrs.indent),d=or(u+n);d!==u&&o.push({pos:a,attrs:{...l.attrs,indent:d}})}return!1}),!o.length)return!1;if(t){let l=e.tr;for(let{pos:a,attrs:c}of o)l.setNodeMarkup(a,void 0,c);t(l.scrollIntoView())}return!0}}var o0=(n,e,t)=>pi(Z(n).list_item)(n,e,t)||Pm(1)(n,e,t),i0=(n,e,t)=>bn(Z(n).list_item)(n,e,t)||Pm(-1)(n,e,t),Ic=(n,e,t)=>pi(Z(n).list_item)(n,e,t),Hc=(n,e,t)=>bn(Z(n).list_item)(n,e,t);function Rm(n,e={}){let t=Ac(n,e);return(r,o)=>{if(!t(r))return!1;if(o){let i=r.tr;for(let s of r.selection.ranges)i.setBlockType(s.$from.pos,s.$to.pos,n,l=>({...e,..."align"in n.spec.attrs&&l.attrs.align?{align:l.attrs.align}:{},..."lineHeight"in n.spec.attrs&&l.attrs.lineHeight?{lineHeight:l.attrs.lineHeight}:{},..."dir"in n.spec.attrs&&l.attrs.dir?{dir:l.attrs.dir}:{},..."indent"in n.spec.attrs&&l.attrs.indent?{indent:l.attrs.indent}:{},..."id"in n.spec.attrs&&l.attrs.id?{id:l.attrs.id}:{}}));o(i.scrollIntoView())}return!0}}function lr(n){return ro("heading",e=>Rm(e,{level:n}))}var Ue={bold:En("bold",Xt),italic:En("italic",Xt),underline:En("underline",Xt),strike:En("strike",Xt),code:En("code",Xt),subscript:En("subscript",Xt),superscript:En("superscript",Xt),paragraph:ro("paragraph",n=>Rm(n)),h1:lr(1),h2:lr(2),h3:lr(3),h4:lr(4),h5:lr(5),h6:lr(6),blockquote:(n,e)=>Ze(n,Z(n).blockquote)?Di(n,e):_i(Z(n).blockquote)(n,e),codeBlock:ro("code_block",n=>Ac(n)),bulletList:ro("bullet_list",Lm),orderedList:ro("ordered_list",Lm),indent:o0,outdent:i0,alignLeft:Vi(null),alignCenter:Vi("center"),alignRight:Vi("right"),alignJustify:Vi("justify"),horizontalRule:t0,unlink:n0,clearFormatting:r0,undo:Fi,redo:zi,moveBlockUp:$i(-1),moveBlockDown:$i(1)};function Dm(n){let e=Z(n),{$from:t}=n.selection;for(let r=t.depth;r>0;r--){let o=t.node(r);if(o.type===e.bullet_list||o.type===e.ordered_list)return{node:o,pos:t.before(r)}}return null}function _m(n,e,t,r=!1){let o=n.doc.type.schema.nodes,i=t===o.bullet_list&&r;return n.setNodeMarkup(e.pos,t,t===o.bullet_list?{listStyle:null,checklist:i}:{start:1}),e.node.forEach((s,l)=>{let a=s.attrs.checked,c=i?typeof a=="boolean"?a:!1:null;c!==a&&n.setNodeMarkup(e.pos+1+l,void 0,{...s.attrs,checked:c})}),n}function Lm(n){return(e,t)=>{let r=Z(e),o=n===r.bullet_list?{checklist:!1}:void 0;if(Ze(e,n,o))return bn(r.list_item)(e,t);let i=Dm(e);return i?(t&&t(_m(e.tr,i,n).scrollIntoView()),!0):ba(n)(e,t)}}function s0(n,e={}){return(t,r)=>{if(!Ie(n))return!1;let{from:o,to:i,empty:s,$from:l}=t.selection,a=ce(t),c=a.link.create({href:n,title:e.title??null,target:e.target??null});if(s){let u=An(t,a.link,l.pos);return u?(r?.(t.tr.removeMark(u.from,u.to,a.link).addMark(u.from,u.to,c)),!0):(r?.(t.tr.insert(o,t.schema.text(n,[c]))),!0)}return r?.(t.tr.removeMark(o,i,a.link).addMark(o,i,c)),!0}}function Bc(n,e){return(t,r)=>fe(n)?(r?.(t.tr.replaceSelectionWith(Z(t).image.create({src:n,alt:e??null})).scrollIntoView()),!0):!1}function ar(n,e){let{from:t,$from:r,to:o,empty:i}=n.selection;return i?!!e.isInSet(n.storedMarks??r.marks()):n.doc.rangeHasMark(t,o,e)}function Ze(n,e,t){let{$from:r,to:o}=n.selection;for(let i=r.depth;i>0;i--){let s=r.node(i);if(s.type===e&&(!t||Object.entries(t).every(([l,a])=>s.attrs[l]===a)))return o<=r.end(i)}return!1}function Zt(n){return n.selection.$from.parent.attrs.align??"left"}function cr(n,e){let t=n.selection.$from.parent,r=Z(n),o=ce(n);switch(e){case"bold":case"italic":case"underline":case"strike":case"code":case"subscript":case"superscript":return ar(n,o[e]);case"paragraph":return t.type===r.paragraph;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t.type===r.heading&&t.attrs.level===Number(e[1]);case"codeBlock":return t.type===r.code_block;case"blockquote":return Ze(n,r.blockquote);case"bulletList":return Ze(n,r.bullet_list,{checklist:!1});case"orderedList":return Ze(n,r.ordered_list);case"alignLeft":return Zt(n)==="left";case"alignCenter":return Zt(n)==="center";case"alignRight":return Zt(n)==="right";case"alignJustify":return Zt(n)==="justify";default:return!1}}function Cn(n){let{$from:e}=n.selection,t=ce(n),r=t.link.isInSet(e.marks())??t.link.isInSet(e.nodeAfter?.marks??[]);return r?r.attrs:null}function An(n,e,t){let r=n.doc.resolve(t),o=r.start(),i=[];return r.parent.forEach((s,l)=>{if(!e.isInSet(s.marks))return;let a=o+l,c=a+s.nodeSize,u=i[i.length-1];u&&u.to===a?u.to=c:i.push({from:a,to:c})}),i.find(s=>s.from<=t&&t<=s.to)??null}var l0={strong:"bold",b:"bold",em:"italic",i:"italic",u:"underline",s:"strike",strike:"strike",del:"strike",code:"code",sub:"subscript",sup:"superscript"},a0={color:{mark:"color",read:Y.color},"background-color":{mark:"background",read:Y.color},"font-family":{mark:"font_family",read:Y.fontFamily},"font-size":{mark:"font_size",read:Y.length}},Gi={p:n=>n.type.name==="paragraph",h1:n=>n.type.name==="heading"&&n.attrs.level===1,h2:n=>n.type.name==="heading"&&n.attrs.level===2,h3:n=>n.type.name==="heading"&&n.attrs.level===3,h4:n=>n.type.name==="heading"&&n.attrs.level===4,h5:n=>n.type.name==="heading"&&n.attrs.level===5,h6:n=>n.type.name==="heading"&&n.attrs.level===6,blockquote:n=>n.type.name==="blockquote",pre:n=>n.type.name==="code_block",img:n=>n.type.name==="image"},Im=new Set;function Yi(n){Im.has(n)||(Im.add(n),console.warn(`[nova] formats: ${n}`))}function Qe(n){return Array.isArray(n)?n.flatMap(Qe):typeof n=="string"?n.split(/\s+/).filter(Boolean):[]}function oo(n){let e=[];for(let t of n)e.push(...Qe(t.classes)),"items"in t&&t.items&&e.push(...oo(t.items));return e}var Ki=(n,e)=>{let t=Qe(n);return e.every(r=>t.includes(r))},ji=(n,e)=>{let t=[...new Set([...Qe(n),...e])];return t.length?t.join(" "):null},Wi=(n,e)=>{let t=Qe(n).filter(r=>!e.includes(r));return t.length?t.join(" "):null};function Ui(n){let e={};for(let[t,r]of Object.entries(n.styles??{}))t==="text-align"&&Yr.includes(r)?e.align=r:t==="line-height"&&Y.lineHeight(r)?e.lineHeight=Y.lineHeight(r):Yi(`style "${t}" is not supported on blocks`);return e}function Vc(n,e){let t=ce(n),r=[];if(e.inline&&e.inline!=="span"){let i=t[l0[e.inline]];i&&r.push(i.create())}let o=Qe(e.classes);o.length&&t.span_class&&r.push(t.span_class.create({class:o.join(" ")}));for(let[i,s]of Object.entries(e.styles??{})){let l=a0[i],a=l?.read(s),c=l?t[l.mark]:void 0;c&&a?r.push(c.create({value:a})):Yi(`style "${i}: ${s}" is not supported on text`)}return r}var Xi=n=>(n.selector??"").split(",").map(e=>e.trim().toLowerCase()).filter(e=>Gi[e]?!0:(Yi(`selector "${e}" is not supported`),!1));function Zi(n,e){let t=[],r=a=>e.some(c=>Gi[c](a)),{selection:o}=n;if(o instanceof R&&r(o.node))return[{node:o.node,pos:o.from}];let{$from:i,from:s,to:l}=o;for(let a=i.depth;a>0;a--){let c=i.node(a);r(c)&&t.push({node:c,pos:i.before(a)})}return n.doc.nodesBetween(s,l,(a,c)=>{r(a)&&!t.some(u=>u.pos===c)&&t.push({node:a,pos:c})}),t}function zc(n){let e=[],{from:t,to:r}=n.selection;return n.doc.nodesBetween(t,r,(o,i)=>o.isTextblock?(e.push({node:o,pos:i}),!1):!0),e}function qc(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.name==="blockquote")return{node:r,pos:e.before(t)}}return null}function Fm(n){return{align:n.align??null,lineHeight:n.lineHeight??null,dir:n.dir??null}}var Ji=class{constructor(e,t){S(this,"editor",e);S(this,"allowedClasses",t);S(this,"registry",new Map)}register(e,t){let r=Array.isArray(t)?t:[t];this.registry.set(e,r),oo(r).forEach(o=>this.allowedClasses.add(o))}unregister(e){this.registry.delete(e)}has(e){return this.registry.has(e)}get(e){return this.registry.get(e)}resolve(e){if(typeof e!="string")return[e];let t=this.registry.get(e);return t||Yi(`unknown format "${e}"`),t??[]}canApply(e){if(!this.editor.isEditable())return!1;let t=this.editor.view.state;return this.resolve(e).some(r=>Hm(t,r))}match(e){let t=this.editor.view.state;return this.resolve(e).some(r=>c0(t,r))}apply(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);if(!t.length)return!1;let r=t.find(o=>Hm(this.editor.view.state,o))??t[0];return this.run((o,i)=>u0(o,i,r))}remove(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);return t.length?this.run((r,o)=>t.forEach(i=>d0(r,o,i))):!1}toggle(e){return this.match(e)?this.remove(e):this.apply(e)}run(e){let{view:t}=this.editor,r=t.state.tr;return e(t.state,r)===!1?!1:((r.docChanged||r.storedMarksSet)&&t.dispatch(r.scrollIntoView()),t.focus(),!0)}};function Hm(n,e){return e.selector?Zi(n,Xi(e)).length>0:!0}function Bm(n,e){return n.type.name==="image"?!0:Object.entries(Ui(e)).every(([t,r])=>n.attrs[t]===r)}function c0(n,e){let t=Qe(e.classes);if(e.block){if(e.block==="blockquote"){let o=qc(n);return!!o&&Ki(o.node.attrs.class,t)}let r=n.selection.$from.parent;return Gi[e.block](r)&&Ki(r.attrs.class,t)&&Bm(r,e)}if(e.selector){let r=Zi(n,Xi(e));return r.length>0&&r.some(({node:o})=>Ki(o.attrs.class,t)&&Bm(o,e))}if(e.inline){let r=Vc(n,e);if(!r.length)return!1;let{$from:o,empty:i,from:s,to:l}=n.selection;if(i){let u=n.storedMarks??o.marks();return r.every(d=>u.some(p=>$c(p,d)))}let a=!1,c=!0;return n.doc.nodesBetween(s,l,u=>{u.isText&&(a=!0,r.every(d=>u.marks.some(p=>$c(p,d)))||(c=!1))}),a&&c}return!1}function $c(n,e){return n.type!==e.type?!1:e.type.name==="span_class"?Ki(n.attrs.class,Qe(e.attrs.class)):e.attrs.value===void 0||n.attrs.value===e.attrs.value}function u0(n,e,t){let r=Qe(t.classes),o=Z(n);if(t.block==="blockquote"){let i=qc(n);return i?(e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:ji(i.node.attrs.class,r)}),!0):_i(o.blockquote,{class:ji(null,r)})(n,s=>s.steps.forEach(l=>e.step(l)))}if(t.block==="pre"){for(let{node:i,pos:s}of zc(n))i.type!==o.code_block&&e.setNodeMarkup(s,o.code_block,{language:null});return!0}if(t.block){let i=t.block==="p"?0:Number(t.block.slice(1)),s=i?o.heading:o.paragraph,l=Ui(t);for(let{node:a,pos:c}of zc(n)){if(a.type===o.code_block&&a.textContent.includes(`
22
+ `))continue;let u=a.type===s&&(!i||a.attrs.level===i);e.setNodeMarkup(c,s,{...Fm(a.attrs),...i?{level:i}:{},...l,class:ji(u?a.attrs.class:null,r)})}return!0}if(t.selector){let i=Ui(t),s=Zi(n,Xi(t));if(!s.length)return!1;for(let{node:l,pos:a}of s){let c=l.type.name==="image"?{}:i;e.setNodeMarkup(a,void 0,{...l.attrs,...c,class:ji(l.attrs.class,r)})}return n.selection instanceof R&&e.setSelection(R.create(e.doc,n.selection.from)),!0}if(t.inline){let i=Vc(n,t);if(!i.length)return!1;let{empty:s,ranges:l}=n.selection;if(s){let a=n.storedMarks??n.selection.$from.marks();for(let c of i)a=c.addToSet(a);return e.setStoredMarks(a),!0}for(let{$from:a,$to:c}of l)for(let u of i)e.addMark(a.pos,c.pos,u);return!0}return!1}function d0(n,e,t){let r=Qe(t.classes),o=Z(n);if(t.block==="blockquote"){let i=qc(n);if(!i)return;let s=Wi(i.node.attrs.class,r);if(r.length&&s!==null){e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:s});return}Di(n,l=>l.steps.forEach(a=>e.step(a)));return}if(t.block){for(let{node:i,pos:s}of zc(n))Gi[t.block](i)&&e.setNodeMarkup(s,o.paragraph,{...Fm(i.attrs),class:t.block==="p"?Wi(i.attrs.class,r):null});return}if(t.selector){let i=Ui(t);for(let{node:s,pos:l}of Zi(n,Xi(t))){let a={};s.type.name!=="image"&&("align"in i&&s.attrs.align===i.align&&(a.align=null),"lineHeight"in i&&s.attrs.lineHeight===i.lineHeight&&(a.lineHeight=null)),e.setNodeMarkup(l,void 0,{...s.attrs,...a,class:Wi(s.attrs.class,r)})}n.selection instanceof R&&e.setSelection(R.create(e.doc,n.selection.from));return}if(t.inline){let i=Vc(n,t),{empty:s,from:l,to:a,$from:c}=n.selection;if(s){let u=(n.storedMarks??c.marks()).filter(d=>!i.some(p=>$c(d,p)));e.setStoredMarks(u);return}for(let u of i){if(u.type.name!=="span_class"){e.removeMark(l,a,u.type);continue}n.doc.nodesBetween(l,a,(d,p)=>{if(!d.isText)return;let f=d.marks.find(k=>k.type===u.type);if(!f)return;let h=Math.max(p,l),m=Math.min(p+d.nodeSize,a);e.removeMark(h,m,u.type);let g=Wi(f.attrs.class,Qe(u.attrs.class));g&&e.addMark(h,m,u.type.create({class:g}))})}}}var Wc={};q(Wc,{absolutizeUrls:()=>jm,attachCss:()=>jc,loadCss:()=>es,scopeCss:()=>Qi,scopeSelector:()=>qm,splitSelectors:()=>Vm,splitTopLevel:()=>$m});var p0=/^@(font-face|(-webkit-)?keyframes|property|counter-style|page|font-feature-values|font-palette-values)\b/i,f0=/^@(media|supports|container|layer|document|scope)\b/i;function $m(n){let e=[],t=0,r=0,o=0,i="";for(;t<n.length;){let s=n[t];if(s==="/"&&n[t+1]==="*"){let l=n.indexOf("*/",t+2),a=l===-1?n.length:l+2;if(o===0){n=n.slice(0,t)+n.slice(a);continue}t=a;continue}if(s==='"'||s==="'"){for(t++;t<n.length&&n[t]!==s;)t+=n[t]==="\\"?2:1;t++;continue}if(s==="{")o===0&&(i=n.slice(r,t).trim(),r=t+1),o++;else if(s==="}")o--,o===0&&(e.push({prelude:i,body:n.slice(r,t)}),r=t+1),o<0&&(o=0);else if(s===";"&&o===0){let l=n.slice(r,t).trim();l&&e.push({prelude:l,body:null}),r=t+1}t++}return e}function Vm(n){let e=[],t=0,r="",o=0;for(let i=0;i<n.length;i++){let s=n[i];r?s==="\\"?i++:s===r&&(r=""):s==='"'||s==="'"?r=s:s==="("||s==="["?t++:s===")"||s==="]"?t--:s===","&&t===0&&(e.push(n.slice(o,i)),o=i+1)}return e.push(n.slice(o)),e.map(i=>i.trim()).filter(Boolean)}function qm(n,e){let t=n,r=!1;for(;;){let o=t.match(/^(html|body|:root)(?![\w-])\s*/i);if(!o)break;r=!0,t=t.slice(o[0].length)}if(!r)return`${e} ${n}`;if(/^[.#[:]/.test(t)){let o=t.search(/[\s>+~]/);return o===-1?`${e}${t}`:`${e}${t.slice(0,o)} ${t.slice(o).trim()}`}return t?`${e} ${t}`:e}function Qi(n,e){let t=[];for(let{prelude:r,body:o}of $m(n)){if(o===null){/^@layer\b/i.test(r)&&t.push(`${r};`);continue}if(p0.test(r))t.push(`${r}{${o}}`);else if(f0.test(r))t.push(`${r}{${Qi(o,e)}}`);else{if(r.startsWith("@"))continue;{let i=Vm(r).map(s=>qm(s,e));i.length&&t.push(`${i.join(", ")}{${o}}`)}}}return t.join(`
23
+ `)}function jm(n,e){return n.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,(t,r,o)=>{if(/^(data:|https?:|\/\/|#)/i.test(o))return t;try{return`url(${r}${new URL(o,e).href}${r})`}catch{return t}})}var zm=/@import\s+(?:url\(\s*)?(['"]?)([^'")\s;]+)\1\s*\)?([^;]*);/gi;async function es(n,e=0){let t=new URL(n,document.baseURI).href,r=await fetch(t);if(!r.ok)throw new Error(`HTTP ${r.status}`);let o=jm(await r.text(),t);if(e>=3)return o.replace(zm,"");let i=[...o.matchAll(zm)];for(let s of i){let l=s[3].trim(),a="";try{a=await es(new URL(s[2],t).href,e+1)}catch(c){console.warn(`[nova] contentCss: could not load ${s[2]}`,c)}o=o.replace(s[0],l?`@media ${l}{${a}}`:a)}return o}function jc(n,e){let t=n.getRootNode();if("adoptedStyleSheets"in t&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)try{let i=new CSSStyleSheet;return i.replaceSync(e),t.adoptedStyleSheets=[...t.adoptedStyleSheets,i],()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(s=>s!==i)}}catch{}let o=document.createElement("style");return o.setAttribute("data-nova-content-css",""),o.textContent=e,n.prepend(o),()=>o.remove()}function Wm(n={}){return new z({view(e){return new Kc(e,n)}})}var Kc=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(t){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let h=f.getBoundingClientRect(),m=d?h.bottom:h.top;d&&p&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Nr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var Ce=class n extends U{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):U.near(r)}content(){return D.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Uc(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!h0(e)||!m0(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!R.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};Ce.prototype.visible=!1;Ce.findFrom=Ce.findGapCursorFrom;U.jsonID("gapcursor",Ce);var Uc=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ce.valid(t)?new Ce(t):U.near(t)}};function Km(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function h0(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Km(o.type))return!0;if(o.inlineContent)return!1}}return!0}function m0(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Km(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Um(){return new z({props:{decorations:k0,createSelectionBetween(n,e,t){return e.pos==t.pos&&Ce.valid(t)?new Ce(t):null},handleClick:y0,handleKeyDown:g0,handleDOMEvents:{beforeinput:b0}}})}var g0=ri({ArrowLeft:ts("horiz",-1),ArrowRight:ts("horiz",1),ArrowUp:ts("vert",-1),ArrowDown:ts("vert",1)});function ts(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof F){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Ce.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new Ce(c))),!0):!1}}function y0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Ce.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&R.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Ce(r))),!0)}function b0(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Ce))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=T.empty;for(let s=r.length-1;s>=0;s--)o=T.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new D(o,0,0));return i.setSelection(F.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function k0(n){if(!(n.selection instanceof Ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(n.doc,[ge.widget(n.selection.head,e,{key:"gapcursor"})])}var au={};q(au,{UPLOAD_RETRY_DELAYS:()=>Ym,dataUrlToFile:()=>Zm,embeddedImageUploadPlugin:()=>tu,exitImageCaption:()=>iu,getSelectedImage:()=>et,hasImageCaption:()=>ru,imageDropPastePlugin:()=>nu,isSupportedImage:()=>so,openImageAltDialog:()=>lu,openImageDialog:()=>lo,setImageAttrs:()=>ur,setImageWidthFraction:()=>su,toggleImageCaption:()=>ou,uploadEmbeddedImage:()=>eu,uploadImages:()=>ns});var Jc={};q(Jc,{attachFilePicker:()=>io});function io(n,e,t,r){let{filePicker:o,filePickerTypes:i}=n.options;if(!o||i&&!i.includes(t))return;let{input:s}=e,l=w("button",{type:"button",className:"nova-btn nova-input-action","aria-label":n.ui.t("dialog.browse"),title:n.ui.t("dialog.browse")},ee(C.browse)),a=w("div",{className:"nova-input-group"});s.replaceWith(a),a.append(s,l),l.addEventListener("click",async()=>{l.disabled=!0;try{let c=await o({type:t,value:s.value});if(!c?.url)return;s.value=c.url,s.removeAttribute("aria-invalid"),r?.(c)}catch(c){console.error("[nova] filePicker failed:",c)}finally{l.disabled=!1,s.isConnected&&s.focus()}})}var Xc={};q(Xc,{checkboxField:()=>Yc,openDialog:()=>Gc,selectField:()=>v0,textField:()=>ze});function Gc(n){let e=je("nova-dialog-title"),t=w("p",{className:"nova-dialog-error",role:"alert",hidden:!0}),r=w("button",{type:"submit",className:"nova-button nova-button-primary",hidden:!n.submitLabel},n.submitLabel??""),o=w("button",{type:"button",className:"nova-button"},n.cancelLabel),i=w("button",{type:"button",className:"nova-btn nova-dialog-close","aria-label":n.closeLabel},ee(C.close)),s=w("form",{className:n.size==="large"?"nova-dialog nova-dialog-large":"nova-dialog",role:"dialog","aria-modal":"true","aria-labelledby":e,novalidate:!0},w("header",{className:"nova-dialog-header"},w("h2",{id:e},n.title),i),w("div",{className:"nova-dialog-body"},n.body,t),w("footer",{className:"nova-dialog-footer"},o,r)),l=w("div",{className:"nova-dialog-backdrop"},s);n.host.append(l);let a=!1,c=()=>{a||(a=!0,l.remove(),p(),n.onClose?.(),n.returnFocus?.())},u=h=>{t.hidden=!h,t.textContent=h??""},d=h=>{r.disabled=h,s.setAttribute("aria-busy",String(h))};s.addEventListener("submit",async h=>{h.preventDefault(),u(null),d(!0);try{let m=n.onSubmit?await n.onSubmit():!0;typeof m=="string"?u(m):m!==!1&&c()}finally{a||d(!1)}}),o.addEventListener("click",c),i.addEventListener("click",c),l.addEventListener("mousedown",h=>{h.target===l&&c()}),s.addEventListener("keydown",h=>{if(h.key==="Escape"&&!h.defaultPrevented)h.preventDefault(),h.stopPropagation(),c();else if(h.key==="Tab"){let m=[...s.querySelectorAll($t)].filter(x=>!x.hidden),g=m[0],k=m[m.length-1];if(!g||!k)return;h.shiftKey&&te(s)===g?(h.preventDefault(),k.focus()):!h.shiftKey&&te(s)===k&&(h.preventDefault(),g.focus())}}),s.tabIndex=-1,s.addEventListener("click",()=>{!a&&!s.contains(te(s))&&s.focus({preventScroll:!0})});let p=ut(s,"focusin",(h,m)=>{let g=m instanceof Element&&m.closest(".nova-dialog")!==null;!s.contains(m)&&!g&&(s.querySelector($t)??s).focus()});return(n.initialFocus??s.querySelector(".nova-dialog-body input, .nova-dialog-body textarea")??(n.submitLabel?r:o)).focus(),{el:s,close:c,setError:u,setBusy:d}}function ze(n){let e=je("nova-field"),t=n.hint?`${e}-hint`:void 0,r=w("input",{id:e,type:n.type??"text",className:"nova-input",value:n.value??"",placeholder:n.placeholder,...n.required?{"aria-required":"true"}:{},autocomplete:n.autocomplete??"off",spellcheck:"false","aria-describedby":t});return r.value=n.value??"",{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),r,n.hint?w("p",{id:t,className:"nova-hint"},n.hint):null),input:r}}function Yc(n,e=!1){let t=je("nova-check"),r=w("input",{id:t,type:"checkbox",className:"nova-checkbox"});return r.checked=e,{el:w("div",{className:"nova-field nova-field-inline"},r,w("label",{for:t},n)),input:r}}function v0(n){let e=je("nova-field"),t=w("select",{id:e,className:"nova-input nova-select"},...n.options.map(o=>w("option",{value:o.value},o.label)));return t.value=n.value,{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),t),select:t}}var x0=/^image\/(png|jpe?g|gif|webp|avif|bmp)$/;function so(n){return x0.test(n.type)}function w0(n){return new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error??new Error("FileReader failed")),r.readAsDataURL(n)})}function Zc(n,e){let t=null;return n.state.doc.descendants((r,o)=>t!==null?!1:(r.type===Z(n.state).image&&r.attrs.src===e&&(t=o),!0)),t}function ns(n,e,t){let r=e.filter(so),o=n.view;for(let i of r){let s=URL.createObjectURL(i),l=Z(o.state).image.create({src:s,alt:null}),a=o.state.tr;t!==void 0?a.insert(Math.min(t,a.doc.content.size),l):a.replaceSelectionWith(l),o.dispatch(a.scrollIntoView()),Qc(n,i,s,0)}}var Ym=[1e3,3e3],rs=class extends Error{};function Qc(n,e,t,r){let o=n.view,{t:i}=n.ui,s=n.options.uploadImage,l=s?n.ui.notify({text:i("image.uploading"),timeout:0}):null,a=s?s(e,d=>l?.setText(`${i("image.uploading")} ${Math.round(d)}%`)):w0(e),c=()=>URL.revokeObjectURL(t),u=()=>{let d=o.isDestroyed?null:Zc(o,t);d!==null&&o.dispatch(o.state.tr.delete(d,d+1).setMeta("addToHistory",!1)),c()};a.then(d=>{if(!fe(d))throw new rs(`Unsafe image URL returned: ${d}`);let p=o.isDestroyed?null:Zc(o,t);if(p!==null){let f=o.state.doc.nodeAt(p);o.dispatch(o.state.tr.setNodeMarkup(p,void 0,{...f.attrs,src:d}).setMeta("addToHistory",!1))}c()}).catch(d=>{if(o.isDestroyed||Zc(o,t)===null)return c();let p=Ym[r];if(s&&p!==void 0&&!(d instanceof rs)){let f=n.ui.notify({text:i("image.retrying"),timeout:0});setTimeout(()=>{if(f.close(),o.isDestroyed)return c();Qc(n,e,t,r+1)},p);return}console.error("[nova] image upload failed",d),n.ui.notify({text:i("image.uploadFailed"),type:"error",actions:[{label:i("image.retry"),onAction:()=>Qc(n,e,t,0)},{label:i("image.delete"),onAction:u}],onClose:u})}).finally(()=>l?.close())}var Xm=/^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i;function Zm(n,e="pasted-image"){let t=n.match(Xm);if(!t)return null;let r=t[1].toLowerCase();try{let o=atob(t[2]),i=new Uint8Array(o.length);for(let l=0;l<o.length;l++)i[l]=o.charCodeAt(l);let s=r.split("/")[1].replace("jpeg","jpg");return new File([i],`${e}.${s}`,{type:r})}catch{return null}}function S0(n,e,t){let r=n.state.tr;n.state.doc.descendants((o,i)=>{o.type===Z(n.state).image&&o.attrs.src===e&&r.setNodeMarkup(i,void 0,{...o.attrs,src:t})}),r.docChanged&&n.dispatch(r.setMeta("addToHistory",!1))}async function eu(n,e){let t=n.options.uploadImage,r=t?Zm(e):null;if(!t||!r)return;let o=n.ui.notify({text:n.ui.t("image.uploading"),timeout:0});try{let i=await t(r,s=>o.setText(`${n.ui.t("image.uploading")} ${Math.round(s)}%`));if(!fe(i))throw new Error(`Unsafe image URL returned: ${i}`);S0(n.view,e,i)}catch(i){console.error("[nova] embedded image upload failed",i),n.ui.notify({text:n.ui.t("image.uploadFailed"),type:"error",actions:[{label:n.ui.t("image.retry"),onAction:()=>{eu(n,e)}}]})}finally{o.close()}}function Jm(n,e){let t=new Set;return n.descendants(r=>{r.type===e&&Xm.test(r.attrs.src)&&t.add(r.attrs.src)}),t}function tu(n){return new z({key:new X("nova-embedded-image-upload"),appendTransaction(e,t,r){if(!n.options.uploadImage||!e.some(a=>["paste","drop"].includes(a.getMeta("uiEvent")))||!e.some(a=>a.docChanged))return null;let i=Z(r).image,s=Jm(t.doc,i),l=[...Jm(r.doc,i)].filter(a=>!s.has(a));return l.length&&queueMicrotask(()=>l.forEach(a=>{eu(n,a)})),null}})}function nu(n){return new z({key:new X("nova-image-drop-paste"),props:{handlePaste(e,t){if(!n.isAllowed("image"))return!1;let r=t.clipboardData;if(!r||r.getData("text/html"))return!1;let o=[...r.files].filter(so);return o.length?(ns(n,o),!0):!1},handleDrop(e,t){if(!n.isAllowed("image"))return!1;let r=[...t.dataTransfer?.files??[]].filter(so);if(!r.length)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return ns(n,r,o?.pos),!0}}})}function lo(n){let{t:e}=n.ui,t=w("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"nova-visually-hidden",tabindex:"-1","aria-label":e("image.drop"),"aria-hidden":"true"}),r=w("button",{type:"button",className:"nova-dropzone"},ee(C.upload),w("span",{},e("image.drop"))),o=ze({label:e("image.url"),type:"url",placeholder:"https://"}),i=ze({label:e("image.alt"),hint:e("image.altHint")});io(n,o,"image",c=>{c.alt&&(i.input.value=c.alt)});let s=w("div",{className:"nova-form"},r,t,w("div",{className:"nova-divider"},w("span",{},e("image.or"))),o.el,i.el),l=n.ui.openDialog({title:e("image.title"),body:s,submitLabel:e("dialog.insert"),initialFocus:o.input,onSubmit:()=>{let c=o.input.value.trim();return!c||!fe(c)?(o.input.setAttribute("aria-invalid","true"),o.input.focus(),e("image.invalid")):(n.exec(Bc(c,i.input.value.trim()||void 0)),!0)}}),a=c=>{let u=c.filter(so);u.length&&(l.close(),ns(n,u))};r.addEventListener("click",()=>t.click()),t.addEventListener("change",()=>a([...t.files??[]])),r.addEventListener("dragover",c=>{c.preventDefault(),r.classList.add("is-dragover")}),r.addEventListener("dragleave",()=>r.classList.remove("is-dragover")),r.addEventListener("drop",c=>{c.preventDefault(),r.classList.remove("is-dragover"),a([...c.dataTransfer?.files??[]])})}function et(n){let{selection:e}=n,t=Z(n),r=(i,s)=>i.type===t.figure?{node:i,pos:s,attrs:{...i.firstChild?.attrs,align:i.attrs.align}}:{node:i,pos:s,attrs:i.attrs};if(e instanceof R&&(e.node.type===t.image||e.node.type===t.figure))return r(e.node,e.from);let{$from:o}=e;for(let i=o.depth;i>0;i--)if(o.node(i).type===t.figure)return r(o.node(i),o.before(i));return null}function ru(n){return et(n)?.node.type===Z(n).figure}var M0=["src","alt","title","width","height"],Gm=n=>Object.fromEntries(M0.map(e=>[e,n[e]??null])),ou=(n,e)=>{let t=et(n);if(!t)return!1;let r=Z(n),{pos:o,node:i,attrs:s}=t;if(!e)return!0;let l=n.tr;if(i.type===r.figure){let f=r.image.create({...Gm(s),align:s.align??null}),h=[r.paragraph.create(null,f)],m=i.child(1);return m.content.size&&h.push(r.paragraph.create(null,m.content)),l.replaceWith(o,o+i.nodeSize,h),l.setSelection(R.create(l.doc,o+1)),e(l.scrollIntoView()),!0}let a=n.doc.resolve(o),c=a.before(a.depth),u=a.after(a.depth),d=r.figure.create({align:s.align??null},[r.figure_image.create(Gm(s)),r.figcaption.create()]),p=3;return a.parent.childCount===1?(l.replaceWith(c,u,d),l.setSelection(F.create(l.doc,c+p))):(l.insert(u,d),l.delete(o,o+i.nodeSize),l.setSelection(F.create(l.doc,l.mapping.map(u,-1)+p))),e(l.scrollIntoView()),!0},iu=(n,e)=>{let{$from:t}=n.selection;if(t.parent.type!==Z(n).figcaption)return!1;if(e){let r=t.after(t.depth-1),o=n.tr.insert(r,Z(n).paragraph.create());o.setSelection(F.create(o.doc,r+1)),e(o.scrollIntoView())}return!0};function ur(n){return(e,t)=>{let r=et(e);if(!r)return!1;if(t){let o=e.tr;if(r.node.type===Z(e).figure){let{align:i,...s}=n;if(i!==void 0&&o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,align:i}),Object.keys(s).length){let l=r.node.firstChild;o.setNodeMarkup(r.pos+1,void 0,{...l.attrs,...s})}}else o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,...n}),o.setSelection(R.create(o.doc,r.pos));t(o)}return!0}}function su(n,e){let t=et(n.view.state);if(!t)return!1;if(e===null)return n.exec(ur({width:null,height:null}));let o=n.view.nodeDOM(t.pos)?.querySelector("img")??null,i=getComputedStyle(n.view.dom),s=n.view.dom.clientWidth-parseFloat(i.paddingLeft||"0")-parseFloat(i.paddingRight||"0"),l=Math.max(24,Math.round(s*e)),a=o&&o.naturalWidth?o.naturalHeight/o.naturalWidth:null;return n.exec(ur({width:l,height:a?Math.round(l*a):null}))}function lu(n){let e=et(n.view.state);if(!e)return;let{t}=n.ui,r=ze({label:t("image.alt"),value:String(e.attrs.alt??""),hint:t("image.altHint")}),o=ze({label:t("link.tooltip"),value:String(e.attrs.title??"")});n.ui.openDialog({title:t("image.editAlt"),body:w("div",{className:"nova-form"},r.el,o.el),submitLabel:t("dialog.save"),initialFocus:r.input,onSubmit:()=>(n.exec(ur({alt:r.input.value.trim()||null,title:o.input.value.trim()||null})),!0)})}function E0(n){let e=n.dom.ownerDocument.getSelection(),t=e?.focusNode;if(!e||!t||!n.dom.contains(t))return null;try{return n.posAtDOM(t,e.focusOffset)}catch{return null}}function Qm(){let n=!0;return new z({props:{handleDOMEvents:{mousedown(e){return n=e.hasFocus(),!1}},handleClick(e,t,r){if(n||r.button!==0||r.shiftKey||r.detail>1)return!1;let{doc:o}=e.state,i=e.posAtCoords({left:r.clientX,top:r.clientY}),s=i&&i.inside>=0?o.nodeAt(i.inside):null;if(s&&!s.isTextblock)return!1;let l=o.resolve(t),a=E0(e);if(a!==null&&o.resolve(a).parent===l.parent)return!1;let c=U.near(l);return e.state.selection.eq(c)||e.dispatch(e.state.tr.setSelection(c).setMeta("pointer",!0)),e.focus(),!0}}})}var ao=new X("nova-announce");function ie(n){return(e,t,r)=>Ue[n](e,t&&(o=>t(o.setMeta(ao,n))),r)}var C0=new Set(["bold","italic","underline","strike","code","subscript","superscript","bulletList","orderedList"]),A0=new Set(["paragraph","h1","h2","h3","h4","h5","h6"]),eg=["alignLeft","alignCenter","alignRight","alignJustify"];function cu(n){let{$from:e}=n.selection,t=[];for(let r=1;r<=e.depth;r++){let o=e.node(r),i=o.type.name;i==="bullet_list"?t.push("bulletList"):i==="ordered_list"?t.push("orderedList"):i==="blockquote"?t.push("blockquote"):i==="code_block"?t.push("codeBlock"):i==="heading"&&t.push(`h${Math.min(6,Math.max(1,Number(o.attrs.level)||1))}`)}return t}function T0(n,e,t){if(C0.has(e))return t(cr(n,e)?"announce.on":"announce.off",{name:t(e)});if(A0.has(e)){let r=cu(n).filter(o=>/^h[1-6]$/.test(o)).pop();return t(r??"paragraph")}return eg.includes(e)?t(eg.find(r=>cr(n,r))??"alignLeft"):t(e)}function N0(n,e,t){let r=cu(n),o=cu(e),i=o.findIndex((s,l)=>s!==r[l]);return i<0?null:t(o[i])}function tg(n,e){return new z({key:ao,state:{init:()=>null,apply(t,r,o,i){let s=t.getMeta(ao);return s?{command:s}:i.plugins.some(l=>l.spec.isInputRules&&t.getMeta(l))?{typed:!0}:null}},view:()=>({update(t,r){let o=ao.getState(t.state);if(!o||o===ao.getState(r))return;let i="command"in o?T0(t.state,o.command,n):N0(r,t.state,n);i&&e(i)}})})}var rg={options:{},commands:{},events:{}},og={options:"the option",commands:"the command",events:"the event"},ng=new Set;function ig(n,e){ng.has(n)||(ng.add(n),console.warn(`[nova] ${n} is deprecated: use ${e}. Old names keep working for at least one minor version (https://novaprose.com/project/versioning/).`))}var O0=(n,e)=>Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function co(n,e,t=rg){let r=O0(t[n],e);return r===void 0?e:(ig(`${og[n]} "${e}"`,`"${r}"`),r)}function sg(n,e=rg){let t=n;for(let[r,o]of Object.entries(e.options))Object.prototype.hasOwnProperty.call(n,r)&&(ig(`${og.options} "${r}"`,`"${o}"`),t===n&&(t={...t}),Object.prototype.hasOwnProperty.call(t,o)||(t[o]=t[r]),delete t[r]);return t}var fu={};q(fu,{InputRule:()=>tt,closeDoubleQuote:()=>cg,closeSingleQuote:()=>dg,ellipsis:()=>pu,emDash:()=>du,inputRules:()=>uu,openDoubleQuote:()=>ag,openSingleQuote:()=>ug,smartQuotes:()=>D0,textblockTypeInputRule:()=>is,undoInputRule:()=>R0,wrappingInputRule:()=>uo});var tt=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?L0(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function L0(n){return function(e,t,r,o){let i=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);i+=t[0].slice(s+t[1].length),r+=s;let l=r-o;l>0&&(i=t[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}var P0=500;function uu({rules:n}){let e=new z({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,i){return lg(t,r,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&lg(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function lg(n,e,t,r,o,i){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=n.state.selection,c=l.parent.textBetween(Math.max(0,l.parentOffset-P0),l.parentOffset,null,"\uFFFC")+r,u=e==a.from&&t==a.to&&n.state.storedMarks||(e==t?l.marks():l.marksAcross(s.doc.resolve(t))||[]);for(let d=0;d<o.length;d++){let p=o[d];if(!p.inCodeMark&&u.some(g=>g.type.spec.code))continue;if(l.parent.type.spec.code){if(!p.inCode)continue}else if(p.inCode==="only")continue;let f=p.match.exec(c);if(!f||f[0].length<r.length)continue;let h=e-(f[0].length-r.length);if(!p.inCodeMark){let g=!1;if(s.doc.nodesBetween(h,l.pos,k=>{k.isInline&&k.marks.some(x=>x.type.spec.code)&&(g=!0)}),g)continue}let m=p.handler(s,f,h,t,r);if(m)return p.undoable&&m.setMeta(i,{transform:m,from:e,to:t,text:r}),n.dispatch(m),!0}return!1}var R0=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){let s=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1},du=new tt(/--$/,"\u2014",{inCodeMark:!1}),pu=new tt(/\.\.\.$/,"\u2026",{inCodeMark:!1}),ag=new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),cg=new tt(/"$/,"\u201D",{inCodeMark:!1}),ug=new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),dg=new tt(/'$/,"\u2019",{inCodeMark:!1}),D0=[ag,cg,ug,dg];function uo(n,e,t,r){let o,i;return e instanceof st?i=e:(o=e,i=e.nodeType,t=e.getAttrs,r=e.joinPredicate),new tt(n,(s,l,a,c)=>{let u=t instanceof Function?t(l):t,d=s.tr.delete(a,c),p=d.doc.resolve(a),f=p.blockRange(),h=f&&ln(f,i,u);if(!h)return null;d.wrap(f,h);let m=d.doc.resolve(a-1).nodeBefore;return m&&m.type==i&&ct(d.doc,a-1)&&(!r||r(l,m))&&d.join(a-1),d},o)}function is(n,e,t){let r,o;return e instanceof st?o=e:(r=e,o=e.nodeType,t=e.getAttrs),new tt(n,(i,s,l,a)=>{let c=i.doc.resolve(l),u=t instanceof Function?t(s):t;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),o)?i.tr.delete(l,a).setBlockType(l,l,o,u):null},r)}var pg="([A-Za-z0-9_+#.-]{0,32})";function fg(n=()=>!0,e=Lt){let{nodes:t}=e,r=[pu,du];n("blockquote")&&r.push(uo(/^\s*>\s$/,t.blockquote)),n("numlist")&&r.push(uo(/^(\d+)\.\s$/,t.ordered_list,o=>({start:Number(o[1])}),(o,i)=>i.childCount+i.attrs.start===Number(o[1]))),n("bullist")&&r.push(uo(/^\s*([-+*])\s$/,t.bullet_list)),n("codeblock")&&r.push(is(new RegExp(`^\`\`\`${pg}\\s$`),t.code_block,o=>({language:o[1]||null})));for(let o=1;o<=6;o++)n(`h${o}`)&&r.push(is(new RegExp(`^(#{${o}})\\s$`),t.heading,{level:o}));return uu({rules:r})}function hg(n=()=>!0,e=Lt){let t=new RegExp(`^\`\`\`${pg}$`);return Ke({Enter:(o,i)=>{let{$from:s,empty:l}=o.selection,a=s.parent;if(!l||a.type!==e.nodes.paragraph||!n("codeblock")||s.parentOffset!==a.content.size||a.childCount!==1)return!1;let c=a.firstChild.isText?t.exec(a.textContent):null;if(!c)return!1;let u=s.index(-1);if(!s.node(-1).canReplaceWith(u,u+1,e.nodes.code_block))return!1;if(i){let d=s.start(),p=o.tr.delete(d,s.pos).setBlockType(d,d,e.nodes.code_block,{language:c[1]||null});i(p.scrollIntoView())}return!0}})}var mg={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",strike:"strike",code:"code",subscript:"subscript",superscript:"superscript",p:"paragraph",paragraph:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"};function gg(n){let e=[];for(let t of n){let r=t;if(!(!r||typeof r.start!="string"||!r.start||r.start.length>40))if(typeof r.replacement=="string")e.push({start:r.start,replacement:r.replacement});else{if(typeof r.format!="string"&&!r.command)continue;typeof r.end=="string"&&r.end,e.push(r)}}return e.sort((t,r)=>r.start.length-t.start.length)}function _0(n){let{$from:e,empty:t}=n.selection;return!t||!e.parent.isTextblock||e.parent.type.spec.code||e.marks().some(r=>r.type.spec.code)?null:e.parent.textBetween(0,e.parentOffset,void 0,"\uFFFC")}function yg(n,e){let{format:t,command:r,value:o}=e;typeof r=="function"?r(n,o):typeof r=="string"?n.exec(r):t&&n.formatter.has(t)?n.formatter.apply(t):t&&mg[t]&&n.exec(mg[t])}function bg(n,e,t){let r=gg(e),o=(s,l)=>{if(!t)return r;let{$from:a}=s.state.selection,c=s.nodeDOM(a.before()),u=[];try{u=t({text:l,block:c instanceof HTMLElement?c:null})}catch(d){console.error("[nova] textPatternsLookup failed:",d)}return Array.isArray(u)?gg([...r,...u]):r},i=(s,l)=>{let a=_0(s.state);if(a===null||!n.isEditable())return null;let{$from:c}=s.state.selection,u=c.start();for(let d of o(s,a)){if("replacement"in d){if(!a.endsWith(d.start))continue;let f=c.pos-d.start.length;return/<[a-z]/i.test(d.replacement)?(s.dispatch(s.state.tr.delete(f,c.pos)),n.insertContent(d.replacement),s.dispatch(s.state.tr.setStoredMarks([]))):s.dispatch(s.state.tr.insertText(d.replacement,f,c.pos)),"replacement"}if("end"in d){if(!a.endsWith(d.end))continue;let f=a.lastIndexOf(d.start,a.length-d.end.length-1),h=f+d.start.length,m=a.length-d.end.length;if(f<0||m<=h||/^\s|\s$/.test(a.slice(h,m)))continue;let g=s.state.tr.delete(u+m,u+a.length).delete(u+f,u+h),k=u+f,x=k+(m-h);s.dispatch(g.setSelection(F.create(g.doc,k,x))),yg(n,d);let{state:M}=s;return s.dispatch(M.tr.setSelection(F.create(M.doc,M.selection.to))),s.dispatch(s.state.tr.setStoredMarks([])),"inline"}if(!((d.trigger??"space")!==l||!(l==="space"?a===d.start:c.parent.textContent.startsWith(d.start)&&c.parentOffset===c.parent.content.size)))return s.dispatch(s.state.tr.delete(u,u+d.start.length)),yg(n,d),"block"}return null};return new z({props:{handleTextInput(s,l,a,c){if(c!==" "||l!==a)return!1;let u=i(s,"space");return u?(u!=="block"&&s.dispatch(s.state.tr.insertText(" ")),!0):!1},handleKeyDown(s,l){return l.key!=="Enter"||l.shiftKey||l.ctrlKey||l.metaKey||i(s,"enter"),!1}}})}var I0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),H0=sr(Cc,(n,e)=>(e?.(n.tr.replaceSelectionWith(Z(n).hard_break.create()).scrollIntoView()),!0)),hu=(n,e)=>(t,r,o)=>n(e)(t,r,o);function kg(n=e=>Ue[e]){let e={"Mod-z":hu(n,"undo"),"Shift-Mod-z":hu(n,"redo"),"Mod-b":ie("bold"),"Mod-i":ie("italic"),"Mod-u":ie("underline"),"Mod-Shift-x":ie("strike"),"Mod-e":ie("code"),"Mod-,":ie("subscript"),"Mod-.":ie("superscript"),"Mod-Alt-0":ie("paragraph"),"Mod-Alt-1":ie("h1"),"Mod-Alt-2":ie("h2"),"Mod-Alt-3":ie("h3"),"Mod-Alt-4":ie("h4"),"Mod-Alt-5":ie("h5"),"Mod-Alt-6":ie("h6"),"Mod-Shift-7":ie("orderedList"),"Mod-Shift-8":ie("bulletList"),"Mod-Shift-l":ie("alignLeft"),"Mod-Shift-e":ie("alignCenter"),"Mod-Shift-r":ie("alignRight"),"Mod-Shift-j":ie("alignJustify"),"Mod-\\":ie("clearFormatting"),"Shift-Enter":H0,Enter:sr(iu,(t,r)=>{let i=typeof B0(t)?.attrs.checked=="boolean"?{checked:!1}:void 0;return di(Z(t).list_item,i)(t,r)}),Tab:Ic,"Shift-Tab":Hc,"Mod-]":Ue.indent,"Mod-[":Ue.outdent,"Alt-Shift-ArrowUp":Ue.moveBlockUp,"Alt-Shift-ArrowDown":Ue.moveBlockDown};return I0||(e["Mod-y"]=hu(n,"redo")),[Ke(e),Ke(Cm)]}function B0(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type===Z(n).list_item)return r}return null}var yu={};q(yu,{applyLink:()=>vg,normalizeUrl:()=>mu,openLinkDialog:()=>_t,removeLink:()=>dr});function mu(n){let e=n.trim();return e?/^[a-z][a-z0-9+.-]*:/i.test(e)||/^[/#?.]/.test(e)?e:/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e)?`mailto:${e}`:/^(www\.)?[^\s/]+\.[a-z]{2,}([/:?#].*)?$/i.test(e)?`https://${e}`:e:""}function gu(n){let{from:e,to:t,empty:r,$from:o}=n.selection;return r?An(n,ce(n).link,o.pos)??{from:e,to:t}:{from:e,to:t}}function vg(n){return(e,t)=>{let r=mu(n.href);if(!r||!Ie(r))return!1;if(!t)return!0;let{from:o,to:i}=gu(e),s=ce(e).link.create({href:r,title:n.title||null,target:n.target||null}),l=e.doc.textBetween(o,i),a=n.text?.trim()?n.text:null,c=e.tr;if(o===i||a!==null&&a!==l){let u=ce(e).link.removeFromSet(e.doc.resolve(o).marks()),d=e.schema.text(a??(l||r),s.addToSet(u));c.replaceWith(o,i,d)}else c.removeMark(o,i,ce(e).link).addMark(o,i,s);return t(c.scrollIntoView()),!0}}function dr(){return(n,e)=>{let{from:t,to:r}=gu(n);return t===r||!n.doc.rangeHasMark(t,r,ce(n).link)?!1:(e?.(n.tr.removeMark(t,r,ce(n).link)),!0)}}function _t(n){let{t:e}=n.ui,t=n.view.state,r=Cn(t),o=gu(t),i=t.doc.textBetween(o.from,o.to),s=!i.includes(`
24
+ `)&&t.selection.$from.sameParent(t.doc.resolve(o.to)),l=ze({label:e("link.url"),type:"url",value:r?.href??"",placeholder:"https://",required:!0}),a=ze({label:e("link.text"),value:i}),c=ze({label:e("link.tooltip"),value:r?.title??""}),u=Yc(e("link.newTab"),r?.target==="_blank");io(n,l,"file",p=>{p.text&&!a.input.value.trim()&&(a.input.value=p.text),p.title&&(c.input.value=p.title)});let d=w("div",{className:"nova-form"},l.el,s?a.el:null,c.el,u.el);n.ui.openDialog({title:e(r?"link.editTitle":"link.title"),body:d,submitLabel:e(r?"dialog.save":"dialog.insert"),initialFocus:l.input,onSubmit:()=>{let p=mu(l.input.value);return!p||!Ie(p)?(l.input.setAttribute("aria-invalid","true"),l.input.focus(),l.input.value.trim()?e("link.invalid"):e("dialog.required")):(n.exec(vg({href:p,...s?{text:a.input.value}:{},title:c.input.value.trim()||null,target:u.input.checked?"_blank":null})),!0)}})}function xg(n){return/<img[^>]+src=["']?file:/i.test(n)}var bt=null,ss=null;function bu(){return ss??(ss=import(__novaChunk("tinymce-chunks/paste-office-4e8e9cb7.js") ).then(n=>bt=n,()=>(ss=null,null))),ss}var F0=new X("nova-paste");function z0(n){let e=document.createElement("template");e.innerHTML=n;let t=/^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/,r="",o=i=>{if(i.nodeType===Node.TEXT_NODE){r+=(i.textContent??"").replace(/\s+/g," ");return}if(!(i instanceof Element)){i.childNodes.forEach(o);return}if(/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(i.tagName))return;if(i.tagName==="BR"){r+=`
15
25
  `;return}let s=t.test(i.tagName);s&&r&&!r.endsWith(`
16
26
  `)&&(r+=`
17
27
  `),i.childNodes.forEach(o),s&&(r+=`
@@ -19,23 +29,20 @@ var __novaChunkBase=typeof document!=="undefined"&&(document.currentScript&&docu
19
29
  `).map(i=>i.trim()).join(`
20
30
  `).replace(/\n{3,}/g,`
21
31
 
22
- `).trim()}function bp(n){let e=!1;return new z({key:sy,props:{transformPasted(t,r){let{selection:o}=r.state,i=o.$from.parent;return t.openStart>0&&o.empty&&i.isTextblock&&i.content.size===0&&t.content.firstChild?.isBlock?new D(t.content,0,t.openEnd):t},transformPastedHTML(t){let{pastePreprocess:r,pastePostprocess:o,pasteStyles:i}=n.options,s=r?r(t,n):t;if(Ho&&(s=Ho.cleanPastedHTML(s,i??"clean")),o){let l=document.createElement("template");l.innerHTML=s;let a=document.createElement("div");a.append(l.content),o(a,n),s=a.innerHTML}return s},handleDOMEvents:{paste(t,r){if(Ho||e||n.isPasteAsText())return!1;let o=r.clipboardData,i=o?.getData("text/html");if(!i)return!1;let s=Rl(i)?o?.getData("text/rtf")??"":"";return r.preventDefault(),Hl().then(()=>{if(t.isDestroyed)return;let l=s&&n.isAllowed("image")?Pl(i,Ll(s)):i;e=!0;try{t.pasteHTML(l)}finally{e=!1}}),!0}},handlePaste(t,r,o){if(e)return!1;let i=r.clipboardData?.getData("text/html");if(!n.isPasteAsText()){let l=i&&Rl(i)?r.clipboardData?.getData("text/rtf"):"";if(!i||!l||!n.isAllowed("image"))return!1;let a=Pl(i,Ll(l));if(a===i)return!1;e=!0;try{t.pasteHTML(a,r)}finally{e=!1}return!0}let s=i?ly(i):r.clipboardData?.getData("text/plain")||o.content.textBetween(0,o.content.size,`
32
+ `).trim()}function $0(n){return Fe(n.options.contentLanguage)??Fe(n.root.parentElement?.closest("[lang]")?.getAttribute("lang"))}function V0(n,e){if(!e||!/\slang\s*=/i.test(n))return n;let t=document.createElement("template");t.innerHTML=n;let r=!1;for(let i of t.content.querySelectorAll("[lang]")){let s=Fe(i.getAttribute("lang"));s&&xi(s)===xi(e)&&(i.removeAttribute("lang"),r=!0)}if(!r)return n;let o=document.createElement("div");return o.append(t.content),o.innerHTML}function Sg(n){let e=!1;return new z({key:F0,props:{transformPasted(t,r){let{selection:o}=r.state,i=o.$from.parent;return t.openStart>0&&o.empty&&i.isTextblock&&i.content.size===0&&t.content.firstChild?.isBlock?new D(t.content,0,t.openEnd):t},transformPastedHTML(t){let{pastePreprocess:r,pastePostprocess:o,pasteStyles:i}=n.options,s=r?r(t,n):t;if(bt&&(s=bt.cleanPastedHTML(s,i??"clean")),s=V0(s,$0(n)),o){let l=document.createElement("template");l.innerHTML=s;let a=document.createElement("div");a.append(l.content),o(a,n),s=a.innerHTML}return s},handleDOMEvents:{paste(t,r){if(bt||e||n.isPasteAsText())return!1;let o=r.clipboardData;if(o?.getData(Mg))return!1;let i=o?.getData("text/html");if(!i)return!1;let s=xg(i)?o?.getData("text/rtf")??"":"";return r.preventDefault(),bu().then(()=>{if(t.isDestroyed)return;let l=s&&bt&&n.isAllowed("image")?bt.replaceLocalImages(i,bt.extractRtfImages(s)):i;e=!0;try{t.pasteHTML(l)}finally{e=!1}}),!0}},handlePaste(t,r,o){if(e)return!1;let i=a=>{e=!0;try{t.pasteText(a)}finally{e=!1}};if(q0(t,r,n,i))return!0;let s=r.clipboardData?.getData("text/html");if(!n.isPasteAsText()){let a=s&&xg(s)?r.clipboardData?.getData("text/rtf"):"";if(!s||!a||!bt||!n.isAllowed("image"))return!1;let c=bt.replaceLocalImages(s,bt.extractRtfImages(a));if(c===s)return!1;e=!0;try{t.pasteHTML(c,r)}finally{e=!1}return!0}let l=s?z0(s):r.clipboardData?.getData("text/plain")||o.content.textBetween(0,o.content.size,`
23
33
 
24
- `);if(!s)return!1;e=!0;try{t.pasteText(s)}finally{e=!1}return!0}}})}var Jl={};Z(Jl,{MAX_GRID:()=>En,createTable:()=>yp,createTableGridPanel:()=>Ul,getCellProps:()=>Wl,getTableProps:()=>Vl,hasHeaderColumn:()=>$l,hasHeaderRow:()=>_l,insertTable:()=>ct,isCellSelection:()=>cy,isInTable:()=>Et,loadTables:()=>Fl,loadedTables:()=>ay,setCellBackground:()=>zl,setCellProps:()=>jl,setTableProps:()=>ql,sortTable:()=>Bo,tableCommands:()=>De,tableRect:()=>Kl});var fe=null,Bl=null;function Fl(){return Bl??(Bl=import(__novaChunk("tinymce-chunks/table-80284f6f.js") ).then(n=>fe=n,n=>(console.warn("[nova] failed to load table editing",n),Bl=null,null))),Bl}function ay(){return fe}var $e=n=>(e,t,r)=>fe?fe.tableCommands[n](e,t,r):!1,De={addRowBefore:$e("addRowBefore"),addRowAfter:$e("addRowAfter"),deleteRow:$e("deleteRow"),addColumnBefore:$e("addColumnBefore"),addColumnAfter:$e("addColumnAfter"),deleteColumn:$e("deleteColumn"),mergeCells:$e("mergeCells"),splitCell:$e("splitCell"),toggleHeaderRow:$e("toggleHeaderRow"),toggleHeaderColumn:$e("toggleHeaderColumn"),deleteTable:$e("deleteTable")};function zl(n){return(e,t,r)=>fe?fe.setCellBackground(n)(e,t,r):!1}function _l(n){return fe?.hasHeaderRow(n)??!1}function $l(n){return fe?.hasHeaderColumn(n)??!1}function cy(n){return fe?.isCellSelection(n)??!1}function Vl(n){return fe?.getTableProps(n)??null}function ql(n){return(e,t,r)=>fe?fe.setTableProps(n)(e,t,r):!1}function Wl(n){return fe?.getCellProps(n)??null}function jl(n){return(e,t,r)=>fe?fe.setCellProps(n)(e,t,r):!1}function Bo(n,e){return(t,r,o)=>fe?fe.sortTable(n,e)(t,r,o):!1}var En=10;function Kl(n){let{$from:e}=n.view.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="table")return n.view.nodeDOM(e.before(t))?.getBoundingClientRect()??null;return null}function yp(n,e,t=!0,r=At){let{table:o,table_row:i,table_cell:s,table_header:l,paragraph:a}=r.nodes,c=[];for(let u=0;u<n;u++){let d=t&&u===0?l:s,p=[];for(let f=0;f<e;f++)p.push(d.create(null,a.create()));c.push(i.create(null,p))}return o.create(null,c)}function ct(n,e,t=!0){return(r,o)=>{if(n<1||e<1||n>100||e>50||Et(r))return!1;if(o){let i=yp(n,e,t,r.schema),s=r.tr.replaceSelectionWith(i),l=-1;s.doc.descendants((a,c)=>(a===i&&(l=c),l<0)),l>=0&&s.setSelection(I.near(s.doc.resolve(l+3))),o(s.scrollIntoView())}return!0}}function Ul(n,e,t){let r=1,o=1,i=[],s=M("div",{className:"nova-grid-caption","aria-live":"polite"}),l=M("div",{className:"nova-grid",role:"grid","aria-label":t}),a=()=>{for(let c of i){let u=Number(c.dataset.row),d=Number(c.dataset.col);c.classList.toggle("is-on",u<=r&&d<=o),c.tabIndex=u===r&&d===o?0:-1}s.textContent=e(r,o)};for(let c=1;c<=En;c++)for(let u=1;u<=En;u++){let d=M("button",{type:"button",className:"nova-grid-cell",role:"gridcell","aria-label":e(c,u),"data-row":String(c),"data-col":String(u)});d.addEventListener("mouseenter",()=>{r=c,o=u,a()}),d.addEventListener("click",()=>n(c,u)),i.push(d),l.append(d)}return l.addEventListener("keydown",c=>{let d={ArrowRight:[0,1],ArrowLeft:[0,-1],ArrowDown:[1,0],ArrowUp:[-1,0]}[c.key];d&&(c.preventDefault(),r=Math.min(En,Math.max(1,r+d[0])),o=Math.min(En,Math.max(1,o+d[1])),a(),i[(r-1)*En+(o-1)].focus())}),a(),M("div",{className:"nova-grid-panel"},l,s)}var Gl=new WeakSet,Yl=new WeakMap,vp=new WeakSet;function Xl(n){for(let e of n){let t=e.spec,r=t.view;!r||vp.has(e)||(vp.add(e),t.view=o=>{let i=Yl.get(o);i||Yl.set(o,i=new Map);let s=i.get(e);s||i.set(e,s=r(o));let l=s;return{update:(a,c)=>l.update?.(a,c),destroy:()=>{Gl.has(o)||(i.delete(e),l.destroy?.())}}})}}function Ql(n,e){Xl(e),Gl.add(n);try{n.updateState(n.state.reconfigure({plugins:e}))}finally{Gl.delete(n)}let t=Yl.get(n);if(t)for(let[r,o]of t)e.includes(r)||(t.delete(r),o.destroy?.())}var Fo="data-nova-own-style",Zl=null;function ea(n){Zl=n}var kp=!1;function Mp(n){return!!n.extendedValidElements||!!n.customElements||/\[/.test(n.validElements??"")?Zl?Zl.create(n):(kp||(kp=!0,console.warn("[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);")),null):null}var uy="data-nova-cell-bg",ta="http://www.w3.org/1999/xhtml",dy="http://www.w3.org/1998/Math/MathML";function py(n){let e=[...n.querySelectorAll("*")].filter(t=>t.namespaceURI!==ta&&(t.parentElement?.namespaceURI??ta)===ta);for(let t of e){let r=t.namespaceURI===dy?t.textContent??"":"";t.replaceWith(t.ownerDocument.createTextNode(r))}}function fy(n){py(n),n.querySelectorAll("td, th").forEach(e=>{if(!e.style)return;let t=e.style.backgroundColor;t&&(e.setAttribute(uy,t),e.style.removeProperty("background-color"),e.getAttribute("style")||e.removeAttribute("style"))})}var na=class extends Qe{constructor(){super(...arguments);E(this,"atomSelector");E(this,"ownStyleSelector")}prepare(t){fy(t),this.ownStyleSelector??(this.ownStyleSelector=Object.values(this.schema.nodes).flatMap(r=>r.spec.ownStyleTags??[]).join(", ")),this.ownStyleSelector&&"querySelectorAll"in t&&t.querySelectorAll(this.ownStyleSelector).forEach(r=>{let o=r.getAttribute("style");o!==null&&(r.setAttribute(Fo,o),r.removeAttribute("style"))}),this.atomSelector??(this.atomSelector=Object.values(this.schema.nodes).filter(r=>r.spec.ignoreStyles).flatMap(r=>(r.spec.parseDOM??[]).map(o=>o.tag)).filter(r=>!!r).join(", ")),!(!this.atomSelector||!("querySelectorAll"in t))&&t.querySelectorAll(this.atomSelector).forEach(r=>{r.removeAttribute("style")})}parse(t,r){return this.prepare(t),super.parse(t,r)}parseSlice(t,r){return this.prepare(t),super.parseSlice(t,r)}},xp=new WeakMap;function dr(n){let e=xp.get(n);return e||(e=new na(n,Qe.fromSchema(n).rules),xp.set(n,e)),e}var A0=dr(At);function zo(n,e,t){let r=[],o=M("div",{className:"nova-menu",role:"menu","aria-label":t}),i=n.some(a=>(a.type===void 0||a.type==="item")&&a.active!==void 0);for(let a of n){if(a.type==="separator"){o.append(M("div",{className:"nova-menu-sep",role:"separator"}));continue}if(a.type==="heading"){o.append(M("div",{className:"nova-menu-heading",role:"presentation"},a.label));continue}let c=M("span",{className:"nova-menu-label"},a.label);a.labelStyle&&c.setAttribute("style",a.labelStyle);let u=M("button",{type:"button",className:"nova-menu-item",role:a.active===void 0?"menuitem":a.checkbox?"menuitemcheckbox":"menuitemradio",tabindex:"-1","data-id":a.id,disabled:a.disabled??!1,...a.active!==void 0?{"aria-checked":String(a.active)}:{}},i?M("span",{className:"nova-menu-check"},a.active?V(S.check):null):null,a.icon?V(a.icon):null,c,a.shortcut?M("kbd",{className:"nova-menu-shortcut"},tt(a.shortcut)):null);u.addEventListener("click",()=>{e(),a.onSelect()}),r.push(u),o.append(u)}let s=()=>r.filter(a=>!a.disabled),l=a=>{let c=s();c.length&&c[(a+c.length)%c.length].focus()};return o.addEventListener("keydown",a=>{let c=s(),u=c.indexOf(j(o));switch(a.key){case"ArrowDown":a.preventDefault(),l(u+1);break;case"ArrowUp":a.preventDefault(),l(u-1);break;case"Home":a.preventDefault(),l(0);break;case"End":a.preventDefault(),l(c.length-1);break;case"Tab":a.preventDefault();break;default:if(a.key.length===1&&/\S/.test(a.key)){let d=a.key.toLowerCase(),p=u+1;[...c.slice(p),...c.slice(0,p)].find(h=>h.textContent?.trim().toLowerCase().startsWith(d))?.focus()}}}),o}function _o(n){(n.querySelector('[aria-checked="true"]:not(:disabled)')??n.querySelector(".nova-menu-item:not(:disabled)"))?.focus()}var Sp={file:{title:"menu.file",items:"preview | print"},edit:{title:"menu.edit",items:"undo redo | selectall | searchreplace pastetext"},view:{title:"menu.view",items:"code preview | fullscreen"},insert:{title:"menu.insert",items:"image link inserttable hr | insertdatetime"},format:{title:"menu.format",items:"bold italic underline strikethrough superscript subscript inlinecode | paragraph h1 h2 h3 blockquote codeblock | alignleft aligncenter alignright alignjustify | removeformat"},table:{title:"menu.table",items:"inserttable | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tabledelete"},help:{title:"menu.help",items:"help"}},wp="file edit view insert format table help";function Ep(n,e,t,r){let{t:o}=n.ui;e.className="nova-menubar",e.setAttribute("role","menubar"),e.setAttribute("aria-label",o("menu.label"));let i=new AbortController,{signal:s}=i,l=f=>f.title.startsWith("menu.")?o(f.title):f.title,a=f=>{let h=[];for(let g of f.items.split(/\s+/)){if(!g)continue;if(g==="|"){h.length&&h[h.length-1].type!=="separator"&&h.push({type:"separator"});continue}if(!n.isAllowed(g))continue;let m=n.ui.registry.getMenuItem(g);m&&h.push({id:g,label:m.text,...m.icon?{icon:m.icon}:{},...m.shortcut?{shortcut:m.shortcut}:{},...m.isActive?{active:m.isActive(n),checkbox:!0}:{},disabled:!n.isEditable()||(m.isEnabled?!m.isEnabled(n):!1),onSelect:()=>m.onAction(n)})}for(;h.length&&h[h.length-1].type==="separator";)h.pop();return h},c=[],u=null,d=()=>{u?.popover.close(),u=null},p=(f,h)=>{d();let g=c[f],m=r[g.dataset.menu],b=a(m);if(!b.length)return;let k=zo(b,()=>n.ui.closePopover(),l(m));k.addEventListener("keydown",w=>{let N=Me(w,k);if(N!=="ArrowLeft"&&N!=="ArrowRight")return;w.preventDefault();let L=(f+(N==="ArrowRight"?1:-1)+c.length)%c.length;p(L,!0)}),g.setAttribute("aria-expanded","true");let y=n.ui.openPopover({anchor:g,content:k,ignore:[e],className:"nova-popover-menu",onClose:w=>{g.setAttribute("aria-expanded","false"),u?.popover===y&&(u=null),w==="escape"&&g.focus()}});u={index:f,popover:y},h&&_o(k)};for(let f of t.split(/\s+/).filter(Boolean)){let h=r[f];if(!h)continue;let g=M("button",{type:"button",className:"nova-menubar-item",role:"menuitem","aria-haspopup":"menu","aria-expanded":"false","data-menu":f,tabindex:c.length===0?"0":"-1"},l(h)),m=c.length;g.addEventListener("click",b=>{if(u?.index===m)return d();p(m,b.detail===0)}),g.addEventListener("mouseenter",()=>{u&&u.index!==m&&p(m,!1)}),c.push(g),e.append(g)}return e.addEventListener("keydown",f=>{let h=c.indexOf(j(e));if(h<0)return;let g=b=>{f.preventDefault();let k=(b+c.length)%c.length;c.forEach((y,w)=>y.tabIndex=w===k?0:-1),c[k].focus()},m=Me(f,e);m==="ArrowRight"?g(h+1):m==="ArrowLeft"?g(h-1):f.key==="Home"?g(0):f.key==="End"?g(c.length-1):f.key==="ArrowDown"?(f.preventDefault(),p(h,!0)):f.key==="Escape"&&(f.preventDefault(),n.focus())},{signal:s}),e.addEventListener("mousedown",f=>{f.target.closest("button")&&f.preventDefault()},{signal:s}),{focus:()=>(c.find(f=>f.tabIndex===0)??c[0])?.focus(),destroy:()=>{d(),i.abort(),e.replaceChildren()}}}var hy=`
25
- body { font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: #000; margin: 2cm; }
26
- img { max-width: 100%; height: auto; }
27
- table { border-collapse: collapse; width: 100%; }
28
- td, th { border: 1px solid #999; padding: 4px 8px; vertical-align: top; }
29
- pre { white-space: pre-wrap; background: #f5f5f5; padding: 8px; }
30
- blockquote { border-left: 3px solid #ccc; margin-left: 0; padding-left: 1em; color: #444; }
31
- `;function my(n){let e=M("iframe",{title:"print","aria-hidden":"true",tabindex:"-1"});e.style.cssText="position:fixed;width:0;height:0;border:0;right:0;bottom:0;visibility:hidden",document.body.append(e);let t=e.contentDocument;if(!t)return e.remove();let r=t.createElement("style");r.textContent=hy,t.head.append(r),t.body.append(Le.fromSchema(n.schema).serializeFragment(n.view.state.doc.content,{document:t}));let o=e.contentWindow,i=()=>setTimeout(()=>e.remove(),1e3);o?.addEventListener("afterprint",i),o?.focus(),o?.print(),i()}function gy(n){let{t:e}=n.ui,t=ee({label:e("table.rows"),value:"3"}),r=ee({label:e("table.cols"),value:"3"});for(let o of[t,r])o.input.type="number",o.input.min="1",o.input.max="50",o.input.inputMode="numeric";n.ui.openDialog({title:e("table.insert"),body:M("div",{className:"nova-form nova-form-row"},t.el,r.el),submitLabel:e("dialog.insert"),initialFocus:t.input,onSubmit:()=>{let o=Number(t.input.value),i=Number(r.input.value);return!Number.isInteger(o)||!Number.isInteger(i)||o<1||i<1||o>50||i>50?e("table.invalidSize"):(n.exec(ct(o,i)),!0)}})}function Cp(n){let{registry:e,t}=n.ui;e.addToggleMenuItem("paragraph",{text:t("paragraph"),icon:S.paragraph,shortcut:"Mod-Alt-0",isActive:r=>r.view.state.selection.$from.parent.type.name==="paragraph",onAction:r=>r.exec("paragraph")}),e.addMenuItem("selectall",{text:t("selectAll"),shortcut:"Mod-a",onAction:r=>{r.view.dispatch(r.view.state.tr.setSelection(new se(r.view.state.doc))),r.focus()}}),e.addMenuItem("print",{text:t("print"),icon:S.print,shortcut:"Mod-p",onAction:r=>my(r)}),e.addMenuItem("inserttable",{text:t("table.insert"),icon:S.table,isEnabled:r=>r.can(ct(1,1)),onAction:r=>gy(r)})}var Ap={b:"strong",i:"em",strike:"s",del:"s",tbody:"table",thead:"table",tfoot:"table",caption:"table",colgroup:"table",col:"table",figcaption:"figure"},by=["p","h1","h2","h3","h4","h5","h6","blockquote","pre","hr","ul","ol","li","img","figure","br","table","tr","td","th","strong","em","u","s","code","a","sub","sup","span"];var yy={bold:["strong"],italic:["em"],underline:["u"],strikethrough:["s"],strike:["s"],inlinecode:["code"],code:["code"],subscript:["sub"],superscript:["sup"],link:["a"],unlink:["a"],quicklink:["a"],image:["img"],quickimage:["img"],table:["table"],quicktable:["table"],inserttable:["table"],tableinsertrowbefore:["table"],tableinsertrowafter:["table"],tabledeleterow:["table"],tableinsertcolbefore:["table"],tableinsertcolafter:["table"],tabledeletecol:["table"],tablemergecells:["table"],tablesplitcells:["table"],tabledelete:["table"],tablerowheader:["th"],tablecolheader:["th"],tablecellbackground:["style:background-color"],bullist:["ul"],bulletlist:["ul"],numlist:["ol"],orderedlist:["ol"],blockquote:["blockquote"],codeblock:["pre"],hr:["hr"],horizontalrule:["hr"],h1:["h1"],h2:["h2"],h3:["h3"],h4:["h4"],h5:["h5"],h6:["h6"],forecolor:["span","style:color"],backcolor:["span","style:background-color"],fontfamily:["span","style:font-family"],fontsize:["span","style:font-size"],lineheight:["style:line-height"],align:["style:text-align"],alignleft:["style:text-align"],aligncenter:["style:text-align"],alignright:["style:text-align"],alignjustify:["style:text-align"],imagealignleft:["style:float"],imagealigncenter:["style:float"],imagealignright:["style:float"]};function ra(n){if(n===void 0)return null;let e=new Set;for(let t of n.split(",")){let r=t.trim().replace(/^[-#+!]+/,"").replace(/\[.*$/,"").toLowerCase();for(let o of r.split("/")){let i=o.trim();i&&e.add(Ap[i]??i)}}return e}function vy(n){if(n===void 0)return null;let e=typeof n=="string"?n:Object.values(n).join(",");return new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}var $o=class{constructor(e){E(this,"tags");E(this,"styles");let t=ra(e.validElements),r=ra(e.invalidElements)??new Set,o=new Set(t??by);if(t)for(let i of ra(e.extendedValidElements)??[])o.add(i);(o.has("ul")||o.has("ol"))&&o.add("li"),o.has("table")&&(o.add("tr"),o.add("td"));for(let i of r)o.delete(i);o.add("p"),this.tags=o,this.styles=vy(e.validStyles)}isTagAllowed(e){let t=e.toLowerCase();return this.tags.has(Ap[t]??t)}isStyleAllowed(e){return!this.styles||this.styles.has(e.toLowerCase())}isAllowed(e){let t=yy[e.toLowerCase()];return t?t.every(r=>r.startsWith("style:")?this.isStyleAllowed(r.slice(6)):this.isTagAllowed(r)):!0}markAllowed(e){switch(e.type.name){case"bold":return this.isTagAllowed("strong");case"italic":return this.isTagAllowed("em");case"underline":return this.isTagAllowed("u");case"strike":return this.isTagAllowed("s");case"code":return this.isTagAllowed("code");case"link":return this.isTagAllowed("a");case"subscript":return this.isTagAllowed("sub");case"superscript":return this.isTagAllowed("sup");case"color":return this.isTagAllowed("span")&&this.isStyleAllowed("color");case"background":return this.isTagAllowed("span")&&this.isStyleAllowed("background-color");case"font_family":return this.isTagAllowed("span")&&this.isStyleAllowed("font-family");case"font_size":return this.isTagAllowed("span")&&this.isStyleAllowed("font-size");default:return!0}}blockAttrs(e){return{...e,...this.isStyleAllowed("text-align")?{}:{align:null},...this.isStyleAllowed("line-height")?{}:{lineHeight:null},...this.isStyleAllowed("margin-left")?{}:{indent:0}}}normalize(e){let t=e.type.schema,{nodes:r}=t;if(e.isText){let l=e.marks.filter(a=>this.markAllowed(a));return[l.length===e.marks.length?e:e.mark(l)]}let o=e.marks.filter(l=>this.markAllowed(l));switch(e.type){case r.image:return this.isTagAllowed("img")?[r.image.create({...e.attrs,...this.isStyleAllowed("float")?{}:{align:null}},null,o)]:[];case r.figure:{let l=e.childCount>1?e.child(1).content:null,a=l?.size?[r.paragraph.create(null,this.normalizeChildren(l))]:[],c=e.firstChild;if(!this.isTagAllowed("img")||!c)return a;let u=this.isStyleAllowed("float")?e.attrs.align:null;if(!this.isTagAllowed("figure")){let d=r.image.create({...c.attrs,align:u});return[r.paragraph.create(null,d),...a]}return[r.figure.create({...e.attrs,align:u},e.content)]}case r.hard_break:return this.isTagAllowed("br")?[e.mark(o)]:[t.text(" ",o)];case r.horizontal_rule:return this.isTagAllowed("hr")?[e]:[]}let i=this.normalizeChildren(e.content),s=(l=e.type,a=e.attrs)=>{try{return[l.createChecked(a,i,e.marks)]}catch{let c=l.createAndFill(a,i,e.marks);return c?[c]:i.content.length?oa(i):[]}};switch(e.type){case r.paragraph:return s(r.paragraph,this.blockAttrs(e.attrs));case r.heading:return this.isTagAllowed(`h${e.attrs.level}`)?s(r.heading,this.blockAttrs(e.attrs)):s(r.paragraph,this.blockAttrs({align:e.attrs.align,lineHeight:e.attrs.lineHeight}));case r.blockquote:return this.isTagAllowed("blockquote")?s():oa(i);case r.code_block:return this.isTagAllowed("pre")?s():e.textContent.split(`
32
- `).map(l=>r.paragraph.create(null,l?t.text(l):null));case r.bullet_list:case r.ordered_list:return this.isTagAllowed(e.type===r.bullet_list?"ul":"ol")?s(e.type,{...e.attrs,...this.isStyleAllowed("list-style-type")?{}:{listStyle:null}}):ky(i);case r.table:return this.isTagAllowed("table")?s():My(i);case r.table_header:return this.isTagAllowed("th")?s():s(r.table_cell,e.attrs);case r.table_cell:return s(r.table_cell,{...e.attrs,...this.isStyleAllowed("background-color")?{}:{background:null}});default:return s()}}normalizeChildren(e){let t=[];return e.forEach(r=>t.push(...this.normalize(r))),A.from(t)}normalizeDoc(e){let t=this.normalizeChildren(e.content),r=e.type.schema;return e.type.createAndFill(null,t.size?t:r.nodes.paragraph.create())}};function oa(n){let e=[],t=[],r=()=>{t.length&&e.push(t[0].type.schema.nodes.paragraph.create(null,t)),t=[]};return n.forEach(o=>{o.isInline?t.push(o):(r(),e.push(o))}),r(),e}function ky(n){let e=[];return n.forEach(t=>{t.type===t.type.schema.nodes.list_item?t.content.forEach(r=>e.push(r)):e.push(...oa(A.from(t)))}),e}function My(n){let e=[];return n.forEach(t=>t.forEach(r=>r.forEach(o=>e.push(o)))),e}var xy=new K("nova-content-rules");function Tp(n){return new z({key:xy,appendTransaction(e,t,r){if(!e.some(c=>c.docChanged))return null;let o=t.doc.content.findDiffStart(r.doc.content);if(o===null)return null;let i=t.doc.content.findDiffEnd(r.doc.content)?.b??r.doc.content.size,s=r.doc,l=[];if(s.forEach((c,u)=>{let d=u,p=u+c.nodeSize;if(p<o||d>Math.max(o,i))return;let f=n.normalize(c);f.length===1&&f[0].eq(c)||l.push({from:d,to:p,nodes:f})}),!l.length)return null;let a=r.tr;for(let{from:c,to:u,nodes:d}of l.reverse())d.length?a.replaceWith(c,u,d):a.doc.childCount>1?a.delete(c,u):a.replaceWith(c,u,r.schema.nodes.paragraph.create());return a.setMeta("addToHistory",e.every(c=>c.getMeta("addToHistory")!==!1))}})}var pr=1e4,Sy="\uFFFC",Jt=new K("nova-search"),ia={query:"",caseSensitive:!1,wholeWord:!1,matches:[],current:-1};function wy({query:n,caseSensitive:e,wholeWord:t}){if(!n)return null;let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=t?`(?<![\\p{L}\\p{N}_])${r}(?![\\p{L}\\p{N}_])`:r;return new RegExp(o,e?"gu":"giu")}function Np(n,e){let t=wy(e);if(!t)return[];let r=[];return n.descendants((o,i)=>{if(r.length>=pr)return!1;if(!o.isTextblock)return!0;let s=o.textBetween(0,o.content.size,void 0,Sy);t.lastIndex=0;let l;for(;(l=t.exec(s))&&r.length<pr;){if(l[0].length===0){t.lastIndex+=1;continue}r.push({from:i+1+l.index,to:i+1+l.index+l[0].length})}return!1}),r}function Op(n,e){if(!n.length)return-1;let t=n.findIndex(r=>r.from>=e);return t<0?0:t}function Dp(){return new z({key:Jt,state:{init:()=>ia,apply(n,e,t,r){let o=n.getMeta(Jt);if(o?.type==="clear")return ia;if(o?.type==="set"){let i=Np(r.doc,o.options);return{...o.options,matches:i,current:Op(i,r.selection.from)}}if(o?.type==="goto")return{...e,current:o.index};if(n.docChanged&&e.query){let i=Np(r.doc,e),s=e.matches[e.current]?.from,l=s===void 0?-1:Op(i,n.mapping.map(s));return{...e,matches:i,current:l}}return e}},props:{decorations(n){let e=Jt.getState(n);return e?.matches.length?G.create(n.doc,e.matches.map((t,r)=>ae.inline(t.from,t.to,{class:r===e.current?"nova-search-match nova-search-current":"nova-search-match"}))):null}}})}function Cn(n){return Jt.getState(n)??ia}function Lp(n){return(e,t)=>(t?.(e.tr.setMeta(Jt,{type:"set",options:n})),!0)}var Rp=(n,e)=>(e?.(n.tr.setMeta(Jt,{type:"clear"})),!0);function Ey(n,e,t){return n.setMeta(Jt,{type:"goto",index:t}).setSelection(I.create(n.doc,e.from,e.to)).scrollIntoView()}function fr(n=1){return(e,t)=>{let{matches:r,current:o}=Cn(e);if(!r.length)return!1;let s=o>=0&&e.selection.from===r[o].from&&e.selection.to===r[o].to||o<0?(Math.max(o,0)+n+r.length)%r.length:o;return t&&t(Ey(e.tr,r[s],s)),!0}}function Pp(n){return(e,t)=>{let{matches:r,current:o}=Cn(e),i=r[o];if(!i)return!1;if(t){let s=e.tr,l=e.doc.resolve(i.from).marksAcross(e.doc.resolve(i.to))??[];n?s.replaceWith(i.from,i.to,e.schema.text(n,l)):s.delete(i.from,i.to);let a=s.mapping.map(i.to);t(s.setSelection(I.create(s.doc,a)).scrollIntoView())}return!0}}function Ip(n){return(e,t)=>{let{matches:r}=Cn(e);if(!r.length)return!1;if(t){let o=e.tr;for(let i=r.length-1;i>=0;i--){let{from:s,to:l}=r[i],a=e.doc.resolve(s).marksAcross(e.doc.resolve(l))??[];n?o.replaceWith(s,l,e.schema.text(n,a)):o.delete(s,l)}t(o.scrollIntoView())}return!0}}function Hp(n,e){let{t}=n.ui,r=Te("nova-find"),o=Te("nova-replace"),i=M("input",{id:r,type:"search",className:"nova-input",placeholder:t("search.find"),"aria-label":t("search.find"),autocomplete:"off",spellcheck:"false"}),s=M("input",{id:o,type:"text",className:"nova-input",placeholder:t("search.replace"),"aria-label":t("search.replace"),autocomplete:"off",spellcheck:"false"}),l=M("span",{className:"nova-search-count","aria-live":"polite"}),a=(R,O)=>{let v=M("button",{type:"button",className:"nova-btn nova-search-toggle","aria-pressed":"false","aria-label":R,"data-tooltip":R},O);return n.ui.tooltip.attach(v),v.addEventListener("click",()=>{v.setAttribute("aria-pressed",String(v.getAttribute("aria-pressed")!=="true")),y(),i.focus()}),v},c=a(t("search.matchCase"),"Aa"),u=a(t("search.wholeWord"),"ab|"),d=(R,O,v)=>{let x=M("button",{type:"button",className:"nova-btn","aria-label":O,"data-tooltip":O},V(R));return n.ui.tooltip.attach(x),x.addEventListener("click",v),x},p=d(S.chevronUp,t("search.prev"),()=>{n.exec(fr(-1)),i.focus()}),f=d(S.chevronDown,t("search.next"),()=>{n.exec(fr(1)),i.focus()}),h=d(S.close,t("dialog.close"),()=>L.close()),g=M("button",{type:"button",className:"nova-button"},t("search.replaceOne")),m=M("button",{type:"button",className:"nova-button"},t("search.replaceAll"));g.addEventListener("click",()=>{w(),n.exec(Pp(s.value)),n.exec(fr(1)),s.focus()}),m.addEventListener("click",()=>{w(),n.exec(Ip(s.value)),s.focus()});let b=M("div",{className:"nova-search",role:"search","aria-label":t("search.title"),hidden:!0},M("div",{className:"nova-search-row"},i,l,c,u,p,f,h),M("div",{className:"nova-search-row"},s,g,m));e.parentElement.insertBefore(b,e);let k=null,y=()=>{k&&clearTimeout(k),k=null,Lp({query:i.value,caseSensitive:c.getAttribute("aria-pressed")==="true",wholeWord:u.getAttribute("aria-pressed")==="true"})(n.view.state,n.view.dispatch)},w=()=>{(k||Cn(n.view.state).query!==i.value)&&y()};i.addEventListener("input",()=>{k&&clearTimeout(k),k=setTimeout(y,120)}),i.addEventListener("keydown",R=>{R.key==="Enter"&&(R.preventDefault(),w(),n.exec(fr(R.shiftKey?-1:1)),i.focus())}),s.addEventListener("keydown",R=>{R.key==="Enter"&&(R.preventDefault(),g.click(),s.focus())}),b.addEventListener("keydown",R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),L.close())}),b.addEventListener("mousedown",R=>{R.target.closest("button")&&R.preventDefault()});let N=()=>{if(b.hidden)return;let{matches:R,current:O,query:v}=Cn(n.view.state),x=R.length;v?x?l.textContent=t("search.count",{current:O+1,total:x>=pr?`${pr}+`:x}):l.textContent=t("search.none"):l.textContent="",b.classList.toggle("is-empty",!!v&&!x);for(let C of[p,f,g,m])C.disabled=!x;g.disabled=!x||!n.isEditable(),m.disabled=!x||!n.isEditable()},L={open(){let R=b.hidden;b.hidden=!1;let{from:O,to:v,empty:x}=n.view.state.selection,C=x?"":n.view.state.doc.textBetween(O,v," ");C&&!C.includes(`
33
- `)&&C.length<=100&&(i.value=C),(R||C)&&y(),i.focus(),i.select(),N()},close(){b.hidden||(b.hidden=!0,k&&clearTimeout(k),Rp(n.view.state,n.view.dispatch),n.focus())},isOpen:()=>!b.hidden,update:N,destroy(){k&&clearTimeout(k),b.remove()}};return L}function sa(n){return n.root.classList.contains("nova-fullscreen")}function hr(n,e=!sa(n)){n.root.classList.toggle("nova-fullscreen",e),document.documentElement.classList.toggle("nova-fullscreen-lock",e),n.ui.closePopover(),n.updateUI(),n.focus()}function Bp(n){let{t:e}=n.ui,t=M("div",{className:"nova-prosemirror nova-preview"});t.append(Le.fromSchema(n.schema).serializeFragment(n.view.state.doc.content)),t.querySelectorAll("a[href]").forEach(r=>{r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")}),n.ui.openDialog({title:e("preview"),body:t,size:"large",cancelLabel:e("dialog.close")})}function Cy(n){return n.replace(/(<\/(p|h[1-6]|ul|ol|li|blockquote|pre|table|tbody|tr)>|<hr>)/g,`$1
34
+ `);return l?(i(l),!0):!1}}})}var Mg="vscode-editor-data",wg={shellscript:"bash",typescriptreact:"tsx",javascriptreact:"jsx",jsonc:"json"};function q0(n,e,t,r){let o=e.clipboardData,i=o?.getData(Mg),s=o?.getData("text/plain");if(!i||!s||n.state.selection.$from.parent.type.spec.code)return!1;let l;try{l=JSON.parse(i).mode}catch{}if(l==="markdown"&&t.hasPlugin("markdown")&&!t.isPasteAsText())return!1;let a=s.replace(/\r\n?/g,`
35
+ `).replace(/\n$/,""),c=n.state.schema.nodes.code_block;if(!a.includes(`
36
+ `)||l==="markdown"||l==="plaintext"||t.isPasteAsText()||!c||!t.isAllowed("codeblock"))return r(a),!0;let u=typeof l=="string"?Object.hasOwn(wg,l)?wg[l]:vn(l):null,d=c.create({language:u},n.state.schema.text(a));return n.dispatch(n.state.tr.replaceSelection(new D(T.from(d),0,0)).setMeta("uiEvent","paste").scrollIntoView()),!0}var Eu={};q(Eu,{MAX_GRID:()=>pr,createTable:()=>Eg,createTableGridPanel:()=>Mu,getCellProps:()=>J0,getTableProps:()=>K0,hasHeaderColumn:()=>wu,hasHeaderRow:()=>xu,insertTable:()=>It,isCellSelection:()=>W0,isInTable:()=>Gt,loadTables:()=>ku,loadedTables:()=>j0,setCellBackground:()=>vu,setCellProps:()=>G0,setTableProps:()=>U0,sortTable:()=>as,tableCommands:()=>$e,tableRect:()=>Su});var xe=null,ls=null;function ku(){return ls??(ls=import(__novaChunk("tinymce-chunks/table-4d43f60d.js") ).then(n=>xe=n,n=>(console.warn("[nova] failed to load table editing",n),ls=null,null))),ls}function j0(){return xe}var nt=n=>(e,t,r)=>xe?xe.tableCommands[n](e,t,r):!1,$e={addRowBefore:nt("addRowBefore"),addRowAfter:nt("addRowAfter"),deleteRow:nt("deleteRow"),addColumnBefore:nt("addColumnBefore"),addColumnAfter:nt("addColumnAfter"),deleteColumn:nt("deleteColumn"),mergeCells:nt("mergeCells"),splitCell:nt("splitCell"),toggleHeaderRow:nt("toggleHeaderRow"),toggleHeaderColumn:nt("toggleHeaderColumn"),deleteTable:nt("deleteTable")};function vu(n){return(e,t,r)=>xe?xe.setCellBackground(n)(e,t,r):!1}function xu(n){return xe?.hasHeaderRow(n)??!1}function wu(n){return xe?.hasHeaderColumn(n)??!1}function W0(n){return xe?.isCellSelection(n)??!1}function K0(n){return xe?.getTableProps(n)??null}function U0(n){return(e,t,r)=>xe?xe.setTableProps(n)(e,t,r):!1}function J0(n){return xe?.getCellProps(n)??null}function G0(n){return(e,t,r)=>xe?xe.setCellProps(n)(e,t,r):!1}function as(n,e){return(t,r,o)=>xe?xe.sortTable(n,e)(t,r,o):!1}var pr=10;function Su(n){let{$from:e}=n.view.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="table")return n.view.nodeDOM(e.before(t))?.getBoundingClientRect()??null;return null}function Eg(n,e,t=!0,r=Lt){let{table:o,table_row:i,table_cell:s,table_header:l,paragraph:a}=r.nodes,c=[];for(let u=0;u<n;u++){let d=t&&u===0?l:s,p=[];for(let f=0;f<e;f++)p.push(d.create(null,a.create()));c.push(i.create(null,p))}return o.create(null,c)}function It(n,e,t=!0){return(r,o)=>{if(n<1||e<1||n>100||e>50||Gt(r))return!1;if(o){let i=Eg(n,e,t,r.schema),s=qi(r.tr,i),l=-1;s.doc.descendants((a,c)=>(a===i&&(l=c),l<0)),l>=0&&s.setSelection(F.near(s.doc.resolve(l+3))),o(s.scrollIntoView())}return!0}}function Mu(n,e,t){let r=1,o=1,i=[],s=w("div",{className:"nova-grid-caption","aria-live":"polite"}),l=w("div",{className:"nova-grid",role:"grid","aria-label":t}),a=()=>{for(let c of i){let u=Number(c.dataset.row),d=Number(c.dataset.col);c.classList.toggle("is-on",u<=r&&d<=o),c.tabIndex=u===r&&d===o?0:-1}s.textContent=e(r,o)};for(let c=1;c<=pr;c++)for(let u=1;u<=pr;u++){let d=w("button",{type:"button",className:"nova-grid-cell",role:"gridcell","aria-label":e(c,u),"data-row":String(c),"data-col":String(u)});d.addEventListener("mouseenter",()=>{r=c,o=u,a()}),d.addEventListener("click",()=>n(c,u)),i.push(d),l.append(d)}return l.addEventListener("keydown",c=>{let d={ArrowRight:[0,1],ArrowLeft:[0,-1],ArrowDown:[1,0],ArrowUp:[-1,0]}[c.key];d&&(c.preventDefault(),r=Math.min(pr,Math.max(1,r+d[0])),o=Math.min(pr,Math.max(1,o+d[1])),a(),i[(r-1)*pr+(o-1)].focus())}),a(),w("div",{className:"nova-grid-panel"},l,s)}var Ou={};q(Ou,{createRenderer:()=>Lg,htmlSerializer:()=>mr,isRtlLanguage:()=>us,renderHTML:()=>ow,sanitizeJSON:()=>po,schemaFromOptions:()=>ds});var Cg={b:"strong",i:"em",strike:"s",del:"s",tbody:"table",thead:"table",tfoot:"table",caption:"table",colgroup:"table",col:"table",figcaption:"figure"},Y0=["p","h1","h2","h3","h4","h5","h6","blockquote","pre","hr","ul","ol","li","img","figure","br","table","tr","td","th","strong","em","u","s","code","a","sub","sup","span"];var X0={bold:["strong"],italic:["em"],underline:["u"],strikethrough:["s"],strike:["s"],inlinecode:["code"],code:["code"],subscript:["sub"],superscript:["sup"],language:["span"],link:["a"],unlink:["a"],quicklink:["a"],image:["img"],quickimage:["img"],table:["table"],quicktable:["table"],inserttable:["table"],tableinsertrowbefore:["table"],tableinsertrowafter:["table"],tabledeleterow:["table"],tableinsertcolbefore:["table"],tableinsertcolafter:["table"],tabledeletecol:["table"],tablemergecells:["table"],tablesplitcells:["table"],tabledelete:["table"],tablerowheader:["th"],tablecolheader:["th"],tablecellbackground:["style:background-color"],bullist:["ul"],checklist:["ul"],accordion:["details"],bulletlist:["ul"],numlist:["ol"],orderedlist:["ol"],blockquote:["blockquote"],codeblock:["pre"],hr:["hr"],horizontalrule:["hr"],h1:["h1"],h2:["h2"],h3:["h3"],h4:["h4"],h5:["h5"],h6:["h6"],forecolor:["span","style:color"],backcolor:["span","style:background-color"],fontfamily:["span","style:font-family"],fontsize:["span","style:font-size"],lineheight:["style:line-height"],align:["style:text-align"],alignleft:["style:text-align"],aligncenter:["style:text-align"],alignright:["style:text-align"],alignjustify:["style:text-align"],imagealignleft:["style:float"],imagealigncenter:["style:float"],imagealignright:["style:float"]};function Cu(n){if(n===void 0)return null;let e=new Set;for(let t of n.split(",")){let r=t.trim().replace(/^[-#+!]+/,"").replace(/\[.*$/,"").toLowerCase();for(let o of r.split("/")){let i=o.trim();i&&e.add(Cg[i]??i)}}return e}function Z0(n){if(n===void 0)return null;let e=typeof n=="string"?n:Object.values(n).join(",");return new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}var fr=class{constructor(e){S(this,"tags");S(this,"styles");let t=Cu(e.validElements),r=Cu(e.invalidElements)??new Set,o=new Set(t??Y0);if(t)for(let i of Cu(e.extendedValidElements)??[])o.add(i);(o.has("ul")||o.has("ol"))&&o.add("li"),o.has("table")&&(o.add("tr"),o.add("td"));for(let i of r)o.delete(i);o.add("p"),this.tags=o,this.styles=Z0(e.validStyles)}isTagAllowed(e){let t=e.toLowerCase();return this.tags.has(Cg[t]??t)}isStyleAllowed(e){return!this.styles||this.styles.has(e.toLowerCase())}isAllowed(e){let t=X0[e.toLowerCase()];return t?t.every(r=>r.startsWith("style:")?this.isStyleAllowed(r.slice(6)):this.isTagAllowed(r)):!0}markAllowed(e){switch(e.type.name){case"bold":return this.isTagAllowed("strong");case"italic":return this.isTagAllowed("em");case"underline":return this.isTagAllowed("u");case"strike":return this.isTagAllowed("s");case"code":return this.isTagAllowed("code");case"link":return this.isTagAllowed("a");case"subscript":return this.isTagAllowed("sub");case"superscript":return this.isTagAllowed("sup");case"color":return this.isTagAllowed("span")&&this.isStyleAllowed("color");case"background":return this.isTagAllowed("span")&&this.isStyleAllowed("background-color");case"font_family":return this.isTagAllowed("span")&&this.isStyleAllowed("font-family");case"font_size":return this.isTagAllowed("span")&&this.isStyleAllowed("font-size");case"language":return this.isTagAllowed("span");default:return!0}}blockAttrs(e){return{...e,...this.isStyleAllowed("text-align")?{}:{align:null},...this.isStyleAllowed("line-height")?{}:{lineHeight:null},...this.isStyleAllowed("margin-left")?{}:{indent:0}}}normalize(e){let t=e.type.schema,{nodes:r}=t;if(e.isText){let l=e.marks.filter(a=>this.markAllowed(a));return[l.length===e.marks.length?e:e.mark(l)]}let o=e.marks.filter(l=>this.markAllowed(l));switch(e.type){case r.image:return this.isTagAllowed("img")?[r.image.create({...e.attrs,...this.isStyleAllowed("float")?{}:{align:null}},null,o)]:[];case r.figure:{let l=e.childCount>1?e.child(1).content:null,a=l?.size?[r.paragraph.create(null,this.normalizeChildren(l))]:[],c=e.firstChild;if(!this.isTagAllowed("img")||!c)return a;let u=this.isStyleAllowed("float")?e.attrs.align:null;if(!this.isTagAllowed("figure")){let d=r.image.create({...c.attrs,align:u});return[r.paragraph.create(null,d),...a]}return[r.figure.create({...e.attrs,align:u},e.content)]}case r.hard_break:return this.isTagAllowed("br")?[e.mark(o)]:[t.text(" ",o)];case r.horizontal_rule:return this.isTagAllowed("hr")?[e]:[]}let i=this.normalizeChildren(e.content),s=(l=e.type,a=e.attrs)=>{try{return[l.createChecked(a,i,e.marks)]}catch{let c=l.createAndFill(a,i,e.marks);return c?[c]:i.content.length?Au(i):[]}};if(e.type.name==="details"&&!this.isTagAllowed("details")){let l=[];return i.forEach(a=>{a.type.name!=="details_summary"?l.push(a):a.content.size&&l.push(r.paragraph.create(null,a.content))}),l}switch(e.type){case r.paragraph:return s(r.paragraph,this.blockAttrs(e.attrs));case r.heading:return this.isTagAllowed(`h${e.attrs.level}`)?s(r.heading,this.blockAttrs(e.attrs)):s(r.paragraph,this.blockAttrs({align:e.attrs.align,lineHeight:e.attrs.lineHeight}));case r.blockquote:return this.isTagAllowed("blockquote")?s():Au(i);case r.code_block:return this.isTagAllowed("pre")?s():e.textContent.split(`
37
+ `).map(l=>r.paragraph.create(null,l?t.text(l):null));case r.bullet_list:case r.ordered_list:return this.isTagAllowed(e.type===r.bullet_list?"ul":"ol")?s(e.type,{...e.attrs,...this.isStyleAllowed("list-style-type")?{}:{listStyle:null}}):Q0(i);case r.table:return this.isTagAllowed("table")?s():ew(i);case r.table_header:return this.isTagAllowed("th")?s():s(r.table_cell,e.attrs);case r.table_cell:return s(r.table_cell,{...e.attrs,...this.isStyleAllowed("background-color")?{}:{background:null}});default:return s()}}normalizeChildren(e){let t=[];return e.forEach(r=>t.push(...this.normalize(r))),T.from(t)}normalizeDoc(e){let t=this.normalizeChildren(e.content),r=e.type.schema;return e.type.createAndFill(e.attrs,t.size?t:r.nodes.paragraph.create())}};function Au(n){let e=[],t=[],r=()=>{t.length&&e.push(t[0].type.schema.nodes.paragraph.create(null,t)),t=[]};return n.forEach(o=>{o.isInline?t.push(o):(r(),e.push(o))}),r(),e}function Q0(n){let e=[];return n.forEach(t=>{t.type===t.type.schema.nodes.list_item?t.content.forEach(r=>e.push(r)):e.push(...Au(T.from(t)))}),e}function ew(n){let e=[];return n.forEach(t=>t.forEach(r=>r.forEach(o=>e.push(o)))),e}var tw=new X("nova-content-rules");function Ag(n){return new z({key:tw,appendTransaction(e,t,r){if(!e.some(c=>c.docChanged))return null;let o=t.doc.content.findDiffStart(r.doc.content);if(o===null)return null;let i=t.doc.content.findDiffEnd(r.doc.content)?.b??r.doc.content.size,s=r.doc,l=[];if(s.forEach((c,u)=>{let d=u,p=u+c.nodeSize;if(p<o||d>Math.max(o,i))return;let f=n.normalize(c);f.length===1&&f[0].eq(c)||l.push({from:d,to:p,nodes:f})}),!l.length)return null;let a=r.tr;for(let{from:c,to:u,nodes:d}of l.reverse())d.length?a.replaceWith(c,u,d):a.doc.childCount>1?a.delete(c,u):a.replaceWith(c,u,r.schema.nodes.paragraph.create());return a.setMeta("addToHistory",e.every(c=>c.getMeta("addToHistory")!==!1))}})}var cs="data-nova-own-style",Tu=null;function Nu(n){Tu=n}var Tg=!1;function Ng(n){return!!n.extendedValidElements||!!n.customElements||/\[/.test(n.validElements??"")?Tu?Tu.create(n):(Tg||(Tg=!0,console.warn("[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);")),null):null}var mr=new Qr,nw=new Set(["ar","he","iw","fa","ur","ps","sd","ug","yi","dv","ckb"]);function us(n){return!!n&&nw.has(n.toLowerCase().split(/[-_]/)[0])}function hr(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}function ds(n,e,t,r){let o=new Set([...oo(Object.values(n.formats??{}).flat()),...oo(n.styleFormats??[]),...Array.isArray(n.validClasses)?n.validClasses:[],...[...n.tableClassList??[],...n.tableCellClassList??[]].flatMap(d=>d.value.split(/\s+/).filter(Boolean))]),i=Ng(n),l=n.validClasses===!0||n.validClasses===void 0&&!!i?.classOnBuiltIn?()=>!0:d=>o.has(d),a={},c={},u={};for(let d of e){Object.assign(u,d.nodeAttributes);let p;try{p=typeof d.nodes=="function"?d.nodes(r):d.nodes}catch(f){hr(`Plugin "${d.name}" failed to define its nodes`,f)}for(let[f,h]of Object.entries(p??{}))f in a?hr(`Node "${f}" is defined by several plugins`):a[f]=h;for(let[f,h]of Object.entries(d.marks??{}))f in c?hr(`Mark "${f}" is defined by several plugins`):c[f]=h}try{return{schema:Ci({nodes:a,marks:c,attributes:u},l,i,t),allowedClasses:o}}catch(d){return hr("Failed to build the document schema from plugins",d),{schema:Ci({},l,i,t),allowedClasses:o}}}function rw(n,e){let t=n?.validate;if(!t)return!0;if(typeof t=="function")try{return t(e),!0}catch{return!1}let r=e===null?"null":typeof e;return t.split("|").includes(r)}function Og(n,e){return!e||typeof e!="object"||!n?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>rw(n[t],r)))}function po(n,e){let t=n.nodes[e.type],r={...e};return t&&(r.attrs=Og(t.spec.attrs,e.attrs)),Array.isArray(e.marks)&&(r.marks=e.marks.map(o=>{let i=o&&n.marks[o.type];return i?{...o,attrs:Og(i.spec.attrs,o.attrs)}:o})),Array.isArray(e.content)&&(r.content=e.content.map(o=>o&&typeof o=="object"?po(n,o):o)),r}function Lg(n={}){let e=vr(n.plugins??[]);e.errors.forEach(u=>hr(u));let{ordered:t,errors:r}=Ln(e.plugins);r.forEach(u=>hr(u));let o=n.direction??(us(n.language)?"rtl":"ltr"),{schema:i}=ds(n,t,o,{options:n}),l=n.validElements!==void 0||n.invalidElements!==void 0||n.validStyles!==void 0?new fr(n):null,a=u=>{let d=Te.fromJSON(i,po(i,u));return l?l.normalizeDoc(d):d},c=kr(t,{options:n});return{schema:i,doc:a,html:(u,{fullPage:d=!0}={})=>{let p=a(u),f=mr.serializeFragment(p.content);return c&&d?c.write(f,p.attrs):f},text:u=>{let d=a(u);return d.textBetween(0,d.content.size,`
38
+
39
+ `)}}}function ow(n,e={}){return Lg(e).html(n)}var Lu=new WeakSet,Pu=new WeakMap,Pg=new WeakSet;function Ru(n){for(let e of n){let t=e.spec,r=t.view;!r||Pg.has(e)||(Pg.add(e),t.view=o=>{let i=Pu.get(o);i||Pu.set(o,i=new Map);let s=i.get(e);s||i.set(e,s=r(o));let l=s;return{update:(a,c)=>l.update?.(a,c),destroy:()=>{Lu.has(o)||(i.delete(e),l.destroy?.())}}})}}function Du(n,e){Ru(e),Lu.add(n);try{n.updateState(n.state.reconfigure({plugins:e}))}finally{Lu.delete(n)}let t=Pu.get(n);if(t)for(let[r,o]of t)e.includes(r)||(t.delete(r),o.destroy?.())}var Hu={};q(Hu,{CELL_BG_ATTR:()=>Dg,novaParser:()=>lw,parserFor:()=>gr,preprocessDOM:()=>_g});var Dg="data-nova-cell-bg",_u="http://www.w3.org/1999/xhtml",iw="http://www.w3.org/1998/Math/MathML";function sw(n){let e=[...n.querySelectorAll("*")].filter(t=>t.namespaceURI!==_u&&(t.parentElement?.namespaceURI??_u)===_u);for(let t of e){let r=t.namespaceURI===iw?t.textContent??"":"";t.replaceWith(t.ownerDocument.createTextNode(r))}}function _g(n){sw(n),n.querySelectorAll("td, th").forEach(e=>{if(!e.style)return;let t=e.style.backgroundColor;t&&(e.setAttribute(Dg,t),e.style.removeProperty("background-color"),e.getAttribute("style")||e.removeAttribute("style"))})}var Iu=class extends Mt{constructor(){super(...arguments);S(this,"atomSelector");S(this,"ownStyleSelector")}prepare(t){_g(t),this.ownStyleSelector??(this.ownStyleSelector=Object.values(this.schema.nodes).flatMap(r=>r.spec.ownStyleTags??[]).join(", ")),this.ownStyleSelector&&"querySelectorAll"in t&&t.querySelectorAll(this.ownStyleSelector).forEach(r=>{let o=r.getAttribute("style");o!==null&&(r.setAttribute(cs,o),r.removeAttribute("style"))}),this.atomSelector??(this.atomSelector=Object.values(this.schema.nodes).filter(r=>r.spec.ignoreStyles).flatMap(r=>(r.spec.parseDOM??[]).map(o=>o.tag)).filter(r=>!!r).join(", ")),!(!this.atomSelector||!("querySelectorAll"in t))&&t.querySelectorAll(this.atomSelector).forEach(r=>{r.removeAttribute("style")})}parse(t,r){return this.prepare(t),super.parse(t,r)}parseSlice(t,r){return this.prepare(t),super.parseSlice(t,r)}},Rg=new WeakMap;function gr(n){let e=Rg.get(n);return e||(e=new Iu(n,Mt.fromSchema(n).rules),Rg.set(n,e)),e}var lw=gr(Lt);var Bu={};q(Bu,{createMenu:()=>fo,focusMenu:()=>ho});function fo(n,e,t){let r=[],o=w("div",{className:"nova-menu",role:"menu","aria-label":t}),i=n.some(a=>(a.type===void 0||a.type==="item")&&a.active!==void 0);for(let a of n){if(a.type==="separator"){o.append(w("div",{className:"nova-menu-sep",role:"separator"}));continue}if(a.type==="heading"){o.append(w("div",{className:"nova-menu-heading",role:"presentation"},a.label));continue}let c=w("span",{className:"nova-menu-label"},a.label);a.labelStyle&&c.setAttribute("style",a.labelStyle);let u=w("button",{type:"button",className:"nova-menu-item",role:a.active===void 0?"menuitem":a.checkbox?"menuitemcheckbox":"menuitemradio",tabindex:"-1","data-id":a.id,disabled:a.disabled??!1,...a.active!==void 0?{"aria-checked":String(a.active)}:{}},i?w("span",{className:"nova-menu-check"},a.active?ee(C.check):null):null,a.icon?ee(a.icon):null,c,a.shortcut?w("kbd",{className:"nova-menu-shortcut"},At(a.shortcut)):null);u.addEventListener("click",()=>{e(),a.onSelect()}),r.push(u),o.append(u)}let s=()=>r.filter(a=>!a.disabled),l=a=>{let c=s();c.length&&c[(a+c.length)%c.length].focus()};return o.addEventListener("keydown",a=>{let c=s(),u=c.indexOf(te(o));switch(a.key){case"ArrowDown":a.preventDefault(),l(u+1);break;case"ArrowUp":a.preventDefault(),l(u-1);break;case"Home":a.preventDefault(),l(0);break;case"End":a.preventDefault(),l(c.length-1);break;case"Tab":a.preventDefault();break;default:if(a.key.length===1&&/\S/.test(a.key)){let d=a.key.toLowerCase(),p=u+1;[...c.slice(p),...c.slice(0,p)].find(h=>h.textContent?.trim().toLowerCase().startsWith(d))?.focus()}}}),o}function ho(n){(n.querySelector('[aria-checked="true"]:not(:disabled)')??n.querySelector(".nova-menu-item:not(:disabled)"))?.focus()}var Ig={file:{title:"menu.file",items:"save cancel | fullpagehtml | importword exportword exportpdf | preview | print"},edit:{title:"menu.edit",items:"undo redo | selectall | searchreplace pastetext"},view:{title:"menu.view",items:"code preview | fullscreen | visualblocks visualchars"},insert:{title:"menu.insert",items:"image link media pageembed inserttable hr | insertdatetime template footnotes"},format:{title:"menu.format",items:"bold italic underline strikethrough superscript subscript inlinecode | paragraph h1 h2 h3 blockquote codeblock | alignleft aligncenter alignright alignjustify | lowercase uppercase titlecase | formatpainter permanentpen configurepermanentpen | language | removeformat"},table:{title:"menu.table",items:"inserttable | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | advtablesort advtablerownumbering | tabledelete"},tools:{title:"menu.tools",items:"spellchecker spellcheckdialog | autocorrect capitalization typography | linkchecker a11ycheck"},help:{title:"menu.help",items:"help"}},Hg="file edit view insert format table help";function Bg(n,e,t,r){let{t:o}=n.ui;e.className="nova-menubar",e.setAttribute("role","menubar"),e.setAttribute("aria-label",o("menu.label"));let i=new AbortController,{signal:s}=i,l=f=>f.title.startsWith("menu.")?o(f.title):f.title,a=f=>{let h=[];for(let m of f.items.split(/\s+/)){if(!m)continue;if(m==="|"){h.length&&h[h.length-1].type!=="separator"&&h.push({type:"separator"});continue}if(!n.isAllowed(m))continue;let g=n.ui.registry.getMenuItem(m);g&&h.push({id:m,label:g.text,...g.icon?{icon:g.icon}:{},...g.shortcut?{shortcut:g.shortcut}:{},...g.isActive?{active:g.isActive(n),checkbox:!0}:{},disabled:!n.isEditable()||(g.isEnabled?!g.isEnabled(n):!1),onSelect:()=>g.onAction(n)})}for(;h.length&&h[h.length-1].type==="separator";)h.pop();return h},c=[],u=null,d=()=>{u?.popover.close(),u=null},p=(f,h)=>{d();let m=c[f],g=r[m.dataset.menu],k=a(g);if(!k.length)return;let x=fo(k,()=>n.ui.closePopover(),l(g));x.addEventListener("keydown",L=>{let O=Ne(L,x);if(O!=="ArrowLeft"&&O!=="ArrowRight")return;L.preventDefault();let B=(f+(O==="ArrowRight"?1:-1)+c.length)%c.length;p(B,!0)}),m.setAttribute("aria-expanded","true");let M=n.ui.openPopover({anchor:m,content:x,ignore:[e],className:"nova-popover-menu",onClose:L=>{m.setAttribute("aria-expanded","false"),u?.popover===M&&(u=null),L==="escape"&&m.focus()}});u={index:f,popover:M},h&&ho(x)};for(let f of t.split(/\s+/).filter(Boolean)){let h=r[f];if(!h)continue;let m=w("button",{type:"button",className:"nova-menubar-item",role:"menuitem","aria-haspopup":"menu","aria-expanded":"false","data-menu":f,tabindex:c.length===0?"0":"-1"},l(h)),g=c.length;m.addEventListener("click",k=>{if(u?.index===g)return d();p(g,k.detail===0)}),m.addEventListener("mouseenter",()=>{u&&u.index!==g&&p(g,!1)}),c.push(m),e.append(m)}return e.addEventListener("keydown",f=>{let h=c.indexOf(te(e));if(h<0)return;let m=k=>{f.preventDefault();let x=(k+c.length)%c.length;c.forEach((M,L)=>M.tabIndex=L===x?0:-1),c[x].focus()},g=Ne(f,e);g==="ArrowRight"?m(h+1):g==="ArrowLeft"?m(h-1):f.key==="Home"?m(0):f.key==="End"?m(c.length-1):f.key==="ArrowDown"?(f.preventDefault(),p(h,!0)):f.key==="Escape"&&(f.preventDefault(),n.focus())},{signal:s}),e.addEventListener("mousedown",f=>{f.target.closest("button")&&f.preventDefault()},{signal:s}),{focus:()=>(c.find(f=>f.tabIndex===0)??c[0])?.focus(),destroy:()=>{d(),i.abort(),e.replaceChildren()}}}function aw(n){import(__novaChunk("tinymce-chunks/print-86762549.js") ).then(e=>e.print(n),e=>console.error("[nova] print: could not load the print module",e))}function cw(n){let{t:e}=n.ui,t=ze({label:e("table.rows"),value:"3"}),r=ze({label:e("table.cols"),value:"3"});for(let o of[t,r])o.input.type="number",o.input.min="1",o.input.max="50",o.input.inputMode="numeric";n.ui.openDialog({title:e("table.insert"),body:w("div",{className:"nova-form nova-form-row"},t.el,r.el),submitLabel:e("dialog.insert"),initialFocus:t.input,onSubmit:()=>{let o=Number(t.input.value),i=Number(r.input.value);return!Number.isInteger(o)||!Number.isInteger(i)||o<1||i<1||o>50||i>50?e("table.invalidSize"):(n.exec(It(o,i)),!0)}})}function Fg(n){let{registry:e,t}=n.ui;e.addToggleMenuItem("paragraph",{text:t("paragraph"),icon:C.paragraph,shortcut:"Mod-Alt-0",isActive:r=>r.view.state.selection.$from.parent.type.name==="paragraph",onAction:r=>r.exec("paragraph")}),e.addMenuItem("selectall",{text:t("selectAll"),shortcut:"Mod-a",onAction:r=>{r.view.dispatch(r.view.state.tr.setSelection(new de(r.view.state.doc))),r.focus()}}),e.addMenuItem("print",{text:t("print"),icon:C.print,shortcut:"Mod-p",onAction:r=>aw(r)}),e.addMenuItem("inserttable",{text:t("table.insert"),icon:C.table,isEnabled:r=>r.can(It(1,1)),onAction:r=>cw(r)})}function uw(n,e){let{selection:t,doc:r,storedMarks:o}=e;return Object.create(n,{doc:{get:()=>r},selection:{get:()=>t},storedMarks:{get:()=>o},tr:{get:()=>({selection:t,doc:r,storedMarks:o}=e,e)}})}function zg(n){console.warn(`[nova] chain: ${n}`)}function $g(n){let e=[],t=o=>{let i=n.view();if(!i)return!1;let{state:s}=i,l=s.tr;for(let a of e){let c=!1,u=d=>{d!==l&&(c=!0)};if(!a(uw(s,l),u,i))return!1;if(c)return zg("a command dispatched its own transaction; build it from state.tr"),!1}return o&&(i.dispatch(l),i.focus()),!0},r={exec(o){return o==="undo"||o==="redo"?(zg(`"${o}" runs on its own \u2014 use editor.exec()`),e.push(()=>!1)):e.push(typeof o=="string"?n.resolve(o):o),r},insertContent(o){return e.push(n.insertContent(o)),r},run:()=>t(!0),can:()=>t(!1)};return r}var $u={};q($u,{pages:()=>Tn,setSourceHTML:()=>zu,sourceHTML:()=>Fu});var Tn=new WeakMap;function Fu(n){return n.getHTML({fullPage:Tn.get(n)?.inSource!==!1})}function zu(n,e){n.setContent(e,{fullPage:Tn.get(n)?.inSource!==!1})}var dw=200,mo=new X("nova-bookmarks");function Vg(){return new z({key:mo,state:{init:()=>new Map,apply(n,e){let t=n.getMeta(mo);if(t)return t;if(!n.docChanged||!e.size)return e;let r=new Map;for(let[o,i]of e){let s=n.mapping.mapResult(i.from,1),l=n.mapping.mapResult(i.to,-1);r.set(o,{from:s.pos,to:Math.max(s.pos,l.pos),gone:i.gone||i.from!==i.to&&s.pos>=l.pos})}return r}}})}var pw=1;function qg(n){let e=()=>n.view,t=i=>{let s=e().state.doc.content.size,l=typeof i=="number"&&Number.isFinite(i)?Math.round(i):0;return Math.max(0,Math.min(l,s))},r=i=>i instanceof Node&&i!==e().dom&&e().dom.contains(i),o={getRange(){let{from:i,to:s}=e().state.selection;return{from:i,to:s}},setRange(i,s=i){let{state:l,dispatch:a}=e(),c=F.between(l.doc.resolve(t(i)),l.doc.resolve(t(s)));a(l.tr.setSelection(c))},isCollapsed:()=>e().state.selection.empty,collapse(i=!1){let{from:s,to:l}=e().state.selection;o.setRange(i?s:l)},selectAll(){let{state:i,dispatch:s}=e();s(i.tr.setSelection(new de(i.doc)))},getHTML(){let{selection:i}=e().state;return i.empty?"":mr.serializeFragment(i.content().content)},getText(){let{state:i}=e();return i.doc.textBetween(i.selection.from,i.selection.to,`
40
+ `)},setHTML:i=>n.insertContent(i),getNode(){let i=e(),{selection:s}=i.state;if(s instanceof R){let c=i.nodeDOM(s.from);if(c instanceof HTMLElement)return c}let l=(c,u)=>{let{node:d}=i.domAtPos(c,u);return d instanceof HTMLElement?d:d.parentElement},a=l(s.from,s.empty?0:1);if(!s.empty){let c=l(s.to,-1);for(;a&&c&&!a.contains(c);)a=a.parentElement}return a&&i.dom.contains(a)?a:null},select(i,s=!1){if(!r(i))return;let l=e(),{doc:a}=l.state,c=l.posAtDOM(i,0);for(let u of[c-1,c]){if(u<0||u>=a.content.size)continue;let d=a.nodeAt(u);if(!d||d.isText)continue;let p=l.nodeDOM(u);if(!(p!==i&&!(d.isLeaf&&p instanceof Node&&p.contains(i)))){d.isLeaf||!s&&R.isSelectable(d)?l.dispatch(l.state.tr.setSelection(R.create(a,u))):o.setRange(u+1,u+d.nodeSize-1);return}}o.setRange(c,l.posAtDOM(i,i.childNodes.length))},setCursorLocation(i,s=0){if(!r(i))return;let l=i.nodeType===3?i.length:i.childNodes.length;o.setRange(e().posAtDOM(i,Math.max(0,Math.min(s,l))))},getDOMRange(){let i=e();if(!i.dom.isConnected)return null;let{from:s,to:l}=i.state.selection;try{let a=i.domAtPos(s),c=i.domAtPos(l),u=document.createRange();return u.setStart(a.node,a.offset),u.setEnd(c.node,c.offset),u}catch{return null}},getRect(){let i=e();if(!i.dom.isConnected)return null;let{from:s,to:l,empty:a}=i.state.selection;try{if(!a){let f=o.getDOMRange()?.getBoundingClientRect?.();if(f&&(f.width||f.height))return f}let c=i.coordsAtPos(s),u=a?c:i.coordsAtPos(l),d=Math.min(c.left,u.left),p=Math.min(c.top,u.top);return new DOMRect(d,p,Math.max(c.right,u.right)-d,Math.max(c.bottom,u.bottom)-p)}catch{return null}},getBookmark(){let i=e(),s=pw++;if(i.isDestroyed)return{id:s};let l=new Map(mo.getState(i.state));for(;l.size>=dw;)l.delete(l.keys().next().value);let{from:a,to:c}=i.state.selection;return l.set(s,{from:a,to:c,gone:!1}),i.dispatch(i.state.tr.setMeta(mo,l).setMeta("addToHistory",!1)),{id:s}},moveToBookmark(i){let s=e(),l=i?.id,a=typeof l=="number"?mo.getState(s.state)?.get(l):void 0;return!a||a.gone?!1:(o.setRange(a.from,a.to),!0)},scrollIntoView(){let{state:i,dispatch:s}=e();s(i.tr.scrollIntoView())}};return o}var Ku={};q(Ku,{MAX_MATCHES:()=>Vu,clearSearch:()=>gw,findMatches:()=>ju,findNext:()=>bw,getSearchState:()=>ps,replaceAll:()=>vw,replaceCurrent:()=>kw,searchKey:()=>Qt,searchPlugin:()=>Wu,setSearch:()=>mw});var Vu=1e4,fw="\uFFFC",Qt=new X("nova-search"),qu={query:"",caseSensitive:!1,wholeWord:!1,matches:[],current:-1};function hw({query:n,caseSensitive:e,wholeWord:t}){if(!n)return null;let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=t?`(?<![\\p{L}\\p{N}_])${r}(?![\\p{L}\\p{N}_])`:r;return new RegExp(o,e?"gu":"giu")}function ju(n,e){let t=hw(e);if(!t)return[];let r=[];return n.descendants((o,i)=>{if(r.length>=Vu)return!1;if(!o.isTextblock)return!0;let s=o.textBetween(0,o.content.size,void 0,fw);t.lastIndex=0;let l;for(;(l=t.exec(s))&&r.length<Vu;){if(l[0].length===0){t.lastIndex+=1;continue}r.push({from:i+1+l.index,to:i+1+l.index+l[0].length})}return!1}),r}function jg(n,e){if(!n.length)return-1;let t=n.findIndex(r=>r.from>=e);return t<0?0:t}function Wu(){return new z({key:Qt,state:{init:()=>qu,apply(n,e,t,r){let o=n.getMeta(Qt);if(o?.type==="clear")return qu;if(o?.type==="set"){let i=ju(r.doc,o.options);return{...o.options,matches:i,current:jg(i,r.selection.from)}}if(o?.type==="goto")return{...e,current:o.index};if(n.docChanged&&e.query){let i=ju(r.doc,e),s=e.matches[e.current]?.from,l=s===void 0?-1:jg(i,n.mapping.map(s));return{...e,matches:i,current:l}}return e}},props:{decorations(n){let e=Qt.getState(n);return e?.matches.length?ae.create(n.doc,e.matches.map((t,r)=>ge.inline(t.from,t.to,{class:r===e.current?"nova-search-match nova-search-current":"nova-search-match"}))):null}}})}function ps(n){return Qt.getState(n)??qu}function mw(n){return(e,t)=>(t?.(e.tr.setMeta(Qt,{type:"set",options:n})),!0)}var gw=(n,e)=>(e?.(n.tr.setMeta(Qt,{type:"clear"})),!0);function yw(n,e,t){return n.setMeta(Qt,{type:"goto",index:t}).setSelection(F.create(n.doc,e.from,e.to)).scrollIntoView()}function bw(n=1){return(e,t)=>{let{matches:r,current:o}=ps(e);if(!r.length)return!1;let s=o>=0&&e.selection.from===r[o].from&&e.selection.to===r[o].to||o<0?(Math.max(o,0)+n+r.length)%r.length:o;return t&&t(yw(e.tr,r[s],s)),!0}}function kw(n){return(e,t)=>{let{matches:r,current:o}=ps(e),i=r[o];if(!i)return!1;if(t){let s=e.tr,l=e.doc.resolve(i.from).marksAcross(e.doc.resolve(i.to))??[];n?s.replaceWith(i.from,i.to,e.schema.text(n,l)):s.delete(i.from,i.to);let a=s.mapping.map(i.to);t(s.setSelection(F.create(s.doc,a)).scrollIntoView())}return!0}}function vw(n){return(e,t)=>{let{matches:r}=ps(e);if(!r.length)return!1;if(t){let o=e.tr;for(let i=r.length-1;i>=0;i--){let{from:s,to:l}=r[i],a=e.doc.resolve(s).marksAcross(e.doc.resolve(l))??[];n?o.replaceWith(s,l,e.schema.text(n,a)):o.delete(s,l)}t(o.scrollIntoView())}return!0}}var Gu={};q(Gu,{formatHTML:()=>Wg,isFullscreen:()=>fs,openHelp:()=>go,openPreview:()=>Uu,openSourceCode:()=>Ju,toggleFullscreen:()=>yr});function fs(n){return n.root.classList.contains("nova-fullscreen")}function yr(n,e=!fs(n)){n.root.classList.toggle("nova-fullscreen",e),document.documentElement.classList.toggle("nova-fullscreen-lock",e),n.ui.closePopover(),n.updateUI(),n.focus()}function Uu(n,{doc:e=n.view.state.doc,title:t}={}){let{t:r}=n.ui,o=w("div",{className:"nova-prosemirror nova-preview"});o.append(qe.fromSchema(n.schema).serializeFragment(e.content)),o.querySelectorAll("a[href]").forEach(i=>{i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer")}),n.ui.openDialog({title:t??r("preview"),body:o,size:"large",cancelLabel:r("dialog.close")})}function Wg(n){return n.replace(/(<\/(p|h[1-6]|ul|ol|li|blockquote|pre|table|tbody|tr)>|<hr>)/g,`$1
34
41
  `).replace(/(<(ul|ol|table|tbody|tr|blockquote)( [^>]*)?>)/g,`$1
35
42
  `).replace(/\n{2,}/g,`
36
- `).trim()}function Fp(n){let{t:e}=n.ui,t=Cy(n.getHTML()),r=M("textarea",{className:"nova-input nova-source",spellcheck:"false","aria-label":e("sourceCode"),autocomplete:"off",rows:"18"});r.value=t,n.ui.openDialog({title:e("sourceCode"),body:r,size:"large",submitLabel:e("dialog.save"),initialFocus:r,onSubmit:()=>(r.value!==t&&n.setContent(r.value),!0)})}var Ay=[{group:"help.formatting",rows:[{label:"bold",keys:"Mod-b"},{label:"italic",keys:"Mod-i"},{label:"underline",keys:"Mod-u"},{label:"strike",keys:"Mod-Shift-x"},{label:"code",keys:"Mod-e"},{label:"superscript",keys:"Mod-."},{label:"subscript",keys:"Mod-,"},{label:"link",keys:"Mod-k"},{label:"clearFormatting",keys:"Mod-\\"}]},{group:"help.blocks",rows:[{label:"paragraph",keys:"Mod-Alt-0"},{label:"h1",keys:"Mod-Alt-1"},{label:"h2",keys:"Mod-Alt-2"},{label:"h3",keys:"Mod-Alt-3"},{label:"bulletList",keys:"Mod-Shift-8"},{label:"orderedList",keys:"Mod-Shift-7"},{label:"alignCenter",keys:"Mod-Shift-e"},{label:"indent",keys:"Mod-]"},{label:"outdent",keys:"Mod-["}]},{group:"help.editing",rows:[{label:"undo",keys:"Mod-z"},{label:"redo",keys:"Mod-Shift-z"},{label:"search.title",keys:"Mod-f"},{label:"pasteAsText",keys:"Mod-Shift-v"},{label:"fullscreen",keys:"Mod-Shift-f"},{label:"help.slash",keys:"/"}]},{group:"help.navigation",rows:[{label:"help.toMenubar",keys:"Alt-F9"},{label:"help.toToolbar",keys:"Alt-F10"},{label:"help.toContextToolbar",keys:"Ctrl-F9"},{label:"help.toEditor",keys:"Escape"},{label:"help.nextCell",keys:"Tab"},{label:"help",keys:"Alt-0"}]}];function Vo(n){let{t:e}=n.ui,t=M("div",{className:"nova-help"});for(let{group:r,rows:o}of Ay)t.append(M("section",{},M("h3",{},e(r)),M("table",{className:"nova-help-table"},M("tbody",{},o.map(({label:i,keys:s})=>M("tr",{},M("td",{},e(i)),M("td",{},M("kbd",{},s.length===1?s:tt(s)))))))));n.ui.openDialog({title:e("help"),body:t,size:"large",cancelLabel:e("dialog.close")})}var aa={};Z(aa,{HTMLSerializer:()=>Ot,escapeAttr:()=>$p,escapeText:()=>qo});var Ty=new Set(["href","xlink:href","action","formaction","cite"]),Ny=new Set(["src","poster","data","background"]),Oy=/url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;function mr(n,e){let t=n.toLowerCase();return t.startsWith("on")?null:Ty.has(t)?Oe(e)?e:null:Ny.has(t)?ce(e)?e:null:t==="srcset"?e.split(",").map(o=>o.trim().split(/\s+/)[0]??"").every(o=>ce(o))?e:null:t==="style"&&Oy.test(e)?null:e}var Dy=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),_p=new RegExp("\xA0","g");function qo(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(_p,"&nbsp;")}var Ly="\xA0";function Ry(n){let e=null,t=!0,r=n.childCount;for(let o=0;o<r;o++){let i=n.child(o);if(!i.isText){t=i.type.name==="hard_break"||!i.isInline;continue}let s=i.text??"";if(!s.includes(" ")){t=!1;continue}let l=o===r-1||!n.child(o+1).isInline,a="";for(let c=0;c<s.length;c++){let u=s[c];u!==" "?(a+=u,t=!1):t||l&&c===s.length-1?(a+=Ly,t=!1):(a+=" ",t=!0)}a!==s&&(e??(e=new Map)).set(o,a)}return e}function $p(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(_p,"&nbsp;")}var Py=/^[a-z][a-z0-9-]*$/i,Iy=new Set(["script","style","base","link","meta","object","embed","applet","frame","frameset","template","noscript"]),zp=new Set;function Hy(n){zp.has(n)||(zp.add(n),console.error(`[nova] toDOM produced <${n}>, which is not allowed in output; the tag was dropped`))}var By=/^[a-z_:][a-z0-9_.:-]*$/i;function la(n){if(typeof n=="string")return{open:"",close:"",hole:!1,html:qo(n)};if(typeof n=="number"||typeof n=="boolean")return{open:"",close:"",hole:!1,html:qo(String(n))};if(n==null)return{open:"",close:"",hole:!1,html:""};if(!Array.isArray(n))throw new Error("[nova] serializer supports only array/string toDOM specs");let[e,...t]=n,r=e.includes(" ")?e.split(" ")[1]:e;if(!Py.test(r))throw new Error(`[nova] invalid tag in toDOM: ${r}`);let o=Iy.has(r.toLowerCase());o&&Hy(r.toLowerCase());let i="",s=t,l=t[0];if(l&&typeof l=="object"&&!Array.isArray(l)){for(let[f,h]of Object.entries(l)){if(h==null)continue;let g=f.includes(" ")?f.split(" ")[1]:f;if(!By.test(g))continue;let m=mr(g,String(h));m!==null&&(i+=` ${g}="${$p(m)}"`)}s=t.slice(1)}let a=o?"":`<${r}${i}>`;if(Dy.has(r.toLowerCase()))return{open:a,close:"",hole:!1,html:a};let c="",u="",d=!1;for(let f of s){if(f===0){if(d)throw new Error("[nova] toDOM spec has more than one content hole");d=!0;continue}let h=la(f);if(d){if(h.hole)throw new Error("[nova] toDOM spec has more than one content hole");u+=h.html}else h.hole?(c+=h.open,u+=h.close,d=!0):c+=h.html}if(o)return{open:"",close:"",hole:d,html:""};let p=`</${r}>`;return{open:a+c,close:u+p,hole:d,html:a+c+u+p}}var Ot=class{constructor(){E(this,"cache",new WeakMap)}serializeFragment(e,{pre:t=!1}={}){let r=t?null:Ry(e),o="",i=[],s=[],l=a=>{for(;i.length>a;)o+=s.pop(),i.pop()};return e.forEach((a,c,u)=>{if(!a.isInline){l(0),o+=this.serializeNode(a);return}let d=0;for(;d<i.length&&d<a.marks.length&&i[d].eq(a.marks[d]);)d++;l(d);for(let p=d;p<a.marks.length;p++){let f=a.marks[p],h=this.renderMark(f,a.isText);o+=h.open,s.push(h.close),i.push(f)}o+=a.isText?qo(r?.get(u)??a.text??""):this.serializeNode(a)}),l(0),i=[],s=[],o}serializeNode(e){let t=e.type.spec.toDOM;if(!t)throw new Error(`[nova] node "${e.type.name}" has no toDOM`);let r=la(t(e));if(!r.hole)return r.html;let o=!!e.type.spec.code||e.type.spec.whitespace==="pre";return r.open+this.serializeFragment(e.content,{pre:o})+r.close}renderMark(e,t){let r=e.type.spec.toDOM;if(!r)throw new Error(`[nova] mark "${e.type.name}" has no toDOM`);let o=this.cache.get(e.type);o||this.cache.set(e.type,o=new Map);let i=JSON.stringify(e.attrs),s=o.get(i);return s||(s=la(r(e,t)),o.size>500&&o.clear(),o.set(i,s)),s}};var Fy={color:q.color,background:q.color,font_family:q.fontFamily,font_size:q.length};function ut(n,e){return(t,r)=>{let o=Y(t)[n],i=e===null?null:Fy[n](e);if(e!==null&&!i)return!1;let{empty:s}=t.selection;if(!r)return!0;let l=t.tr;if(s)l.removeStoredMark(o),i&&l.addStoredMark(o.create({value:i}));else for(let a of t.selection.ranges)l.removeMark(a.$from.pos,a.$to.pos,o),i&&l.addMark(a.$from.pos,a.$to.pos,o.create({value:i}));return r(l.scrollIntoView()),!0}}function Ye(n,e){let t=Y(n)[e],{$from:r,empty:o}=n.selection,i=o?n.storedMarks??r.marks():r.nodeAfter?.marks??r.marks(),s=t.isInSet(i);return s?s.attrs.value:null}function gr(n){return(e,t)=>{let r=n===null?null:q.lineHeight(n);if(n!==null&&!r)return!1;let{from:o,to:i}=e.selection,s=e.tr,l=!1;return e.doc.nodesBetween(o,i,(a,c)=>{(a.type===$(e).paragraph||a.type===$(e).heading)&&(l=!0,s.setNodeMarkup(c,void 0,{...a.attrs,lineHeight:r}))}),l?(t?.(s),!0):!1}}function ca(n){return n.selection.$from.parent.attrs.lineHeight??null}var Wo=["#000000","#434343","#666666","#999999","#b7b7b7","#d9d9d9","#efefef","#ffffff","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#fecaca","#fed7aa","#fef08a","#bbf7d0","#a5f3fc","#bfdbfe","#ddd6fe","#fbcfe8"];function jo(n){let t=[],r=n.current?.toLowerCase()??null,o=M("div",{className:"nova-swatches",role:"grid","aria-label":n.label}),i=null;for(let a of n.colors){let c=r===a.toLowerCase(),u=M("button",{type:"button",className:"nova-swatch",role:"gridcell","aria-label":a,"aria-selected":String(c),title:a,tabindex:"-1"},c?V(S.check):null);u.style.setProperty("--swatch",a),u.addEventListener("click",()=>n.onPick(a)),t.push(u),(!i||i.childElementCount===8)&&(i=M("div",{className:"nova-swatch-row",role:"row"}),o.append(i)),i.append(u)}(t.find(a=>a.getAttribute("aria-selected")==="true")??t[0])?.setAttribute("tabindex","0"),o.addEventListener("keydown",a=>{let c=t.indexOf(j(o));if(c<0)return;let d={ArrowRight:1,ArrowLeft:-1,ArrowDown:8,ArrowUp:-8}[Me(a,o)];if(d===void 0)return;a.preventDefault();let p=t[Math.min(t.length-1,Math.max(0,c+d))];t[c].tabIndex=-1,p.tabIndex=0,p.focus()});let s=M("button",{type:"button",className:"nova-panel-action"},V(S.clearFormatting),n.removeLabel);s.addEventListener("click",()=>n.onPick(null));let l=M("input",{type:"color",className:"nova-color-input","aria-label":n.customLabel,value:/^#[0-9a-f]{6}$/i.test(r??"")?r:"#000000"});return l.addEventListener("change",()=>n.onPick(l.value)),M("div",{className:"nova-color-panel"},o,M("div",{className:"nova-panel-footer"},s,M("label",{className:"nova-panel-action"},l,n.customLabel)))}function Vp(n){let{registry:e,t}=n.ui,r=(i,s)=>t("table.size",{rows:i,cols:s});e.addPanelButton("table",{icon:S.table,tooltip:t("table.insert"),isEnabled:i=>i.can(ct(1,1)),render:(i,s)=>Ul((l,a)=>{s(),i.exec(ct(l,a))},r,t("table.insert"))});let o=(i,s,l,a,c)=>e.addButton(i,{icon:l,tooltip:t(s),onAction:u=>u.exec(a),isEnabled:u=>u.can(a),...c?{isActive:c}:{}});o("tableinsertrowbefore","table.rowBefore",S.rowBefore,De.addRowBefore),o("tableinsertrowafter","table.rowAfter",S.rowAfter,De.addRowAfter),o("tabledeleterow","table.rowDelete",S.rowDelete,De.deleteRow),o("tableinsertcolbefore","table.colBefore",S.colBefore,De.addColumnBefore),o("tableinsertcolafter","table.colAfter",S.colAfter,De.addColumnAfter),o("tabledeletecol","table.colDelete",S.colDelete,De.deleteColumn),o("tablemergecells","table.merge",S.merge,De.mergeCells),o("tablesplitcells","table.split",S.split,De.splitCell),o("tablerowheader","table.rowHeader",S.rowHeader,De.toggleHeaderRow,i=>_l(i.view.state)),o("tablecolheader","table.colHeader",S.colHeader,De.toggleHeaderColumn,i=>$l(i.view.state)),o("tabledelete","table.delete",S.tableDelete,De.deleteTable),e.addPanelButton("tablecellbackground",{icon:S.highlight,tooltip:t("table.cellBackground"),isEnabled:i=>Et(i.view.state),render:(i,s)=>jo({colors:i.options.colors??Wo,current:null,label:t("table.cellBackground"),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:l=>{s(),i.exec(zl(l))}})}),e.addMenuButton("advtablesort",{icon:S.sort,tooltip:t("table.sort"),isEnabled:i=>i.can(Bo("asc")),items:i=>["asc","desc"].map(s=>({id:s,label:t(s==="asc"?"table.sortAsc":"table.sortDesc"),onSelect:()=>i.exec(Bo(s,i.options.language))}))}),e.addButton("tableprops",{icon:S.tableProps,tooltip:t("table.props"),isEnabled:i=>Et(i.view.state),onAction:i=>zy(i)}),e.addButton("tablecellprops",{icon:S.cellProps,tooltip:t("table.cellProps"),isEnabled:i=>Et(i.view.state),onAction:i=>_y(i)}),e.addContextToolbar("table",{label:t("table.toolbar"),predicate:i=>Et(i.view.state),anchor:i=>Kl(i),placement:"bottom-start",items:"tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort tablecellprops tableprops | tabledelete"})}function qp(n,e,t){if(!e?.length)return null;let{t:r}=n.ui,o=[{value:"",label:r("table.styleDefault")}];for(let i of e)i.value&&o.push({value:i.value,label:i.title});return t&&!o.some(i=>i.value===t)&&o.push({value:t,label:t}),qn({label:r("table.style"),value:t??"",options:o})}function zy(n){let{t:e}=n.ui,t=Vl(n.view.state);if(!t)return;let r=ee({label:e("table.width"),hint:e("table.widthHint"),value:t.width??""}),o=qn({label:e("table.align"),value:t.align??"",options:[{value:"",label:e("table.alignDefault")},{value:"center",label:e("table.alignCenter")},{value:"right",label:e("table.alignRight")}]}),i=qp(n,n.options.tableClassList,t.class??null);n.ui.openDialog({title:e("table.props"),body:M("div",{className:"nova-form"},i?.el??null,r.el,o.el),submitLabel:e("dialog.save"),onSubmit:()=>{let l={width:r.input.value.trim().replace(/^(\d+(\.\d+)?)$/,"$1px")||null,align:o.select.value||null,...i?{class:i.select.value||null}:{}};return n.exec(ql(l))||e("table.invalidWidth")}})}function _y(n){let{t:e}=n.ui,t=Wl(n.view.state);if(!t)return;let r=qn({label:e("table.valign"),value:t.valign??"",options:[{value:"",label:e("table.alignDefault")},{value:"top",label:e("table.valignTop")},{value:"middle",label:e("table.valignMiddle")},{value:"bottom",label:e("table.valignBottom")}]}),o=qn({label:e("table.cellType"),value:t.header?"th":"td",options:[{value:"td",label:e("table.cellData")},{value:"th",label:e("table.cellHeader")}]}),i=ee({label:e("table.colWidth"),hint:e("table.colWidthHint"),value:t.width?String(t.width):""}),s=qp(n,n.options.tableCellClassList,t.class??null);n.ui.openDialog({title:e("table.cellProps"),body:M("div",{className:"nova-form"},s?.el??null,r.el,o.el,i.el),submitLabel:e("dialog.save"),onSubmit:()=>{let l=i.input.value.trim(),a=l?Number(l.replace(/px$/i,"")):null;return a!==null&&!(Number.isInteger(a)&&a>=24&&a<=4e3)?e("table.invalidColWidth"):(n.exec(jl({valign:r.select.value||null,header:o.select.value==="th",width:a,...s?{class:s.select.value||null}:{}})),!0)}})}var $y=[{label:"Sans Serif",value:'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif'},{label:"Serif",value:'Georgia, "Times New Roman", serif'},{label:"Monospace",value:"ui-monospace, Menlo, Consolas, monospace"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:'"Times New Roman", Times, serif'},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Courier New",value:'"Courier New", Courier, monospace'}],Vy=["8pt","10pt","12pt","14pt","16pt","18pt","24pt","36pt","48pt"],qy=["1","1.15","1.5","2","2.5","3"],Ve={undo:"Mod-z",redo:"Mod-Shift-z",bold:"Mod-b",italic:"Mod-i",underline:"Mod-u",strike:"Mod-Shift-x",code:"Mod-e",subscript:"Mod-,",superscript:"Mod-.",bulletList:"Mod-Shift-8",orderedList:"Mod-Shift-7",alignLeft:"Mod-Shift-l",alignCenter:"Mod-Shift-e",alignRight:"Mod-Shift-r",alignJustify:"Mod-Shift-j",indent:"Mod-]",outdent:"Mod-[",clearFormatting:"Mod-\\",paragraph:"Mod-Alt-0",h1:"Mod-Alt-1",h2:"Mod-Alt-2",h3:"Mod-Alt-3",h4:"Mod-Alt-4",h5:"Mod-Alt-5",h6:"Mod-Alt-6"};function Wp(n){try{let{node:e}=n.view.domAtPos(n.view.state.selection.from),t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return t?getComputedStyle(t):null}catch{return null}}var Wy={"system-ui":"Sans Serif","-apple-system":"Sans Serif","sans-serif":"Sans Serif",serif:"Serif",monospace:"Monospace","ui-monospace":"Monospace"};function jp(n){let e=String(n).split(",")[0].trim().replace(/["']/g,"");return Wy[e.toLowerCase()]??e}function jy(n){let e=parseFloat(n);return!Number.isFinite(e)||e<=0?null:`${Math.round(e*.75*2)/2}pt`}var Kp=(n,e)=>typeof n=="string"&&n.replace(/["'\s]/g,"").toLowerCase()===e.replace(/["'\s]/g,"").toLowerCase();function Up(n){let{registry:e,t}=n.ui,r=()=>n.view.state,o=(v,x,C,B)=>e.addButton(v,{icon:C,tooltip:t(x),...Ve[x]?{shortcut:Ve[x]}:{},onAction:Q=>Q.exec(x),isEnabled:Q=>Q.can(x),...B?{isActive:B}:{}}),i=(v,x,C,B)=>o(v,x,B,()=>xn(r(),n.schema.marks[C]));o("undo","undo",S.undo),o("redo","redo",S.redo),i("bold","bold","bold",S.bold),i("italic","italic","italic",S.italic),i("underline","underline","underline",S.underline),i("strikethrough","strike","strike",S.strike),i("inlinecode","code","code",S.code),i("subscript","subscript","subscript",S.subscript),i("superscript","superscript","superscript",S.superscript),o("bullist","bulletList",S.bulletList,()=>Be(r(),n.schema.nodes.bullet_list)),o("numlist","orderedList",S.orderedList,()=>Be(r(),n.schema.nodes.ordered_list)),o("indent","indent",S.indent),o("outdent","outdent",S.outdent),o("blockquote","blockquote",S.blockquote,()=>Be(r(),n.schema.nodes.blockquote)),o("codeblock","codeBlock",S.codeBlock,()=>Be(r(),n.schema.nodes.code_block)),o("hr","horizontalRule",S.horizontalRule),o("removeformat","clearFormatting",S.clearFormatting);let s=[["alignLeft","left",S.alignLeft],["alignCenter","center",S.alignCenter],["alignRight","right",S.alignRight],["alignJustify","justify",S.alignJustify]];for(let[v,x,C]of s)o(v.toLowerCase(),v,C,()=>Nt(r())===x);e.addMenuButton("align",{icon:S.alignLeft,tooltip:t("align"),isEnabled:v=>v.can("alignLeft"),items:v=>s.map(([x,C,B])=>({id:x,label:t(x),icon:B,...Ve[x]?{shortcut:Ve[x]}:{},active:Nt(v.view.state)===C,onSelect:()=>v.exec(x)}))});let l=[{command:"paragraph",style:""},{command:"h1",style:"font-size: 1.6em; font-weight: 700"},{command:"h2",style:"font-size: 1.35em; font-weight: 700"},{command:"h3",style:"font-size: 1.15em; font-weight: 700"},{command:"h4",style:"font-size: 1em; font-weight: 700"},{command:"h5",style:"font-size: 0.9em; font-weight: 700"},{command:"h6",style:"font-size: 0.85em; font-weight: 700"},{command:"codeBlock",style:"font-family: ui-monospace, monospace"}],a=()=>{let v=r().selection.$from.parent;return v.type===n.schema.nodes.heading?`h${v.attrs.level}`:v.type===n.schema.nodes.code_block?"codeBlock":"paragraph"};for(let v=1;v<=6;v++){let x=`h${v}`;e.addToggleButton(x,{...v<=3?{icon:S[`h${v}`]}:{text:`H${v}`},tooltip:t(x),...Ve[x]?{shortcut:Ve[x]}:{},isActive:()=>a()===x,isEnabled:C=>C.can(x)||a()===x,onAction:C=>C.exec(a()===x?"paragraph":x)})}let c={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",pre:"codeBlock"},u=()=>{let v=n.options.blockFormats;return v?.length?v.flatMap(({label:x,block:C})=>{let B=c[C],Q=l.find(he=>he.command===B);return Q?[{...Q,label:x}]:[]}):l};e.addMenuButton("blocks",{tooltip:t("blocks"),label:()=>u().find(v=>v.command===a())?.label??t(a()),minChars:11,isEnabled:v=>u().some(({command:x})=>v.can(x)),items:v=>u().filter(({command:x})=>v.isAllowed(x)).map(({command:x,style:C,label:B})=>({id:x,label:B??t(x),labelStyle:C,...Ve[x]?{shortcut:Ve[x]}:{},active:a()===x,onSelect:()=>v.exec(x)}))});let d="p,h1,h2,h3,h4,h5,h6",p=()=>[{title:t("styles.headings"),items:[1,2,3,4,5,6].map(v=>({title:t(`h${v}`),block:`h${v}`}))},{title:t("styles.inline"),items:[{title:t("bold"),inline:"strong"},{title:t("italic"),inline:"em"},{title:t("underline"),inline:"u"},{title:t("strike"),inline:"s"},{title:t("superscript"),inline:"sup"},{title:t("subscript"),inline:"sub"},{title:t("code"),inline:"code"}]},{title:t("styles.blocks"),items:[{title:t("paragraph"),block:"p"},{title:t("blockquote"),block:"blockquote"},{title:t("codeBlock"),block:"pre"}]},{title:t("styles.align"),items:["left","center","right","justify"].map(v=>({title:t(`align${v==="justify"?"Justify":v[0].toUpperCase()+v.slice(1)}`),selector:d,styles:{"text-align":v}}))}],f=v=>v.format??v,h=v=>{let x=v.format?n.formatter.get(v.format)?.[0]:v,C=[],B=x?.block;B&&/^h[1-6]$/.test(B)&&C.push("font-weight: 700"),(x?.inline==="strong"||x?.inline==="b")&&C.push("font-weight: 700"),(x?.inline==="em"||x?.inline==="i")&&C.push("font-style: italic"),x?.inline==="u"&&C.push("text-decoration: underline"),(x?.inline==="s"||x?.inline==="strike"||x?.inline==="del")&&C.push("text-decoration: line-through"),(x?.inline==="code"||B==="pre")&&C.push("font-family: ui-monospace, monospace");for(let Q of["color","background-color","font-family"]){let he=x?.styles?.[Q];he&&/^[#\w\s,'"().%-]+$/.test(he)&&C.push(`${Q}: ${he}`)}return C.join("; ")},g=v=>v.flatMap(x=>x.items?g(x.items):[x]),m=()=>{let v=n.options.styleFormats;return v?n.options.styleFormatsMerge?[...p(),...v]:v:p()};e.addMenuButton("styles",{tooltip:t("styles"),minChars:10,label:v=>g(m()).find(x=>v.formatter.match(f(x)))?.title??t("styles"),items:v=>{let x=[],C=(B,Q)=>{B.forEach((he,wr)=>{if(he.items){x.length&&x.push({type:"separator"}),x.push({type:"heading",label:he.title}),C(he.items,`${Q}${wr}-`);return}x.push({id:`style-${Q}${wr}`,label:he.title,labelStyle:h(he),active:v.formatter.match(f(he)),disabled:!v.formatter.canApply(f(he)),onSelect:()=>v.formatter.toggle(f(he))})})};return C(m(),""),x}});let b=n.options.fontFamilies??$y;e.addMenuButton("fontfamily",{tooltip:t("fontFamily"),minChars:9,label:v=>{let x=Ye(r(),"font_family");if(x)return b.find(B=>Kp(x,B.value))?.label??jp(x);let C=Wp(v)?.fontFamily;return C?jp(C):t("fontFamily")},items:v=>{let x=Ye(v.view.state,"font_family");return[{id:"default",label:t("default"),active:x===null,onSelect:()=>v.exec(ut("font_family",null))},{type:"separator"},...b.map(C=>({id:C.label,label:C.label,labelStyle:`font-family: ${C.value}`,active:Kp(x,C.value),onSelect:()=>v.exec(ut("font_family",C.value))}))]}});let k=n.options.fontSizes??Vy;e.addMenuButton("fontsize",{tooltip:t("fontSize"),minChars:4,label:v=>Ye(r(),"font_size")??jy(Wp(v)?.fontSize??"")??"\u2014",items:v=>{let x=Ye(v.view.state,"font_size");return[{id:"default",label:t("default"),active:x===null,onSelect:()=>v.exec(ut("font_size",null))},{type:"separator"},...k.map(C=>({id:C,label:C,active:x===C,onSelect:()=>v.exec(ut("font_size",C))}))]}});let y=n.options.lineHeights??qy;e.addMenuButton("lineheight",{icon:S.lineHeight,tooltip:t("lineHeight"),isEnabled:v=>v.can(gr(null)),items:v=>{let x=ca(v.view.state);return[{id:"default",label:t("default"),active:x===null,onSelect:()=>v.exec(gr(null))},...y.map(C=>({id:C,label:C,active:x===C,onSelect:()=>v.exec(gr(C))}))]}});let w=(v,x,C,B)=>e.addPanelButton(v,{icon:C,tooltip:t(B),indicator:()=>Ye(r(),x),render:(Q,he)=>jo({colors:Q.options.colors??Wo,current:Ye(Q.view.state,x),label:t(B),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:wr=>{he(),Q.exec(ut(x,wr))}})});w("forecolor","color",S.textColor,"textColor"),w("backcolor","background",S.highlight,"backgroundColor");let N=[["superscript","superscript",S.superscript],["subscript","subscript",S.subscript],["code","code",S.code]];e.addMenuButton("moreformats",{icon:S.formatMore,tooltip:t("moreFormats"),isActive:v=>N.some(([,x])=>xn(v.view.state,n.schema.marks[x])),items:v=>[...N.filter(([x])=>v.isAllowed(x)).map(([x,C,B])=>({id:x,label:t(x),icon:B,checkbox:!0,active:xn(v.view.state,n.schema.marks[C]),disabled:!v.can(x),...Ve[x]?{shortcut:Ve[x]}:{},onSelect:()=>v.exec(x)})),{type:"separator"},{id:"clearFormatting",label:t("clearFormatting"),icon:S.clearFormatting,disabled:!v.can("clearFormatting"),shortcut:Ve.clearFormatting,onSelect:()=>v.exec("clearFormatting")},{id:"pasteAsText",label:t("pasteAsText"),icon:S.pasteText,checkbox:!0,active:v.isPasteAsText(),onSelect:()=>{v.setPasteAsText(!v.isPasteAsText()),v.focus()}}]}),e.addToggleButton("pastetext",{icon:S.pasteText,tooltip:t("pasteAsText"),isActive:v=>v.isPasteAsText(),onAction:v=>{v.setPasteAsText(!v.isPasteAsText()),v.focus()}}),e.addButton("link",{icon:S.link,tooltip:t("link"),shortcut:"Mod-k",onAction:v=>at(v),isActive:()=>!!Kt(r())}),e.addButton("unlink",{icon:S.unlink,tooltip:t("unlink"),onAction:v=>v.exec(wn()),isEnabled:v=>v.can(wn())}),e.addButton("image",{icon:S.image,tooltip:t("image"),onAction:v=>cr(v)});let L=()=>ze(r())?.attrs.align??null,R=(v,x,C,B)=>e.addToggleButton(v,{icon:C,tooltip:t(B),isActive:()=>L()===x,onAction:Q=>Q.exec(Sn({align:L()===x?null:x}))});R("imagealignleft","left",S.imageLeft,"image.alignLeft"),R("imagealigncenter","center",S.imageCenter,"image.alignCenter"),R("imagealignright","right",S.imageRight,"image.alignRight");let O=[["image.sizeSmall",.25],["image.sizeMedium",.5],["image.sizeLarge",.75],["image.sizeFull",1],["image.sizeOriginal",null]];e.addMenuButton("imagesize",{icon:S.resize,tooltip:t("image.size"),items:v=>O.map(([x,C])=>({id:x,label:t(x),onSelect:()=>Ml(v,C)}))}),e.addButton("imagealt",{icon:S.altText,tooltip:t("image.editAlt"),onAction:v=>xl(v)}),e.addToggleButton("imagecaption",{icon:S.imageCaption,tooltip:t("image.caption"),isActive:v=>yl(v.view.state),onAction:v=>v.exec(vl)}),e.addButton("imagedelete",{icon:S.trash,tooltip:t("image.delete"),onAction:v=>v.exec((x,C)=>{let B=ze(x);return B?(C?.(x.tr.delete(B.pos,B.pos+B.node.nodeSize).scrollIntoView()),!0):!1})}),Vp(n),e.addButton("searchreplace",{icon:S.search,tooltip:t("search.title"),shortcut:"Mod-f",onAction:v=>v.openSearch()}),e.addToggleButton("fullscreen",{icon:S.fullscreen,tooltip:t("fullscreen"),shortcut:"Mod-Shift-f",isActive:v=>sa(v),onAction:v=>hr(v)}),e.addButton("preview",{icon:S.preview,tooltip:t("preview"),onAction:v=>Bp(v)}),e.addButton("code",{icon:S.sourceCode,tooltip:t("sourceCode"),onAction:v=>Fp(v)}),e.addButton("help",{icon:S.help,tooltip:t("help"),shortcut:"Alt-0",onAction:v=>Vo(v)}),e.addContextToolbar("image",{label:t("image.toolbar"),predicate:v=>!!ze(v.view.state),items:"imagealignleft imagealigncenter imagealignright | imagesize imagealt imagecaption | imagedelete",anchor:v=>{let x=ze(v.view.state);return(x?v.view.nodeDOM(x.pos):null)?.getBoundingClientRect()??null}})}var Ko=6,Uo=8;function dt(n,e,t){let r=window.innerWidth,o=window.innerHeight,i=n.offsetWidth,s=n.offsetHeight,l=o-e.bottom,a=e.top,u=t==="top-start"?a>=s+Ko||a>l:l<s+Ko&&a>l,d=u?e.top-s-Ko:e.bottom+Ko,p=rn(n),h=t==="bottom"?e.left+e.width/2-i/2:t==="bottom-end"!==p?e.right-i:e.left;h=Math.max(Uo,Math.min(h,r-i-Uo)),d=Math.max(Uo,Math.min(d,o-s-Uo)),n.style.left=`${Math.round(h)}px`,n.style.top=`${Math.round(d)}px`,n.dataset.side=u?"top":"bottom"}var br=[],An=class{constructor(e){E(this,"el");E(this,"options");E(this,"closed",!1);E(this,"unlisten",[]);E(this,"reposition",()=>{if(this.closed)return;let{anchor:e,placement:t="bottom-start"}=this.options,r=typeof e=="function"?e():e.getBoundingClientRect();dt(this.el,r,t)});E(this,"focusWasInside",!1);E(this,"onKeyDown",(e,t)=>{e.key!=="Escape"||e.defaultPrevented||br[br.length-1]===this&&(t?.closest?.(".nova-dialog")||(e.preventDefault(),e.stopPropagation(),this.focusWasInside=this.el.contains(j(this.el)),this.close("escape")))});E(this,"onPointerDown",(e,t)=>{this.options.dismissOnOutside!==!1&&(this.el.contains(t)||this.options.ignore?.some(r=>r.contains(t))||this.close("outside"))});this.options=e,this.el=document.createElement("div"),this.el.className=`nova-popover ${e.className??""}`.trim(),this.el.append(e.content),e.host.append(this.el),this.reposition(),this.unlisten=[yt(this.el,"keydown",this.onKeyDown),yt(this.el,"pointerdown",this.onPointerDown)],br.push(this),window.addEventListener("resize",this.reposition),window.addEventListener("scroll",this.reposition,!0)}get isOpen(){return!this.closed}close(e="api"){this.closed||(this.closed=!0,br.splice(br.indexOf(this),1),this.unlisten.forEach(t=>t()),window.removeEventListener("resize",this.reposition),window.removeEventListener("scroll",this.reposition,!0),this.el.remove(),this.options.onClose?.(e))}};function Jp(n){return new z({key:new K("nova-link-bubble"),view(e){let{t}=n.ui,r=M("a",{className:"nova-bubble-link",target:"_blank",rel:"noopener noreferrer"}),o=(c,u,d)=>{let p=M("button",{type:"button",className:"nova-btn","aria-label":u,"data-tooltip":u},V(c));return p.addEventListener("click",d),n.ui.tooltip.attach(p),p},i=M("div",{className:"nova-bubble",role:"toolbar","aria-label":t("link"),hidden:!0},V(S.externalLink),r,M("span",{className:"nova-bubble-sep"}),o(S.edit,t("link.edit"),()=>at(n)),o(S.copy,t("link.copy"),()=>{navigator.clipboard?.writeText(r.href).then(()=>n.ui.notify({text:t("link.copied"),type:"success",timeout:2e3}))}),o(S.unlink,t("unlink"),()=>n.exec(wn())));i.addEventListener("mousedown",c=>{c.target.closest("button")&&c.preventDefault()}),n.ui.overlayHost.append(i);let s=()=>{i.hidden=!0},l=()=>{let c=e.state,u=Kt(c),d=e.hasFocus()||i.contains(j(i));if(!u||!d||!n.isEditable()||n.ui.activeDialog||!c.selection.empty){s();return}let p=Ut(c,Y(c).link,c.selection.from);if(!p)return s();r.textContent=u.href,r.title=u.href,Oe(u.href)?r.setAttribute("href",u.href):r.removeAttribute("href"),i.hidden=!1;let f=e.coordsAtPos(p.from),h=e.coordsAtPos(p.to),g=new DOMRect(f.left,f.top,Math.max(1,h.right-f.left),h.bottom-f.top);dt(i,g,"bottom-start")},a=c=>{i.contains(c.relatedTarget)||s()};return e.dom.addEventListener("blur",a),i.addEventListener("focusout",c=>{!i.contains(c.relatedTarget)&&!e.hasFocus()&&s()}),{update:l,destroy(){e.dom.removeEventListener("blur",a),i.remove()}}}})}var ua="undo redo | blocks | bold italic underline strikethrough moreformats | forecolor backcolor | link image table | bullist numlist | align lineheight outdent indent | fontfamily fontsize | blockquote codeblock hr | removeformat | searchreplace preview code fullscreen help";function da(n){let e=Array.isArray(n)?n:n.split(/\s+/),t=[[]];for(let r of e){let o=r.trim();o&&(o==="|"?t.push([]):t[t.length-1].push(o))}return t.filter(r=>r.length>0)}function pa(n,e,t,r,{warnUnknown:o=!0}={}){let{ui:i}=n,s=i.t,l=new AbortController,{signal:a}=l;e.className=`nova-toolbar nova-toolbar-${r}`,e.setAttribute("role","toolbar"),e.setAttribute("aria-label",s("toolbar.label"));let c=[],u=[];for(let O of da(t)){let v=M("div",{className:"nova-tb-group",role:"group"});for(let x of O){if(!n.isAllowed(x))continue;let C=i.registry.get(x);if(!C){o&&console.warn(`[nova] Unknown toolbar item "${x}"`);continue}let B=yr(n,x,C);c.push(B),v.append(B.el)}v.childElementCount&&(u.push(v),e.append(v))}let d=M("div",{className:"nova-toolbar nova-tb-overflow",role:"group"}),p=M("button",{type:"button",className:"nova-btn nova-tb-more","aria-label":s("more"),"aria-haspopup":"true","aria-expanded":"false","data-tooltip":s("more"),hidden:!0},V(S.more));i.tooltip.attach(p);let f=null,h=()=>{f?.close(),f=null},g=i.onDialogOpen(h);p.addEventListener("click",O=>{if(f)return h();p.setAttribute("aria-expanded","true");let v=new An({host:i.overlayHost,anchor:p,placement:"bottom-end",content:d,className:"nova-tb-overflow-popover",ignore:[i.overlayHost,p],onClose:x=>{f=null,p.setAttribute("aria-expanded","false"),x==="escape"&&v.focusWasInside&&p.focus()}});f=v,O.detail===0&&d.querySelector("button:not(:disabled)")?.focus()}),r==="sliding"&&e.append(p);let m=()=>{if(r!=="sliding")return;for(let v of u)e.insertBefore(v,p);if(p.hidden=!0,e.scrollWidth<=e.clientWidth+1){h();return}p.hidden=!1;let O=u.length;for(;O>1&&e.scrollWidth>e.clientWidth+1;)O-=1,d.prepend(u[O]);d.childElementCount||(p.hidden=!0),f?.reposition(),N()},b=-1,k=typeof ResizeObserver<"u"&&r==="sliding"?new ResizeObserver(()=>{e.clientWidth!==b&&(b=e.clientWidth,m())}):null;k?.observe(e);let y=()=>[...e.querySelectorAll("button")].filter(O=>!O.disabled&&!O.hidden),w=null,N=()=>{let O=y();(!w||!O.includes(w))&&(w=O[0]??null);for(let v of e.querySelectorAll("button"))v.tabIndex=v===w?0:-1};e.addEventListener("focusin",O=>{let v=O.target;v instanceof HTMLButtonElement&&e.contains(v)&&(w=v,N())},{signal:a}),e.addEventListener("keydown",O=>{let v=y(),x=v.indexOf(j(e));if(x<0)return;let C=null,B=Me(O,e);if(B==="ArrowRight")C=x+1;else if(B==="ArrowLeft")C=x-1;else if(O.key==="Home")C=0;else if(O.key==="End")C=v.length-1;else if(O.key==="Escape"){O.preventDefault(),n.focus();return}C!==null&&(O.preventDefault(),v[(C+v.length)%v.length].focus())},{signal:a});let L=O=>{O.target.closest("button")&&O.preventDefault()};e.addEventListener("mousedown",L,{signal:a}),d.addEventListener("mousedown",L),d.addEventListener("keydown",O=>{if(O.key==="Escape")return;let v=[...d.querySelectorAll("button")].filter(B=>!B.disabled),x=v.indexOf(j(d));if(x<0)return;let C=Me(O,d);C==="ArrowRight"||C==="ArrowDown"?(O.preventDefault(),v[(x+1)%v.length].focus()):(C==="ArrowLeft"||C==="ArrowUp")&&(O.preventDefault(),v[(x-1+v.length)%v.length].focus())});let R=()=>{for(let O of c)O.update();N()};return R(),m(),{update:R,focus:()=>{N(),w?.focus()},destroy:()=>{k?.disconnect(),g(),h(),l.abort(),e.replaceChildren()}}}function yr(n,e,t){if(t.type==="split")return Ky(n,e,t);let{ui:r}=n,o=M("button",{type:"button",className:`nova-btn nova-tb-${t.type}`,"aria-label":t.tooltip,"data-tooltip":t.tooltip,"data-control":e,...t.shortcut?{"data-shortcut":t.shortcut}:{}});r.tooltip.attach(o),t.icon&&o.append(V(t.icon));let i=t.type==="menu"&&(t.label||t.text)?M("span",{className:"nova-tb-label"}):null;i?(t.type==="menu"&&t.minChars&&(i.style.minWidth=`${t.minChars}ch`),o.append(i),o.classList.add("nova-tb-has-label")):!t.icon&&t.text&&o.append(t.text);let s=null;return t.type==="panel"&&t.indicator&&(s=M("span",{className:"nova-color-bar"}),o.append(s)),t.type!=="button"&&(o.setAttribute("aria-haspopup",t.type==="menu"?"menu":"dialog"),o.setAttribute("aria-expanded","false"),o.append(V(S.chevronDown)),o.lastElementChild?.classList.add("nova-chevron")),o.addEventListener("click",a=>{if(t.type==="button"){t.onAction(n);return}if(o.getAttribute("aria-expanded")==="true"){r.closePopover();return}let c=a.detail===0,u=()=>r.closePopover(),d=t.type==="menu"?zo(t.items(n),u,t.tooltip):t.render(n,u);o.setAttribute("aria-expanded","true");let p=r.openPopover({anchor:o,content:d,ignore:[o],className:t.type==="menu"?"nova-popover-menu":"nova-popover-panel",onClose:f=>{o.setAttribute("aria-expanded","false"),f==="escape"&&p.focusWasInside&&o.focus()}});t.type==="menu"?_o(d):c&&d.querySelector("button, input")?.focus()}),t.type!=="button"&&o.addEventListener("keydown",a=>{a.key==="ArrowDown"&&o.getAttribute("aria-expanded")!=="true"&&(a.preventDefault(),o.click())}),{el:o,update:()=>{let a=n.isEditable();if(o.disabled=!a||(t.isEnabled?!t.isEnabled(n):!1),t.isActive){let c=t.isActive(n);o.classList.toggle("is-active",c),t.type==="button"&&o.setAttribute("aria-pressed",String(c))}if(i&&t.type==="menu"){let c=t.label?.(n)??t.text??"";i.textContent=c,o.setAttribute("aria-label",c&&c!==t.tooltip?`${c}, ${t.tooltip}`:t.tooltip??c)}if(s&&t.type==="panel"&&t.indicator){let c=t.indicator(n);s.style.background=c??"",s.classList.toggle("is-empty",!c)}}}}function Ky(n,e,t){let r=yr(n,e,{type:"button",tooltip:t.tooltip,onAction:t.onAction,...t.icon?{icon:t.icon}:{},...t.text?{text:t.text}:{},...t.shortcut?{shortcut:t.shortcut}:{},...t.isActive?{isActive:t.isActive}:{},...t.isEnabled?{isEnabled:t.isEnabled}:{}}),o=yr(n,`${e}-options`,{type:"menu",tooltip:`${t.tooltip}: ${n.ui.t("toolbar.options")}`,items:t.items,...t.isEnabled?{isEnabled:t.isEnabled}:{}});return o.el.classList.add("nova-tb-split-more"),{el:M("span",{className:"nova-tb-split"},r.el,o.el),update:()=>{r.update(),o.update()}}}function Gp(n){return new z({key:new K("nova-context-toolbar"),view(e){let t=M("div",{className:"nova-bubble nova-context-toolbar",role:"toolbar",hidden:!0});n.ui.overlayHost.append(t);let r=new Map,o=null,i=(m,b)=>{let k=r.get(m);if(k)return k;let y=M("div",{className:"nova-context-items"}),w=[];return da(b.items).forEach((N,L)=>{L>0&&y.append(M("span",{className:"nova-bubble-sep",role:"separator"}));for(let R of N){if(!n.isAllowed(R))continue;let O=n.ui.registry.get(R);if(!O)continue;let v=yr(n,R,O);w.push(v),y.append(v.el)}}),k={el:y,controls:w},r.set(m,k),k},s=()=>{t.hidden=!0,o=null},l=m=>{let{selection:b}=e.state;if((m.position??"node")==="node"&&b instanceof P)return e.nodeDOM(b.from)?.getBoundingClientRect()??null;let k=e.coordsAtPos(b.from),y=e.coordsAtPos(b.to);return new DOMRect(k.left,k.top,Math.max(1,y.right-k.left),y.bottom-k.top)},a=!1,c=m=>{m.pointerType==="mouse"&&m.button===0&&(a=!0)},u=()=>{a&&(a=!1,setTimeout(()=>f(e),0))};e.dom.addEventListener("pointerdown",c);let d=yt(t,"pointerup",u),p=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,f=m=>{if(!(m.hasFocus()||t.contains(j(t)))||!n.isEditable()||n.ui.activeDialog||a)return s();let k=n.ui.registry.getContextToolbars().find(([,O])=>O.predicate(n));if(!k)return s();let[y,w]=k,N=i(y,w);o!==y&&(t.replaceChildren(N.el),t.setAttribute("aria-label",w.label),o=y);for(let O of N.controls)O.update();let L=w.anchor?w.anchor(n):l(w);if(!L)return s();t.hidden=!1;let R=w.placement??(w.position==="selection"?"bottom-start":"top-start");p&&w.position==="selection"&&(R="bottom-start"),dt(t,L,R)};t.addEventListener("mousedown",m=>{m.target.closest("button")&&m.preventDefault()}),t.addEventListener("keydown",m=>{let b=[...t.querySelectorAll("button:not(:disabled)")],k=b.indexOf(j(t));if(m.key==="Escape")m.preventDefault(),n.focus();else if(k>=0&&(m.key==="ArrowRight"||m.key==="ArrowLeft")){m.preventDefault();let y=Me(m,t)==="ArrowRight"?1:-1;b[(k+y+b.length)%b.length].focus()}});let h=m=>{let b=m.relatedTarget;!t.contains(b)&&!n.ui.overlayHost.contains(b)&&s()};e.dom.addEventListener("blur",h),t.addEventListener("focusout",m=>{let b=m.relatedTarget;!t.contains(b)&&!e.hasFocus()&&!n.ui.overlayHost.contains(b)&&s()});let g=()=>{t.hidden||f(e)};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),{update:f,destroy(){e.dom.removeEventListener("blur",h),e.dom.removeEventListener("pointerdown",c),d(),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),t.remove()}}}})}function Yp(n){let e=n.ui.overlayHost.querySelector(".nova-context-toolbar:not([hidden]) button:not(:disabled)");return e?.focus(),!!e}var Xp=24,Jo=class{constructor(e,t,r,o){E(this,"view",t);E(this,"getPos",r);E(this,"editor",o);E(this,"dom");E(this,"img");E(this,"node");E(this,"resizing",!1);this.node=e,this.dom=document.createElement("span"),this.dom.className="nova-image",this.img=document.createElement("img"),this.img.draggable=!1,this.dom.append(this.img);for(let i of["nw","ne","sw","se"]){let s=document.createElement("span");s.className=`nova-image-handle nova-image-handle-${i}`,s.dataset.corner=i,s.addEventListener("pointerdown",l=>this.startResize(l,i)),this.dom.append(s)}this.render()}render(){let{src:e,alt:t,title:r,width:o,height:i,align:s}=this.node.attrs,l=ce(e)?e:"";this.img.getAttribute("src")!==l&&this.img.setAttribute("src",l),this.setAttr("alt",t),this.setAttr("title",r),this.setAttr("class",He(this.node.attrs.class).class??null);let a=ne(o),c=ne(i);this.img.style.width=a?`${a}px`:"",this.img.style.aspectRatio=a&&c?`${a} / ${c}`:"",this.dom.dataset.align=s??""}setAttr(e,t){t?this.img.setAttribute(e,t):this.img.removeAttribute(e)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.resizing||this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return e.target.classList?.contains("nova-image-handle")??!1}ignoreMutation(){return!0}startResize(e,t){if(!this.editor.isEditable())return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r.setPointerCapture(e.pointerId);let o=this.img.getBoundingClientRect(),i=e.clientX,s=o.width,l=o.width>0?o.height/o.width:this.img.naturalHeight/(this.img.naturalWidth||1),a=Math.max(Xp,this.view.dom.clientWidth-40),c=t==="ne"||t==="se"?1:-1,u=s;this.resizing=!0,this.dom.classList.add("is-resizing");let d=f=>{u=Math.round(Math.min(a,Math.max(Xp,s+c*(f.clientX-i)))),this.img.style.width=`${u}px`,this.dom.dataset.size=`${u} \xD7 ${Math.round(u*l)}`},p=()=>{r.removeEventListener("pointermove",d),r.removeEventListener("pointerup",p),r.removeEventListener("pointercancel",p),this.resizing=!1,this.dom.classList.remove("is-resizing"),delete this.dom.dataset.size;let f=this.getPos();if(f===void 0||Math.abs(u-s)<1)return this.render();let h=this.view.state.tr.setNodeMarkup(f,void 0,{...this.node.attrs,width:u,height:Math.round(u*l)});h.setSelection(P.create(h.doc,f)),this.view.dispatch(h)};r.addEventListener("pointermove",d),r.addEventListener("pointerup",p),r.addEventListener("pointercancel",p)}};var Uy=30;function Jy(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gy(n,e){let{selection:t}=n.state;if(!t.empty)return null;let r=t.$from;if(!r.parent.isTextblock||r.parent.type.spec.code)return null;let o=r.parent.textBetween(Math.max(0,r.parentOffset-Uy-1),r.parentOffset,"\0","\0");for(let[i,s]of e.ui.registry.getAutocompleters()){let l=new RegExp(`(?:^|\\s)${Jy(s.trigger)}([\\p{L}\\p{N}_-]*)$`,"u"),a=o.match(l);if(!a)continue;let c=a[1]??"";if(c.length<(s.minChars??0))continue;let u=r.parentOffset-c.length-s.trigger.length,d=u>0?r.parent.textBetween(u-1,u,"\0","\0"):"";if(!(d&&!/\s/.test(d)))return{name:i,spec:s,from:r.pos-c.length-s.trigger.length,to:r.pos,query:c}}return null}function Qp(n){let e,t=[],r=0,o=null,i=null,s=0,l=Te("nova-ac"),a=()=>!e.hidden,c=h=>{e.hidden=!0,o=null,t=[],h.dom.removeAttribute("aria-activedescendant"),h.dom.removeAttribute("aria-controls"),h.dom.removeAttribute("aria-expanded")},u=(h,g)=>{let m=t[g];if(!m||!o)return;let{spec:b,from:k,to:y}=o;c(h),b.onSelect(m,{from:k,to:y},n)},d=h=>{if(!o)return;let{spec:g}=o;if(e.replaceChildren(),e.setAttribute("aria-label",g.label),!t.length){if(!g.emptyText)return c(h);e.append(M("div",{className:"nova-ac-empty"},g.emptyText))}t.forEach((b,k)=>{let y=M("div",{id:`${l}-${k}`,className:"nova-menu-item nova-ac-item",role:"option","aria-selected":String(k===r)},b.icon?V(b.icon):null,M("span",{className:"nova-menu-label"},b.label),b.shortcut?M("kbd",{className:"nova-menu-shortcut"},tt(b.shortcut)):b.detail?M("span",{className:"nova-menu-shortcut"},b.detail):null);y.addEventListener("mousedown",w=>{w.preventDefault(),u(h,k)}),y.addEventListener("mousemove",()=>{r!==k&&p(h,k)}),e.append(y)}),e.hidden=!1,h.dom.setAttribute("aria-controls",l),p(h,Math.min(r,Math.max(0,t.length-1)));let m=h.coordsAtPos(o.from);dt(e,new DOMRect(m.left,m.top,1,m.bottom-m.top),"bottom-start")},p=(h,g)=>{r=g,e.querySelectorAll('[role="option"]').forEach((b,k)=>b.setAttribute("aria-selected",String(k===g)));let m=e.querySelector(`#${l}-${g}`);m&&(h.dom.setAttribute("aria-activedescendant",m.id),m.scrollIntoView?.({block:"nearest"}))},f=h=>{let g=n.isEditable()&&h.hasFocus()?Gy(h,n):null;if(!g||g.from===i){g||(i=null),(a()||o)&&c(h);return}let m=!o||o.query!==g.query||o.from!==g.from;if(o=g,!m&&a())return d(h);let b=++s;Promise.resolve(g.spec.fetch(g.query,n)).then(k=>{b!==s||!o||(t=k.slice(0,g.spec.maxResults??10),r=0,d(h))})};return new z({key:new K("nova-autocompleter"),view(h){e=M("div",{className:"nova-popover nova-ac",id:l,role:"listbox",hidden:!0}),n.ui.overlayHost.append(e),h.dom.setAttribute("aria-autocomplete","list");let g=()=>c(h);return h.dom.addEventListener("blur",g),{update:m=>f(m),destroy(){h.dom.removeEventListener("blur",g),e.remove()}}},props:{handleKeyDown(h,g){if(!a()||!o)return!1;let m=t.length;switch(g.key){case"ArrowDown":return m&&p(h,(r+1)%m),!0;case"ArrowUp":return m&&p(h,(r-1+m)%m),!0;case"Enter":case"Tab":return m?(u(h,r),!0):!1;case"Escape":return i=o.from,c(h),!0;default:return!1}}}})}var pt=n=>e=>e.exec(n),Yy=[{name:"paragraph",label:"paragraph",icon:S.paragraph,keywords:["text","p","paragraph"],run:pt("paragraph")},{name:"h1",label:"h1",icon:S.h1,keywords:["h1","heading","title"],shortcut:"Mod-Alt-1",run:pt("h1")},{name:"h2",label:"h2",icon:S.h2,keywords:["h2","heading","subtitle"],shortcut:"Mod-Alt-2",run:pt("h2")},{name:"h3",label:"h3",icon:S.h3,keywords:["h3","heading"],shortcut:"Mod-Alt-3",run:pt("h3")},{name:"bullist",label:"bulletList",icon:S.bulletList,keywords:["ul","list","bullet"],shortcut:"Mod-Shift-8",run:pt("bulletList")},{name:"numlist",label:"orderedList",icon:S.orderedList,keywords:["ol","list","numbered"],shortcut:"Mod-Shift-7",run:pt("orderedList")},{name:"blockquote",label:"blockquote",icon:S.blockquote,keywords:["quote","blockquote","citation"],run:pt("blockquote")},{name:"codeblock",label:"codeBlock",icon:S.codeBlock,keywords:["code","pre","snippet"],run:pt("codeBlock")},{name:"hr",label:"horizontalRule",icon:S.horizontalRule,keywords:["hr","divider","line","separator"],run:pt("horizontalRule")},{name:"table",label:"table",icon:S.table,keywords:["table","grid"],run:n=>n.exec(ct(3,3))},{name:"image",label:"image",icon:S.image,keywords:["image","picture","photo","img"],run:n=>cr(n)},{name:"link",label:"link",icon:S.link,keywords:["link","url","href"],shortcut:"Mod-k",run:n=>at(n)}];function Xy(n,e,t){let r=e.toLowerCase();if(!r)return n;let o=[];return n.forEach((i,s)=>{let l=t(i.label).toLowerCase(),a=[l,...l.split(/\s+/),...i.keywords],c=-1;l.startsWith(r)?c=3:a.some(u=>u.startsWith(r))?c=2:a.some(u=>u.includes(r))&&(c=1),c>0&&o.push([c,s,i])}),o.sort((i,s)=>s[0]-i[0]||i[1]-s[1]).map(([,,i])=>i)}function Zp(n,e=[]){let{t}=n.ui,r=[...Yy,...e].filter(o=>n.isAllowed(o.name));n.ui.registry.addAutocompleter("slashcommands",{trigger:"/",label:t("slash.label"),emptyText:t("slash.empty"),fetch:o=>Xy(r,o,t).map(i=>({value:i.name,label:t(i.label),icon:i.icon,...i.shortcut?{shortcut:i.shortcut}:{}})),onSelect:(o,i,s)=>{let l=r.find(a=>a.name===o.value);l&&(s.view.dispatch(s.view.state.tr.delete(i.from,i.to)),l.run(s))}})}var Go=class{constructor(e,t){E(this,"region");E(this,"closeLabel");this.closeLabel=t,this.region=M("div",{className:"nova-notifications","aria-live":"polite"}),e.append(this.region)}open(e){let t=e.type??"info",r=e.timeout??(t==="error"?0:4e3),o=M("span",{className:"nova-notification-text"},e.text),i=M("button",{type:"button",className:"nova-btn","aria-label":this.closeLabel},V(S.close)),s=(e.actions??[]).map(p=>M("button",{type:"button",className:"nova-btn nova-notification-action"},p.label)),l=M("div",{className:`nova-notification nova-notification-${t}`,role:t==="error"?"alert":"status"},o,...s,i);this.region.append(l);let a=null,c=!1,u=()=>{c||(c=!0,a&&clearTimeout(a),l.remove())},d=()=>{c||(u(),e.onClose?.())};return s.forEach((p,f)=>p.addEventListener("click",()=>{u(),e.actions[f].onAction()})),i.addEventListener("click",d),r>0&&(a=setTimeout(d,r)),s[0]?.focus({preventScroll:!0}),{close:u,setText:p=>o.textContent=p}}destroy(){this.region.remove()}};var Qy=S.sidebar,Yo=class{constructor(){E(this,"controls",new Map);E(this,"menuItems",new Map);E(this,"contextToolbars",new Map);E(this,"autocompleters",new Map);E(this,"sidebars",new Map)}addButton(e,t){this.controls.set(e.toLowerCase(),{type:"button",...t})}addToggleButton(e,t){this.addButton(e,t)}addMenuButton(e,t){this.controls.set(e.toLowerCase(),{type:"menu",...t})}addPanelButton(e,t){this.controls.set(e.toLowerCase(),{type:"panel",...t})}addSplitButton(e,t){this.controls.set(e.toLowerCase(),{type:"split",...t})}addMenuItem(e,t){this.menuItems.set(e.toLowerCase(),t)}addToggleMenuItem(e,t){this.addMenuItem(e,t)}getMenuItem(e){let t=this.menuItems.get(e.toLowerCase());if(t)return t;let r=this.get(e);if(!(r?.type!=="button"&&r?.type!=="split"))return{text:r.tooltip,...r.icon?{icon:r.icon}:{},...r.shortcut?{shortcut:r.shortcut}:{},onAction:r.onAction,...r.isActive?{isActive:r.isActive}:{},...r.isEnabled?{isEnabled:r.isEnabled}:{}}}addSidebar(e,t){this.sidebars.set(e,t),!(t.button===!1||this.has(e))&&this.addToggleButton(e,{tooltip:t.tooltip??t.title,icon:t.icon??Qy,isActive:r=>r.ui.sidebar.isOpen(e),onAction:r=>{r.ui.sidebar.toggle(e)}})}getSidebar(e){return this.sidebars.get(e)}addAutocompleter(e,t){this.autocompleters.set(e.toLowerCase(),t)}getAutocompleters(){return[...this.autocompleters]}addContextToolbar(e,t){this.contextToolbars.set(e.toLowerCase(),t)}getContextToolbars(){return[...this.contextToolbars].sort((e,t)=>(t[1].priority??0)-(e[1].priority??0))}get(e){return this.controls.get(e.toLowerCase())}has(e){return this.controls.has(e.toLowerCase())}names(){return[...this.controls.keys()]}};var Xo=class{constructor(e){E(this,"editor",e);E(this,"current",null);E(this,"mounted",new Map);E(this,"column",null);E(this,"opening",Promise.resolve());E(this,"destroyed",!1)}get active(){return this.current}isOpen(e){return this.current===e}async show(e,t={}){let r=this.editor.ui.registry.getSidebar(e);if(!r){console.warn(`[nova] sidebar "${e}" is not registered`);return}if(this.current!==e){this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.current=e;let o=this.mount(e,r);this.opening=o.ready.then(i=>{if(!i||this.current!==e||this.destroyed){this.current===e&&(this.current=null);return}o.el.hidden=!1,this.editor.root.classList.add("nova-sidebar-open"),r.onShow?.(this.editor),this.editor.updateUI()})}if(await this.opening,t.focus&&this.current===e){let o=this.mounted.get(e).el;(o.querySelector(nn)??o).focus()}}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(j(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-sidebar-open"),this.editor.ui.registry.getSidebar(t)?.onHide?.(this.editor),this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e,t={}){return this.current===e?(this.hide(),Promise.resolve()):this.show(e,t)}destroy(){this.destroyed=!0,this.mounted.forEach(e=>e.cleanup?.()),this.mounted.clear()}host(){if(this.column)return this.column;let e=this.editor.view.dom.parentElement,t=M("div",{className:"nova-body"});return e.before(t),t.append(e),this.column=t,t}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=Te("nova-sidebar-title"),i=M("div",{className:"nova-sidebar-body"}),s=M("button",{type:"button",className:"nova-btn nova-sidebar-close","aria-label":this.editor.ui.t("dialog.close"),onClick:()=>this.hide()},V(S.close)),l=t.header===!1?null:M("div",{className:"nova-sidebar-head"},M("h2",{id:o,className:"nova-sidebar-title"},t.title),s),a=M("div",{className:`nova-sidebar${l?"":" nova-sidebar-bare"}`,hidden:!0,"data-sidebar":e,...l?{role:"complementary","aria-labelledby":o}:{},onKeydown:(u=>{u.key!=="Escape"||u.defaultPrevented||(u.preventDefault(),this.hide())})},l,i);this.host().append(a);let c={el:a,ready:Promise.resolve(!1)};return c.ready=(async()=>{try{let u=await t.render(i,this.editor);return typeof u=="function"&&(c.cleanup=u),!0}catch(u){return console.error(`[nova] sidebar "${e}" failed to render`,u),a.remove(),this.mounted.delete(e),!1}})(),this.mounted.set(e,c),c}};var Zy=450,Qo=class{constructor(e){E(this,"el");E(this,"timer",null);E(this,"target",null);this.el=M("div",{className:"nova-tooltip",role:"tooltip",hidden:!0}),e.append(this.el)}attach(e){e.addEventListener("pointerenter",t=>{t.pointerType==="mouse"&&this.schedule(e)}),e.addEventListener("pointerleave",()=>this.hide()),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&this.show(e)}),e.addEventListener("blur",()=>this.hide()),e.addEventListener("pointerdown",()=>this.hide())}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>this.show(e),Zy)}show(e){this.clearTimer();let t=e.dataset.tooltip;if(!t||e.getAttribute("aria-expanded")==="true")return;this.target=e;let r=e.dataset.shortcut;this.el.replaceChildren(M("span",{},t)),r&&this.el.append(M("kbd",{},tt(r))),this.el.hidden=!1,dt(this.el,e.getBoundingClientRect(),"bottom")}hide(){this.clearTimer(),this.el.hidden=!0,this.target=null}get current(){return this.target}destroy(){this.hide(),this.el.remove()}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}};var Zo=class{constructor(e,t,r,o){E(this,"focusEditor",r);E(this,"registry",new Yo);E(this,"t");E(this,"overlayHost");E(this,"tooltip");E(this,"sidebar");E(this,"notifications");E(this,"popover",null);E(this,"currentDialog",null);E(this,"dialogListeners",new Set);this.t=t,this.overlayHost=M("div",{className:"nova-overlays"}),e.append(this.overlayHost),this.tooltip=new Qo(this.overlayHost),this.notifications=new Go(e,t("dialog.close")),this.sidebar=new Xo(o)}async dialog(e){let{openFormDialog:t}=await import(__novaChunk("tinymce-chunks/form-dialog-9cde0ef7.js") );return t(e,this.t,r=>this.openDialog(r))}openPopover(e){this.closePopover(),this.tooltip.hide();let t=new An({...e,host:this.overlayHost,onClose:r=>{this.popover===t&&(this.popover=null),e.onClose?.(r)}});return this.popover=t,t}closePopover(){this.popover?.close("api"),this.popover=null}get activePopover(){return this.popover}onDialogOpen(e){return this.dialogListeners.add(e),()=>this.dialogListeners.delete(e)}closeOverlays(){this.closePopover(),this.dialogListeners.forEach(e=>e())}openDialog(e){this.closePopover(),this.dialogListeners.forEach(r=>r()),this.currentDialog?.close();let t=Cc({cancelLabel:this.t("dialog.cancel"),closeLabel:this.t("dialog.close"),...e,host:this.overlayHost,returnFocus:this.focusEditor,onClose:()=>{this.currentDialog===t&&(this.currentDialog=null),e.onClose?.()}});return this.currentDialog=t,t}get activeDialog(){return this.currentDialog}notify(e){return this.notifications.open(typeof e=="string"?{text:e}:e)}destroy(){this.sidebar.destroy(),this.closePopover(),this.currentDialog?.close(),this.tooltip.destroy(),this.notifications.destroy(),this.overlayHost.remove()}};var ev={paragraph:()=>"p",heading:n=>`h${n.attrs.level}`,blockquote:()=>"blockquote",code_block:()=>"pre",bullet_list:()=>"ul",ordered_list:()=>"ol",list_item:()=>"li",table:()=>"table",table_row:()=>"tr",table_cell:()=>"td",table_header:()=>"th"},tv={bold:"strong",italic:"em",underline:"u",strike:"s",code:"code",link:"a",subscript:"sub",superscript:"sup"},tf=String.raw`\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}`,ef=String.raw`(?:(?![${tf}])[\p{L}\p{N}])`,nv=new RegExp(`[${tf}]|${ef}+(?:['\u2019-]${ef}+)*`,"gu");function rv(n){return n.match(nv)?.length??0}function nf(n,e){e.className="nova-statusbar";let t=M("div",{className:"nova-path","aria-hidden":"true"}),r=M("div",{className:"nova-wordcount","aria-live":"off"});e.append(t,r);let o=n.options.resize,i=o?sv(n,e,o==="both"):null,s=null,l=()=>{let c=n.view.state.doc;r.textContent=n.ui.t("status.words",{count:rv(c.textBetween(0,c.content.size," "," "))})},a=c=>{let{$from:u}=n.view.state.selection,d=[];for(let f=1;f<=u.depth;f++){let h=u.node(f),g=ev[h.type.name]?.(h);g&&d.push(g)}n.view.state.selection.node?.type.name==="image"&&d.push("img");for(let f of u.marks()){let h=tv[f.type.name];h&&d.push(h)}t.replaceChildren(...d.flatMap((f,h)=>[...h?[" \u203A "]:[],M("span",{className:"nova-path-item"},f)])),c&&(s&&clearTimeout(s),s=setTimeout(l,250))};return l(),a(!1),{update:a,destroy:()=>{s&&clearTimeout(s),i?.(),e.replaceChildren()}}}var ov=100,iv=200,ei=20;function sv(n,e,t){let r=n.root,o=M("div",{className:"nova-resize-handle",role:"separator",tabIndex:0,"aria-orientation":"horizontal","aria-label":n.ui.t("status.resize")});o.append(V(t?S.resizeHandleBoth:S.resizeHandle)),r.dataset.resize=t?"both":"vertical",e.append(o);let i=(d,p)=>{if(r.style.boxSizing="border-box",r.style.height=`${Math.max(ov,Math.round(d))}px`,t&&p!==void 0){let f=r.parentElement?.clientWidth||1/0;r.style.width=`${Math.min(f,Math.max(iv,Math.round(p)))}px`}o.setAttribute("aria-valuenow",String(r.offsetHeight))},s=null,l=d=>{n.isDisabled()||(d.preventDefault(),o.setPointerCapture(d.pointerId),s={x:d.clientX,y:d.clientY,height:r.offsetHeight,width:r.offsetWidth})},a=d=>{if(!s)return;let p=(d.clientX-s.x)*(rn(r)?-1:1);i(s.height+d.clientY-s.y,s.width+p)},c=d=>{s&&(s=null,o.hasPointerCapture(d.pointerId)&&o.releasePointerCapture(d.pointerId))},u=d=>{let p=d.key==="ArrowDown"?ei:d.key==="ArrowUp"?-ei:0,f=Me(d,r),h=t?f==="ArrowRight"?ei:f==="ArrowLeft"?-ei:0:0;!h&&!p||(d.preventDefault(),i(r.offsetHeight+p,r.offsetWidth+h))};return o.addEventListener("pointerdown",l),o.addEventListener("pointermove",a),o.addEventListener("pointerup",c),o.addEventListener("pointercancel",c),o.addEventListener("keydown",u),()=>{o.remove(),delete r.dataset.resize}}var lv=new Set(["ar","he","iw","fa","ur","ps","sd","ug","yi","dv","ckb"]);function av(n){return!!n&&lv.has(n.toLowerCase().split(/[-_]/)[0])}var cv=new Ot,ha="nova:remote",vr="nova:api",uv=new Set("P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE".split(" ")),dv=0,kr=class{constructor(e){E(this,"view");E(this,"root");E(this,"ui");E(this,"options");E(this,"listeners",new Map);E(this,"ready");E(this,"toolbar");E(this,"toolbarHost");E(this,"menubar");E(this,"mode");E(this,"direction");E(this,"pluginsByName",new Map);E(this,"commandOverrides",new Map);E(this,"transactionTransforms",[]);E(this,"cleanups",[]);E(this,"contentRules");E(this,"schema");E(this,"formatter");E(this,"statusbar");E(this,"searchBar");E(this,"destroyed",!1);E(this,"editable");E(this,"disabled");E(this,"pasteAsText");this.options=e,this.root=document.createElement("div"),this.root.className="nova-editor";let t=e.direction??(av(e.language)?"rtl":void 0);t&&(this.root.dir=t),this.direction=t??(e.element.closest("[dir]")?.getAttribute("dir")==="rtl"?"rtl":"ltr"),e.element.appendChild(this.root);let r=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div");o.className="nova-content";let s=document.createElement("div");s.className="nova-header";let l=document.createElement("div");s.append(l,r),this.root.append(s,o,i),this.toolbarHost=r,this.mode=e.mode??"classic",this.root.classList.add(`nova-mode-${this.mode}`);let a=this.mode==="distraction-free";this.mode!=="classic"&&(this.root.addEventListener("focusin",()=>this.root.classList.add("is-focused")),this.root.addEventListener("focusout",()=>{setTimeout(()=>{this.root.contains(j(this.root))||this.root.classList.remove("is-focused")},0)})),this.ui=new Zo(this.root,Bi(e.language,e.translations),()=>this.focus(),this),this.root.style.setProperty("--nova-caption-placeholder",JSON.stringify(this.ui.t("image.captionPlaceholder")));let c=Ke({"Mod-k":()=>(at(this),!0),"Alt-F9":()=>this.menubar?(this.menubar.focus(),!0):!1,"Alt-F10":()=>this.toolbar?(this.toolbar.focus(),!0):!1,"Ctrl-F9":()=>Yp(this),"Mod-f":()=>(this.openSearch(),!0),"Mod-Shift-f":()=>(hr(this),!0),"Alt-0":()=>(Vo(this),!0),Escape:()=>this.searchBar.isOpen()?(this.searchBar.close(),!0):!1}),u=[...e.plugins??[]];a&&!u.includes("quickbars")&&u.push("quickbars");let d=ui(u);d.errors.forEach(C=>Pe(C));let{ordered:p,errors:f}=Ar(d.plugins);f.forEach(C=>Pe(C));let h=p.flatMap(C=>this.collectPmPlugins(C)),g=e.validElements!==void 0||e.invalidElements!==void 0||e.validStyles!==void 0;this.contentRules=g?new $o(e):null;let m=new Set([...lr(Object.values(e.formats??{}).flat()),...lr(e.styleFormats??[]),...Array.isArray(e.validClasses)?e.validClasses:[],...[...e.tableClassList??[],...e.tableCellClassList??[]].flatMap(C=>C.value.split(/\s+/).filter(Boolean))]),b=Mp(e),k=e.validClasses===!0||e.validClasses===void 0&&!!b?.classOnBuiltIn;this.schema=this.buildSchema(p,k?()=>!0:C=>m.has(C),b),this.formatter=new Ao(this,m);for(let[C,B]of Object.entries(e.formats??{}))this.formatter.register(C,B);p.forEach(C=>this.registerCommands(C));let y=fa(this.schema,e.content??""),w=Dp(),N=[Qp(this),hp(C=>this.isAllowed(C),this.schema),c,w,...mp(C=>this.resolveCommand(C)),...p.some(C=>C.replaceHistory)?[]:[Xs()],tp({color:"var(--nova-accent)",width:2}),rp(),bl(this),gl(this),bp(this),Jp(this),Gp(this),...this.contentRules?[Tp(this.contentRules)]:[],...h,...e.prosemirrorPlugins??[]];Xl(N);let L=Vn.create({doc:this.contentRules?this.contentRules.normalizeDoc(y):y,plugins:N});this.editable=e.editable??!0,this.disabled=e.disabled??!1,this.pasteAsText=e.pasteAsText??!1;let R=this.handleTransaction.bind(this);this.view=new fn(o,{state:L,editable:()=>this.isEditable(),attributes:{class:"nova-prosemirror",role:"textbox","aria-multiline":"true","aria-label":this.ui.t("editor.label"),...e.placeholder?{"data-placeholder":e.placeholder}:{}},dispatchTransaction:function(C){R(C,this)},clipboardParser:dr(this.schema),nodeViews:{image:(C,B,Q)=>new Jo(C,B,Q,this)},handleDOMEvents:{focus:(C,B)=>(this.emit("focus",{event:B}),!1),blur:(C,B)=>(this.emit("blur",{event:B}),!1)},handleKeyDown:(C,B)=>(this.emit("keydown",{event:B}),B.defaultPrevented)}),this.root.classList.toggle("nova-readonly",!this.editable),this.applyDisabled(),Up(this),Cp(this),e.slashCommands!==!1&&Zp(this,e.slashCommands??[]),p.forEach(C=>this.setupPlugin(C)),e.setup?.(this);let O=e.menubar===!0?wp:typeof e.menubar=="string"?e.menubar:null;this.menubar=O?Ep(this,l,O,{...Sp,...e.menu}):null,this.menubar||l.remove(),this.toolbar=e.toolbar===!1||a&&e.toolbar===void 0?null:pa(this,r,this.toolbarConfig(),e.toolbarMode??"sliding",{warnUnknown:d.loaders.length===0}),this.toolbar||r.remove(),!this.toolbar&&!this.menubar&&s.remove(),this.searchBar=Hp(this,o);let v=e.statusbar??this.mode==="classic";this.statusbar=v?nf(this,i):null,this.statusbar||i.remove(),e.onChange&&this.on("change",e.onChange),this.updatePlaceholder();let x=this.applyContentStyles();this.ready=Promise.all([d.loaders.length?this.loadLazyPlugins(d.loaders):void 0,x,Hl(),this.installTables(w)]).then(()=>{this.destroyed||this.emit("init")})}async installTables(e){let t=await Fl();if(!t||this.destroyed)return;let{state:r}=this.view,o=r.plugins.indexOf(e),i=[...r.plugins];i.splice(o<0?i.length:o,0,...t.tablePlugins()),Ql(this.view,i),this.updateUI()}applyContentStyles(){let{contentStyle:e,contentCss:t}=this.options,r=t===void 0?[]:Array.isArray(t)?t:[t];if(!e&&!r.length)return;let o=`nova-cs-${++dv}`;this.root.classList.add(o);let i=`.nova-editor.${o} .nova-prosemirror`,s=r.map(()=>""),l=null,a=()=>{this.destroyed||(l?.(),l=ep(this.root,cl([...s,e??""].join(`
37
- `),i)))};if(this.cleanups.push(()=>l?.()),a(),!!r.length)return Promise.all(r.map((c,u)=>ul(c).then(d=>{s[u]=d},d=>console.warn(`[nova] contentCss: could not load ${c}`,d)))).then(a)}isAllowed(e){return this.contentRules?.isAllowed(e)??!0}hasPlugin(e){return this.pluginsByName.has(e)}buildSchema(e,t,r){let o={},i={};for(let s of e){let l=typeof s.nodes=="function"?s.nodes(this):s.nodes;for(let[a,c]of Object.entries(l??{}))a in o?Pe(`Node "${a}" is defined by several plugins`):o[a]=c;for(let[a,c]of Object.entries(s.marks??{}))a in i?Pe(`Mark "${a}" is defined by several plugins`):i[a]=c}try{return po({nodes:o,marks:i},t,r,this.direction)}catch(s){return Pe("Failed to build the document schema from plugins",s),po({},t,r,this.direction)}}collectPmPlugins(e){try{return e.prosemirrorPlugins?.(this)??[]}catch(t){return Pe(`Plugin "${e.name}" failed to create ProseMirror plugins`,t),[]}}setupPlugin(e){try{let t=e.setup?.(this);typeof t=="function"&&this.cleanups.push(t),this.pluginsByName.set(e.name,e)}catch(t){Pe(`Plugin "${e.name}" failed during setup`,t)}}async loadLazyPlugins(e){let t=await Promise.all(e.map(l=>di(l).catch(a=>(Pe("Failed to load plugin",a),null))));if(this.destroyed)return;let r=t.filter(l=>l?l.nodes||l.marks?(Pe(`Plugin "${l.name}" defines nodes or marks and cannot be loaded lazily; pass the plugin object instead`),!1):!0:!1),{ordered:o,errors:i}=Ar(r,new Set(this.pluginsByName.keys()));i.forEach(l=>Pe(l));let s=o.flatMap(l=>this.collectPmPlugins(l));s.length&&Ql(this.view,[...this.view.state.plugins,...s]),o.forEach(l=>{this.registerCommands(l),this.setupPlugin(l)}),this.rebuildToolbar()}updateUI(){this.destroyed||this.toolbar?.update()}rebuildToolbar(){!this.toolbar||this.destroyed||(this.toolbar.destroy(),this.toolbar=pa(this,this.toolbarHost,this.toolbarConfig(),this.options.toolbarMode??"sliding"))}toolbarConfig(){if(this.options.toolbar)return this.options.toolbar;let e=[...this.pluginsByName.values()].map(t=>t.toolbar).filter(Boolean);return e.length?`${ua} | ${e.join(" ")}`:ua}handleTransaction(e,t=this.view){if(!t.isDestroyed){for(let r of this.transactionTransforms)e=r(e,t.state,this);t.updateState(t.state.apply(e)),this.view&&(this.toolbar?.update(),this.statusbar?.update(e.docChanged),this.searchBar?.update(),this.updatePlaceholder(),e.docChanged&&(this.emit("change",{transaction:e}),!(e.getMeta(vr)||e.getMeta(ha))&&e.getMeta("addToHistory")!==!1&&this.emit("input",{transaction:e})),(e.selectionSet||e.docChanged)&&this.emit("selectionChange",{transaction:e}))}}updatePlaceholder(){let e=this.view.state.doc,t=e.childCount===1&&e.firstChild?.type===this.schema.nodes.paragraph&&e.firstChild.content.size===0;this.view.dom.classList.toggle("nova-empty",t)}getHTML(){return cv.serializeFragment(this.view.state.doc.content)}getJSON(){return this.view.state.doc.toJSON()}getText(){return this.view.state.doc.textBetween(0,this.view.state.doc.content.size,`
43
+ `).trim()}function Ju(n){let{t:e}=n.ui,t=Wg(Fu(n)),r=w("textarea",{className:"nova-input nova-source",spellcheck:"false","aria-label":e("sourceCode"),autocomplete:"off",rows:"18"});r.value=t,n.ui.openDialog({title:e("sourceCode"),body:r,size:"large",submitLabel:e("dialog.save"),initialFocus:r,onSubmit:()=>(r.value!==t&&zu(n,r.value),!0)})}var xw=[{group:"help.formatting",rows:[{label:"bold",keys:"Mod-b"},{label:"italic",keys:"Mod-i"},{label:"underline",keys:"Mod-u"},{label:"strike",keys:"Mod-Shift-x"},{label:"code",keys:"Mod-e"},{label:"superscript",keys:"Mod-."},{label:"subscript",keys:"Mod-,"},{label:"link",keys:"Mod-k"},{label:"clearFormatting",keys:"Mod-\\"}]},{group:"help.blocks",rows:[{label:"paragraph",keys:"Mod-Alt-0"},{label:"h1",keys:"Mod-Alt-1"},{label:"h2",keys:"Mod-Alt-2"},{label:"h3",keys:"Mod-Alt-3"},{label:"bulletList",keys:"Mod-Shift-8"},{label:"orderedList",keys:"Mod-Shift-7"},{label:"alignCenter",keys:"Mod-Shift-e"},{label:"indent",keys:"Mod-]"},{label:"outdent",keys:"Mod-["}]},{group:"help.editing",rows:[{label:"undo",keys:"Mod-z"},{label:"redo",keys:"Mod-Shift-z"},{label:"search.title",keys:"Mod-f"},{label:"pasteAsText",keys:"Mod-Shift-v"},{label:"fullscreen",keys:"Mod-Shift-f"},{label:"help.slash",keys:"/"},{label:"moveBlockUp",keys:"Alt-Shift-ArrowUp"},{label:"moveBlockDown",keys:"Alt-Shift-ArrowDown"}]},{group:"help.navigation",rows:[{label:"help.toMenubar",keys:"Alt-F9"},{label:"help.toToolbar",keys:"Alt-F10"},{label:"help.toContextToolbar",keys:"Ctrl-F9"},{label:"help.toEditor",keys:"Escape"},{label:"help.nextCell",keys:"Tab"},{label:"help",keys:"Alt-0"}]}];function go(n){let{t:e}=n.ui,t=w("div",{className:"nova-help"});for(let{group:r,rows:o}of xw)t.append(w("section",{},w("h3",{},e(r)),w("ul",{className:"nova-help-list"},o.map(({label:i,keys:s})=>w("li",{},w("span",{},e(i))," ",w("kbd",{},s.length===1?s:At(s)))))));n.ui.openDialog({title:e("help"),body:t,size:"large",cancelLabel:e("dialog.close")})}var Zu={};q(Zu,{defaultFontFamilies:()=>Yg,defaultFontSizes:()=>Xg,defaultLineHeights:()=>Zg,registerBuiltins:()=>Xu});var ww={color:Y.color,background:Y.color,font_family:Y.fontFamily,font_size:Y.length};function Ht(n,e){return(t,r)=>{let o=ce(t)[n],i=e===null?null:ww[n](e);if(e!==null&&!i)return!1;let{empty:s}=t.selection;if(!r)return!0;let l=t.tr;if(s)l.removeStoredMark(o),i&&l.addStoredMark(o.create({value:i}));else for(let a of t.selection.ranges)l.removeMark(a.$from.pos,a.$to.pos,o),i&&l.addMark(a.$from.pos,a.$to.pos,o.create({value:i}));return r(l.scrollIntoView()),!0}}function kt(n,e){let t=ce(n)[e],{$from:r,empty:o}=n.selection,i=o?n.storedMarks??r.marks():r.nodeAfter?.marks??r.marks(),s=t.isInSet(i);return s?s.attrs.value:null}function yo(n){return(e,t)=>{let r=n===null?null:Y.lineHeight(n);if(n!==null&&!r)return!1;let{from:o,to:i}=e.selection,s=e.tr,l=!1;return e.doc.nodesBetween(o,i,(a,c)=>{(a.type===Z(e).paragraph||a.type===Z(e).heading)&&(l=!0,s.setNodeMarkup(c,void 0,{...a.attrs,lineHeight:r}))}),l?(t?.(s),!0):!1}}function Yu(n){return n.selection.$from.parent.attrs.lineHeight??null}var hs=["#000000","#434343","#666666","#999999","#b7b7b7","#d9d9d9","#efefef","#ffffff","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#fecaca","#fed7aa","#fef08a","#bbf7d0","#a5f3fc","#bfdbfe","#ddd6fe","#fbcfe8"];function ms(n){let t=[],r=n.current?.toLowerCase()??null,o=w("div",{className:"nova-swatches",role:"grid","aria-label":n.label}),i=null;for(let a of n.colors){let c=r===a.toLowerCase(),u=w("button",{type:"button",className:"nova-swatch",role:"gridcell","aria-label":a,"aria-selected":String(c),title:a,tabindex:"-1"},c?ee(C.check):null);u.style.setProperty("--swatch",a),u.addEventListener("click",()=>n.onPick(a)),t.push(u),(!i||i.childElementCount===8)&&(i=w("div",{className:"nova-swatch-row",role:"row"}),o.append(i)),i.append(u)}(t.find(a=>a.getAttribute("aria-selected")==="true")??t[0])?.setAttribute("tabindex","0"),o.addEventListener("keydown",a=>{let c=t.indexOf(te(o));if(c<0)return;let d={ArrowRight:1,ArrowLeft:-1,ArrowDown:8,ArrowUp:-8}[Ne(a,o)];if(d===void 0)return;a.preventDefault();let p=t[Math.min(t.length-1,Math.max(0,c+d))];t[c].tabIndex=-1,p.tabIndex=0,p.focus()});let s=w("button",{type:"button",className:"nova-panel-action"},ee(C.clearFormatting),n.removeLabel);s.addEventListener("click",()=>n.onPick(null));let l=w("input",{type:"color",className:"nova-color-input","aria-label":n.customLabel,value:/^#[0-9a-f]{6}$/i.test(r??"")?r:"#000000"});return l.addEventListener("change",()=>n.onPick(l.value)),w("div",{className:"nova-color-panel"},o,w("div",{className:"nova-panel-footer"},s,w("label",{className:"nova-panel-action"},l,n.customLabel)))}function Kg(n){let{registry:e,t}=n.ui,r=(i,s)=>t("table.size",{rows:i,cols:s});e.addPanelButton("table",{icon:C.table,tooltip:t("table.insert"),isEnabled:i=>i.can(It(1,1)),render:(i,s)=>Mu((l,a)=>{s(),i.exec(It(l,a))},r,t("table.insert"))});let o=(i,s,l,a,c)=>e.addButton(i,{icon:l,tooltip:t(s),onAction:u=>u.exec(a),isEnabled:u=>u.can(a),...c?{isActive:c}:{}});o("tableinsertrowbefore","table.rowBefore",C.rowBefore,$e.addRowBefore),o("tableinsertrowafter","table.rowAfter",C.rowAfter,$e.addRowAfter),o("tabledeleterow","table.rowDelete",C.rowDelete,$e.deleteRow),o("tableinsertcolbefore","table.colBefore",C.colBefore,$e.addColumnBefore),o("tableinsertcolafter","table.colAfter",C.colAfter,$e.addColumnAfter),o("tabledeletecol","table.colDelete",C.colDelete,$e.deleteColumn),o("tablemergecells","table.merge",C.merge,$e.mergeCells),o("tablesplitcells","table.split",C.split,$e.splitCell),o("tablerowheader","table.rowHeader",C.rowHeader,$e.toggleHeaderRow,i=>xu(i.view.state)),o("tablecolheader","table.colHeader",C.colHeader,$e.toggleHeaderColumn,i=>wu(i.view.state)),o("tabledelete","table.delete",C.tableDelete,$e.deleteTable),e.addPanelButton("tablecellbackground",{icon:C.highlight,tooltip:t("table.cellBackground"),isEnabled:i=>Gt(i.view.state),render:(i,s)=>ms({colors:i.options.colors??hs,current:null,label:t("table.cellBackground"),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:l=>{s(),i.exec(vu(l))}})}),e.addMenuButton("advtablesort",{icon:C.sort,tooltip:t("table.sort"),isEnabled:i=>i.can(as("asc")),items:i=>{let s=["asc","desc"].map(a=>({id:a,label:t(a==="asc"?"table.sortAsc":"table.sortDesc"),onSelect:()=>i.exec(as(a,i.options.language))})),l=i.ui.registry.getMenuItem("advtablesort");return l?[...s,{id:"advanced",label:l.text,onSelect:()=>l.onAction(i)}]:s}}),e.addButton("tableprops",{icon:C.tableProps,tooltip:t("table.props"),isEnabled:i=>Gt(i.view.state),onAction:i=>{import(__novaChunk("tinymce-chunks/table-dialogs-0445847c.js") ).then(s=>s.openTableProps(i))}}),e.addButton("tablecellprops",{icon:C.cellProps,tooltip:t("table.cellProps"),isEnabled:i=>Gt(i.view.state),onAction:i=>{import(__novaChunk("tinymce-chunks/table-dialogs-0445847c.js") ).then(s=>s.openCellProps(i))}}),e.addContextToolbar("table",{label:t("table.toolbar"),predicate:i=>Gt(i.view.state),anchor:i=>Su(i),placement:"bottom-start",items:"tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort advtablerownumbering tablecellprops tableprops | tabledelete"})}var Yg=[{label:"Sans Serif",value:'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif'},{label:"Serif",value:'Georgia, "Times New Roman", serif'},{label:"Monospace",value:"ui-monospace, Menlo, Consolas, monospace"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:'"Times New Roman", Times, serif'},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Courier New",value:'"Courier New", Courier, monospace'}],Xg=["8pt","10pt","12pt","14pt","16pt","18pt","24pt","36pt","48pt"],Zg=["1","1.15","1.5","2","2.5","3"],rt={undo:"Mod-z",redo:"Mod-Shift-z",bold:"Mod-b",italic:"Mod-i",underline:"Mod-u",strike:"Mod-Shift-x",code:"Mod-e",subscript:"Mod-,",superscript:"Mod-.",bulletList:"Mod-Shift-8",orderedList:"Mod-Shift-7",alignLeft:"Mod-Shift-l",alignCenter:"Mod-Shift-e",alignRight:"Mod-Shift-r",alignJustify:"Mod-Shift-j",indent:"Mod-]",outdent:"Mod-[",clearFormatting:"Mod-\\",paragraph:"Mod-Alt-0",h1:"Mod-Alt-1",h2:"Mod-Alt-2",h3:"Mod-Alt-3",h4:"Mod-Alt-4",h5:"Mod-Alt-5",h6:"Mod-Alt-6"};function Ug(n){try{let{node:e}=n.view.domAtPos(n.view.state.selection.from),t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return t?getComputedStyle(t):null}catch{return null}}var Sw={"system-ui":"Sans Serif","-apple-system":"Sans Serif","sans-serif":"Sans Serif",serif:"Serif",monospace:"Monospace","ui-monospace":"Monospace"};function Jg(n){let e=String(n).split(",")[0].trim().replace(/["']/g,"");return Sw[e.toLowerCase()]??e}function Mw(n){let e=parseFloat(n);return!Number.isFinite(e)||e<=0?null:`${Math.round(e*.75*2)/2}pt`}var Gg=(n,e)=>typeof n=="string"&&n.replace(/["'\s]/g,"").toLowerCase()===e.replace(/["'\s]/g,"").toLowerCase();function Xu(n){let{registry:e,t}=n.ui,r=()=>n.view.state,o=(y,v,b,E)=>e.addButton(y,{icon:b,tooltip:t(v),...rt[v]?{shortcut:rt[v]}:{},onAction:_=>_.exec(v),isEnabled:_=>_.can(v),...E?{isActive:E}:{}}),i=(y,v,b,E)=>o(y,v,E,()=>ar(r(),n.schema.marks[b]));o("undo","undo",C.undo),o("redo","redo",C.redo),i("bold","bold","bold",C.bold),i("italic","italic","italic",C.italic),i("underline","underline","underline",C.underline),i("strikethrough","strike","strike",C.strike),i("inlinecode","code","code",C.code),i("subscript","subscript","subscript",C.subscript),i("superscript","superscript","superscript",C.superscript),o("bullist","bulletList",C.bulletList,()=>Ze(r(),n.schema.nodes.bullet_list)),o("numlist","orderedList",C.orderedList,()=>Ze(r(),n.schema.nodes.ordered_list)),o("indent","indent",C.indent),o("outdent","outdent",C.outdent),o("blockquote","blockquote",C.blockquote,()=>Ze(r(),n.schema.nodes.blockquote)),o("codeblock","codeBlock",C.codeBlock,()=>Ze(r(),n.schema.nodes.code_block)),o("hr","horizontalRule",C.horizontalRule),o("removeformat","clearFormatting",C.clearFormatting);let s=[["alignLeft","left",C.alignLeft],["alignCenter","center",C.alignCenter],["alignRight","right",C.alignRight],["alignJustify","justify",C.alignJustify]];for(let[y,v,b]of s)o(y.toLowerCase(),y,b,()=>Zt(r())===v);e.addMenuButton("align",{icon:C.alignLeft,tooltip:t("align"),isEnabled:y=>y.can("alignLeft"),items:y=>s.map(([v,b,E])=>({id:v,label:t(v),icon:E,...rt[v]?{shortcut:rt[v]}:{},active:Zt(y.view.state)===b,onSelect:()=>y.exec(v)}))});let l=[{command:"paragraph",style:""},{command:"h1",style:"font-size: 1.6em; font-weight: 700"},{command:"h2",style:"font-size: 1.35em; font-weight: 700"},{command:"h3",style:"font-size: 1.15em; font-weight: 700"},{command:"h4",style:"font-size: 1em; font-weight: 700"},{command:"h5",style:"font-size: 0.9em; font-weight: 700"},{command:"h6",style:"font-size: 0.85em; font-weight: 700"},{command:"codeBlock",style:"font-family: ui-monospace, monospace"}],a=()=>{let y=r().selection.$from.parent;return y.type===n.schema.nodes.heading?`h${y.attrs.level}`:y.type===n.schema.nodes.code_block?"codeBlock":"paragraph"};for(let y=1;y<=6;y++){let v=`h${y}`;e.addToggleButton(v,{...y<=3?{icon:C[`h${y}`]}:{text:`H${y}`},tooltip:t(v),...rt[v]?{shortcut:rt[v]}:{},isActive:()=>a()===v,isEnabled:b=>b.can(v)||a()===v,onAction:b=>b.exec(a()===v?"paragraph":v)})}let c={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",pre:"codeBlock"},u=()=>{let y=n.options.blockFormats;return y?.length?y.flatMap(({label:v,block:b})=>{let E=c[b],_=l.find(N=>N.command===E);return _?[{..._,label:v}]:[]}):l};e.addMenuButton("blocks",{tooltip:t("blocks"),label:()=>u().find(y=>y.command===a())?.label??t(a()),minChars:11,isEnabled:y=>u().some(({command:v})=>y.can(v)),items:y=>u().filter(({command:v})=>y.isAllowed(v)).map(({command:v,style:b,label:E})=>({id:v,label:E??t(v),labelStyle:b,...rt[v]?{shortcut:rt[v]}:{},active:a()===v,onSelect:()=>y.exec(v)}))});let d="p,h1,h2,h3,h4,h5,h6",p=()=>[{title:t("styles.headings"),items:[1,2,3,4,5,6].map(y=>({title:t(`h${y}`),block:`h${y}`}))},{title:t("styles.inline"),items:[{title:t("bold"),inline:"strong"},{title:t("italic"),inline:"em"},{title:t("underline"),inline:"u"},{title:t("strike"),inline:"s"},{title:t("superscript"),inline:"sup"},{title:t("subscript"),inline:"sub"},{title:t("code"),inline:"code"}]},{title:t("styles.blocks"),items:[{title:t("paragraph"),block:"p"},{title:t("blockquote"),block:"blockquote"},{title:t("codeBlock"),block:"pre"}]},{title:t("styles.align"),items:["left","center","right","justify"].map(y=>({title:t(`align${y==="justify"?"Justify":y[0].toUpperCase()+y.slice(1)}`),selector:d,styles:{"text-align":y}}))}],f=y=>y.format??y,h=y=>{let v=y.format?n.formatter.get(y.format)?.[0]:y,b=[],E=v?.block;E&&/^h[1-6]$/.test(E)&&b.push("font-weight: 700"),(v?.inline==="strong"||v?.inline==="b")&&b.push("font-weight: 700"),(v?.inline==="em"||v?.inline==="i")&&b.push("font-style: italic"),v?.inline==="u"&&b.push("text-decoration: underline"),(v?.inline==="s"||v?.inline==="strike"||v?.inline==="del")&&b.push("text-decoration: line-through"),(v?.inline==="code"||E==="pre")&&b.push("font-family: ui-monospace, monospace");for(let _ of["color","background-color","font-family"]){let N=v?.styles?.[_];N&&/^[#\w\s,'"().%-]+$/.test(N)&&b.push(`${_}: ${N}`)}return b.join("; ")},m=y=>y.flatMap(v=>v.items?m(v.items):[v]),g=()=>{let y=n.options.styleFormats,v=y?n.options.styleFormatsMerge?[...p(),...y]:y:p(),b=e.getStyleFormats();return b.items.length?b.replace?[...b.items]:[...v,...b.items]:v};e.addMenuButton("styles",{tooltip:t("styles"),minChars:10,label:y=>m(g()).find(v=>y.formatter.match(f(v)))?.title??t("styles"),items:y=>{let v=[],b=(E,_)=>{E.forEach((N,$)=>{if(N.items){v.length&&v.push({type:"separator"}),v.push({type:"heading",label:N.title}),b(N.items,`${_}${$}-`);return}v.push({id:`style-${_}${$}`,label:N.title,labelStyle:h(N),active:y.formatter.match(f(N)),disabled:!y.formatter.canApply(f(N)),onSelect:()=>y.formatter.toggle(f(N))})})};return b(g(),""),v}});let k=n.options.fontFamilies??Yg;e.addMenuButton("fontfamily",{tooltip:t("fontFamily"),minChars:9,label:y=>{let v=kt(r(),"font_family");if(v)return k.find(E=>Gg(v,E.value))?.label??Jg(v);let b=Ug(y)?.fontFamily;return b?Jg(b):t("fontFamily")},items:y=>{let v=kt(y.view.state,"font_family");return[{id:"default",label:t("default"),active:v===null,onSelect:()=>y.exec(Ht("font_family",null))},{type:"separator"},...k.map(b=>({id:b.label,label:b.label,labelStyle:`font-family: ${b.value}`,active:Gg(v,b.value),onSelect:()=>y.exec(Ht("font_family",b.value))}))]}});let x=n.options.fontSizes??Xg;e.addMenuButton("fontsize",{tooltip:t("fontSize"),minChars:4,label:y=>kt(r(),"font_size")??Mw(Ug(y)?.fontSize??"")??"\u2014",items:y=>{let v=kt(y.view.state,"font_size");return[{id:"default",label:t("default"),active:v===null,onSelect:()=>y.exec(Ht("font_size",null))},{type:"separator"},...x.map(b=>({id:b,label:b,active:v===b,onSelect:()=>y.exec(Ht("font_size",b))}))]}});let M=n.options.lineHeights??Zg;e.addMenuButton("lineheight",{icon:C.lineHeight,tooltip:t("lineHeight"),isEnabled:y=>y.can(yo(null)),items:y=>{let v=Yu(y.view.state);return[{id:"default",label:t("default"),active:v===null,onSelect:()=>y.exec(yo(null))},...M.map(b=>({id:b,label:b,active:v===b,onSelect:()=>y.exec(yo(b))}))]}});let L=()=>Si(n.options.contentLangs,n.options.language);if(L().length){let y=v=>v.can(rr("en"));e.addMenuButton("language",{icon:C.language,tooltip:t("language"),isEnabled:y,items:v=>{let b=Mi(v.view.state);return[{id:"default",label:t("language.default"),active:b===null,onSelect:()=>v.exec(rr(null))},{type:"separator"},...L().map(({code:E,title:_})=>({id:E,label:_,active:b===E,onSelect:()=>v.exec(rr(E))}))]}}),e.addMenuItem("language",{text:`${t("language")}\u2026`,icon:C.language,isEnabled:y,onAction:v=>{Ew(v)}})}let O=(y,v,b,E)=>e.addPanelButton(y,{icon:b,tooltip:t(E),indicator:()=>kt(r(),v),render:(_,N)=>ms({colors:_.options.colors??hs,current:kt(_.view.state,v),label:t(E),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:$=>{N(),_.exec(Ht(v,$))}})});O("forecolor","color",C.textColor,"textColor"),O("backcolor","background",C.highlight,"backgroundColor");let B=[["superscript","superscript",C.superscript],["subscript","subscript",C.subscript],["code","code",C.code]];e.addMenuButton("moreformats",{icon:C.formatMore,tooltip:t("moreFormats"),isActive:y=>B.some(([,v])=>ar(y.view.state,n.schema.marks[v])),items:y=>[...B.filter(([v])=>y.isAllowed(v)).map(([v,b,E])=>({id:v,label:t(v),icon:E,checkbox:!0,active:ar(y.view.state,n.schema.marks[b]),disabled:!y.can(v),...rt[v]?{shortcut:rt[v]}:{},onSelect:()=>y.exec(v)})),{type:"separator"},{id:"clearFormatting",label:t("clearFormatting"),icon:C.clearFormatting,disabled:!y.can("clearFormatting"),shortcut:rt.clearFormatting,onSelect:()=>y.exec("clearFormatting")},{id:"pasteAsText",label:t("pasteAsText"),icon:C.pasteText,checkbox:!0,active:y.isPasteAsText(),onSelect:()=>{y.setPasteAsText(!y.isPasteAsText()),y.focus()}}]}),e.addToggleButton("pastetext",{icon:C.pasteText,tooltip:t("pasteAsText"),isActive:y=>y.isPasteAsText(),onAction:y=>{y.setPasteAsText(!y.isPasteAsText()),y.focus()}}),e.addButton("link",{icon:C.link,tooltip:t("link"),shortcut:"Mod-k",onAction:y=>_t(y),isActive:()=>!!Cn(r())}),e.addButton("unlink",{icon:C.unlink,tooltip:t("unlink"),onAction:y=>y.exec(dr()),isEnabled:y=>y.can(dr())}),e.addButton("image",{icon:C.image,tooltip:t("image"),onAction:y=>lo(y)});let J=()=>et(r())?.attrs.align??null,P=(y,v,b,E)=>e.addToggleButton(y,{icon:b,tooltip:t(E),isActive:()=>J()===v,onAction:_=>_.exec(ur({align:J()===v?null:v}))});P("imagealignleft","left",C.imageLeft,"image.alignLeft"),P("imagealigncenter","center",C.imageCenter,"image.alignCenter"),P("imagealignright","right",C.imageRight,"image.alignRight");let G=[["image.sizeSmall",.25],["image.sizeMedium",.5],["image.sizeLarge",.75],["image.sizeFull",1],["image.sizeOriginal",null]];e.addMenuButton("imagesize",{icon:C.resize,tooltip:t("image.size"),items:y=>G.map(([v,b])=>({id:v,label:t(v),onSelect:()=>su(y,b)}))}),e.addButton("imagealt",{icon:C.altText,tooltip:t("image.editAlt"),onAction:y=>lu(y)}),e.addToggleButton("imagecaption",{icon:C.imageCaption,tooltip:t("image.caption"),isActive:y=>ru(y.view.state),onAction:y=>y.exec(ou)}),e.addButton("imagedelete",{icon:C.trash,tooltip:t("image.delete"),onAction:y=>y.exec((v,b)=>{let E=et(v);return E?(b?.(v.tr.delete(E.pos,E.pos+E.node.nodeSize).scrollIntoView()),!0):!1})}),Kg(n),e.addButton("searchreplace",{icon:C.search,tooltip:t("search.title"),shortcut:"Mod-f",onAction:y=>y.openSearch()}),e.addToggleButton("fullscreen",{icon:C.fullscreen,tooltip:t("fullscreen"),shortcut:"Mod-Shift-f",isActive:y=>fs(y),onAction:y=>yr(y)}),e.addButton("preview",{icon:C.preview,tooltip:t("preview"),onAction:y=>Uu(y)}),e.addButton("code",{icon:C.sourceCode,tooltip:t("sourceCode"),onAction:y=>Ju(y)}),e.addButton("help",{icon:C.help,tooltip:t("help"),shortcut:"Alt-0",onAction:y=>go(y)}),e.addContextToolbar("image",{label:t("image.toolbar"),predicate:y=>!!et(y.view.state),items:"imagealignleft imagealigncenter imagealignright | imagesize imagealt imagecaption | imagedelete",anchor:y=>{let v=et(y.view.state);return(v?y.view.nodeDOM(v.pos):null)?.getBoundingClientRect()??null}})}async function Ew(n){let e=n.ui.t,t=Mi(n.view.state),r=Si(n.options.contentLangs,n.options.language);t&&!r.some(i=>i.code===t)&&r.unshift({code:t,title:wi(t,n.options.language)});let o=await n.ui.dialog({title:e("language"),submitLabel:e("dialog.save"),initialData:{lang:t??""},fields:[{type:"select",name:"lang",label:e("language.field"),options:[{value:"",label:e("language.default")},...r.map(({code:i,title:s})=>({value:i,label:s}))]}]});o&&n.exec(rr(String(o.lang??"")||null))}var nd={};q(nd,{addLinkNote:()=>Cw,linkBubblePlugin:()=>td});var Qu={};q(Qu,{Popover:()=>Nn,positionFloating:()=>vt,visibleArea:()=>bs});var gs=6,ys=8;function bs(){let n=window.visualViewport;return n?{left:n.offsetLeft,top:n.offsetTop,right:n.offsetLeft+n.width,bottom:n.offsetTop+n.height}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}}function vt(n,e,t){let r=bs(),o=n.offsetWidth,i=n.offsetHeight,s=r.bottom-e.bottom,l=e.top-r.top,c=t==="top-start"||t==="top-end"?l>=i+gs||l>s:s<i+gs&&l>s,u=c?e.top-i-gs:e.bottom+gs,d=Fn(n),f=t==="bottom"?e.left+e.width/2-o/2:(t==="bottom-end"||t==="top-end")!==d?e.right-o:e.left;f=Math.max(r.left+ys,Math.min(f,r.right-o-ys)),u=Math.max(r.top+ys,Math.min(u,r.bottom-i-ys)),n.style.left=`${Math.round(f)}px`,n.style.top=`${Math.round(u)}px`,n.dataset.side=c?"top":"bottom"}var bo=[],Nn=class{constructor(e){S(this,"el");S(this,"options");S(this,"closed",!1);S(this,"unlisten",[]);S(this,"reposition",()=>{if(this.closed)return;let{anchor:e,placement:t="bottom-start"}=this.options,r=typeof e=="function"?e():e.getBoundingClientRect();vt(this.el,r,t)});S(this,"focusWasInside",!1);S(this,"onKeyDown",(e,t)=>{e.key!=="Escape"||e.defaultPrevented||bo[bo.length-1]===this&&(t?.closest?.(".nova-dialog")||(e.preventDefault(),e.stopPropagation(),this.focusWasInside=this.el.contains(te(this.el)),this.close("escape")))});S(this,"onPointerDown",(e,t)=>{this.options.dismissOnOutside!==!1&&(this.el.contains(t)||this.options.ignore?.some(r=>r.contains(t))||this.close("outside"))});this.options=e,this.el=document.createElement("div"),this.el.className=`nova-popover ${e.className??""}`.trim(),this.el.append(e.content),e.host.append(this.el),this.reposition(),this.unlisten=[ut(this.el,"keydown",this.onKeyDown),ut(this.el,"pointerdown",this.onPointerDown)],bo.push(this),window.addEventListener("resize",this.reposition),window.addEventListener("scroll",this.reposition,!0)}get isOpen(){return!this.closed}close(e="api"){this.closed||(this.closed=!0,bo.splice(bo.indexOf(this),1),this.unlisten.forEach(t=>t()),window.removeEventListener("resize",this.reposition),window.removeEventListener("scroll",this.reposition,!0),this.el.remove(),this.options.onClose?.(e))}};var ed=new WeakMap;function Cw(n,e){let t=ed.get(n)??new Set;return ed.set(n,t),t.add(e),()=>t.delete(e)}function td(n){return new z({key:new X("nova-link-bubble"),view(e){let{t}=n.ui,r=w("a",{className:"nova-bubble-link",target:"_blank",rel:"noopener noreferrer"}),o=(h,m,g)=>{let k=w("button",{type:"button",className:"nova-btn","aria-label":m,"data-tooltip":m},ee(h));return k.addEventListener("click",g),n.ui.tooltip.attach(k),k},i=w("div",{className:"nova-bubble-row"},ee(C.externalLink),r,w("span",{className:"nova-bubble-sep"}),o(C.edit,t("link.edit"),()=>_t(n)),o(C.copy,t("link.copy"),()=>{navigator.clipboard?.writeText(r.href).then(()=>n.ui.notify({text:t("link.copied"),type:"success",timeout:2e3}))}),o(C.unlink,t("unlink"),()=>n.exec(dr()))),s=w("span",{className:"nova-bubble-note-text"}),l=w("button",{type:"button",className:"nova-button nova-bubble-note-action"}),a=w("div",{className:"nova-bubble-note",hidden:!0},s,l),c=w("div",{className:"nova-bubble nova-link-bubble",role:"toolbar","aria-label":t("link"),hidden:!0},i,a),u=null;l.addEventListener("click",()=>u?.()),c.addEventListener("mousedown",h=>{h.target.closest("button")&&h.preventDefault()}),n.ui.overlayHost.append(c);let d=()=>{c.hidden=!0},p=()=>{let h=e.state,m=Cn(h),g=e.hasFocus()||c.contains(te(c));if(!m||!g||!n.isEditable()||n.ui.activeDialog||!h.selection.empty){d();return}let k=An(h,ce(h).link,h.selection.from);if(!k)return d();r.textContent=m.href,r.title=m.href;let x=null;for(let B of ed.get(n)??[])if(x=B(m.href),x)break;a.hidden=!x,s.textContent=x?.text??"",l.hidden=!x?.action,l.textContent=x?.action?.label??"",u=x?.action?.run??null,Ie(m.href)?r.setAttribute("href",m.href):r.removeAttribute("href"),c.hidden=!1;let M=e.coordsAtPos(k.from),L=e.coordsAtPos(k.to),O=new DOMRect(M.left,M.top,Math.max(1,L.right-M.left),L.bottom-M.top);vt(c,O,"bottom-start")},f=h=>{c.contains(h.relatedTarget)||d()};return e.dom.addEventListener("blur",f),c.addEventListener("focusout",h=>{!c.contains(h.relatedTarget)&&!e.hasFocus()&&d()}),{update:p,destroy(){e.dom.removeEventListener("blur",f),c.remove()}}}})}var rd="undo redo | blocks | bold italic underline strikethrough moreformats | forecolor backcolor | link image table | bullist numlist | align lineheight outdent indent | fontfamily fontsize | blockquote codeblock hr | removeformat | searchreplace preview code fullscreen help";function od(n){let e=Array.isArray(n)?n:n.split(/\s+/),t=[[]];for(let r of e){let o=r.trim();o&&(o==="|"?t.push([]):t[t.length-1].push(o))}return t.filter(r=>r.length>0)}function id(n,e,t,r,{warnUnknown:o=!0}={}){let{ui:i}=n,s=i.t,l=new AbortController,{signal:a}=l;e.className=`nova-toolbar nova-toolbar-${r}`,e.setAttribute("role","toolbar"),e.setAttribute("aria-label",s("toolbar.label"));let c=[],u=[];for(let y of od(t)){let v=w("div",{className:"nova-tb-group",role:"group"});for(let b of y){if(!n.isAllowed(b))continue;let E=i.registry.get(b);if(!E){o&&console.warn(`[nova] Unknown toolbar item "${b}"`);continue}let _=ko(n,b,E);c.push(_),v.append(_.el)}v.childElementCount&&(u.push(v),e.append(v))}let d=r==="floating"||r==="sliding",p=r==="sliding",f=w("div",{className:p?"nova-toolbar nova-tb-strip":"nova-toolbar nova-tb-overflow",role:"group",id:je("nova-tb-more"),"aria-label":s("more"),hidden:p}),h=w("button",{type:"button",className:"nova-btn nova-tb-more","aria-label":s("more"),"aria-expanded":"false","data-tooltip":s("more"),hidden:!0,...p?{"aria-controls":f.id}:{"aria-haspopup":"true"}},ee(C.more));i.tooltip.attach(h);let m=null,g=()=>{m?.close(),m=null,p&&!f.hidden&&(f.hidden=!0,h.setAttribute("aria-expanded","false"))},k=i.onDialogOpen(()=>{p||g()});h.addEventListener("click",y=>{if(p){let b=f.hidden;f.hidden=!b,h.setAttribute("aria-expanded",String(b)),b&&y.detail===0&&f.querySelector("button:not(:disabled)")?.focus();return}if(m)return g();h.setAttribute("aria-expanded","true");let v=new Nn({host:i.overlayHost,anchor:h,placement:"bottom-end",content:f,className:"nova-tb-overflow-popover",ignore:[i.overlayHost,h],onClose:b=>{m=null,h.setAttribute("aria-expanded","false"),b==="escape"&&v.focusWasInside&&h.focus()}});m=v,y.detail===0&&f.querySelector("button:not(:disabled)")?.focus()}),d&&e.append(h),p&&e.after(f),r==="scrolling"&&e.addEventListener("focusin",y=>y.target.scrollIntoView?.({block:"nearest",inline:"nearest"}),{signal:a});let x=()=>{if(!d)return;for(let v of u)e.insertBefore(v,h);if(h.hidden=!0,e.scrollWidth<=e.clientWidth+1){g();return}h.hidden=!1;let y=u.length;for(;y>1&&e.scrollWidth>e.clientWidth+1;)y-=1,f.prepend(u[y]);f.childElementCount||(h.hidden=!0,g()),m?.reposition(),J()},M=-1,L=typeof ResizeObserver<"u"&&d?new ResizeObserver(()=>{e.clientWidth!==M&&(M=e.clientWidth,x())}):null;L?.observe(e);let O=()=>[...e.querySelectorAll("button")].filter(y=>!y.disabled&&!y.hidden),B=null,J=()=>{let y=O();(!B||!y.includes(B))&&(B=y[0]??null);for(let v of e.querySelectorAll("button"))v.tabIndex=v===B?0:-1};e.addEventListener("focusin",y=>{let v=y.target;v instanceof HTMLButtonElement&&e.contains(v)&&(B=v,J())},{signal:a}),e.addEventListener("keydown",y=>{let v=O(),b=v.indexOf(te(e));if(b<0)return;let E=null,_=Ne(y,e);if(_==="ArrowRight")E=b+1;else if(_==="ArrowLeft")E=b-1;else if(y.key==="Home")E=0;else if(y.key==="End")E=v.length-1;else if(y.key==="Escape"){y.preventDefault(),n.focus();return}E!==null&&(y.preventDefault(),v[(E+v.length)%v.length].focus())},{signal:a});let P=y=>{y.target.closest("button")&&y.preventDefault()};e.addEventListener("mousedown",P,{signal:a}),f.addEventListener("mousedown",P),f.addEventListener("keydown",y=>{if(y.key==="Escape"){p&&(y.preventDefault(),g(),h.focus());return}let v=[...f.querySelectorAll("button")].filter(_=>!_.disabled),b=v.indexOf(te(f));if(b<0)return;let E=Ne(y,f);E==="ArrowRight"||E==="ArrowDown"?(y.preventDefault(),v[(b+1)%v.length].focus()):(E==="ArrowLeft"||E==="ArrowUp")&&(y.preventDefault(),v[(b-1+v.length)%v.length].focus())});let G=()=>{for(let y of c)y.update();J()};return G(),x(),{update:G,focus:()=>{J(),B?.focus()},destroy:()=>{L?.disconnect(),k(),g(),l.abort(),e.replaceChildren(),p&&f.remove()}}}function ko(n,e,t){if(t.type==="split")return Aw(n,e,t);let{ui:r}=n,o=w("button",{type:"button",className:`nova-btn nova-tb-${t.type}`,"aria-label":t.tooltip,"data-tooltip":t.tooltip,"data-control":e,...t.shortcut?{"data-shortcut":t.shortcut}:{}});r.tooltip.attach(o),t.icon&&o.append(ee(t.icon));let i=t.type==="menu"&&(t.label||t.text)?w("span",{className:"nova-tb-label"}):null;i?(t.type==="menu"&&t.minChars&&(i.style.minWidth=`${t.minChars}ch`),o.append(i),o.classList.add("nova-tb-has-label")):!t.icon&&t.text&&o.append(t.text);let s=null;return t.type==="panel"&&t.indicator&&(s=w("span",{className:"nova-color-bar"}),o.append(s)),t.type!=="button"&&(o.setAttribute("aria-haspopup",t.type==="menu"?"menu":"dialog"),o.setAttribute("aria-expanded","false"),o.append(ee(C.chevronDown)),o.lastElementChild?.classList.add("nova-chevron")),o.addEventListener("click",a=>{if(t.type==="button"){t.onAction(n);return}if(o.getAttribute("aria-expanded")==="true"){r.closePopover();return}let c=a.detail===0,u=()=>r.closePopover(),d=t.type==="menu"?fo(t.items(n),u,t.tooltip):t.render(n,u);o.setAttribute("aria-expanded","true");let p=r.openPopover({anchor:o,content:d,ignore:[o],className:t.type==="menu"?"nova-popover-menu":"nova-popover-panel",onClose:f=>{o.setAttribute("aria-expanded","false"),f==="escape"&&p.focusWasInside&&o.focus()}});t.type==="menu"?ho(d):c&&d.querySelector("button, input")?.focus()}),t.type!=="button"&&o.addEventListener("keydown",a=>{a.key==="ArrowDown"&&o.getAttribute("aria-expanded")!=="true"&&(a.preventDefault(),o.click())}),{el:o,update:()=>{let a=n.isEditable();if(o.disabled=!a||(t.isEnabled?!t.isEnabled(n):!1),t.isActive){let c=t.isActive(n);o.classList.toggle("is-active",c),t.type==="button"&&o.setAttribute("aria-pressed",String(c))}if(i&&t.type==="menu"){let c=t.label?.(n)??t.text??"";i.textContent=c,o.setAttribute("aria-label",c&&c!==t.tooltip?`${c}, ${t.tooltip}`:t.tooltip??c)}if(s&&t.type==="panel"&&t.indicator){let c=t.indicator(n);s.style.background=c??"",s.classList.toggle("is-empty",!c)}}}}function Aw(n,e,t){let r=ko(n,e,{type:"button",tooltip:t.tooltip,onAction:t.onAction,...t.icon?{icon:t.icon}:{},...t.text?{text:t.text}:{},...t.shortcut?{shortcut:t.shortcut}:{},...t.isActive?{isActive:t.isActive}:{},...t.isEnabled?{isEnabled:t.isEnabled}:{}}),o=ko(n,`${e}-options`,{type:"menu",tooltip:`${t.tooltip}: ${n.ui.t("toolbar.options")}`,items:t.items,...t.isEnabled?{isEnabled:t.isEnabled}:{}});return o.el.classList.add("nova-tb-split-more"),{el:w("span",{className:"nova-tb-split"},r.el,o.el),update:()=>{r.update(),o.update()}}}function Qg(n){return new z({key:new X("nova-context-toolbar"),view(e){let t=w("div",{className:"nova-bubble nova-context-toolbar",role:"toolbar",hidden:!0});n.ui.overlayHost.append(t);let r=new Map,o=null,i=(k,x)=>{let M=r.get(k);if(M)return M;let L=w("div",{className:"nova-context-items"}),O=[];return od(x.items).forEach((B,J)=>{J>0&&L.append(w("span",{className:"nova-bubble-sep",role:"separator"}));for(let P of B){if(!n.isAllowed(P))continue;let G=n.ui.registry.get(P);if(!G)continue;let y=ko(n,P,G);O.push(y),L.append(y.el)}}),M={el:L,controls:O},r.set(k,M),M},s=()=>{t.hidden=!0,o=null},l=k=>{let{selection:x}=e.state;if((k.position??"node")==="node"&&x instanceof R)return e.nodeDOM(x.from)?.getBoundingClientRect()??null;let M=e.coordsAtPos(x.from),L=e.coordsAtPos(x.to);return new DOMRect(M.left,M.top,Math.max(1,L.right-M.left),L.bottom-M.top)},a=!1,c=k=>{k.pointerType==="mouse"&&k.button===0&&(a=!0)},u=()=>{a&&(a=!1,setTimeout(()=>h(e),0))};e.dom.addEventListener("pointerdown",c);let d=ut(t,"pointerup",u),p=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,f=()=>{let k=bs();t.style.left=`${Math.round(k.left)}px`,t.style.width=`${Math.round(k.right-k.left)}px`,t.style.top=`${Math.round(k.bottom-t.offsetHeight)}px`,t.dataset.side="docked"},h=k=>{if(!(k.hasFocus()||t.contains(te(t)))||!n.isEditable()||n.ui.activeDialog||a)return s();let M=n.ui.registry.getContextToolbars().find(([,y])=>y.predicate(n));if(!M)return s();let[L,O]=M,B=i(L,O);o!==L&&(t.replaceChildren(B.el),t.setAttribute("aria-label",O.label),o=L);for(let y of B.controls)y.update();let J=O.anchor?O.anchor(n):l(O);if(!J)return s();t.hidden=!1;let P=p&&O.position==="selection";if(t.classList.toggle("nova-context-toolbar-docked",P),P)return f();t.style.width="";let G=(typeof O.placement=="function"?O.placement(n):O.placement)??(O.position==="selection"?"bottom-start":"top-start");vt(t,J,G)};t.addEventListener("mousedown",k=>{k.target.closest("button")&&k.preventDefault()}),t.addEventListener("keydown",k=>{let x=[...t.querySelectorAll("button:not(:disabled)")],M=x.indexOf(te(t));if(k.key==="Escape")k.preventDefault(),n.focus();else if(M>=0&&(k.key==="ArrowRight"||k.key==="ArrowLeft")){k.preventDefault();let L=Ne(k,t)==="ArrowRight"?1:-1;x[(M+L+x.length)%x.length].focus()}});let m=k=>{let x=k.relatedTarget;!t.contains(x)&&!n.ui.overlayHost.contains(x)&&s()};e.dom.addEventListener("blur",m),t.addEventListener("focusout",k=>{let x=k.relatedTarget;!t.contains(x)&&!e.hasFocus()&&!n.ui.overlayHost.contains(x)&&s()});let g=()=>{t.hidden||h(e)};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),e.dom.addEventListener("load",g,!0),window.visualViewport?.addEventListener("resize",g),window.visualViewport?.addEventListener("scroll",g),{update:h,destroy(){e.dom.removeEventListener("blur",m),e.dom.removeEventListener("pointerdown",c),d(),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),e.dom.removeEventListener("load",g,!0),window.visualViewport?.removeEventListener("resize",g),window.visualViewport?.removeEventListener("scroll",g),t.remove()}}}})}function ey(n){let e=n.ui.overlayHost.querySelector(".nova-context-toolbar:not([hidden]) button:not(:disabled)");return e?.focus(),!!e}var ty=24,ks=class{constructor(e,t,r,o){S(this,"view",t);S(this,"getPos",r);S(this,"editor",o);S(this,"dom");S(this,"img");S(this,"node");S(this,"resizing",!1);this.node=e,this.dom=document.createElement("span"),this.dom.className="nova-image",this.img=document.createElement("img"),this.img.draggable=!1,this.dom.append(this.img);for(let i of["nw","ne","sw","se"]){let s=document.createElement("span");s.className=`nova-image-handle nova-image-handle-${i}`,s.dataset.corner=i,s.addEventListener("pointerdown",l=>this.startResize(l,i)),this.dom.append(s)}this.render()}render(){let{src:e,alt:t,title:r,width:o,height:i,align:s}=this.node.attrs,l=fe(e)?e:"";this.img.getAttribute("src")!==l&&this.img.setAttribute("src",l),this.setAttr("alt",t),this.setAttr("title",r),this.setAttr("class",Xe(this.node.attrs.class).class??null);let a=ne(o),c=ne(i);this.img.style.width=a?`${a}px`:"",this.img.style.aspectRatio=a&&c?`${a} / ${c}`:"",this.dom.dataset.align=s??""}setAttr(e,t){t?this.img.setAttribute(e,t):this.img.removeAttribute(e)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.resizing||this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return e.target.classList?.contains("nova-image-handle")??!1}ignoreMutation(){return!0}startResize(e,t){if(!this.editor.isEditable())return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r.setPointerCapture(e.pointerId);let o=this.img.getBoundingClientRect(),i=e.clientX,s=o.width,l=o.width>0?o.height/o.width:this.img.naturalHeight/(this.img.naturalWidth||1),a=Math.max(ty,this.view.dom.clientWidth-40),c=t==="ne"||t==="se"?1:-1,u=s;this.resizing=!0,this.dom.classList.add("is-resizing");let d=f=>{u=Math.round(Math.min(a,Math.max(ty,s+c*(f.clientX-i)))),this.img.style.width=`${u}px`,this.dom.dataset.size=`${u} \xD7 ${Math.round(u*l)}`},p=()=>{r.removeEventListener("pointermove",d),r.removeEventListener("pointerup",p),r.removeEventListener("pointercancel",p),this.resizing=!1,this.dom.classList.remove("is-resizing"),delete this.dom.dataset.size;let f=this.getPos();if(f===void 0||Math.abs(u-s)<1)return this.render();let h=this.view.state.tr.setNodeMarkup(f,void 0,{...this.node.attrs,width:u,height:Math.round(u*l)});h.setSelection(R.create(h.doc,f)),this.view.dispatch(h)};r.addEventListener("pointermove",d),r.addEventListener("pointerup",p),r.addEventListener("pointercancel",p)}};var ld={};q(ld,{FLAT_MARK_SELECTOR:()=>Nw,flatMarkViews:()=>sd});var Tw=["bold","italic","strike","code","subscript","superscript"],Nw="strong, em, s, code, sub, sup";function sd(n){let e={};for(let t of Tw){let r=n.marks[t]?.spec.toDOM;r&&(e[t]=(o,i,s)=>{let{dom:l,contentDOM:a}=qe.renderSpec(i.dom.ownerDocument,r(o,s));return l.setAttribute("role","none"),{dom:l,contentDOM:a??void 0}})}return e}var Ow=30;function Lw(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pw(n,e){let{selection:t}=n.state;if(!t.empty)return null;let r=t.$from;if(!r.parent.isTextblock||r.parent.type.spec.code)return null;let o=r.parent.textBetween(Math.max(0,r.parentOffset-Ow-1),r.parentOffset,"\0","\0");for(let[i,s]of e.ui.registry.getAutocompleters()){let l=new RegExp(`(?:^|\\s)${Lw(s.trigger)}([\\p{L}\\p{N}_-]*)$`,"u"),a=o.match(l);if(!a)continue;let c=a[1]??"";if(c.length<(s.minChars??0))continue;let u=r.parentOffset-c.length-s.trigger.length,d=u>0?r.parent.textBetween(u-1,u,"\0","\0"):"";if(!(d&&!/\s/.test(d)))return{name:i,spec:s,from:r.pos-c.length-s.trigger.length,to:r.pos,query:c}}return null}function ny(n){let e,t=[],r=0,o=null,i=null,s=0,l=je("nova-ac"),a=()=>!e.hidden,c=h=>{e.hidden=!0,o=null,t=[],h.dom.removeAttribute("aria-activedescendant"),h.dom.removeAttribute("aria-controls"),h.dom.removeAttribute("aria-expanded")},u=(h,m)=>{let g=t[m];if(!g||!o)return;let{spec:k,from:x,to:M}=o;c(h),k.onSelect(g,{from:x,to:M},n)},d=h=>{if(!o)return;let{spec:m}=o;if(e.replaceChildren(),e.setAttribute("aria-label",m.label),!t.length){if(!m.emptyText)return c(h);e.append(w("div",{className:"nova-ac-empty"},m.emptyText))}t.forEach((k,x)=>{let M=w("div",{id:`${l}-${x}`,className:"nova-menu-item nova-ac-item",role:"option","aria-selected":String(x===r)},k.icon?ee(k.icon):null,w("span",{className:"nova-menu-label"},k.label),k.shortcut?w("kbd",{className:"nova-menu-shortcut"},At(k.shortcut)):k.detail?w("span",{className:"nova-menu-shortcut"},k.detail):null);M.addEventListener("mousedown",L=>{L.preventDefault(),u(h,x)}),M.addEventListener("mousemove",()=>{r!==x&&p(h,x)}),e.append(M)}),e.hidden=!1,h.dom.setAttribute("aria-controls",l),p(h,Math.min(r,Math.max(0,t.length-1)));let g=h.coordsAtPos(o.from);vt(e,new DOMRect(g.left,g.top,1,g.bottom-g.top),"bottom-start")},p=(h,m)=>{r=m,e.querySelectorAll('[role="option"]').forEach((k,x)=>k.setAttribute("aria-selected",String(x===m)));let g=e.querySelector(`#${l}-${m}`);g&&(h.dom.setAttribute("aria-activedescendant",g.id),g.scrollIntoView?.({block:"nearest"}))},f=h=>{let m=n.isEditable()&&h.hasFocus()?Pw(h,n):null;if(!m||m.from===i){m||(i=null),(a()||o)&&c(h);return}let g=!o||o.query!==m.query||o.from!==m.from;if(o=m,!g&&a())return d(h);let k=++s;Promise.resolve(m.spec.fetch(m.query,n)).then(x=>{k!==s||!o||(t=x.slice(0,m.spec.maxResults??10),r=0,d(h))})};return new z({key:new X("nova-autocompleter"),view(h){e=w("div",{className:"nova-popover nova-ac",id:l,role:"listbox",hidden:!0}),n.ui.overlayHost.append(e),h.dom.setAttribute("aria-autocomplete","list");let m=()=>c(h);return h.dom.addEventListener("blur",m),{update:g=>f(g),destroy(){h.dom.removeEventListener("blur",m),e.remove()}}},props:{handleKeyDown(h,m){if(!a()||!o)return!1;let g=t.length;switch(m.key){case"ArrowDown":return g&&p(h,(r+1)%g),!0;case"ArrowUp":return g&&p(h,(r-1+g)%g),!0;case"Enter":case"Tab":return g?(u(h,r),!0):!1;case"Escape":return i=o.from,c(h),!0;default:return!1}}}})}var Bt=n=>e=>e.exec(n),Rw=[{name:"paragraph",label:"paragraph",icon:C.paragraph,keywords:["text","p","paragraph"],run:Bt("paragraph")},{name:"h1",label:"h1",icon:C.h1,keywords:["h1","heading","title"],shortcut:"Mod-Alt-1",run:Bt("h1")},{name:"h2",label:"h2",icon:C.h2,keywords:["h2","heading","subtitle"],shortcut:"Mod-Alt-2",run:Bt("h2")},{name:"h3",label:"h3",icon:C.h3,keywords:["h3","heading"],shortcut:"Mod-Alt-3",run:Bt("h3")},{name:"bullist",label:"bulletList",icon:C.bulletList,keywords:["ul","list","bullet"],shortcut:"Mod-Shift-8",run:Bt("bulletList")},{name:"numlist",label:"orderedList",icon:C.orderedList,keywords:["ol","list","numbered"],shortcut:"Mod-Shift-7",run:Bt("orderedList")},{name:"blockquote",label:"blockquote",icon:C.blockquote,keywords:["quote","blockquote","citation"],run:Bt("blockquote")},{name:"codeblock",label:"codeBlock",icon:C.codeBlock,keywords:["code","pre","snippet"],run:Bt("codeBlock")},{name:"hr",label:"horizontalRule",icon:C.horizontalRule,keywords:["hr","divider","line","separator"],run:Bt("horizontalRule")},{name:"table",label:"table",icon:C.table,keywords:["table","grid"],run:n=>n.exec(It(3,3))},{name:"image",label:"image",icon:C.image,keywords:["image","picture","photo","img"],run:n=>lo(n)},{name:"link",label:"link",icon:C.link,keywords:["link","url","href"],shortcut:"Mod-k",run:n=>_t(n)}];function Dw(n,e,t){let r=e.toLowerCase();if(!r)return n;let o=[];return n.forEach((i,s)=>{let l=t(i.label).toLowerCase(),a=[l,...l.split(/\s+/),...i.keywords],c=-1;l.startsWith(r)?c=3:a.some(u=>u.startsWith(r))?c=2:a.some(u=>u.includes(r))&&(c=1),c>0&&o.push([c,s,i])}),o.sort((i,s)=>s[0]-i[0]||i[1]-s[1]).map(([,,i])=>i)}function ry(n,e=[]){let{t}=n.ui,r=[...Rw,...e].filter(o=>n.isAllowed(o.name));n.ui.registry.addAutocompleter("slashcommands",{trigger:"/",label:t("slash.label"),emptyText:t("slash.empty"),fetch:o=>Dw(r,o,t).map(i=>({value:i.name,label:t(i.label),icon:i.icon,...i.shortcut?{shortcut:i.shortcut}:{}})),onSelect:(o,i,s)=>{let l=r.find(a=>a.name===o.value);l&&(s.view.dispatch(s.view.state.tr.delete(i.from,i.to)),l.run(s))}})}var vs=class{constructor(e,t){S(this,"region");S(this,"closeLabel");this.closeLabel=t,this.region=w("div",{className:"nova-notifications","aria-live":"polite"}),e.append(this.region)}open(e){let t=e.type??"info",r=e.timeout??(t==="error"?0:4e3),o=w("span",{className:"nova-notification-text"},e.text),i=w("button",{type:"button",className:"nova-btn","aria-label":this.closeLabel},ee(C.close)),s=(e.actions??[]).map(p=>w("button",{type:"button",className:"nova-btn nova-notification-action"},p.label)),l=w("div",{className:`nova-notification nova-notification-${t}`,role:t==="error"?"alert":"status"},o,...s,i);this.region.append(l);let a=null,c=!1,u=()=>{c||(c=!0,a&&clearTimeout(a),l.remove())},d=()=>{c||(u(),e.onClose?.())};return s.forEach((p,f)=>p.addEventListener("click",()=>{u(),e.actions[f].onAction()})),i.addEventListener("click",d),r>0&&(a=setTimeout(d,r)),s[0]?.focus({preventScroll:!0}),{close:u,setText:p=>o.textContent=p}}destroy(){this.region.remove()}};var _w=C.sidebar,xs=class{constructor(){S(this,"controls",new Map);S(this,"menuItems",new Map);S(this,"styleFormats",{items:[],replace:!1});S(this,"contextToolbars",new Map);S(this,"autocompleters",new Map);S(this,"sidebars",new Map);S(this,"views",new Map)}addButton(e,t){this.controls.set(e.toLowerCase(),{type:"button",...t})}addToggleButton(e,t){this.addButton(e,t)}addMenuButton(e,t){this.controls.set(e.toLowerCase(),{type:"menu",...t})}addPanelButton(e,t){this.controls.set(e.toLowerCase(),{type:"panel",...t})}addSplitButton(e,t){this.controls.set(e.toLowerCase(),{type:"split",...t})}addStyleFormats(e,{replace:t=!1}={}){this.styleFormats={items:[...this.styleFormats.items,...e],replace:this.styleFormats.replace||t}}getStyleFormats(){return this.styleFormats}addMenuItem(e,t){this.menuItems.set(e.toLowerCase(),t)}addToggleMenuItem(e,t){this.addMenuItem(e,t)}getMenuItem(e){let t=this.menuItems.get(e.toLowerCase());if(t)return t;let r=this.get(e);if(!(r?.type!=="button"&&r?.type!=="split"))return{text:r.tooltip,...r.icon?{icon:r.icon}:{},...r.shortcut?{shortcut:r.shortcut}:{},onAction:r.onAction,...r.isActive?{isActive:r.isActive}:{},...r.isEnabled?{isEnabled:r.isEnabled}:{}}}addSidebar(e,t){this.sidebars.set(e,t),!(t.button===!1||this.has(e))&&this.addToggleButton(e,{tooltip:t.tooltip??t.title,icon:t.icon??_w,isActive:r=>r.ui.sidebar.isOpen(e),onAction:r=>{r.ui.sidebar.toggle(e)}})}getSidebar(e){return this.sidebars.get(e)}addView(e,t){this.views.set(e,t)}getView(e){return this.views.get(e)}addAutocompleter(e,t){this.autocompleters.set(e.toLowerCase(),t)}getAutocompleters(){return[...this.autocompleters]}addContextToolbar(e,t){this.contextToolbars.set(e.toLowerCase(),t)}getContextToolbars(){return[...this.contextToolbars].sort((e,t)=>(t[1].priority??0)-(e[1].priority??0))}get(e){return this.controls.get(e.toLowerCase())}has(e){return this.controls.has(e.toLowerCase())}names(){return[...this.controls.keys()]}};var ws=class{constructor(e){S(this,"editor",e);S(this,"current",null);S(this,"mounted",new Map);S(this,"column",null);S(this,"opening",Promise.resolve());S(this,"destroyed",!1)}get active(){return this.current}isOpen(e){return this.current===e}async show(e,t={}){let r=this.editor.ui.registry.getSidebar(e);if(!r){console.warn(`[nova] sidebar "${e}" is not registered`);return}if(this.current!==e){this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.current=e;let o=this.mount(e,r);this.opening=o.ready.then(i=>{if(!i||this.current!==e||this.destroyed){this.current===e&&(this.current=null);return}o.el.hidden=!1,this.editor.root.classList.add("nova-sidebar-open"),r.onShow?.(this.editor),this.editor.updateUI()})}if(await this.opening,t.focus&&this.current===e){let o=this.mounted.get(e).el;(o.querySelector($t)??o).focus()}}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(te(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-sidebar-open"),this.editor.ui.registry.getSidebar(t)?.onHide?.(this.editor),this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e,t={}){return this.current===e?(this.hide(),Promise.resolve()):this.show(e,t)}destroy(){this.destroyed=!0,this.mounted.forEach(e=>e.cleanup?.()),this.mounted.clear()}host(){if(this.column)return this.column;let e=this.editor.view.dom.parentElement,t=w("div",{className:"nova-body"});return e.before(t),t.append(e),this.column=t,t}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=je("nova-sidebar-title"),i=w("div",{className:"nova-sidebar-body"}),s=w("button",{type:"button",className:"nova-btn nova-sidebar-close","aria-label":this.editor.ui.t("dialog.close"),onClick:()=>this.hide()},ee(C.close)),l=t.header===!1?null:w("div",{className:"nova-sidebar-head"},w("h2",{id:o,className:"nova-sidebar-title"},t.title),s),a=w("div",{className:`nova-sidebar${l?"":" nova-sidebar-bare"}`,hidden:!0,"data-sidebar":e,...this.editor.options.language?{lang:this.editor.options.language}:{},...l?{role:"complementary","aria-labelledby":o}:{},onKeydown:(u=>{u.key!=="Escape"||u.defaultPrevented||(u.preventDefault(),this.hide())})},l,i);this.host().append(a);let c={el:a,ready:Promise.resolve(!1)};return c.ready=(async()=>{try{let u=await t.render(i,this.editor);return typeof u=="function"&&(c.cleanup=u),!0}catch(u){return console.error(`[nova] sidebar "${e}" failed to render`,u),a.remove(),this.mounted.delete(e),!1}})(),this.mounted.set(e,c),c}};var oy=".nova-editor.nova-view-open>:not(.nova-view):not(.nova-overlays){display:none}.nova-view{display:flex;flex:1 1 auto;flex-direction:column;min-height:240px;background:var(--nova-surface);color:var(--nova-fg)}.nova-view[hidden]{display:none}.nova-view:focus{outline:none}.nova-view-head{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid var(--nova-border);background:var(--nova-toolbar-bg)}.nova-view-title{margin:0;font-size:15px;font-weight:600}.nova-view-buttons{display:flex;gap:8px;margin-inline-start:auto}.nova-view-body{flex:1;min-height:0;padding:12px;overflow:auto}";var Ss=class{constructor(e){S(this,"editor",e);S(this,"current",null);S(this,"mounted",new Map)}get active(){return this.current}isOpen(e){return this.current===e}show(e){let t=this.editor.ui.registry.getView(e);if(!t){console.warn(`[nova] view "${e}" is not registered`);return}if(this.current===e)return;this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.editor.ui.addStyles("nova-editor-views",oy);let r=this.mount(e,t);this.current=e,r.el.hidden=!1,this.editor.root.classList.add("nova-view-open");try{t.onShow?.(r.api)}catch(o){console.error(`[nova] view "${e}" failed to show`,o)}(r.el.querySelector($t)??r.el).focus(),this.editor.updateUI()}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(te(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-view-open");try{this.editor.ui.registry.getView(t)?.onHide?.(r.api)}catch(i){console.error(`[nova] view "${t}" failed to hide`,i)}this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e){this.current===e?this.hide():this.show(e)}destroy(){this.mounted.forEach(({el:e})=>e.remove()),this.mounted.clear(),this.current=null}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=w("div",{className:"nova-view-body"}),i=(t.buttons??[]).map(a=>w("button",{type:"button",className:a.buttonType==="primary"?"nova-button nova-button-primary":"nova-button",onClick:()=>{try{a.onAction(this.editor)}catch(c){console.error(`[nova] a button of view "${e}" failed`,c)}}},a.text)),s=w("section",{className:"nova-view",hidden:!0,tabindex:"-1","data-view":e,"aria-label":t.title??e,...this.editor.options.language?{lang:this.editor.options.language}:{},onKeydown:(a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),this.hide())})},w("div",{className:"nova-view-head"},t.title?w("h2",{className:"nova-view-title"},t.title):null,w("div",{className:"nova-view-buttons"},...i)),o);this.editor.root.append(s);let l={el:s,api:{getContainer:()=>o}};return this.mounted.set(e,l),l}};var Hw=450,Bw=150,Ms=class{constructor(e){S(this,"el");S(this,"timer",null);S(this,"target",null);S(this,"offEscape",null);this.el=w("div",{className:"nova-tooltip",role:"tooltip",hidden:!0}),this.el.addEventListener("pointerenter",()=>this.clearTimer()),this.el.addEventListener("pointerleave",()=>this.hide()),this.el.addEventListener("pointerdown",()=>this.hide()),e.append(this.el)}attach(e){e.addEventListener("pointerenter",t=>{t.pointerType==="mouse"&&this.schedule(e)}),e.addEventListener("pointerleave",()=>{this.clearTimer(),this.el.hidden||(this.timer=setTimeout(()=>this.hide(),Bw))}),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&this.show(e)}),e.addEventListener("blur",()=>this.hide()),e.addEventListener("pointerdown",()=>this.hide())}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>this.show(e),Hw)}show(e){this.clearTimer();let t=e.dataset.tooltip;if(!t||e.getAttribute("aria-expanded")==="true")return;this.target=e;let r=e.dataset.shortcut;this.el.replaceChildren(w("span",{},t)),r&&this.el.append(w("kbd",{},At(r))),this.el.hidden=!1,vt(this.el,e.getBoundingClientRect(),"bottom"),this.offEscape??(this.offEscape=ut(this.el,"keydown",o=>{o.key!=="Escape"||this.el.hidden||(o.preventDefault(),o.stopPropagation(),this.hide())}))}hide(){this.clearTimer(),this.el.hidden=!0,this.target=null,this.offEscape?.(),this.offEscape=null}get current(){return this.target}destroy(){this.hide(),this.el.remove()}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}};var iy=new WeakMap,Es=class{constructor(e,t,r,o){S(this,"focusEditor",r);S(this,"registry",new xs);S(this,"t");S(this,"overlayHost");S(this,"tooltip");S(this,"sidebar");S(this,"view");S(this,"notifications");S(this,"popover",null);S(this,"currentDialog",null);S(this,"liveRegion");S(this,"announceTimer");S(this,"rootEl");S(this,"dialogListeners",new Set);this.t=t,this.rootEl=e,this.overlayHost=w("div",{className:"nova-overlays"}),e.append(this.overlayHost),this.tooltip=new Ms(this.overlayHost),this.notifications=new vs(e,t("dialog.close")),this.sidebar=new ws(o),this.view=new Ss(o),this.liveRegion=w("div",{className:"nova-visually-hidden nova-announcer",role:"status","aria-live":"polite","aria-atomic":"true"}),e.append(this.liveRegion)}announce(e){let t=this.liveRegion;t.textContent="",clearTimeout(this.announceTimer),this.announceTimer=setTimeout(()=>{t.textContent=e},50)}addStyles(e,t){let r=this.rootEl.getRootNode(),o=iy.get(r);if(o||iy.set(r,o=new Set),o.has(e))return;if(o.add(e),"adoptedStyleSheets"in r&&typeof CSSStyleSheet<"u")try{let s=new CSSStyleSheet;s.replaceSync(t),r.adoptedStyleSheets=[...r.adoptedStyleSheets,s];return}catch{}let i=document.createElement("style");i.dataset.novaStyles=e,i.textContent=t,(r.head??r).append(i)}async dialog(e){let{openFormDialog:t,formDialogCss:r}=await import(__novaChunk("tinymce-chunks/form-dialog-9eb62199.js") );return this.addStyles("nova-form-dialog",r),t(e,this.t,o=>this.openDialog(o))}openPopover(e){this.closePopover(),this.tooltip.hide();let t=new Nn({...e,host:this.overlayHost,onClose:r=>{this.popover===t&&(this.popover=null),e.onClose?.(r)}});return this.popover=t,t}closePopover(){this.popover?.close("api"),this.popover=null}get activePopover(){return this.popover}onDialogOpen(e){return this.dialogListeners.add(e),()=>this.dialogListeners.delete(e)}closeOverlays(){this.closePopover(),this.dialogListeners.forEach(e=>e())}openDialog(e){this.closePopover(),this.dialogListeners.forEach(r=>r()),this.currentDialog?.close();let t=Gc({cancelLabel:this.t("dialog.cancel"),closeLabel:this.t("dialog.close"),...e,host:this.overlayHost,returnFocus:this.focusEditor,onClose:()=>{this.currentDialog===t&&(this.currentDialog=null),e.onClose?.()}});return this.currentDialog=t,t}get activeDialog(){return this.currentDialog}notify(e){return this.notifications.open(typeof e=="string"?{text:e}:e)}destroy(){this.sidebar.destroy(),this.view.destroy(),this.closePopover(),this.currentDialog?.close(),this.tooltip.destroy(),this.notifications.destroy(),this.overlayHost.remove(),clearTimeout(this.announceTimer),this.liveRegion.remove()}};var Fw={paragraph:()=>"p",heading:n=>`h${n.attrs.level}`,blockquote:()=>"blockquote",code_block:()=>"pre",bullet_list:()=>"ul",ordered_list:()=>"ol",list_item:()=>"li",table:()=>"table",table_row:()=>"tr",table_cell:()=>"td",table_header:()=>"th"},zw={bold:"strong",italic:"em",underline:"u",strike:"s",code:"code",link:"a",subscript:"sub",superscript:"sup"},ly=String.raw`\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}`,sy=String.raw`(?:(?![${ly}])[\p{L}\p{N}])`,$w=new RegExp(`[${ly}]|${sy}+(?:['\u2019-]${sy}+)*`,"gu");function Vw(n){return n.match($w)?.length??0}function ay(n,e){e.className="nova-statusbar";let t=w("div",{className:"nova-path","aria-hidden":"true"}),r=w("div",{className:"nova-wordcount","aria-live":"off"});e.append(t,r);let o=n.options.resize,i=o?Ww(n,e,o==="both"):null,s=null,l=()=>{let c=n.view.state.doc;r.textContent=n.ui.t("status.words",{count:Vw(c.textBetween(0,c.content.size," "," "))})},a=c=>{let{$from:u}=n.view.state.selection,d=[];for(let f=1;f<=u.depth;f++){let h=u.node(f),m=Fw[h.type.name]?.(h);m&&d.push(m)}n.view.state.selection.node?.type.name==="image"&&d.push("img");for(let f of u.marks()){let h=zw[f.type.name];h&&d.push(h)}t.replaceChildren(...d.flatMap((f,h)=>[...h?[" \u203A "]:[],w("span",{className:"nova-path-item"},f)])),c&&(s&&clearTimeout(s),s=setTimeout(l,250))};return l(),a(!1),{update:a,destroy:()=>{s&&clearTimeout(s),i?.(),e.replaceChildren()}}}var ad=100,qw=200,Cs=20,jw=4e3;function Ww(n,e,t){let r=n.root,o=w("div",{className:"nova-resize-handle",role:"separator",tabIndex:0,"aria-orientation":"horizontal","aria-label":n.ui.t("status.resize"),"aria-valuemin":String(ad)});o.append(ee(t?C.resizeHandleBoth:C.resizeHandle)),r.dataset.resize=t?"both":"vertical",e.append(o);let i=()=>{let p=Math.max(ad,r.offsetHeight);o.setAttribute("aria-valuenow",String(p)),o.setAttribute("aria-valuemax",String(Math.max(jw,p)))};i(),o.addEventListener("focus",i);let s=(p,f)=>{if(r.style.boxSizing="border-box",r.style.height=`${Math.max(ad,Math.round(p))}px`,t&&f!==void 0){let h=r.parentElement?.clientWidth||1/0;r.style.width=`${Math.min(h,Math.max(qw,Math.round(f)))}px`}i()},l=null,a=p=>{n.isDisabled()||(p.preventDefault(),o.setPointerCapture(p.pointerId),l={x:p.clientX,y:p.clientY,height:r.offsetHeight,width:r.offsetWidth})},c=p=>{if(!l)return;let f=(p.clientX-l.x)*(Fn(r)?-1:1);s(l.height+p.clientY-l.y,l.width+f)},u=p=>{l&&(l=null,o.hasPointerCapture(p.pointerId)&&o.releasePointerCapture(p.pointerId))},d=p=>{let f=p.key==="ArrowDown"?Cs:p.key==="ArrowUp"?-Cs:0,h=Ne(p,r),m=t?h==="ArrowRight"?Cs:h==="ArrowLeft"?-Cs:0:0;!m&&!f||(p.preventDefault(),s(r.offsetHeight+f,r.offsetWidth+m))};return o.addEventListener("pointerdown",a),o.addEventListener("pointermove",c),o.addEventListener("pointerup",u),o.addEventListener("pointercancel",u),o.addEventListener("keydown",d),()=>{o.remove(),delete r.dataset.resize}}var ud="nova:remote",As="nova:api",Kw=new Set("P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE".split(" "));function cy(n){return(e,t)=>{if(!t)return!0;let r=document.createElement("template");r.innerHTML=n;let o=document.createElement("div");o.append(r.content);let i=gr(e.schema),l=[...o.children].some(p=>Kw.has(p.tagName))?new D(i.parse(o).content,0,0):i.parseSlice(o),a=!1;l.content.descendants(p=>(p.type.spec.tableRole==="table"&&(a=!0),!a));let{$from:c}=e.selection,u=0;for(let p=1;p<=c.depth;p++)if(c.node(p).type.spec.tableRole==="table"){u=p;break}let d=a&&u?e.tr.insert(c.after(u),l.content):e.tr.replaceSelection(l);return t(d.setMeta(As,!0).scrollIntoView()),!0}}var Uw=0,uy=new Set,vo=class{constructor(e){S(this,"view");S(this,"root");S(this,"ui");S(this,"options");S(this,"listeners",new Map);S(this,"ready");S(this,"toolbar");S(this,"toolbarHost");S(this,"menubar");S(this,"mode");S(this,"direction");S(this,"pluginsByName",new Map);S(this,"commandOverrides",new Map);S(this,"transactionTransforms",[]);S(this,"cleanups",[]);S(this,"contentRules");S(this,"schema");S(this,"formatter");S(this,"selection");S(this,"statusbar");S(this,"searchBar",null);S(this,"searchBarLoad",null);S(this,"contentHost");S(this,"destroyed",!1);S(this,"editable");S(this,"disabled");S(this,"pasteAsText");e=sg(e),this.options=e,this.root=document.createElement("div"),this.root.className="nova-editor";let t=e.direction??(us(e.language)?"rtl":void 0);t&&(this.root.dir=t),this.direction=t??(e.element.closest("[dir]")?.getAttribute("dir")==="rtl"?"rtl":"ltr"),e.element.appendChild(this.root);let r=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div");o.className="nova-content";let s=document.createElement("div");s.className="nova-header";let l=document.createElement("div");s.append(l,r),this.root.append(s,o,i),this.toolbarHost=r;let a=Number(e.toolbarStickyOffset);Number.isFinite(a)&&a>0&&this.root.style.setProperty("--nova-sticky-offset",`${Math.min(a,1e3)}px`),this.mode=e.mode??"classic",this.root.classList.add(`nova-mode-${this.mode}`);let c=this.mode==="distraction-free";if(this.mode!=="classic"&&(this.root.addEventListener("focusin",()=>this.root.classList.add("is-focused")),this.root.addEventListener("focusout",()=>{setTimeout(()=>{this.root.contains(te(this.root))||this.root.classList.remove("is-focused")},0)})),this.ui=new Es(this.root,Rp(e.language,e.translations),()=>this.focus(),this),e.language)for(let N of[s,i,this.ui.overlayHost])N.lang=e.language;this.root.style.setProperty("--nova-caption-placeholder",JSON.stringify(this.ui.t("image.captionPlaceholder")));let u=Ke({"Mod-k":()=>(_t(this),!0),"Alt-F9":()=>this.menubar?(this.menubar.focus(),!0):!1,"Alt-F10":()=>this.toolbar?(this.toolbar.focus(),!0):!1,"Ctrl-F9":()=>ey(this),"Mod-f":()=>(this.openSearch(),!0),"Mod-Shift-f":()=>(yr(this),!0),"Alt-0":()=>(go(this),!0),Escape:()=>this.searchBar?.isOpen()?(this.searchBar.close(),!0):!1}),d=[...e.plugins??[]];c&&!d.includes("quickbars")&&d.push("quickbars");let p=vr(d);p.errors.forEach(N=>xt(N));let{ordered:f,errors:h}=Ln(p.plugins);h.forEach(N=>xt(N));for(let N of f)N.load&&p.loaders.push(N.load);let m=f.flatMap(N=>this.collectPmPlugins(N)),g=e.validElements!==void 0||e.invalidElements!==void 0||e.validStyles!==void 0;this.contentRules=g?new fr(e):null;let{schema:k,allowedClasses:x}=ds(e,f,this.direction,this);this.schema=k,this.formatter=new Ji(this,x),this.selection=qg(this);for(let[N,$]of Object.entries(e.formats??{}))this.formatter.register(N,$);f.forEach(N=>this.registerCommands(N));let M=kr(f,this);M&&Tn.set(this,M);let L=cd(this.schema,e.content??"",M),O=Wu(),B=bm(s,o),J=[ny(this),...e.textPatterns===!1?[]:Array.isArray(e.textPatterns)||e.textPatternsLookup?[bg(this,Array.isArray(e.textPatterns)?e.textPatterns:[],e.textPatternsLookup)]:[fg(N=>this.isAllowed(N),this.schema),hg(N=>this.isAllowed(N),this.schema)],u,O,...kg(N=>this.resolveCommand(N)),tg(this.ui.t,N=>this.ui.announce(N)),...f.some(N=>N.replaceHistory)?[]:[Lc()],Wm({color:"var(--nova-accent)",width:2}),Um(),nu(this),tu(this),Sg(this),td(this),Qg(this),...this.contentRules?[Ag(this.contentRules)]:[],Qm(),Vg(),B.plugin,...m,...e.prosemirrorPlugins??[]];Ru(J);let P=un.create({doc:this.contentRules?this.contentRules.normalizeDoc(L):L,plugins:J});this.editable=e.editable??!0,this.disabled=e.disabled??!1,this.pasteAsText=e.pasteAsText??!1;let G=this.handleTransaction.bind(this),y=Fe(e.contentLanguage);this.view=new Zn(o,{state:P,editable:()=>this.isEditable(),...B.props,attributes:{class:"nova-prosemirror",role:"textbox","aria-multiline":"true","aria-label":this.ui.t("editor.label"),...y?{lang:y}:{},...e.placeholder?{"data-placeholder":e.placeholder,"aria-placeholder":e.placeholder}:{}},dispatchTransaction:function(N){G(N,this)},clipboardParser:gr(this.schema),nodeViews:{image:(N,$,K)=>new ks(N,$,K,this)},markViews:sd(this.schema),handleDOMEvents:{focus:(N,$)=>(this.emit("focus",{event:$}),!1),blur:(N,$)=>(this.emit("blur",{event:$}),!1)},handleKeyDown:(N,$)=>(this.emit("keydown",{event:$}),$.defaultPrevented)}),this.root.classList.toggle("nova-readonly",!this.editable),this.applyDisabled(),Xu(this),Fg(this),e.slashCommands!==!1&&ry(this,e.slashCommands??[]),f.forEach(N=>this.setupPlugin(N)),e.setup?.(this);let v=e.menubar===!0?Hg:typeof e.menubar=="string"?e.menubar:null;this.menubar=v?Bg(this,l,v,{...Ig,...e.menu}):null,this.menubar||l.remove(),this.toolbar=e.toolbar===!1||c&&e.toolbar===void 0?null:id(this,r,this.toolbarConfig(),e.toolbarMode??"floating",{warnUnknown:p.loaders.length===0}),this.toolbar||r.remove(),!this.toolbar&&!this.menubar&&s.remove(),this.contentHost=o;let b=this.loadSearchBar(),E=e.statusbar??this.mode==="classic";this.statusbar=E?ay(this,i):null,this.statusbar||i.remove(),e.onChange&&this.on("change",e.onChange),this.updatePlaceholder();let _=this.applyContentStyles();this.ready=Promise.all([p.loaders.length?this.loadLazyPlugins(p.loaders):void 0,_,bu(),this.installTables(O),b]).then(()=>{this.destroyed||this.emit("init")})}async installTables(e){let t=await ku();if(!t||this.destroyed)return;let{state:r}=this.view,o=r.plugins.indexOf(e),i=[...r.plugins];i.splice(o<0?i.length:o,0,...t.tablePlugins()),Du(this.view,i),this.updateUI()}applyContentStyles(){let{contentStyle:e,contentCss:t}=this.options,r=t===void 0?[]:Array.isArray(t)?t:[t];if(!e&&!r.length)return;let o=`nova-cs-${++Uw}`;this.root.classList.add(o);let i=`.nova-editor.${o} .nova-prosemirror`,s=r.map(()=>""),l=null,a=()=>{this.destroyed||(l?.(),l=jc(this.root,Qi([...s,e??""].join(`
44
+ `),i)))};if(this.cleanups.push(()=>l?.()),a(),!!r.length)return Promise.all(r.map((c,u)=>es(c).then(d=>{s[u]=d},d=>console.warn(`[nova] contentCss: could not load ${c}`,d)))).then(a)}isAllowed(e){return this.contentRules?.isAllowed(e)??!0}hasPlugin(e){return this.pluginsByName.has(e)}collectPmPlugins(e){try{let t=e.prosemirrorPlugins?.(this)??[];if(e.nodeViews){let r=Object.fromEntries(Object.entries(e.nodeViews).map(([o,i])=>[o,i(this)]));t.push(new z({props:{nodeViews:r}}))}return t}catch(t){return xt(`Plugin "${e.name}" failed to create ProseMirror plugins`,t),[]}}setupPlugin(e){try{let t=e.setup?.(this);typeof t=="function"&&this.cleanups.push(t),this.pluginsByName.set(e.name,e)}catch(t){xt(`Plugin "${e.name}" failed during setup`,t)}}async loadLazyPlugins(e){let t=await Promise.all(e.map(l=>Bs(l).catch(a=>(xt("Failed to load plugin",a),null))));if(this.destroyed)return;let r=t.filter(l=>l?l.nodes||l.marks?(xt(`Plugin "${l.name}" defines nodes or marks and cannot be loaded lazily; pass the plugin object instead`),!1):!0:!1),{ordered:o,errors:i}=Ln(r,new Set(this.pluginsByName.keys()));i.forEach(l=>xt(l));let s=o.flatMap(l=>this.collectPmPlugins(l));s.length&&Du(this.view,[...this.view.state.plugins,...s]),o.forEach(l=>{this.registerCommands(l),this.setupPlugin(l)}),this.rebuildToolbar()}updateUI(){this.destroyed||this.toolbar?.update()}rebuildToolbar(){!this.toolbar||this.destroyed||(this.toolbar.destroy(),this.toolbar=id(this,this.toolbarHost,this.toolbarConfig(),this.options.toolbarMode??"floating"))}toolbarConfig(){if(this.options.toolbar)return this.options.toolbar;let e=[...this.pluginsByName.values()].map(t=>t.toolbar).filter(Boolean);return e.length?`${rd} | ${e.join(" ")}`:rd}handleTransaction(e,t=this.view){if(!t.isDestroyed){for(let r of this.transactionTransforms)e=r(e,t.state,this);t.updateState(t.state.apply(e)),this.view&&(this.toolbar?.update(),this.statusbar?.update(e.docChanged),this.searchBar?.update(),this.updatePlaceholder(),e.docChanged&&(this.emit("change",{transaction:e}),!(e.getMeta(As)||e.getMeta(ud))&&e.getMeta("addToHistory")!==!1&&this.emit("input",{transaction:e})),(e.selectionSet||e.docChanged)&&this.emit("selectionChange",{transaction:e}))}}updatePlaceholder(){let e=this.view.state.doc,t=e.childCount===1&&e.firstChild?.type===this.schema.nodes.paragraph&&e.firstChild.content.size===0;this.view.dom.classList.toggle("nova-empty",t)}getHTML({fullPage:e=!0}={}){let t=this.view.state.doc,r=mr.serializeFragment(t.content),o=e?Tn.get(this):void 0;return o?o.write(r,t.attrs):r}getJSON(){return this.view.state.doc.toJSON()}getText(){return this.view.state.doc.textBetween(0,this.view.state.doc.content.size,`
38
45
 
39
- `)}setContent(e,{addToHistory:t=!0}={}){let r={content:e};this.emit("beforeSetContent",r);let o=fa(this.schema,r.content),i=this.view.state.tr.replaceWith(0,this.view.state.doc.content.size,o.content);i.setMeta(vr,!0),t||i.setMeta("addToHistory",!1),this.view.dispatch(i),this.emit("setContent",{content:r.content})}insertContent(e){if(!this.isEditable())return!1;let t=document.createElement("template");t.innerHTML=e;let r=document.createElement("div");r.append(t.content);let o=dr(this.schema),i=[...r.children].some(p=>uv.has(p.tagName)),{state:s}=this.view,l=i?new D(o.parse(r).content,0,0):o.parseSlice(r),a=!1;l.content.descendants(p=>(p.type.spec.tableRole==="table"&&(a=!0),!a));let{$from:c}=s.selection,u=0;for(let p=1;p<=c.depth;p++)if(c.node(p).type.spec.tableRole==="table"){u=p;break}let d=a&&u?s.tr.insert(c.after(u),l.content):s.tr.replaceSelection(l);return this.view.dispatch(d.setMeta(vr,!0).scrollIntoView()),!0}isEmpty(){return this.view.dom.classList.contains("nova-empty")}resolveCommand(e){return this.commandOverrides.get(e)??W[e]}registerCommands(e){for(let[t,r]of Object.entries(e.commands??{}))r&&this.commandOverrides.set(t,r);e.transformTransaction&&this.transactionTransforms.push(e.transformTransaction)}exec(e){let r=(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,this.view.dispatch,this.view);return r&&this.view.focus(),r}can(e){return(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,void 0,this.view)}isActive(e){return rl(this.view.state,e)}getCommandState(e){return{active:this.isActive(e),enabled:this.isEditable()&&this.can(e)}}focus(){this.destroyed||this.view.focus()}isPasteAsText(){return this.pasteAsText}setPasteAsText(e){this.pasteAsText=e,this.toolbar?.update()}openSearch(){this.searchBar.open()}closeSearch(){this.searchBar.close()}isEditable(){return this.editable&&!this.disabled}isDisabled(){return this.disabled}setDisabled(e){this.disabled!==e&&(this.disabled=e,this.view.setProps({}),this.applyDisabled(),e&&(this.ui.closePopover(),this.view.dom.blur()),this.toolbar?.update(),this.emit("editableChange"))}applyDisabled(){this.root.classList.toggle("nova-disabled",this.disabled),this.disabled?this.root.setAttribute("aria-disabled","true"):this.root.removeAttribute("aria-disabled"),this.disabled?this.view.dom.setAttribute("tabindex","-1"):this.view.dom.removeAttribute("tabindex")}setEditable(e){this.editable!==e&&(this.editable=e,this.view.setProps({}),this.root.classList.toggle("nova-readonly",!e),e||this.ui.closePopover(),this.toolbar?.update(),this.emit("editableChange"))}on(e,t){let r=this.listeners.get(e);return r||this.listeners.set(e,r=new Set),r.add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...[t]){for(let r of this.listeners.get(e)??[])try{r(this,t)}catch(o){Pe(`Listener for "${e}" failed`,o)}}destroy(){if(!this.destroyed){this.emit("destroy"),this.destroyed=!0,this.menubar?.destroy(),this.ui.destroy(),this.toolbar?.destroy(),this.statusbar?.destroy();for(let e of this.cleanups.splice(0))try{e()}catch(t){Pe("Plugin cleanup failed",t)}this.searchBar.destroy(),this.root.classList.contains("nova-fullscreen")&&hr(this,!1),this.view.destroy(),this.root.remove(),this.listeners.clear()}}};function Pe(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}function pv(n,e){let t=n?.validate;if(!t)return!0;if(typeof t=="function")try{return t(e),!0}catch{return!1}let r=e===null?"null":typeof e;return t.split("|").includes(r)}function rf(n,e){return!e||typeof e!="object"||!n?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>pv(n[t],r)))}function of(n,e){let t=n.nodes[e.type],r={...e};return t&&(r.attrs=rf(t.spec.attrs,e.attrs)),Array.isArray(e.marks)&&(r.marks=e.marks.map(o=>{let i=o&&n.marks[o.type];return i?{...o,attrs:rf(i.spec.attrs,o.attrs)}:o})),Array.isArray(e.content)&&(r.content=e.content.map(o=>o&&typeof o=="object"?of(n,o):o)),r}function fa(n,e){if(typeof e!="string")return Ae.fromJSON(n,of(n,e));let t=document.createElement("div"),r=document.createElement("template");return r.innerHTML=e,t.appendChild(r.content),dr(n).parse(t)}function ti(n){return new kr(n)}var fv={"toolbar.label":"\u0424\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","toolbar.options":"\u0432\u0430\u0440\u0438\u0430\u043D\u0442\u044B","editor.label":"\u0422\u0435\u043A\u0441\u0442\u043E\u0432\u044B\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440","editor.required":"\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u044D\u0442\u043E \u043F\u043E\u043B\u0435.",undo:"\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C",redo:"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C",bold:"\u0416\u0438\u0440\u043D\u044B\u0439",italic:"\u041A\u0443\u0440\u0441\u0438\u0432",underline:"\u041F\u043E\u0434\u0447\u0451\u0440\u043A\u043D\u0443\u0442\u044B\u0439",strike:"\u0417\u0430\u0447\u0451\u0440\u043A\u043D\u0443\u0442\u044B\u0439",code:"\u041A\u043E\u0434 \u0432 \u0441\u0442\u0440\u043E\u043A\u0435",subscript:"\u041F\u043E\u0434\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439",superscript:"\u041D\u0430\u0434\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439",link:"\u0421\u0441\u044B\u043B\u043A\u0430",unlink:"\u0423\u0431\u0440\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443",image:"\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435",bulletList:"\u041C\u0430\u0440\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A",orderedList:"\u041D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A",indent:"\u0423\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C \u043E\u0442\u0441\u0442\u0443\u043F",outdent:"\u0423\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C \u043E\u0442\u0441\u0442\u0443\u043F",align:"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435",alignLeft:"\u041F\u043E \u043B\u0435\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E",alignCenter:"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443",alignRight:"\u041F\u043E \u043F\u0440\u0430\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E",alignJustify:"\u041F\u043E \u0448\u0438\u0440\u0438\u043D\u0435",blockquote:"\u0426\u0438\u0442\u0430\u0442\u0430",codeBlock:"\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430",horizontalRule:"\u0413\u043E\u0440\u0438\u0437\u043E\u043D\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u043B\u0438\u043D\u0438\u044F",clearFormatting:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",more:"\u0415\u0449\u0451",moreFormats:"\u0415\u0449\u0451 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",blocks:"\u0421\u0442\u0438\u043B\u044C \u0442\u0435\u043A\u0441\u0442\u0430",styles:"\u0424\u043E\u0440\u043C\u0430\u0442\u044B","styles.headings":"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0438","styles.inline":"\u0422\u0435\u043A\u0441\u0442","styles.blocks":"\u0411\u043B\u043E\u043A\u0438","styles.align":"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435",paragraph:"\u041E\u0431\u044B\u0447\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442",h1:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1",h2:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2",h3:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 3",h4:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 4",h5:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 5",h6:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 6",fontFamily:"\u0428\u0440\u0438\u0444\u0442",fontSize:"\u0420\u0430\u0437\u043C\u0435\u0440 \u0448\u0440\u0438\u0444\u0442\u0430",lineHeight:"\u041C\u0435\u0436\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B",default:"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",textColor:"\u0426\u0432\u0435\u0442 \u0442\u0435\u043A\u0441\u0442\u0430",backgroundColor:"\u0426\u0432\u0435\u0442 \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u0438\u044F",removeColor:"\u0423\u0431\u0440\u0430\u0442\u044C \u0446\u0432\u0435\u0442",customColor:"\u0421\u0432\u043E\u0439 \u0446\u0432\u0435\u0442","dialog.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","dialog.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C","dialog.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C","dialog.close":"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","dialog.required":"\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u044D\u0442\u043E \u043F\u043E\u043B\u0435","dialog.invalid":"\u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0444\u043E\u0440\u043C\u0430\u0442","link.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.editTitle":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.url":"\u0410\u0434\u0440\u0435\u0441","link.text":"\u0422\u0435\u043A\u0441\u0442 \u0441\u0441\u044B\u043B\u043A\u0438","link.tooltip":"\u041F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0430 (title)","link.newTab":"\u041E\u0442\u043A\u0440\u044B\u0432\u0430\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435","link.open":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.edit":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.copy":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.copied":"\u0421\u0441\u044B\u043B\u043A\u0430 \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u0430","link.invalid":"\u0422\u0430\u043A\u043E\u0439 \u0430\u0434\u0440\u0435\u0441 \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D","image.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.url":"\u0410\u0434\u0440\u0435\u0441 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","image.alt":"\u0410\u043B\u044C\u0442\u0435\u0440\u043D\u0430\u0442\u0438\u0432\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442","image.altHint":"\u041E\u043F\u0438\u0448\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044E\u0449\u0438\u0445 \u044D\u043A\u0440\u0430\u043D\u043D\u044B\u0439 \u0434\u0438\u043A\u0442\u043E\u0440","image.upload":"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C","image.drop":"\u041F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0441\u044E\u0434\u0430 \u0438\u043B\u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0432\u044B\u0431\u0440\u0430\u0442\u044C","image.uploading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F\u2026","image.uploadFailed":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.retry":"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C","image.retrying":"\u041F\u0440\u043E\u0431\u043B\u0435\u043C\u0430 \u0441\u043E \u0441\u0432\u044F\u0437\u044C\u044E \u2014 \u043F\u043E\u0432\u0442\u043E\u0440\u044F\u0435\u043C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0443\u2026","image.invalid":"\u0422\u0430\u043A\u043E\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D","image.or":"\u0438\u043B\u0438","image.toolbar":"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","image.alignLeft":"\u041E\u0431\u0442\u0435\u043A\u0430\u043D\u0438\u0435, \u0441\u043B\u0435\u0432\u0430","image.alignCenter":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","image.alignRight":"\u041E\u0431\u0442\u0435\u043A\u0430\u043D\u0438\u0435, \u0441\u043F\u0440\u0430\u0432\u0430","image.editAlt":"\u0410\u043B\u044C\u0442\u0435\u0440\u043D\u0430\u0442\u0438\u0432\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442","image.size":"\u0420\u0430\u0437\u043C\u0435\u0440","image.sizeSmall":"\u041C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0439 (25%)","image.sizeMedium":"\u0421\u0440\u0435\u0434\u043D\u0438\u0439 (50%)","image.sizeLarge":"\u0411\u043E\u043B\u044C\u0448\u043E\u0439 (75%)","image.sizeFull":"\u0412\u043E \u0432\u0441\u044E \u0448\u0438\u0440\u0438\u043D\u0443","image.sizeOriginal":"\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440","image.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.caption":"\u041F\u043E\u0434\u043F\u0438\u0441\u044C","image.captionPlaceholder":"\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043F\u043E\u0434\u043F\u0438\u0441\u044C\u2026","status.words":"\u0421\u043B\u043E\u0432: {count}","status.resize":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0440\u0430\u0437\u043C\u0435\u0440 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u0430","dialog.browse":"\u041E\u0431\u0437\u043E\u0440",pasteAsText:"\u0412\u0441\u0442\u0430\u0432\u043B\u044F\u0442\u044C \u043A\u0430\u043A \u0442\u0435\u043A\u0441\u0442","menu.label":"\u041C\u0435\u043D\u044E","menu.file":"\u0424\u0430\u0439\u043B","menu.edit":"\u041F\u0440\u0430\u0432\u043A\u0430","menu.view":"\u0412\u0438\u0434","menu.insert":"\u0412\u0441\u0442\u0430\u0432\u043A\u0430","menu.format":"\u0424\u043E\u0440\u043C\u0430\u0442","menu.table":"\u0422\u0430\u0431\u043B\u0438\u0446\u0430","menu.help":"\u0421\u043F\u0440\u0430\u0432\u043A\u0430",selectAll:"\u0412\u044B\u0434\u0435\u043B\u0438\u0442\u044C \u0432\u0441\u0451",print:"\u041F\u0435\u0447\u0430\u0442\u044C","table.rows":"\u0421\u0442\u0440\u043E\u043A\u0438","table.cols":"\u0421\u0442\u043E\u043B\u0431\u0446\u044B","table.invalidSize":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u043E\u0442 1 \u0434\u043E 50","quickbars.selection":"\u0411\u044B\u0441\u0442\u0440\u043E\u0435 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","quickbars.insert":"\u0411\u044B\u0441\u0442\u0440\u0430\u044F \u0432\u0441\u0442\u0430\u0432\u043A\u0430","search.title":"\u041D\u0430\u0439\u0442\u0438 \u0438 \u0437\u0430\u043C\u0435\u043D\u0438\u0442\u044C","search.find":"\u041D\u0430\u0439\u0442\u0438","search.replace":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430","search.next":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0435","search.prev":"\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0435\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0435","search.replaceOne":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C","search.replaceAll":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C \u0432\u0441\u0435","search.matchCase":"\u0423\u0447\u0438\u0442\u044B\u0432\u0430\u0442\u044C \u0440\u0435\u0433\u0438\u0441\u0442\u0440","search.wholeWord":"\u0422\u043E\u043B\u044C\u043A\u043E \u0441\u043B\u043E\u0432\u043E \u0446\u0435\u043B\u0438\u043A\u043E\u043C","search.count":"{current} \u0438\u0437 {total}","search.none":"\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E",fullscreen:"\u041D\u0430 \u0432\u0435\u0441\u044C \u044D\u043A\u0440\u0430\u043D",preview:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",sourceCode:"HTML-\u043A\u043E\u0434",help:"\u0413\u043E\u0440\u044F\u0447\u0438\u0435 \u043A\u043B\u0430\u0432\u0438\u0448\u0438","help.formatting":"\u0424\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0442\u0435\u043A\u0441\u0442\u0430","help.blocks":"\u0410\u0431\u0437\u0430\u0446\u044B \u0438 \u0441\u043F\u0438\u0441\u043A\u0438","help.editing":"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","help.navigation":"\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F","help.slash":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0431\u043B\u043E\u043A (\u0441\u043B\u044D\u0448-\u043A\u043E\u043C\u0430\u043D\u0434\u044B)","help.toMenubar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0433\u043B\u0430\u0432\u043D\u043E\u0435 \u043C\u0435\u043D\u044E","help.toToolbar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043D\u0430 \u043F\u0430\u043D\u0435\u043B\u044C \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u043E\u0432","help.toContextToolbar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043D\u0430 \u043F\u0430\u043D\u0435\u043B\u044C \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0438/\u0442\u0430\u0431\u043B\u0438\u0446\u044B","help.toEditor":"\u0412\u0435\u0440\u043D\u0443\u0442\u044C\u0441\u044F \u0432 \u0442\u0435\u043A\u0441\u0442","help.nextCell":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u044F\u0447\u0435\u0439\u043A\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B",table:"\u0422\u0430\u0431\u043B\u0438\u0446\u0430","table.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0442\u0430\u0431\u043B\u0438\u0446\u0443","table.size":"{rows} \xD7 {cols}","table.toolbar":"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0442\u0430\u0431\u043B\u0438\u0446\u044B","table.rowBefore":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u0432\u044B\u0448\u0435","table.rowAfter":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u043D\u0438\u0436\u0435","table.rowDelete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443","table.colBefore":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446 \u0441\u043B\u0435\u0432\u0430","table.colAfter":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446 \u0441\u043F\u0440\u0430\u0432\u0430","table.colDelete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446","table.merge":"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438","table.split":"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443","table.rowHeader":"\u0421\u0442\u0440\u043E\u043A\u0430 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u043E\u0432","table.colHeader":"\u0421\u0442\u043E\u043B\u0431\u0435\u0446 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u043E\u0432","table.cellBackground":"\u0424\u043E\u043D \u044F\u0447\u0435\u0439\u043A\u0438","table.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0442\u0430\u0431\u043B\u0438\u0446\u0443","table.sort":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0430","table.sortAsc":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0410 \u2192 \u042F, 1 \u2192 9","table.sortDesc":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u042F \u2192 \u0410, 9 \u2192 1","table.props":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B","table.style":"\u0421\u0442\u0438\u043B\u044C","table.styleDefault":"\u041E\u0431\u044B\u0447\u043D\u044B\u0439","table.width":"\u0428\u0438\u0440\u0438\u043D\u0430","table.widthHint":"\u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, 100% \u0438\u043B\u0438 600px. \u041F\u0443\u0441\u0442\u043E \u2014 \u043F\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u043C\u0443.","table.invalidWidth":"\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u0448\u0438\u0440\u0438\u043D\u0443, \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440 100% \u0438\u043B\u0438 600px","table.align":"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435 \u043D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0435","table.alignDefault":"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","table.alignCenter":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","table.alignRight":"\u0421\u043F\u0440\u0430\u0432\u0430","table.cellProps":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u044F\u0447\u0435\u0439\u043A\u0438","table.valign":"\u0412\u0435\u0440\u0442\u0438\u043A\u0430\u043B\u044C\u043D\u043E\u0435 \u0432\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435","table.valignTop":"\u0421\u0432\u0435\u0440\u0445\u0443","table.valignMiddle":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","table.valignBottom":"\u0421\u043D\u0438\u0437\u0443","table.cellType":"\u0422\u0438\u043F \u044F\u0447\u0435\u0439\u043A\u0438","table.cellData":"\u041E\u0431\u044B\u0447\u043D\u0430\u044F","table.cellHeader":"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A","table.colWidth":"\u0428\u0438\u0440\u0438\u043D\u0430 \u0441\u0442\u043E\u043B\u0431\u0446\u0430, px","table.colWidthHint":"\u041F\u0443\u0441\u0442\u043E \u2014 \u043F\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u043C\u0443.","table.invalidColWidth":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u043E\u0442 24 \u0434\u043E 4000","slash.label":"\u041A\u043E\u043C\u0430\u043D\u0434\u044B","slash.empty":"\u041D\u0435\u0442 \u043F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0438\u0445 \u043A\u043E\u043C\u0430\u043D\u0434","advlist.disc":"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","advlist.circle":"\u041A\u0440\u0443\u0436\u043E\u043A","advlist.square":"\u041A\u0432\u0430\u0434\u0440\u0430\u0442","advlist.decimal":"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E (1, 2, 3)","advlist.lower-alpha":"\u0421\u0442\u0440\u043E\u0447\u043D\u044B\u0435 \u0431\u0443\u043A\u0432\u044B (a, b, c)","advlist.upper-alpha":"\u041F\u0440\u043E\u043F\u0438\u0441\u043D\u044B\u0435 \u0431\u0443\u043A\u0432\u044B (A, B, C)","advlist.lower-roman":"\u0420\u0438\u043C\u0441\u043A\u0438\u0435 \u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0435 (i, ii, iii)","advlist.upper-roman":"\u0420\u0438\u043C\u0441\u043A\u0438\u0435 \u043F\u0440\u043E\u043F\u0438\u0441\u043D\u044B\u0435 (I, II, III)","advlist.lower-greek":"\u0413\u0440\u0435\u0447\u0435\u0441\u043A\u0438\u0435 (\u03B1, \u03B2, \u03B3)","anchor.title":"\u042F\u043A\u043E\u0440\u044C","anchor.id":"\u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440","anchor.hint":"\u041B\u0430\u0442\u0438\u043D\u0441\u043A\u0438\u0435 \u0431\u0443\u043A\u0432\u044B, \u0446\u0438\u0444\u0440\u044B, \xAB-\xBB, \xAB_\xBB, \xAB.\xBB; \u043D\u0430\u0447\u0438\u043D\u0430\u0435\u0442\u0441\u044F \u0441 \u0431\u0443\u043A\u0432\u044B. \u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u044F\u043A\u043E\u0440\u044C \u2014 #\u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440.","anchor.invalid":"\u0422\u043E\u043B\u044C\u043A\u043E \u043B\u0430\u0442\u0438\u043D\u0441\u043A\u0438\u0435 \u0431\u0443\u043A\u0432\u044B, \u0446\u0438\u0444\u0440\u044B, \xAB-\xBB, \xAB_\xBB \u0438\u043B\u0438 \xAB.\xBB, \u043F\u0435\u0440\u0432\u0430\u044F \u2014 \u0431\u0443\u043A\u0432\u0430","anchor.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C","autosave.restore":"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A","autosave.found":"\u041D\u0430\u0439\u0434\u0435\u043D \u043D\u0435\u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D\u043D\u044B\u0439 \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A. \u0415\u0433\u043E \u043C\u043E\u0436\u043D\u043E \u0432\u0435\u0440\u043D\u0443\u0442\u044C \u043A\u043D\u043E\u043F\u043A\u043E\u0439 \xAB\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A\xBB.","autosave.restored":"\u0427\u0435\u0440\u043D\u043E\u0432\u0438\u043A \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D","charmap.title":"\u0421\u043F\u0435\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u0439 \u0441\u0438\u043C\u0432\u043E\u043B","charmap.search":"\u041F\u043E\u0438\u0441\u043A \u0441\u0438\u043C\u0432\u043E\u043B\u0430","charmap.empty":"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","charmap.groups.0":"\u0412\u0430\u043B\u044E\u0442\u044B","charmap.groups.1":"\u0422\u0438\u043F\u043E\u0433\u0440\u0430\u0444\u0438\u043A\u0430","charmap.groups.2":"\u041C\u0430\u0442\u0435\u043C\u0430\u0442\u0438\u043A\u0430","charmap.groups.3":"\u0421\u0442\u0440\u0435\u043B\u043A\u0438","charmap.groups.4":"\u041B\u0430\u0442\u0438\u043D\u0438\u0446\u0430","charmap.groups.5":"\u0413\u0440\u0435\u0447\u0435\u0441\u043A\u0438\u0435","comments.add":"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439","comments.show":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438","comments.panel":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438","comments.guest":"\u0413\u043E\u0441\u0442\u044C","comments.newComment":"\u041D\u043E\u0432\u044B\u0439 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439","comments.placeholder":"\u041D\u0430\u043F\u0438\u0448\u0438\u0442\u0435 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439\u2026","comments.replyPlaceholder":"\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C\u2026","comments.comment":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C","comments.reply":"\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C","comments.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","comments.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C","comments.edit":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C","comments.remove":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C","comments.resolve":"\u0420\u0435\u0448\u0435\u043D\u043E","comments.reopen":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u043D\u043E\u0432\u0430","comments.deleteThread":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u0435","comments.close":"\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438","comments.showResolved":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0440\u0435\u0448\u0451\u043D\u043D\u044B\u0435","comments.resolvedBy":"\u0420\u0435\u0448\u0435\u043D\u043E: {name}","comments.orphan":"\u041F\u0440\u043E\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442 \u0443\u0434\u0430\u043B\u0451\u043D","comments.empty":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442. \u0412\u044B\u0434\u0435\u043B\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \xAB\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439\xBB ({shortcut}).","comments.people":"\u041B\u044E\u0434\u0438","comments.noPeople":"\u041D\u0438\u043A\u043E\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","comments.edited":"\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u043E","comments.you":"\u0432\u044B","comments.count":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432: {count}","directionality.ltr":"\u0421\u043B\u0435\u0432\u0430 \u043D\u0430\u043F\u0440\u0430\u0432\u043E","directionality.rtl":"\u0421\u043F\u0440\u0430\u0432\u0430 \u043D\u0430\u043B\u0435\u0432\u043E","emoticons.title":"\u042D\u043C\u043E\u0434\u0437\u0438","emoticons.search":"\u041F\u043E\u0438\u0441\u043A \u044D\u043C\u043E\u0434\u0437\u0438","emoticons.empty":"\u042D\u043C\u043E\u0434\u0437\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B","emoticons.groups.0":"\u0421\u043C\u0430\u0439\u043B\u044B","emoticons.groups.1":"\u0416\u0435\u0441\u0442\u044B","emoticons.groups.2":"\u0421\u0435\u0440\u0434\u0446\u0430","emoticons.groups.3":"\u041F\u0440\u0438\u0440\u043E\u0434\u0430","emoticons.groups.4":"\u0415\u0434\u0430","emoticons.groups.5":"\u0417\u0430\u043D\u044F\u0442\u0438\u044F","emoticons.groups.6":"\u041F\u0440\u0435\u0434\u043C\u0435\u0442\u044B","emoticons.groups.7":"\u0421\u0438\u043C\u0432\u043E\u043B\u044B","insertdatetime.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0434\u0430\u0442\u0443/\u0432\u0440\u0435\u043C\u044F","insertdatetime.date":"\u0414\u0430\u0442\u0430","insertdatetime.time":"\u0412\u0440\u0435\u043C\u044F","insertdatetime.dateTime":"\u0414\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F","insertdatetime.long":"\u0414\u0430\u0442\u0430 \u043F\u0440\u043E\u043F\u0438\u0441\u044C\u044E","media.title":"\u0412\u0438\u0434\u0435\u043E","media.url":"\u0410\u0434\u0440\u0435\u0441 \u0432\u0438\u0434\u0435\u043E","media.hint":"YouTube, Vimeo \u0438\u043B\u0438 \u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0444\u0430\u0439\u043B .mp4 / .webm","media.name":"\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 (\u0434\u043B\u044F \u044D\u043A\u0440\u0430\u043D\u043D\u043E\u0433\u043E \u0434\u0438\u043A\u0442\u043E\u0440\u0430)","media.invalid":"\u042D\u0442\u043E\u0442 \u0430\u0434\u0440\u0435\u0441 \u0432\u0438\u0434\u0435\u043E \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F","media.save":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C","mentions.list":"\u041B\u044E\u0434\u0438","mentions.empty":"\u041D\u0438\u043A\u043E\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","mergetags.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0443\u044E","mergetags.search":"\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435","mergetags.empty":"\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B","mergetags.unknown":"\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0430\u044F","nonbreaking.title":"\u041D\u0435\u0440\u0430\u0437\u0440\u044B\u0432\u043D\u044B\u0439 \u043F\u0440\u043E\u0431\u0435\u043B","pagebreak.title":"\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B","revisionhistory.button":"\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439","revisionhistory.title":"\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439","revisionhistory.current":"\u0422\u0435\u043A\u0443\u0449\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F","revisionhistory.restore":"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u044D\u0442\u0443 \u0432\u0435\u0440\u0441\u0438\u044E","revisionhistory.close":"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","revisionhistory.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u0432\u0435\u0440\u0441\u0438\u044E","revisionhistory.saved":"\u0412\u0435\u0440\u0441\u0438\u044F \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0430","revisionhistory.highlight":"\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F","revisionhistory.onlyHere":"\u0422\u043E\u043B\u044C\u043A\u043E \u0432 \u044D\u0442\u043E\u0439 \u0432\u0435\u0440\u0441\u0438\u0438","revisionhistory.onlyNow":"\u0422\u043E\u043B\u044C\u043A\u043E \u0432 \u0442\u0435\u043A\u0443\u0449\u0435\u043C \u0442\u0435\u043A\u0441\u0442\u0435","revisionhistory.loading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026","revisionhistory.failed":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438\u0441\u0442\u043E\u0440\u0438\u044E \u0432\u0435\u0440\u0441\u0438\u0439.","revisionhistory.retry":"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C","revisionhistory.empty":"\u0421\u043E\u0445\u0440\u0430\u043D\u0451\u043D\u043D\u044B\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442.","revisionhistory.restored":"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u0432\u0435\u0440\u0441\u0438\u044F \u043E\u0442 {date}. \u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C \u2014 Ctrl+Z.","revisionhistory.versions":"\u0412\u0435\u0440\u0441\u0438\u0438","suggestions.toggle":"\u041F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0442\u044C \u043F\u0440\u0430\u0432\u043A\u0438","suggestions.review":"\u041F\u0440\u0430\u0432\u043A\u0438","suggestions.accept":"\u041F\u0440\u0438\u043D\u044F\u0442\u044C","suggestions.reject":"\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C","suggestions.acceptAll":"\u041F\u0440\u0438\u043D\u044F\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438","suggestions.rejectAll":"\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438","suggestions.next":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430","suggestions.previous":"\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430","suggestions.inserted":"\u0412\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043E: {name}","suggestions.deleted":"\u0423\u0434\u0430\u043B\u0435\u043D\u043E: {name}","suggestions.toolbar":"\u041F\u0440\u0430\u0432\u043A\u0430","suggestions.guest":"\u0413\u043E\u0441\u0442\u044C","suggestions.none":"\u041F\u0440\u0430\u0432\u043E\u043A \u043D\u0435\u0442","visualblocks.title":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438"},sf=fv;var lf=new Set("script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image".split(",")),hv=/^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/,mv=/^[a-z_:][a-z0-9_.:-]*$/,af=/^[a-z][a-z0-9._-]*$/,Tn=new Set("p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,img,figure,figcaption,br,table,tr,td,th,strong,em,u,s,code,a,sub,sup".split(",")),Mr=new Set(["span","i","b","del","strike","mark"]),gv=new Set("abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr".split(",")),hf=new Set("div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search".split(",")),bv=new Set([...hf,..."p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure".split(",")]),yv={a:["href"],img:["src"],td:["colspan","rowspan"],th:["colspan","rowspan"]};function cf(n){let e=[],t=0,r="";for(let o of n)o==="["?t++:o==="]"&&(t=Math.max(0,t-1)),o===","&&!t?(e.push(r),r=""):r+=o;return e.push(r),e.map(o=>o.trim()).filter(Boolean)}function vv(n){let e=n.trim(),t=e.startsWith("!");t&&(e=e.slice(1));let r=/^([^=:<]+)(?:([=:<])(.*))?$/s.exec(e);if(!r)return null;let o=r[1].trim().toLowerCase();if(!o)return null;let i={name:o,required:t},s=r[3]??"";return r[2]==="="?i.def=s:r[2]===":"?i.forced=s:r[2]==="<"&&(i.values=s.split("?")),i}function ga(n,e){return n==="*"?!0:n.endsWith("*")?e.startsWith(n.slice(0,-1)):n===e}var uf=new Set;function ba(n,e){uf.has(n)||(uf.add(n),console.warn(`[nova] <${n}> in content rules is ignored: ${e}`))}var ya=class{constructor(e){E(this,"elements",new Map);E(this,"globals",[]);E(this,"blockTags",new Map);E(this,"inlineTags",new Map);let t=new Set((e.invalidElements??"").split(",").map(s=>s.trim().toLowerCase()).filter(Boolean)),r=new Set,o=new Set;for(let s of(e.customElements??"").split(",")){let l=s.trim().toLowerCase(),a=l.replace(/^~/,"");if(af.test(a)){if(lf.has(a)||Tn.has(a)){ba(a,"it cannot be a custom element");continue}o.add(a),l.startsWith("~")&&r.add(a)}}let i=(s,l)=>{let[a,...c]=s;if(a){if(a==="@"||a==="*"){this.globals.push(...l??[]);return}for(let u of s){if(!af.test(u)||t.has(u))continue;if(lf.has(u)){ba(u,"not allowed for security reasons (iframes and video: use the media plugin)");continue}this.elements.set(u,l);let d=Tn.has(u)||Mr.has(u)?u:a;if(Tn.has(u))continue;if(Mr.has(u)){u===a&&l?.length&&this.inlineTags.set(u,u);continue}let p=o.has(u)||o.has(a)||u.includes("-");gv.has(a)||r.has(a)?this.inlineTags.set(u,d):hf.has(a)||p?this.blockTags.set(u,d):(!c.includes(u)||u===a)&&ba(u,"unknown element")}}};for(let s of cf(e.validElements??"")){let{names:l,attrs:a}=df(s);a?i(l,a):l.every(c=>Tn.has(c)||Mr.has(c))||i(l,null)}for(let s of cf(e.extendedValidElements??"")){let{names:l,attrs:a}=df(s);i(l,a)}for(let s of o)t.has(s)||(this.elements.has(s)||this.elements.set(s,[{name:"*",required:!1}]),r.has(s)?this.inlineTags.set(s,s):this.inlineTags.has(s)||this.blockTags.set(s,s))}apply(e,t){return wv(e.nodes,e.marks,this,t)}get active(){return this.elements.size>0||this.globals.length>0}touches(e){return this.globals.length>0||this.elements.has(e)}rulesFor(e){return[...this.elements.get(e)??[],...this.globals]}allows(e,t){return hv.test(t)||!mv.test(t)?!1:this.rulesFor(e).some(r=>ga(r.name,t))}extends(e){return this.rulesFor(e).some(t=>t.name!=="class"&&t.name!=="style")}get classOnBuiltIn(){if(this.globals.some(e=>ga(e.name,"class")))return!0;for(let[e,t]of this.elements)if(Tn.has(e)&&t?.some(r=>ga(r.name,"class")))return!0;return!1}hasRequired(e,t){return this.rulesFor(e).every(r=>!r.required||t.hasAttribute(r.name))}readAttrs(e,t,r){let o=null;for(let i of Array.from(t.attributes)){let s=i.name.toLowerCase();if(s===Fo&&(s="style"),r.includes(s)||!this.allows(e,s))continue;let l=mr(s,i.value);l!==null&&((o??(o={}))[s]=l)}return o}outputAttrs(e,t,r){let o={...t};if(r&&typeof r=="object"&&!Array.isArray(r))for(let[s,l]of Object.entries(r)){let a=s.toLowerCase();if(o[a]!=null||!this.allows(e,a)||!["string","number","boolean"].includes(typeof l))continue;let c=mr(a,String(l));c!==null&&(o[a]=c)}if(this.elements.get(e))for(let s of Object.keys(o))this.allows(e,s)||yv[e]?.includes(s)||s.startsWith("data-nova-")||delete o[s];for(let s of this.rulesFor(e)){if(s.name.includes("*"))continue;s.forced!==void 0?o[s.name]=s.forced:s.def!==void 0&&o[s.name]==null&&(o[s.name]=s.def);let l=o[s.name];s.values&&l!=null&&!s.values.includes(String(l))&&delete o[s.name]}return e==="a"&&o.target!=null&&o.rel==null&&(o.rel="noopener noreferrer"),o}decorate(e,t){if(!Array.isArray(e)||typeof e[0]!="string")return e;let r=e[0],o=(r.includes(" ")?r.split(" ")[1]:r).toLowerCase();if(!this.touches(o))return e;let i=e[1],s=!!i&&typeof i=="object"&&!Array.isArray(i)&&i.nodeType===void 0,l=this.outputAttrs(o,s?i:{},t);return[r,l,...e.slice(s?2:1)]}};function df(n){let e=/^([^[]*)(?:\[(.*)\])?$/s.exec(n.trim()),t=(e?.[1]??"").trim().replace(/^[-#+!]+/,"").split("/").map(i=>i.trim().toLowerCase()).filter(Boolean),r=e?.[2],o=r===void 0?null:r.split("|").map(vv).filter(i=>i!==null);return{names:t,attrs:o}}function kv(n){if(!n.validElements&&!n.extendedValidElements&&!n.customElements)return null;let e=new ya(n);return e.active?e:null}var pf=n=>(/^[a-z][a-z0-9-]*/i.exec(n)?.[0]??"").toLowerCase();function Mv(n,e,t,r,o){try{let i=n.schema,s=e==="node"?o(i.nodes[t].create(r)):o(i.marks[t].create(r),!0),l=Array.isArray(s)?s[1]:null;return l&&typeof l=="object"&&!Array.isArray(l)?Object.keys(l):[]}catch{return[]}}function xv(n,e,t,r,o){let i=(e.parseDOM??[]).map(a=>a.tag?pf(a.tag):"").filter(a=>Tn.has(a)&&r.touches(a));if(!i.length||!e.toDOM)return e;let s=i.some(a=>r.extends(a)),l=e.toDOM;return{...e,...s?{attrs:{...e.attrs,htmlAttrs:{default:null}}}:{},parseDOM:e.parseDOM.map(a=>{let c=a.tag?pf(a.tag):"";if(!i.includes(c))return a;let u=a.getAttrs;return{...a,getAttrs:d=>{let p=u?u(d):a.attrs??null;if(p===!1||!r.hasRequired(c,d))return!1;if(!s)return p;let f=r.readAttrs(c,d,["class","style"]);if(!f)return p;for(let h of Mv(o,t,n,{...p},l))delete f[h];return Object.keys(f).length?{...p,htmlAttrs:f}:p}}}),toDOM:((a,c)=>r.decorate(l(a,c),a.attrs.htmlAttrs))}}function ff(n,e){return Array.from(n.children).some(t=>{let r=t.localName;return bv.has(r)||e.blockTags.has(r)})}function Sv(n){let e={},t={},r=(a,c,u)=>{if(!n.hasRequired(a,c))return!1;let d=Mr.has(a),p=d?u&&a==="span"?["class","style"]:["style"]:[],f=n.readAttrs(a,c,p);return d&&!f?!1:{tag:a,htmlAttrs:f}},o=a=>[...a].filter(([,c])=>!Mr.has(c)).map(([c])=>c),i=(a,c,u)=>{let d=typeof u.tag=="string"&&a.has(u.tag)?u.tag:c;return{tag:d,attrs:n.outputAttrs(d,{},u.htmlAttrs)}},s=[...n.blockTags];if(s.length){let a=new Set(n.blockTags.values()),c=a.has("div")?"div":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_block={ownStyleTags:o(n.blockTags),group:"block",content:"block+",defining:!0,attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ff(f,n)?r(p,f,!1):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}},e.html_textblock={group:"block",content:"inline*",attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ff(f,n)?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}let l=[...n.inlineTags];if(l.length){let a=new Set(n.inlineTags.values()),c=a.has("span")?"span":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_inline_atom={ownStyleTags:o(n.inlineTags),group:"inline",inline:!0,atom:!0,attrs:u,parseDOM:l.map(([d,p])=>({tag:d,priority:65,getAttrs:f=>f.firstChild?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f]}},t.html_inline={attrs:u,excludes:"",parseDOM:l.map(([d,p])=>({tag:d,priority:p==="span"?40:60,getAttrs:f=>f.firstChild?r(p,f,!0):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}return{nodes:e,marks:t}}function wv(n,e,t,r){let o=(s,l)=>Object.fromEntries(Object.entries(s).map(([a,c])=>[a,xv(a,c,l,t,r)])),i=Sv(t);return{nodes:{...o(n,"node"),...i.nodes},marks:{...o(e,"mark"),...i.marks}}}var mf={create:kv};var Ev=new Set(["lists","link","image","table","code","codesample","preview","searchreplace","fullscreen","help","wordcount","paste","hr","print","textcolor","colorpicker","contextmenu","tabfocus","textpattern","imagetools","powerpaste","importcss","accordion"]),Cv={tinycomments:"comments"},Av=new Set(["selector","target","license_key","api_key","branding","promotion","skin","skin_url","content_css","icons","icons_url","theme","theme_url","base_url","suffix","referrer_policy","convert_urls","relative_urls","remove_script_host","document_base_url","entity_encoding","height","min_height","max_height","width","resize","content_style","setup","init_instance_callback","inline","plugins","toolbar","menubar","statusbar","placeholder","readonly","disabled","block_formats","file_picker_callback","formats","style_formats","style_formats_merge","valid_classes","table_class_list","table_cell_class_list","file_picker_types","language","images_upload_handler","paste_as_text","paste_preprocess","paste_postprocess","invalid_elements","valid_elements","directionality","extended_valid_elements","custom_elements","valid_styles","toolbar_mode","toolbar_sticky","font_family_formats","font_size_formats","line_height_formats","color_map","autosave_interval","autosave_retention","autosave_prefix","quickbars_selection_toolbar","quickbars_insert_toolbar","mentions_fetch","tinycomments_author","tinycomments_author_name"]),ni=n=>(Array.isArray(n)?n.join(" "):String(n??"")).split(/[\s,]+/).filter(Boolean);function ri(n){if(typeof n=="string")return n.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,r]=e.includes("=")?e.split("="):[e,e];return{label:t.trim(),value:(r??t).trim()}})}function Tv(n){let e="",t=new Promise(o=>{let i=new FileReader;i.onload=()=>{e=String(i.result).replace(/^data:[^,]*,/,""),o()},i.onerror=()=>o(),i.readAsDataURL(n)}),r="";return{ready:t,info:{id:()=>n.name.replace(/\.[^.]+$/,"")||"image",name:()=>n.name.replace(/\.[^.]+$/,"")||"image",filename:()=>n.name||"image",blob:()=>n,base64:()=>e,blobUri:()=>r||(r=URL.createObjectURL(n)),uri:()=>{}}}}var Nv=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),Ov=new Set(["span","strong","b","em","i","u","s","strike","del","code","sub","sup"]);function oi(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r,i={};typeof o.block=="string"&&Nv.has(o.block.toLowerCase())&&(i.block=o.block.toLowerCase()),typeof o.inline=="string"&&Ov.has(o.inline.toLowerCase())&&(i.inline=o.inline.toLowerCase()),typeof o.selector=="string"&&(i.selector=o.selector),(typeof o.classes=="string"||Array.isArray(o.classes))&&(i.classes=o.classes),o.styles&&typeof o.styles=="object"&&(i.styles=Object.fromEntries(Object.entries(o.styles).filter(([,s])=>typeof s=="string"&&!s.includes("%")).map(([s,l])=>[s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),l]))),(i.block||i.inline||i.selector)&&t.push(i)}return t}function gf(n){return Array.isArray(n)?n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=String(t.title??"");if(!r)return[];if(Array.isArray(t.items))return[{title:r,items:gf(t.items)}];if(typeof t.format=="string")return[{title:r,format:t.format}];let[o]=oi(t);return o?[{title:r,...o}]:[]}):[]}function bf(n){let e=Object.keys(n).filter(f=>!Av.has(f)),t=[],r=[];for(let f of ni(n.plugins)){let h=Cv[f]??f;Ev.has(f)||(Cr(h)?t.push(h):r.push(f))}let o={plugins:t};n.toolbar===!1?o.toolbar=!1:Array.isArray(n.toolbar)?o.toolbar=n.toolbar.join(" | "):typeof n.toolbar=="string"&&(o.toolbar=n.toolbar),n.menubar!==void 0&&(o.menubar=n.menubar),typeof n.statusbar=="boolean"&&(o.statusbar=n.statusbar),typeof n.placeholder=="string"&&(o.placeholder=n.placeholder),n.readonly===!0&&(o.editable=!1),typeof n.content_style=="string"&&(o.contentStyle=n.content_style);let i=f=>Array.isArray(f)?f.filter(h=>!!h&&typeof h.title=="string"&&typeof h.value=="string").map(({title:h,value:g})=>({title:h,value:g})):void 0,s=i(n.table_class_list);s&&(o.tableClassList=s);let l=i(n.table_cell_class_list);if(l&&(o.tableCellClassList=l),n.formats&&typeof n.formats=="object"&&(o.formats=Object.fromEntries(Object.entries(n.formats).map(([f,h])=>[f,oi(h)]).filter(([,f])=>f.length))),Array.isArray(n.style_formats)&&(o.styleFormats=gf(n.style_formats),n.style_formats_merge===!0&&(o.styleFormatsMerge=!0)),typeof n.valid_classes=="string"?o.validClasses=ni(n.valid_classes):n.valid_classes&&typeof n.valid_classes=="object"?o.validClasses=Object.values(n.valid_classes).flatMap(f=>ni(f)):o.validClasses=!0,n.content_css!==void 0&&n.content_css!==!1){let f=new Set(["default","dark","document","writer","tinymce-5","tinymce-5-dark"]),h=(Array.isArray(n.content_css)?n.content_css:String(n.content_css).split(",")).map(g=>String(g).trim()).filter(g=>g&&!f.has(g));h.length&&(o.contentCss=h)}n.disabled===!0&&(o.disabled=!0),n.resize!==!1&&(o.resize=n.resize==="both"?"both":!0);let a=ri(n.block_formats);if(a){let f=["p","h1","h2","h3","h4","h5","h6","pre"];o.blockFormats=a.map(({label:h,value:g})=>({label:h,block:g.toLowerCase()})).filter(h=>f.includes(h.block))}if(typeof n.language=="string"&&(o.language=n.language.replace("_","-")),n.toolbar_mode==="sliding"||n.toolbar_mode==="wrap"?o.toolbarMode=n.toolbar_mode:(n.toolbar_mode==="floating"||n.toolbar_mode==="scrolling")&&(o.toolbarMode="sliding"),n.inline===!0&&(o.mode="inline"),n.paste_as_text===!0&&(o.pasteAsText=!0),typeof n.paste_preprocess=="function"){let f=n.paste_preprocess;o.pastePreprocess=(h,g)=>{let m={content:h};return f(g,m),m.content}}typeof n.invalid_elements=="string"&&(o.invalidElements=n.invalid_elements),typeof n.valid_elements=="string"&&(o.validElements=n.valid_elements),typeof n.extended_valid_elements=="string"&&(o.extendedValidElements=n.extended_valid_elements),typeof n.custom_elements=="string"&&(o.customElements=n.custom_elements),(n.directionality==="rtl"||n.directionality==="ltr")&&(o.direction=n.directionality),n.valid_styles&&(o.validStyles=n.valid_styles);let c=ri(n.font_family_formats);c&&(o.fontFamilies=c);let u=ri(n.font_size_formats);u&&(o.fontSizes=u.map(f=>f.value));let d=ri(n.line_height_formats);if(d&&(o.lineHeights=d.map(f=>f.value)),Array.isArray(n.color_map)&&(o.colors=n.color_map.filter((f,h)=>h%2===0).map(f=>f.startsWith("#")?f:`#${f}`)),typeof n.images_upload_handler=="function"){let f=n.images_upload_handler,h=async(g,m)=>{let{ready:b,info:k}=Tv(g);return await b,f(k,m)};o.uploadImage=h}if(typeof n.file_picker_callback=="function"){let f=n.file_picker_callback;typeof n.file_picker_types=="string"&&(o.filePickerTypes=ni(n.file_picker_types).filter(h=>h==="file"||h==="image"||h==="media")),o.filePicker=({type:h,value:g})=>new Promise(m=>f((b,k={})=>m({url:b,...k}),g,{filetype:h,fieldname:"src"}))}let p={};if(n.autosave_interval||n.autosave_retention||n.autosave_prefix){let f=h=>parseInt(String(h),10);p.autosave={...n.autosave_interval?{delay:f(n.autosave_interval)*1e3}:{},...n.autosave_retention?{retention:f(n.autosave_retention)}:{},...n.autosave_prefix?{key:String(n.autosave_prefix)}:{}}}if((n.quickbars_selection_toolbar!==void 0||n.quickbars_insert_toolbar!==void 0)&&(p.quickbars={...n.quickbars_selection_toolbar!==void 0?{selection:n.quickbars_selection_toolbar}:{},...n.quickbars_insert_toolbar!==void 0?{insert:n.quickbars_insert_toolbar}:{}}),typeof n.mentions_fetch=="function"){let f=n.mentions_fetch;p.mentions={fetch:h=>new Promise(g=>f({term:h},g))}}return n.tinycomments_author&&(p.comments={author:{id:String(n.tinycomments_author),name:String(n.tinycomments_author_name??n.tinycomments_author)}}),Object.keys(p).length&&(o.pluginOptions=p),{options:o,unknown:e,missingPlugins:r}}var Dv=0,yf=()=>`nova-compat-field-${++Dv}`;function X(n,e,t){let r=document.createElement(n);return e&&(r.className=e),t!==void 0&&(r.textContent=t),r}function Lv(n){let e=document.createElement("template");return e.innerHTML=n,e.content.querySelectorAll("script, style, iframe, object, embed, link, meta, base, form").forEach(t=>t.remove()),e.content.querySelectorAll("*").forEach(t=>{for(let r of[...t.attributes]){let o=r.value.trim().toLowerCase();(r.name.startsWith("on")||/^(javascript|vbscript|data):/.test(o))&&t.removeAttribute(r.name)}}),e.content}function vf(n,e,t){let r=new Map,o=new Map,i="",s=!1,l=null,a=m=>e.onChange?.(g,{name:m});function c(m,b){let k=yf();b.id=k;let y=X("div","nova-field");if(m.label){let w=X("label","nova-label",m.label);w.htmlFor=k,y.append(w)}return y.append(b),y}function u(m){let b=m.name??"",k=m.enabled!==!1&&m.disabled!==!0;switch(m.type){case"input":case"urlinput":case"colorinput":{let y=X("input","nova-input");return y.type=m.type==="colorinput"?"color":m.type==="urlinput"?"url":"text",m.inputMode&&(y.inputMode=m.inputMode),m.placeholder&&(y.placeholder=m.placeholder),y.disabled=!k,y.addEventListener("input",()=>a(b)),b&&r.set(b,{get:()=>m.type==="urlinput"?{value:y.value}:y.value,set:w=>{y.value=String(m.type==="urlinput"&&w&&typeof w=="object"?w.value??"":w??"")},focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),c(m,y)}case"textarea":{let y=X("textarea","nova-input");return y.rows=m.maximized?10:4,m.placeholder&&(y.placeholder=m.placeholder),y.disabled=!k,y.addEventListener("input",()=>a(b)),b&&r.set(b,{get:()=>y.value,set:w=>y.value=String(w??""),focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),c(m,y)}case"checkbox":{let y=X("input","nova-checkbox");y.type="checkbox",y.id=yf(),y.disabled=!k,y.addEventListener("change",()=>a(b));let w=X("label",void 0,m.label??"");w.htmlFor=y.id,b&&r.set(b,{get:()=>y.checked,set:L=>y.checked=!!L,focus:()=>y.focus(),setEnabled:L=>y.disabled=!L});let N=X("div","nova-field nova-field-inline");return N.append(y,w),N}case"selectbox":case"listbox":{let y=X("select","nova-input nova-select");for(let w of m.items??[]){let N=X("option",void 0,w.text);N.value=w.value,y.append(N)}return y.disabled=!k,y.addEventListener("change",()=>a(b)),b&&r.set(b,{get:()=>y.value,set:w=>y.value=String(w??""),focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),c(m,y)}case"button":{let y=X("button",m.primary||m.buttonType==="primary"?"nova-button nova-button-primary":"nova-button",m.text??"");return y.type="button",y.disabled=!k,y.addEventListener("click",()=>e.onAction?.(g,{name:b})),b&&r.set(b,{get:()=>{},set:()=>{},focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),y}case"htmlpanel":{let y=X("div","nova-compat-html");return y.append(Lv(m.html??"")),y}case"alertbanner":{let y=X("p",`nova-compat-alert is-${m.level??"info"}`,m.text??"");return y.setAttribute("role",m.level==="error"?"alert":"status"),y}case"label":{let y=X("div","nova-compat-group");y.append(X("p","nova-label",m.label??""));for(let w of m.items??[]){let N=u(w);N&&y.append(N)}return y}case"grid":case"bar":{let y=X("div","nova-compat-grid"),w=m.type==="bar"?m.items?.length??1:m.columns==="auto"?2:m.columns??2;y.style.gridTemplateColumns=`repeat(${Number(w)||2}, minmax(0, 1fr))`;for(let N of m.items??[]){let L=u(N);L&&y.append(L)}return y}default:return console.warn(`[nova] tinymce-compat: dialog component "${m.type}" is not supported yet`),null}}let d=X("div","nova-compat-dialog nova-form");if(e.body.type==="tabpanel"){let m=X("div","nova-compat-tabs");m.setAttribute("role","tablist"),d.append(m),e.body.tabs.forEach((b,k)=>{let y=b.name??b.title,w=X("button","nova-compat-tab",b.title);w.type="button",w.setAttribute("role","tab");let N=X("div","nova-compat-tabpanel");N.setAttribute("role","tabpanel");for(let L of b.items){let R=u(L);R&&N.append(R)}w.addEventListener("click",()=>g.showTab(y)),o.set(y,{button:w,panel:N}),m.append(w),d.append(N),k===0&&(i=y)})}else for(let m of e.body.items){let b=u(m);b&&d.append(b)}let p=e.buttons??[],f=p.find(m=>m.type==="submit"),h=p.filter(m=>m.type==="custom");if(h.length){let m=X("div","nova-compat-actions");for(let b of h){let k=X("button",b.primary?"nova-button nova-button-primary":"nova-button",b.text);k.type="button",k.disabled=b.enabled===!1,k.addEventListener("click",()=>e.onAction?.(g,{name:b.name??b.text})),b.name&&r.set(b.name,{get:()=>{},set:()=>{},focus:()=>k.focus(),setEnabled:y=>k.disabled=!y}),m.append(k)}d.append(m)}let g={getData:()=>{let m={};return r.forEach((b,k)=>{let y=b.get();y!==void 0&&(m[k]=y)}),m},setData:m=>{for(let[b,k]of Object.entries(m))r.get(b)?.set(k)},close:()=>{s=!0,l?.close()},block:()=>l?.setBusy(!0),unblock:()=>l?.setBusy(!1),focus:m=>r.get(m)?.focus(),disable:m=>r.get(m)?.setEnabled(!1),enable:m=>r.get(m)?.setEnabled(!0),showTab:m=>{if(!o.has(m))return;let b=i;i=m,o.forEach(({button:k,panel:y},w)=>{let N=w===m;k.setAttribute("aria-selected",String(N)),k.tabIndex=N?0:-1,y.hidden=!N}),b&&b!==m&&e.onTabChange?.(g,{newTabName:m,oldTabName:b})},redial:m=>{g.close(),Object.assign(g,t(m))}};return e.initialData&&g.setData(e.initialData),i&&g.showTab(i),l=n.ui.openDialog({title:e.title,body:d,...f?{submitLabel:f.text}:{},...e.size==="large"?{size:"large"}:{},onSubmit:()=>(e.onSubmit?.(g),s),onClose:()=>{s||e.onCancel?.(g),e.onClose?.()}}),g}var Rv=new Ot,ii={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",justifyleft:"alignLeft",justifycenter:"alignCenter",justifyright:"alignRight",justifyfull:"alignJustify",insertunorderedlist:"bulletList",insertorderedlist:"orderedList",indent:"indent",outdent:"outdent",undo:"undo",redo:"redo",removeformat:"clearFormatting",unlink:"unlink",inserthorizontalrule:"horizontalRule",mceblockquote:"blockquote"},Pv={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"},Iv={bold:"bold",italic:"italic",underline:"underline","strike-through":"strike",link:"link",unlink:"unlink",image:"image",table:"table",undo:"undo",redo:"redo","align-left":"alignLeft","align-center":"alignCenter","align-right":"alignRight","align-justify":"alignJustify","unordered-list":"bulletList","ordered-list":"orderedList",indent:"indent",outdent:"outdent",quote:"blockquote","code-sample":"codeBlock","horizontal-rule":"horizontalRule","remove-formatting":"clearFormatting",fullscreen:"fullscreen",preview:"preview",sourcecode:"sourceCode",help:"help",print:"print",search:"search",copy:"copy","edit-block":"edit",checkmark:"check",close:"close",upload:"upload",subscript:"subscript",superscript:"superscript","paste-text":"pasteText","text-color":"textColor","highlight-bg-color":"highlight","line-height":"lineHeight"},va={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",code:"code",p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock",alignleft:"alignLeft",aligncenter:"alignCenter",alignright:"alignRight",alignjustify:"alignJustify"},Hv=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),Bv=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","alignleft","aligncenter","alignright","alignjustify"]),ka={forecolor:"color",hilitecolor:"background",fontname:"font_family",fontsize:"font_size"};function xr(n){console.warn(`[nova] tinymce-compat: editor.dom.${n} changes the editor DOM directly, which NovaProse redraws from its document model. Use setContent, insertContent or editor.formatter instead.`)}var li=new Map;function si(n){if(typeof n!="string"||!n)return;if(li.has(n))return li.get(n);let e=Iv[n]??(n in S?n:void 0);return e?S[e]:void 0}function Fv(n){let e=!1,t=!0;return{state:{get active(){return e},get enabled(){return t}},api:{isActive:()=>e,setActive:r=>{e=r,n.core.updateUI()},isEnabled:()=>t,setEnabled:r=>{t=r,n.core.updateUI()},isDisabled:()=>!t,setDisabled:r=>{t=!r,n.core.updateUI()}}}}var Sr=class{constructor(e,t,r,o){E(this,"id");E(this,"core");E(this,"targetElm");E(this,"settings");E(this,"initialized",!1);E(this,"removed",!1);E(this,"handlers",new Map);E(this,"dirty",!1);E(this,"teardowns",[]);E(this,"commands",new Map);E(this,"options",{get:e=>this.settings[e],set:(e,t)=>(this.settings[e]=t,e==="disabled"&&this.core.setDisabled(t===!0),!0),isSet:e=>e in this.settings,isRegistered:()=>!0,register:()=>{}});E(this,"mode",{get:()=>this.core.isEditable()?"design":"readonly",set:e=>this.core.setEditable(e!=="readonly"),isReadOnly:()=>!this.core.isEditable()});E(this,"undoManager",{undo:()=>this.core.exec("undo"),redo:()=>this.core.exec("redo"),hasUndo:()=>this.core.can("undo"),hasRedo:()=>this.core.can("redo"),add:()=>null,clear:()=>{},transact:e=>(e(),null),ignore:e=>e()});E(this,"selection",{getContent:(e={})=>{let{state:t}=this.core.view,{from:r,to:o}=t.selection;return e.format==="text"?t.doc.textBetween(r,o,`
40
- `):Rv.serializeFragment(t.selection.content().content)},setContent:e=>this.insertContent(e),getNode:()=>{let{from:e}=this.core.view.state.selection,{node:t}=this.core.view.domAtPos(e);return t instanceof Element?t:t.parentElement},getStart:()=>this.selection.getNode(),getEnd:()=>this.selection.getNode(),isCollapsed:()=>this.core.view.state.selection.empty,collapse:(e=!1)=>{let{state:t,dispatch:r}=this.core.view,o=e?t.selection.from:t.selection.to;r(t.tr.setSelection(I.near(t.doc.resolve(o))))},setCursorLocation:(e,t=0)=>{let{view:r}=this.core;if(!e||!r.dom.contains(e))return;let o=r.posAtDOM(e,t);r.dispatch(r.state.tr.setSelection(I.near(r.state.doc.resolve(o))))},select:(e,t=!1)=>{let{view:r}=this.core;if(!r.dom.contains(e))return;let o=r.posAtDOM(e,0),i=r.posAtDOM(e,e.childNodes.length),{doc:s}=r.state,l=!t&&e instanceof HTMLImageElement?P.create(s,Math.max(0,o-(s.resolve(o).nodeAfter?0:1))):I.between(s.resolve(o),s.resolve(i));r.dispatch(r.state.tr.setSelection(l))}});E(this,"notificationManager",{open:e=>this.core.ui.notify({text:e.text,...e.type?{type:e.type}:{},...e.timeout!==void 0?{timeout:e.timeout}:{}}),close:()=>{}});E(this,"windowManager",{alert:(e,t)=>{let r=document.createElement("p");r.textContent=e,this.core.ui.openDialog({title:"",body:r,onSubmit:()=>!0,...t?{onClose:t}:{}})},confirm:(e,t)=>{let r=document.createElement("p");r.textContent=e;let o=!1;this.core.ui.openDialog({title:"",body:r,submitLabel:"OK",onSubmit:()=>(o=!0,!0),onClose:()=>t?.(o)})},open:e=>vf(this.core,e,t=>this.windowManager.open(t))});E(this,"ui",{registry:{addIcon:(e,t)=>{li.set(e,t)},addButton:(e,t)=>this.addButton(e,t,!1),addToggleButton:(e,t)=>this.addButton(e,t,!0),addMenuButton:(e,t)=>{let r=[];t.fetch(i=>r=i);let o=si(t.icon);this.core.ui.registry.addMenuButton(e,{tooltip:t.tooltip??t.text??e,...o?{icon:o}:{text:t.text??e},items:()=>(t.fetch(i=>r=i),r.map((i,s)=>i.type==="separator"?{type:"separator"}:{id:`${e}-${s}`,label:i.text??"",onSelect:()=>i.onAction?.({})}))})},addMenuItem:(e,t)=>{let r=si(t.icon);this.core.ui.registry.addMenuItem(e,{text:t.text??e,...r?{icon:r}:{},onAction:()=>t.onAction?.({})})},addContextToolbar:(e,t)=>{this.core.ui.registry.addContextToolbar(e,{label:t.label??e,items:t.items,position:t.position==="node"?"node":"selection",predicate:()=>{let r=this.selection.getNode();return!!r&&this.getBody().contains(r)&&t.predicate(r)}})},addSidebar:(e,t)=>{let r=null,o={element:()=>r},i=si(t.icon);this.core.ui.registry.addSidebar(e,{title:t.tooltip??e,...i?{icon:i}:{},render:s=>{r=s;let l=t.onSetup?.(o);return typeof l=="function"?l:void 0},onShow:()=>t.onShow?.(o),onHide:()=>t.onHide?.(o)})},addContextForm:()=>{console.warn("[nova] tinymce-compat: addContextForm is not supported yet")},getAll:()=>({})}});E(this,"dom",{select:(e,t)=>[...(t??this.getBody()).querySelectorAll(e)],get:e=>typeof e=="string"?this.getBody().querySelector(`#${CSS.escape(e)}`):e,getParent:(e,t)=>{let r=e instanceof Element?e:e?.parentElement??null;for(;r&&r!==this.getBody();){if(typeof t=="string"?r.matches(t):t(r))return r;r=r.parentElement}return null},getParents:(e,t)=>{let r=[],o=e instanceof Element?e:e?.parentElement??null;for(;o&&o!==this.getBody();)(!t||o.matches(t))&&r.push(o),o=o.parentElement;return r},is:(e,t)=>!!e?.matches(t),getAttrib:(e,t,r="")=>e?.getAttribute(t)??r,hasClass:(e,t)=>!!e?.classList.contains(t),getStyle:(e,t)=>e instanceof HTMLElement?e.style.getPropertyValue(t):"",getRoot:()=>this.getBody(),encode:e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`),decode:e=>{let t=document.createElement("textarea");return t.innerHTML=e,t.value},create:(e,t={},r)=>{let o=document.createElement(e);for(let[i,s]of Object.entries(t))i.startsWith("on")||o.setAttribute(i,s);return r!==void 0&&(o.textContent=r),o},uniqueId:(e="mce_")=>`${e}${Math.random().toString(36).slice(2,10)}`,setAttrib:()=>xr("setAttrib"),addClass:()=>xr("addClass"),removeClass:()=>xr("removeClass"),setStyle:()=>xr("setStyle"),remove:()=>xr("remove")});E(this,"formatter",{apply:(e,t={})=>this.applyFormat(e,t,"apply"),remove:e=>this.applyFormat(e,{},"remove"),toggle:(e,t={})=>this.applyFormat(e,t,this.formatter.match(e)?"remove":"apply"),match:e=>{if(this.core.formatter.has(e))return this.core.formatter.match(e);let t=e.toLowerCase();if(Hv.has(t))return this.blockMatches(t);let r=va[t];if(r)return this.core.isActive(r);let o=ka[t];if(!o)return!1;let{state:i}=this.core.view,{from:s,to:l,empty:a}=i.selection,c=i.schema.marks[o];return a||!c?Ye(i,o)!==null:i.doc.rangeHasMark(s,l,c)},canApply:e=>this.core.formatter.has(e)||e.toLowerCase()in va||e.toLowerCase()in ka,register:(e,t)=>{let r=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[o,i]of r){let s=oi(i);s.length?this.core.formatter.register(o,s):console.warn(`[nova] tinymce-compat: format "${o}" is not supported yet`)}},unregister:e=>this.core.formatter.unregister(e),get:e=>this.core.formatter.get(e)});this.core=e,this.targetElm=t,this.id=r,this.settings=o}getContent(e={}){let t={format:e.format??"html",content:""};return t.content=t.format==="text"?this.core.getText():this.core.getHTML(),this.fire("GetContent",t),t.content}setContent(e,t={}){let r={content:e,...t};return this.fire("BeforeSetContent",r),this.core.setContent(r.content),this.fire("SetContent",r),r.content}insertContent(e){this.core.insertContent(e)}resetContent(e){this.core.setContent(e??this.settings.__initialContent??"",{addToHistory:!1}),this.setDirty(!1)}getBody(){return this.core.view.dom}getElement(){return this.targetElm}getContainer(){return this.core.root}getContentAreaContainer(){return this.core.view.dom.parentElement??this.core.root}getDoc(){return this.core.root.ownerDocument}getWin(){return this.core.root.ownerDocument.defaultView}queryCommandValue(e){return e.toLowerCase()==="togglesidebar"?this.core.ui.sidebar.active??"":""}execCommand(e,t,r){let o=e.toLowerCase(),i=!1;if(ii[o])i=this.core.exec(ii[o]);else if(o==="formatblock"||o==="mcetoggleformat"){let s=Pv[String(r??"").toLowerCase()];i=s?this.core.exec(s):!1}else if(o==="mceinsertcontent"||o==="inserthtml")this.insertContent(String(r??"")),i=!0;else if(o==="togglesidebar")this.core.ui.sidebar.toggle(String(r??"")),i=!0;else if(o==="mcesetcontent")this.setContent(String(r??"")),i=!0;else if(o==="selectall"){let{state:s,dispatch:l}=this.core.view;l(s.tr.setSelection(new se(s.doc))),i=!0}else if(o==="mcecleanup")i=!0;else{let s=this.commands.get(o);s&&(s(t,r),i=!0)}return i&&this.fire("ExecCommand",{command:e,ui:t,value:r}),i}queryCommandState(e){let t=ii[e.toLowerCase()];return t?this.core.isActive(t):!1}queryCommandSupported(e){let t=e.toLowerCase();return t in ii||["formatblock","mceinsertcontent","mcesetcontent"].includes(t)||this.commands.has(t)}addCommand(e,t){this.commands.set(e.toLowerCase(),t)}on(e,t,r=!1){for(let o of e.toLowerCase().split(/\s+/).filter(Boolean)){let i=this.handlers.get(o)??new Set;r?this.handlers.set(o,new Set([t,...i])):this.handlers.set(o,i.add(t))}return this}off(e,t){if(!e)return this.handlers.clear(),this;for(let r of e.toLowerCase().split(/\s+/).filter(Boolean))t?this.handlers.get(r)?.delete(t):this.handlers.delete(r);return this}once(e,t){let r=o=>(this.off(e,r),t(o));return this.on(e,r)}fire(e,t={}){let r=Object.assign(t,{type:e.toLowerCase(),target:this});for(let o of[...this.handlers.get(e.toLowerCase())??[]])try{o(r)}catch(i){console.error(`[nova] tinymce-compat: "${e}" handler failed`,i)}return r}fireNative(e,t){for(let r of[...this.handlers.get(e)??[]])try{r(t)}catch(o){console.error(`[nova] tinymce-compat: "${e}" handler failed`,o)}}static registerIcon(e,t){li.set(e,t)}dispatch(e,t){return this.fire(e,t)}hasEventListeners(e){return(this.handlers.get(e.toLowerCase())?.size??0)>0}isDirty(){return this.dirty}setDirty(e){let t=this.dirty!==e;this.dirty=e,t&&e&&this.fire("Dirty")}save(){let e=this.getContent(),t=this.fire("SaveContent",{content:e});return this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.value=String(t.content)),this.setDirty(!1),String(t.content)}focus(){this.core.focus()}hasFocus(){return this.core.view.hasFocus()}hide(){this.core.root.hidden=!0,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!1)}show(){this.core.root.hidden=!1,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!0)}isHidden(){return this.core.root.hidden===!0}getParam(e,t){return e in this.settings?this.settings[e]:t}addButton(e,t,r){let{api:o,state:i}=Fv(this);t.enabled===!1&&o.setEnabled(!1),t.active&&o.setActive(!0);let s=si(t.icon);if(this.core.ui.registry.addButton(e,{tooltip:t.tooltip??t.text??e,...s?{icon:s}:{text:t.text??e},isEnabled:()=>i.enabled,...r?{isActive:()=>i.active}:{},onAction:()=>t.onAction?.(o)}),t.onSetup){let l=()=>{let a=t.onSetup(o);typeof a=="function"&&this.teardowns.push(a)};this.initialized?l():this.once("init",l)}}blockMatches(e){let{$from:t}=this.core.view.state.selection;for(let o=t.depth;o>0;o-=1){let i=t.node(o),s=i.type.name;if(e==="blockquote"&&s==="blockquote")return!0;if(o===t.depth){if(e==="p")return s==="paragraph";if(e==="pre")return s==="code_block";if(/^h[1-6]$/.test(e))return s==="heading"&&i.attrs.level===Number(e[1])}}let r=null;if(this.core.view.state.doc.descendants(o=>r||!o.isTextblock?!r:(r={name:o.type.name,level:o.attrs.level},!1)),!t.depth&&r){let o=r;if(e==="p")return o.name==="paragraph";if(e==="pre")return o.name==="code_block";if(/^h[1-6]$/.test(e))return o.name==="heading"&&o.level===Number(e[1])}return!1}applyFormat(e,t,r){if(this.core.formatter.has(e)){r==="apply"?this.core.formatter.apply(e):this.core.formatter.remove(e);return}let o=e.toLowerCase(),i=va[o];if(i){let l=this.formatter.match(o);Bv.has(o)?r==="apply"?this.core.exec(i):l&&this.core.exec("paragraph"):r==="apply"!==l&&this.core.exec(i);return}let s=ka[o];if(s){this.core.exec(ut(s,r==="apply"?t.value??null:null));return}console.warn(`[nova] tinymce-compat: format "${e}" is not supported yet`)}remove(){if(this.removed)return;this.fire("remove"),this.save(),this.teardowns.splice(0).forEach(t=>t()),this.removed=!0,this.core.destroy(),this.core.root.remove(),this.settings.__wrapper?.remove(),this.targetElm.hidden=!1,this.off()}destroy(){this.remove()}};var kf=new Set;function Ma(n){kf.has(n)||(kf.add(n),console.warn(`[nova] tinymce-compat: ${n}`))}var zv=0,ai=n=>typeof n=="number"?`${n}px`:String(n);function _v(){ea(mf);let n=[],e=new Map,t=null;async function r(i,s){let l=n.find(L=>L.targetElm===i&&!L.removed);if(l)return l;let{options:a,unknown:c,missingPlugins:u}=bf(s);c.length&&Ma(`options not supported yet: ${c.join(", ")}`);let d=String(Array.isArray(s.plugins)?s.plugins.join(" "):s.plugins??"").split(/[\s,]+/).filter(L=>e.has(L)),p=u.filter(L=>!e.has(L));p.length&&Ma(`plugins not available: ${p.join(", ")}`);let f=i.id||`mce_${++zv}`;i.id||(i.id=f);let h=i instanceof HTMLTextAreaElement,g=h?i.value:i.innerHTML,m={...s,__initialContent:g},b;s.inline===!0&&!h?(i.replaceChildren(),b=i):(b=document.createElement("div"),b.className="nova-compat",i.after(b),i.hidden=!0,m.__wrapper=b);let k,y=ti({...a,element:b,content:g,setup:L=>{k=new Sr(L,i,f,m);for(let R of d)try{e.get(R)(k,"")}catch(O){console.error(`[nova] tinymce-compat: plugin "${R}" failed`,O)}s.setup?.(k)}});s.height!==void 0&&(y.root.style.height=ai(s.height)),s.min_height!==void 0&&(y.root.style.minHeight=ai(s.min_height)),s.max_height!==void 0&&(y.root.style.maxHeight=ai(s.max_height)),s.width!==void 0&&(y.root.style.width=ai(s.width));let w=!1;y.on("change",()=>{k.setDirty(!0),w=!0,k.fire("input")}),y.on("selectionChange",()=>{k.fire("NodeChange",{element:k.selection.getNode(),selectionChange:!0})}),y.on("focus",()=>{t=k,w=!1,k.fire("focus")}),y.on("blur",()=>{w&&k.fire("change",{level:{content:k.getContent()}}),w=!1,k.fire("blur")});for(let L of["keydown","keyup","keypress","click","dblclick","mousedown","mouseup","paste","copy","cut","drop"])y.view.dom.addEventListener(L,R=>k.fireNative(L,R));return(h?i.form:i.closest("form"))?.addEventListener("submit",()=>k.save()),k.on("remove",()=>{let L=n.indexOf(k);L>=0&&n.splice(L,1),t===k&&(t=n[0]??null)}),n.push(k),t??(t=k),await y.ready,k.removed||(k.initialized=!0,k.fire("init"),s.init_instance_callback?.(k)),k}return{majorVersion:"7",minorVersion:"0.0",novaprose:!0,get activeEditor(){return t},get editors(){return[...n]},async init(i){document.readyState==="loading"&&await new Promise(a=>document.addEventListener("DOMContentLoaded",a,{once:!0}));let s=i.target?[i.target]:i.selector?[...document.querySelectorAll(i.selector)]:[];s.length||Ma(`no elements match "${i.selector??""}"`);let l=[];for(let a of s)l.push(await r(a,i));return l},get:(i=>i===void 0?[...n]:typeof i=="number"?n[i]??null:n.find(s=>s.id===i)??null),remove(i){(i===void 0?[...n]:typeof i=="string"?n.filter(l=>l.id===i.replace(/^#/,"")||l.targetElm.matches(i)):[i]).forEach(l=>l.remove())},triggerSave(){n.forEach(i=>i.save())},execCommand(i,s,l){return t?.execCommand(i,s,l)??!1},PluginManager:{add:(i,s)=>{e.set(i,s)},get:i=>e.get(i),requireLangPack:()=>{},urls:{}},IconManager:{add:(i,s)=>{for(let[l,a]of Object.entries(s.icons??{}))Sr.registerIcon(l,a)}},util:{I18n:{translate:i=>i}}}}var Mf=_v();Hi("ru",sf);var xf=document.currentScript;if(xf?.src&&!document.querySelector("link[data-novaprose-css]")){let n=document.createElement("link");n.rel="stylesheet",n.href=xf.src.replace(/[^/]*$/,"novaprose.css"),n.setAttribute("data-novaprose-css",""),document.head.append(n)}window.tinymce=Mf;var re=globalThis.__novaprose_tinymce={};re["node_modules/.pnpm/prosemirror-history@1.5.2/node_modules/prosemirror-history/dist/index.js"]=Qs;re["node_modules/.pnpm/prosemirror-inputrules@1.7.0/node_modules/prosemirror-inputrules/dist/index.js"]=Al;re["node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.js"]=gs;re["node_modules/.pnpm/prosemirror-model@1.25.13/node_modules/prosemirror-model/dist/index.js"]=xi;re["node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js"]=Ri;re["node_modules/.pnpm/prosemirror-transform@1.12.7/node_modules/prosemirror-transform/dist/index.js"]=Ni;re["node_modules/.pnpm/prosemirror-view@1.43.1/node_modules/prosemirror-view/dist/index.js"]=hs;re["packages/core/src/commands.ts"]=ol;re["packages/core/src/comments.ts"]=Ms;re["packages/core/src/editor.ts"]=ma;re["packages/core/src/image.ts"]=Sl;re["packages/core/src/link.ts"]=Dl;re["packages/core/src/plugins.ts"]=pi;re["packages/core/src/plugins/shared.ts"]=Fi;re["packages/core/src/schema.ts"]=qs;re["packages/core/src/serializer.ts"]=aa;re["packages/core/src/tables.ts"]=Jl;re["packages/core/src/ui/dom.ts"]=Ii;re["packages/core/src/ui/icons.ts"]=fi;re["packages/core/src/url.ts"]=Ps;})();
46
+ `)}setContent(e,{addToHistory:t=!0,fullPage:r=!0}={}){let o={content:e};this.emit("beforeSetContent",o);let i=r?Tn.get(this):void 0,s=cd(this.schema,o.content,i),l=this.view.state.tr.replaceWith(0,this.view.state.doc.content.size,s.content);if(i&&(typeof o.content!="string"||dy.has(s)))for(let[a,c]of Object.entries(s.attrs))c!==this.view.state.doc.attrs[a]&&l.setDocAttribute(a,c);l.setMeta(As,!0).setMeta(fi,!0),t||l.setMeta("addToHistory",!1),this.view.dispatch(l),this.emit("setContent",{content:o.content})}insertContent(e){return this.isEditable()?cy(e)(this.view.state,this.view.dispatch):!1}isEmpty(){return this.view.dom.classList.contains("nova-empty")}resolveCommand(e){e=co("commands",e);let t=this.commandOverrides.get(e)??(Object.prototype.hasOwnProperty.call(Ue,e)?Ue[e]:void 0);return t||(uy.has(e)||(uy.add(e),console.warn(`[nova] unknown command "${String(e)}": editor.exec() returns false`)),()=>!1)}registerCommands(e){for(let[t,r]of Object.entries(e.commands??{}))r&&this.commandOverrides.set(t,r);e.transformTransaction&&this.transactionTransforms.push(e.transformTransaction)}exec(e){let r=(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,this.view.dispatch,this.view);return r&&this.view.focus(),r}chain(){return $g({view:()=>this.destroyed?null:this.view,resolve:e=>this.resolveCommand(e),insertContent:e=>(t,r,o)=>this.isEditable()&&cy(e)(t,r,o)})}can(e){let t=typeof e=="string"?this.resolveCommand(e):e;try{return t(this.view.state,void 0,this.view)}catch{return!1}}isActive(e){return cr(this.view.state,co("commands",e))}getCommandState(e){return{active:this.isActive(e),enabled:this.isEditable()&&this.can(e)}}focus(){this.destroyed||this.view.focus()}isPasteAsText(){return this.pasteAsText}setPasteAsText(e){this.pasteAsText=e,this.toolbar?.update()}loadSearchBar(){return this.searchBarLoad??(this.searchBarLoad=import(__novaChunk("tinymce-chunks/search-bar-1c8ef2ee.js") ).then(({createSearchBar:e})=>{if(this.destroyed)return null;let t=this.toolbarHost.parentElement;return this.searchBar=e(this,r=>t?t.append(r):this.contentHost.before(r)),this.searchBar},e=>(xt("The find and replace bar failed to load",e),null))),this.searchBarLoad}openSearch(){return this.loadSearchBar().then(e=>e?.open())}closeSearch(){this.searchBar?.close()}isEditable(){return this.editable&&!this.disabled}isDisabled(){return this.disabled}setDisabled(e){this.disabled!==e&&(this.disabled=e,this.view.setProps({}),this.applyDisabled(),e&&(this.ui.closePopover(),this.view.dom.blur()),this.toolbar?.update(),this.emit("editableChange"))}applyDisabled(){this.root.classList.toggle("nova-disabled",this.disabled),this.disabled?this.root.setAttribute("aria-disabled","true"):this.root.removeAttribute("aria-disabled"),this.disabled?this.view.dom.setAttribute("tabindex","-1"):this.view.dom.removeAttribute("tabindex")}setEditable(e){this.editable!==e&&(this.editable=e,this.view.setProps({}),this.root.classList.toggle("nova-readonly",!e),e||this.ui.closePopover(),this.toolbar?.update(),this.emit("editableChange"))}on(e,t){e=co("events",e);let r=this.listeners.get(e);return r||this.listeners.set(e,r=new Set),r.add(t),()=>this.off(e,t)}off(e,t){e=co("events",e),this.listeners.get(e)?.delete(t)}emit(e,...[t]){for(let r of this.listeners.get(e)??[])try{r(this,t)}catch(o){xt(`Listener for "${e}" failed`,o)}}destroy(){if(!this.destroyed){this.emit("destroy"),this.destroyed=!0,this.menubar?.destroy(),this.ui.destroy(),this.toolbar?.destroy(),this.statusbar?.destroy();for(let e of this.cleanups.splice(0))try{e()}catch(t){xt("Plugin cleanup failed",t)}this.searchBar?.destroy(),this.root.classList.contains("nova-fullscreen")&&yr(this,!1),this.view.destroy(),this.root.remove(),this.listeners.clear()}}};function xt(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}var dy=new WeakSet;function cd(n,e,t){if(typeof e!="string")return Te.fromJSON(n,po(n,e));let r=t?t.read(e):null,o=document.createElement("div"),i=document.createElement("template");i.innerHTML=r?r.content:e,o.appendChild(i.content);let s=gr(n).parse(o);if(!r)return s;let l=s.type.create(r.attrs,s.content);return dy.add(l),l}function Ts(n){return new vo(n)}var fd={};q(fd,{prettyHTML:()=>Ns});var py=new Set(["address","article","aside","blockquote","caption","col","colgroup","dd","details","div","dl","dt","figcaption","figure","footer","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"]),Jw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Gw=/<!--[\s\S]*?-->|<\/?[a-zA-Z][^>]*>|[^<]+|</g;function pd(n){let e=/^<(\/?)([a-zA-Z][\w-]*)/.exec(n);return e?{name:e[2].toLowerCase(),closing:e[1]==="/"}:null}function Ns(n,e=" "){let t=n.match(Gw)??[],r="",o=0,i=[],s=()=>(r?`
47
+ `:"")+e.repeat(o);for(let l=0;l<t.length;l++){let a=t[l],c=pd(a);if(c&&!c.closing&&c.name==="pre"){let f=l,h=0;for(;f<t.length;f++){let m=pd(t[f]);if(m?.name==="pre"&&(h+=m.closing?-1:1),h===0)break}r+=s()+t.slice(l,f+1).join(""),l=f;continue}if(!c||!py.has(c.name)){r+=a;continue}if(c.closing){i.pop()?.spread&&(o=Math.max(0,o-1),r+=s()),r+=a;continue}let u=i[i.length-1];if((!u||u.spread)&&(r+=s()),r+=a,Jw.has(c.name)||a.endsWith("/>"))continue;let d=pd(t[l+1]??""),p=!!d&&!d.closing&&py.has(d.name);i.push({name:c.name,spread:p}),p&&o++}return r}var fy=new Set("script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image".split(",")),Yw=/^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/,Xw=/^[a-z_:][a-z0-9_.:-]*$/,hy=/^[a-z][a-z0-9._-]*$/,br=new Set("p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,img,figure,figcaption,br,table,tr,td,th,strong,em,u,s,code,a,sub,sup".split(",")),xo=new Set(["span","i","b","del","strike","mark"]),Zw=new Set("abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr".split(",")),vy=new Set("div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search".split(",")),Qw=new Set([...vy,..."p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure".split(",")]),eS={a:["href"],ul:["data-type"],li:["data-type","data-checked"],img:["src"],td:["colspan","rowspan"],th:["colspan","rowspan"]};function my(n){let e=[],t=0,r="";for(let o of n)o==="["?t++:o==="]"&&(t=Math.max(0,t-1)),o===","&&!t?(e.push(r),r=""):r+=o;return e.push(r),e.map(o=>o.trim()).filter(Boolean)}function tS(n){let e=n.trim(),t=e.startsWith("!");t&&(e=e.slice(1));let r=/^([^=:<]+)(?:([=:<])(.*))?$/s.exec(e);if(!r)return null;let o=r[1].trim().toLowerCase();if(!o)return null;let i={name:o,required:t},s=r[3]??"";return r[2]==="="?i.def=s:r[2]===":"?i.forced=s:r[2]==="<"&&(i.values=s.split("?")),i}function hd(n,e){return n==="*"?!0:n.endsWith("*")?e.startsWith(n.slice(0,-1)):n===e}var gy=new Set;function md(n,e){gy.has(n)||(gy.add(n),console.warn(`[nova] <${n}> in content rules is ignored: ${e}`))}var gd=class{constructor(e){S(this,"elements",new Map);S(this,"globals",[]);S(this,"blockTags",new Map);S(this,"inlineTags",new Map);let t=new Set((e.invalidElements??"").split(",").map(s=>s.trim().toLowerCase()).filter(Boolean)),r=new Set,o=new Set;for(let s of(e.customElements??"").split(",")){let l=s.trim().toLowerCase(),a=l.replace(/^~/,"");if(hy.test(a)){if(fy.has(a)||br.has(a)){md(a,"it cannot be a custom element");continue}o.add(a),l.startsWith("~")&&r.add(a)}}let i=(s,l)=>{let[a,...c]=s;if(a){if(a==="@"||a==="*"){this.globals.push(...l??[]);return}for(let u of s){if(!hy.test(u)||t.has(u))continue;if(fy.has(u)){md(u,"not allowed for security reasons (iframes and video: use the media plugin)");continue}this.elements.set(u,l);let d=br.has(u)||xo.has(u)?u:a;if(br.has(u))continue;if(xo.has(u)){u===a&&l?.length&&this.inlineTags.set(u,u);continue}let p=o.has(u)||o.has(a)||u.includes("-");Zw.has(a)||r.has(a)?this.inlineTags.set(u,d):vy.has(a)||p?this.blockTags.set(u,d):(!c.includes(u)||u===a)&&md(u,"unknown element")}}};for(let s of my(e.validElements??"")){let{names:l,attrs:a}=yy(s);a?i(l,a):l.every(c=>br.has(c)||xo.has(c))||i(l,null)}for(let s of my(e.extendedValidElements??"")){let{names:l,attrs:a}=yy(s);i(l,a)}for(let s of o)t.has(s)||(this.elements.has(s)||this.elements.set(s,[{name:"*",required:!1}]),r.has(s)?this.inlineTags.set(s,s):this.inlineTags.has(s)||this.blockTags.set(s,s))}apply(e,t){return sS(e.nodes,e.marks,this,t)}get active(){return this.elements.size>0||this.globals.length>0}touches(e){return this.globals.length>0||this.elements.has(e)}rulesFor(e){return[...this.elements.get(e)??[],...this.globals]}allows(e,t){return Yw.test(t)||!Xw.test(t)?!1:this.rulesFor(e).some(r=>hd(r.name,t))}extends(e){return this.rulesFor(e).some(t=>t.name!=="class"&&t.name!=="style")}get classOnBuiltIn(){if(this.globals.some(e=>hd(e.name,"class")))return!0;for(let[e,t]of this.elements)if(br.has(e)&&t?.some(r=>hd(r.name,"class")))return!0;return!1}hasRequired(e,t){return this.rulesFor(e).every(r=>!r.required||t.hasAttribute(r.name))}readAttrs(e,t,r){let o=null;for(let i of Array.from(t.attributes)){let s=i.name.toLowerCase();if(s===cs&&(s="style"),s==="lang"||r.includes(s)||!this.allows(e,s))continue;let l=Zr(s,i.value);l!==null&&((o??(o={}))[s]=l)}return o}outputAttrs(e,t,r){let o={...t};if(r&&typeof r=="object"&&!Array.isArray(r))for(let[s,l]of Object.entries(r)){let a=s.toLowerCase();if(o[a]!=null||a==="lang"||!this.allows(e,a)||!["string","number","boolean"].includes(typeof l))continue;let c=Zr(a,String(l));c!==null&&(o[a]=c)}if(this.elements.get(e))for(let s of Object.keys(o))this.allows(e,s)||eS[e]?.includes(s)||s.startsWith("data-nova-")||delete o[s];for(let s of this.rulesFor(e)){if(s.name.includes("*"))continue;s.forced!==void 0?o[s.name]=s.forced:s.def!==void 0&&o[s.name]==null&&(o[s.name]=s.def);let l=o[s.name];s.values&&l!=null&&!s.values.includes(String(l))&&delete o[s.name]}return e==="a"&&o.target!=null&&o.rel==null&&(o.rel="noopener noreferrer"),o}decorate(e,t){if(!Array.isArray(e)||typeof e[0]!="string")return e;let r=e[0],o=(r.includes(" ")?r.split(" ")[1]:r).toLowerCase();if(!this.touches(o))return e;let i=e[1],s=!!i&&typeof i=="object"&&!Array.isArray(i)&&i.nodeType===void 0,l=this.outputAttrs(o,s?i:{},t);return[r,l,...e.slice(s?2:1)]}};function yy(n){let e=/^([^[]*)(?:\[(.*)\])?$/s.exec(n.trim()),t=(e?.[1]??"").trim().replace(/^[-#+!]+/,"").split("/").map(i=>i.trim().toLowerCase()).filter(Boolean),r=e?.[2],o=r===void 0?null:r.split("|").map(tS).filter(i=>i!==null);return{names:t,attrs:o}}function nS(n){if(!n.validElements&&!n.extendedValidElements&&!n.customElements)return null;let e=new gd(n);return e.active?e:null}var by=n=>(/^[a-z][a-z0-9-]*/i.exec(n)?.[0]??"").toLowerCase();function rS(n,e,t,r,o){try{let i=n.schema,s=e==="node"?o(i.nodes[t].create(r)):o(i.marks[t].create(r),!0),l=Array.isArray(s)?s[1]:null;return l&&typeof l=="object"&&!Array.isArray(l)?Object.keys(l):[]}catch{return[]}}function oS(n,e,t,r,o){let i=(e.parseDOM??[]).map(a=>a.tag?by(a.tag):"").filter(a=>br.has(a)&&r.touches(a));if(!i.length||!e.toDOM)return e;let s=i.some(a=>r.extends(a)),l=e.toDOM;return{...e,...s?{attrs:{...e.attrs,htmlAttrs:{default:null}}}:{},parseDOM:e.parseDOM.map(a=>{let c=a.tag?by(a.tag):"";if(!i.includes(c))return a;let u=a.getAttrs;return{...a,getAttrs:d=>{let p=u?u(d):a.attrs??null;if(p===!1||!r.hasRequired(c,d))return!1;if(!s)return p;let f=r.readAttrs(c,d,["class","style"]);if(!f)return p;for(let h of rS(o,t,n,{...p},l))delete f[h];return Object.keys(f).length?{...p,htmlAttrs:f}:p}}}),toDOM:((a,c)=>r.decorate(l(a,c),a.attrs.htmlAttrs))}}function ky(n,e){return Array.from(n.children).some(t=>{let r=t.localName;return Qw.has(r)||e.blockTags.has(r)})}function iS(n){let e={},t={},r=(a,c,u)=>{if(!n.hasRequired(a,c))return!1;let d=xo.has(a),p=d?u&&a==="span"?["class","style"]:["style"]:[],f=n.readAttrs(a,c,p);return d&&!f?!1:{tag:a,htmlAttrs:f}},o=a=>[...a].filter(([,c])=>!xo.has(c)).map(([c])=>c),i=(a,c,u)=>{let d=typeof u.tag=="string"&&a.has(u.tag)?u.tag:c;return{tag:d,attrs:n.outputAttrs(d,{},u.htmlAttrs)}},s=[...n.blockTags];if(s.length){let a=new Set(n.blockTags.values()),c=a.has("div")?"div":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_block={ownStyleTags:o(n.blockTags),group:"block",content:"block+",defining:!0,attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ky(f,n)?r(p,f,!1):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}},e.html_textblock={group:"block",content:"inline*",attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ky(f,n)?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}let l=[...n.inlineTags];if(l.length){let a=new Set(n.inlineTags.values()),c=a.has("span")?"span":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_inline_atom={ownStyleTags:o(n.inlineTags),group:"inline",inline:!0,atom:!0,attrs:u,parseDOM:l.map(([d,p])=>({tag:d,priority:65,getAttrs:f=>f.firstChild?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f]}},t.html_inline={attrs:u,excludes:"",parseDOM:l.map(([d,p])=>({tag:d,priority:p==="span"?40:60,getAttrs:f=>f.firstChild?r(p,f,!0):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}return{nodes:e,marks:t}}function sS(n,e,t,r){let o=(s,l)=>Object.fromEntries(Object.entries(s).map(([a,c])=>[a,oS(a,c,l,t,r)])),i=iS(t);return{nodes:{...o(n,"node"),...i.nodes},marks:{...o(e,"mark"),...i.marks}}}var xy={create:nS};var wy=new Set(["lists","link","image","table","code","preview","searchreplace","fullscreen","help","wordcount","paste","hr","print","textcolor","colorpicker","contextmenu","tabfocus","textpattern","imagetools","powerpaste"]),Sy={tinycomments:"comments",tinymcespellchecker:"spellchecker",inlinecss:"email"},lS=new Set(["selector","target","license_key","api_key","branding","promotion","skin","skin_url","content_css","icons","icons_url","theme","theme_url","base_url","suffix","referrer_policy","convert_urls","relative_urls","remove_script_host","document_base_url","entity_encoding","height","min_height","max_height","width","resize","content_style","setup","init_instance_callback","inline","plugins","toolbar","menubar","statusbar","placeholder","readonly","disabled","block_formats","file_picker_callback","formats","style_formats","style_formats_merge","valid_classes","table_class_list","table_cell_class_list","file_picker_types","language","images_upload_handler","paste_as_text","paste_preprocess","paste_postprocess","invalid_elements","valid_elements","directionality","extended_valid_elements","custom_elements","valid_styles","toolbar_mode","toolbar_sticky","toolbar_sticky_offset","content_language","content_langs","font_family_formats","font_size_formats","line_height_formats","color_map","autosave_interval","autosave_retention","autosave_prefix","quickbars_selection_toolbar","quickbars_insert_toolbar","mentions_fetch","tinycomments_author","tinycomments_author_name","codesample_languages","details_initial_state","details_serialized_state","tableofcontents_class","tableofcontents_depth","tableofcontents_header","tableofcontents_orderedlist","tableofcontents_includeheader","codesample_global_prismjs","casechange_title_case_minors","permanentpen_properties","visualchars_default_state","save_enablewhendirty","save_onsavecallback","save_oncancelcallback","importcss_append","importcss_file_filter","importcss_selector_filter","importcss_groups","importcss_exclusive","importcss_selector_converter","templates","spellchecker_active","spellchecker_language","spellchecker_languages","spellchecker_ignore_list","spellchecker_dialog","spellchecker_languagetool_url","spellchecker_check","a11ychecker_level","a11ychecker_ignored_rules","a11ychecker_allow_decorative_images","a11y_advanced_options","a11ychecker_alt_text_max_length","a11ychecker_filter_issue","a11ychecker_html_version","a11ychecker_issue_url_callback","ai_request","ai_shortcuts","inlinecss_selector_filter","inlinecss_file_filter","linkchecker_service_url","linkchecker_preprocess","linkchecker_content_css","tiny_pageembed_classes","tiny_pageembed_inline_styles","fullpagehtml_default_doctype","fullpagehtml_default_title","fullpagehtml_default_encoding","fullpagehtml_default_body_style","fullpagehtml_hide_in_source_view","mediaembed_service_url","mediaembed_max_width","mediaembed_inline_styles","advtable_value_series","advcode_prettify_editor","advcode_prettify_getcontent","advcode_inline","view_show","sidebar_show","editimage_toolbar","editimage_credentials_hosts","editimage_fetch_image","editimage_cors_hosts","editimage_proxy","editimage_proxy_service_url","editimage_upload_timeout","autocorrect_autocorrect","autocorrect_capitalize","autocorrect_service_url","typography_default_lang","typography_langs","typography_rules","typography_ignore","text_patterns","text_patterns_lookup","template_replace_values","template_preview_replace_values","template_selected_content_classes","template_cdate_classes","template_mdate_classes","template_cdate_format","template_mdate_format"]),On=n=>(Array.isArray(n)?n.join(" "):String(n??"")).split(/[\s,]+/).filter(Boolean);function My(n,e){return On(n.plugins).filter(t=>wy.has(t)||e(Sy[t]??t))}function aS(n){return/\/dash\//.test(n)?"dashes":/^common\/punctuation\/(quote|apostrophe)$/.test(n)?"quotes":n==="common/punctuation/hellip"?"ellipsis":n==="common/punctuation/delDoublePunctuation"||n.startsWith("common/space/")?"spaces":n==="common/symbols/arrow"?"arrows":n.startsWith("common/symbols/")?"symbols":n==="common/number/fraction"?"fractions":n.startsWith("common/number/")?"math":n.startsWith("common/nbsp/")?"nbsp":null}var cS={code:["code","code_block"],pre:["code_block"],a:["link"],strong:["bold"],b:["bold"],em:["italic"],i:["italic"],blockquote:["blockquote"]};function uS(n){let e={},t=n.typography_default_lang,r=Array.isArray(t)?t[0]:t;typeof r=="string"&&r&&(e.language=r.replace(/_/g,"-"));let o=n.typography_langs,s=(Array.isArray(o)?o:o&&typeof o=="object"?Object.keys(o):[]).filter(l=>typeof l=="string").map(l=>l.replace(/_/g,"-"));if(s.length&&(e.languages=s),Array.isArray(n.typography_rules)){let l=new Set(n.typography_rules.map(a=>typeof a=="string"?aS(a):null));e.rules=Object.fromEntries(["quotes","dashes","ellipsis","symbols","arrows","math","fractions","spaces","nbsp"].map(a=>[a,l.has(a)]))}if(Array.isArray(n.typography_ignore)){let l=n.typography_ignore.flatMap(a=>typeof a=="string"?cS[a.toLowerCase().replace(/\[.*$/,"")]??[]:[]);l.length&&(e.ignore=[...new Set(l)])}return e}function Os(n){if(typeof n=="string")return n.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,r]=e.includes("=")?e.split("="):[e,e];return{label:t.trim(),value:(r??t).trim()}})}function dS(n){let e="",t=new Promise(o=>{let i=new FileReader;i.onload=()=>{e=String(i.result).replace(/^data:[^,]*,/,""),o()},i.onerror=()=>o(),i.readAsDataURL(n)}),r="";return{ready:t,info:{id:()=>n.name.replace(/\.[^.]+$/,"")||"image",name:()=>n.name.replace(/\.[^.]+$/,"")||"image",filename:()=>n.name||"image",blob:()=>n,base64:()=>e,blobUri:()=>r||(r=URL.createObjectURL(n)),uri:()=>{}}}}var pS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),fS=new Set(["span","strong","b","em","i","u","s","strike","del","code","sub","sup"]);function Ls(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r,i={};typeof o.block=="string"&&pS.has(o.block.toLowerCase())&&(i.block=o.block.toLowerCase()),typeof o.inline=="string"&&fS.has(o.inline.toLowerCase())&&(i.inline=o.inline.toLowerCase()),typeof o.selector=="string"&&(i.selector=o.selector),(typeof o.classes=="string"||Array.isArray(o.classes))&&(i.classes=o.classes),o.styles&&typeof o.styles=="object"&&(i.styles=Object.fromEntries(Object.entries(o.styles).filter(([,s])=>typeof s=="string"&&!s.includes("%")).map(([s,l])=>[s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),l]))),(i.block||i.inline||i.selector)&&t.push(i)}return t}function Ey(n){return Array.isArray(n)?n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=String(t.title??"");if(!r)return[];if(Array.isArray(t.items))return[{title:r,items:Ey(t.items)}];if(typeof t.format=="string")return[{title:r,format:t.format}];let[o]=Ls(t);return o?[{title:r,...o}]:[]}):[]}function Cy(n){return n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=typeof t.title=="string"?t.title:"";return r?Array.isArray(t.subprompts)?[{title:r,items:Cy(t.subprompts)}]:typeof t.prompt!="string"?[]:[{title:r,prompt:t.prompt,...typeof t.selection=="boolean"?{selection:t.selection}:{}}]:[]})}function Ay(n){let e=Object.keys(n).filter(b=>!lS.has(b)),t=[],r=[];for(let b of On(n.plugins)){let E=Sy[b]??b;wy.has(b)||(Co(E)?t.push(E):r.push(b))}t.includes("ai")&&!t.includes("suggestions")&&t.splice(t.indexOf("ai"),0,"suggestions"),t.includes("mediaembed")&&!t.includes("media")&&t.splice(t.indexOf("mediaembed"),0,"media");let o={plugins:t};n.toolbar===!1?o.toolbar=!1:Array.isArray(n.toolbar)?o.toolbar=n.toolbar.join(" | "):typeof n.toolbar=="string"&&(o.toolbar=n.toolbar),n.menubar!==void 0&&(o.menubar=n.menubar),n.text_patterns===!1&&(o.textPatterns=!1),typeof n.statusbar=="boolean"&&(o.statusbar=n.statusbar),typeof n.placeholder=="string"&&(o.placeholder=n.placeholder),n.readonly===!0&&(o.editable=!1),typeof n.content_style=="string"&&(o.contentStyle=n.content_style);let i=b=>Array.isArray(b)?b.filter(E=>!!E&&typeof E.title=="string"&&typeof E.value=="string").map(({title:E,value:_})=>({title:E,value:_})):void 0,s=i(n.table_class_list);s&&(o.tableClassList=s);let l=i(n.table_cell_class_list);if(l&&(o.tableCellClassList=l),n.formats&&typeof n.formats=="object"&&(o.formats=Object.fromEntries(Object.entries(n.formats).map(([b,E])=>[b,Ls(E)]).filter(([,b])=>b.length))),Array.isArray(n.style_formats)&&(o.styleFormats=Ey(n.style_formats),n.style_formats_merge===!0&&(o.styleFormatsMerge=!0)),typeof n.valid_classes=="string"?o.validClasses=On(n.valid_classes):n.valid_classes&&typeof n.valid_classes=="object"?o.validClasses=Object.values(n.valid_classes).flatMap(b=>On(b)):o.validClasses=!0,n.content_css!==void 0&&n.content_css!==!1){let b=new Set(["default","dark","document","writer","tinymce-5","tinymce-5-dark"]),E=(Array.isArray(n.content_css)?n.content_css:String(n.content_css).split(",")).map(_=>String(_).trim()).filter(_=>_&&!b.has(_));E.length&&(o.contentCss=E)}n.disabled===!0&&(o.disabled=!0),n.resize!==!1&&(o.resize=n.resize==="both"?"both":!0);let a=Os(n.block_formats);if(a){let b=["p","h1","h2","h3","h4","h5","h6","pre"];o.blockFormats=a.map(({label:E,value:_})=>({label:E,block:_.toLowerCase()})).filter(E=>b.includes(E.block))}if(typeof n.language=="string"&&(o.language=n.language.replace("_","-")),typeof n.content_language=="string"&&n.content_language&&(o.contentLanguage=n.content_language.replace(/_/g,"-")),o.contentLangs=Array.isArray(n.content_langs)?n.content_langs.flatMap(b=>{let{code:E,title:_}=b??{};return typeof E=="string"?[{code:E,...typeof _=="string"?{title:_}:{}}]:[]}):[],typeof n.toolbar_sticky_offset=="number"&&(o.toolbarStickyOffset=n.toolbar_sticky_offset),(n.toolbar_mode==="floating"||n.toolbar_mode==="sliding"||n.toolbar_mode==="scrolling"||n.toolbar_mode==="wrap")&&(o.toolbarMode=n.toolbar_mode),n.inline===!0&&(o.mode="inline"),n.paste_as_text===!0&&(o.pasteAsText=!0),typeof n.paste_preprocess=="function"){let b=n.paste_preprocess;o.pastePreprocess=(E,_)=>{let N={content:E};return b(_,N),N.content}}typeof n.invalid_elements=="string"&&(o.invalidElements=n.invalid_elements),typeof n.valid_elements=="string"&&(o.validElements=n.valid_elements),typeof n.extended_valid_elements=="string"&&(o.extendedValidElements=n.extended_valid_elements),typeof n.custom_elements=="string"&&(o.customElements=n.custom_elements),(n.directionality==="rtl"||n.directionality==="ltr")&&(o.direction=n.directionality),n.valid_styles&&(o.validStyles=n.valid_styles);let c=Os(n.font_family_formats);c&&(o.fontFamilies=c);let u=Os(n.font_size_formats);u&&(o.fontSizes=u.map(b=>b.value));let d=Os(n.line_height_formats);if(d&&(o.lineHeights=d.map(b=>b.value)),Array.isArray(n.color_map)&&(o.colors=n.color_map.filter((b,E)=>E%2===0).map(b=>b.startsWith("#")?b:`#${b}`)),typeof n.images_upload_handler=="function"){let b=n.images_upload_handler,E=async(_,N)=>{let{ready:$,info:K}=dS(_);return await $,b(K,N)};o.uploadImage=E}if(typeof n.file_picker_callback=="function"){let b=n.file_picker_callback;typeof n.file_picker_types=="string"&&(o.filePickerTypes=On(n.file_picker_types).filter(E=>E==="file"||E==="image"||E==="media")),o.filePicker=({type:E,value:_})=>new Promise(N=>b(($,K={})=>N({url:$,...K}),_,{filetype:E,fieldname:"src"}))}let p={};if(n.autosave_interval||n.autosave_retention||n.autosave_prefix){let b=E=>parseInt(String(E),10);p.autosave={...n.autosave_interval?{delay:b(n.autosave_interval)*1e3}:{},...n.autosave_retention?{retention:b(n.autosave_retention)}:{},...n.autosave_prefix?{key:String(n.autosave_prefix)}:{}}}if((n.quickbars_selection_toolbar!==void 0||n.quickbars_insert_toolbar!==void 0)&&(p.quickbars={...n.quickbars_selection_toolbar!==void 0?{selection:n.quickbars_selection_toolbar}:{},...n.quickbars_insert_toolbar!==void 0?{insert:n.quickbars_insert_toolbar}:{}}),typeof n.mentions_fetch=="function"){let b=n.mentions_fetch;p.mentions={fetch:E=>new Promise(_=>b({term:E},_))}}if(n.tinycomments_author&&(p.comments={author:{id:String(n.tinycomments_author),name:String(n.tinycomments_author_name??n.tinycomments_author)}}),Array.isArray(n.codesample_languages)){let b=n.codesample_languages.flatMap(E=>{let{text:_,value:N}=E??{};return typeof N=="string"&&N?[{value:N,label:typeof _=="string"&&_?_:N}]:[]});p.codesample={languages:b}}let f=b=>b==="inherited"||b==="collapsed"||b==="expanded"?b:void 0;(n.details_initial_state||n.details_serialized_state)&&(p.accordion={...f(n.details_initial_state)?{initialState:f(n.details_initial_state)}:{},...f(n.details_serialized_state)?{serializedState:f(n.details_serialized_state)}:{}}),On(n.plugins).includes("tableofcontents")&&(p.tableofcontents={className:typeof n.tableofcontents_class=="string"?n.tableofcontents_class:"mce-toc",titleTag:typeof n.tableofcontents_header=="string"?n.tableofcontents_header:"h2",...n.tableofcontents_depth!==void 0?{depth:Number(n.tableofcontents_depth)}:{},...n.tableofcontents_orderedlist?{orderedList:!0}:{},...n.tableofcontents_includeheader===!1?{title:""}:{}}),Array.isArray(n.casechange_title_case_minors)&&(p.casechange={titleCaseMinors:n.casechange_title_case_minors.map(String)}),n.permanentpen_properties&&typeof n.permanentpen_properties=="object"&&(p.permanentpen={properties:{...n.permanentpen_properties}}),n.visualchars_default_state===!0&&(p.visualchars={default:!0});let h=Object.fromEntries([["append",n.importcss_append],["fileFilter",n.importcss_file_filter],["selectorFilter",n.importcss_selector_filter],["groups",n.importcss_groups],["exclusive",n.importcss_exclusive],["converter",n.importcss_selector_converter]].filter(([,b])=>b!==void 0));Object.keys(h).length&&(p.importcss=h);let m=n.templates,g=Object.fromEntries([["templates",typeof m=="function"?()=>new Promise(b=>m(b)):m],["values",n.template_replace_values],["previewValues",n.template_preview_replace_values],["selectedContentClasses",n.template_selected_content_classes],["creationDateClasses",n.template_cdate_classes],["modifiedDateClasses",n.template_mdate_classes],["creationDateFormat",n.template_cdate_format],["modifiedDateFormat",n.template_mdate_format]].filter(([,b])=>b!==void 0));Object.keys(g).length&&(p.template=g);let k={};typeof n.spellchecker_active=="boolean"&&(k.active=n.spellchecker_active);let x=n.content_language??n.spellchecker_language;typeof x=="string"&&x&&(k.language=x.replace(/_/g,"-")),typeof n.spellchecker_languages=="string"&&(k.languages=n.spellchecker_languages.split(",").map(b=>b.split("=")).filter(b=>b.length===2&&!!b[0].trim()&&!!b[1].trim()).map(([b,E])=>({name:b.trim(),code:E.trim().replace(/_/g,"-")})));let M=n.spellchecker_ignore_list,L=Array.isArray(M)?M:M&&typeof M=="object"?Object.values(M).flatMap(b=>Array.isArray(b)?b:[]):[];if(L.length&&(k.ignore=L.filter(b=>typeof b=="string")),typeof n.spellchecker_check=="function"&&(k.check=n.spellchecker_check),typeof n.spellchecker_languagetool_url=="string"&&(k.languageTool={url:n.spellchecker_languagetool_url}),Object.keys(k).length&&(p.spellchecker=k),On(n.plugins).includes("a11ychecker")){let b={allowDecorativeImages:(n.a11ychecker_allow_decorative_images??n.a11y_advanced_options)===!0};typeof n.a11ychecker_level=="string"&&(b.level=n.a11ychecker_level.toLowerCase()),typeof n.a11ychecker_ignored_rules=="string"&&(b.ignoredRules=n.a11ychecker_ignored_rules.split(",").map(_=>_.trim()).filter(Boolean)),typeof n.a11ychecker_alt_text_max_length=="number"&&(b.altTextMaxLength=n.a11ychecker_alt_text_max_length);let E=n.a11ychecker_filter_issue;typeof E=="function"&&(b.filterIssue=_=>E({..._,id:_.rule,contentID:_.text})!==!1),p.a11ychecker=b}let O=n.ai_shortcuts;O===!1||Array.isArray(O)&&!O.length?p.ai={shortcuts:!1}:Array.isArray(O)&&(p.ai={shortcuts:Cy(O)});let B={};(["string","function"].includes(typeof n.inlinecss_selector_filter)||n.inlinecss_selector_filter instanceof RegExp)&&(B.selectorFilter=n.inlinecss_selector_filter),(["string","function"].includes(typeof n.inlinecss_file_filter)||n.inlinecss_file_filter instanceof RegExp)&&(B.fileFilter=n.inlinecss_file_filter),Object.keys(B).length&&(p.email=B);let J={};typeof n.autocorrect_autocorrect=="boolean"&&(J.autocorrect=n.autocorrect_autocorrect),typeof n.autocorrect_capitalize=="boolean"&&(J.capitalize=n.autocorrect_capitalize),Object.keys(J).length&&(p.autocorrect=J);let P={};typeof n.linkchecker_service_url=="string"&&(P.serviceUrl=n.linkchecker_service_url);let G=n.linkchecker_preprocess;if(typeof G=="function"&&(P.preprocess=b=>{let E=G({url:b});return typeof E?.url=="string"?E.url:b}),Object.keys(P).length&&(p.linkchecker=P),t.includes("pageembed")){let b=n.tiny_pageembed_classes;p.pageembed={className:"tiny-pageembed",sizes:Array.isArray(b)?b.filter(E=>!!E&&typeof E.value=="string").map(E=>({value:E.value,...typeof E.text=="string"?{text:E.text}:{}})):["21by9","16by9","4by3","1by1"].map(E=>({value:`tiny-pageembed--${E}`})),inlineStyles:n.tiny_pageembed_inline_styles===!0}}if(t.includes("fullpagehtml")){let b={},E=(_,N)=>{typeof n[_]=="string"&&(b[N]=n[_])};E("fullpagehtml_default_doctype","doctype"),E("fullpagehtml_default_title","title"),E("fullpagehtml_default_encoding","encoding"),E("fullpagehtml_default_body_style","bodyStyle"),n.fullpagehtml_hide_in_source_view===!0&&(b.hideInSourceView=!0),Object.keys(b).length&&(p.fullpagehtml=b)}if(t.includes("mediaembed")){let b={className:"ephox-summary-card",inlineStyles:n.mediaembed_inline_styles===!0};typeof n.mediaembed_service_url=="string"&&n.mediaembed_service_url&&(b.serviceUrl=n.mediaembed_service_url);let E=Number(n.mediaembed_max_width);n.mediaembed_max_width!==void 0&&Number.isFinite(E)&&(b.maxWidth=E),p.mediaembed=b}let y=n.advtable_value_series;if(t.includes("advtable")&&y&&typeof y=="object"){let b={};for(let[E,_]of Object.entries(y)){let{title:N,generator:$}=_??{};if(typeof N!="string"||typeof $!="function")continue;let K;b[E]={title:N,value:se=>{se===0&&(K=void 0);let ot=$({sectionType:"tbody",cellType:"td",getRowType:()=>"body",classes:[],direction:"column",prev:K},se,0);K=ot;let Ve=ot?.value;return typeof Ve=="string"||typeof Ve=="number"?String(Ve):void 0}}}Object.keys(b).length&&(p.advtable={series:b})}if(t.includes("editimage")){let b={};typeof n.editimage_toolbar=="string"&&(b.toolbar=n.editimage_toolbar),Array.isArray(n.editimage_credentials_hosts)&&(b.credentialsHosts=n.editimage_credentials_hosts.filter(_=>typeof _=="string"));let E=n.editimage_fetch_image;typeof E=="function"&&(b.fetchImage=_=>{let N=document.createElement("img");return N.src=_,E(N)}),Object.keys(b).length&&(p.editimage=b)}t.includes("advcode")&&typeof n.advcode_prettify_editor=="boolean"&&(p.advcode={prettify:n.advcode_prettify_editor});let v=uS(n);return Object.keys(v).length&&(p.typography=v),Object.keys(p).length&&(o.pluginOptions=p),{options:o,unknown:e,missingPlugins:r}}var vd=null,yd=null;function Oy(){return yd??(yd=import(__novaChunk("tinymce-chunks/dialog-126a0355.js") ).then(n=>vd=n)),yd}function hS(n,e,t){if(vd)return vd.openSpecDialog(n,e,t);let r=null,o={...e.initialData??{}},i=[];Oy().then(l=>{r=l.openSpecDialog(n,{...e,initialData:o},t);for(let a of i.splice(0))a(r)},l=>console.error("[nova] windowManager: could not load dialogs",l));let s=l=>(...a)=>{let c=u=>u[l](...a);r?c(r):i.push(c)};return{getData:()=>r?r.getData():{...o},setData:l=>{r?r.setData(l):o={...o,...l}},close:s("close"),block:s("block"),unblock:s("unblock"),focus:s("focus"),disable:s("disable"),enable:s("enable"),showTab:s("showTab"),redial:s("redial")}}var Ps={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",justifyleft:"alignLeft",justifycenter:"alignCenter",justifyright:"alignRight",justifyfull:"alignJustify",insertunorderedlist:"bulletList",insertorderedlist:"orderedList",indent:"indent",outdent:"outdent",undo:"undo",redo:"redo",removeformat:"clearFormatting",unlink:"unlink",inserthorizontalrule:"horizontalRule",mceblockquote:"blockquote"},wo={mcelowercase:"lowercase",mceuppercase:"uppercase",mcetitlecase:"titlecase",mcetoggleformatpainter:"formatpainter",mcetogglepermanentpen:"permanentpen",mceconfigurepermanentpen:"configurepermanentpen",mcevisualchars:"visualchars",mcesave:"save",mcecancel:"cancel",mcetemplate:"template",mceinsertfootnote:"footnotes",mceupdatefootnotes:"footnotesupdate",mcespellcheckdialog:"spellcheckdialog",mcetypography:"typography",mcecodeeditor:"code",mceimagerotateleft:"rotateleft",mceimagerotateright:"rotateright",mceimageflipvertical:"flipv",mceimagefliphorizontal:"fliph",mceeditimage:"editimage",mcefullpagehtmlproperties:"fullpagehtml"},Ty=new Set(["mcespellcheckenable","mcespellcheckdisable","mcespellcheckupdate","mcespellcheckdialogclose"]),Ny={mceadvancedtablesort:()=>({command:"dialog"}),mcesorttablebycolumnasc:()=>({command:"sort",value:{by:"column",direction:"asc"}}),mcesorttablebycolumndesc:()=>({command:"sort",value:{by:"column",direction:"desc"}}),mcesorttablebyrowasc:()=>({command:"sort",value:{by:"row",direction:"asc"}}),mcesorttablebyrowdesc:()=>({command:"sort",value:{by:"row",direction:"desc"}}),mcesorttableadvanced:n=>{let e=n&&typeof n=="object"?n:{},t=Number(e.roworcol);return{command:"sort",value:{by:e.sortby==="row"?"row":"column",...Number.isInteger(t)&&t>=0?{index:t}:{},direction:e.order==="descending"?"desc":"asc",scope:e.sort==="selection"?"selection":"table"}}},mcetabletoggleseries:n=>({command:"series",value:n?.name})},mS=new Set(["insertaccordion","removeaccordion","toggleaccordion","toggleallaccordions"]),gS={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"},yS={bold:"bold",italic:"italic",underline:"underline","strike-through":"strike",link:"link",unlink:"unlink",image:"image",table:"table",undo:"undo",redo:"redo","align-left":"alignLeft","align-center":"alignCenter","align-right":"alignRight","align-justify":"alignJustify","unordered-list":"bulletList","ordered-list":"orderedList",indent:"indent",outdent:"outdent",quote:"blockquote","code-sample":"codeBlock","horizontal-rule":"horizontalRule","remove-formatting":"clearFormatting",fullscreen:"fullscreen",preview:"preview",sourcecode:"sourceCode",help:"help",print:"print",search:"search",copy:"copy","edit-block":"edit",checkmark:"check",close:"close",upload:"upload",subscript:"subscript",superscript:"superscript","paste-text":"pasteText","text-color":"textColor","highlight-bg-color":"highlight","line-height":"lineHeight"},bd={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",code:"code",p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock",alignleft:"alignLeft",aligncenter:"alignCenter",alignright:"alignRight",alignjustify:"alignJustify"},bS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),kS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","alignleft","aligncenter","alignright","alignjustify"]),kd={forecolor:"color",hilitecolor:"background",fontname:"font_family",fontsize:"font_size"};function So(n){console.warn(`[nova] tinymce-compat: editor.dom.${n} changes the editor DOM directly, which NovaProse redraws from its document model. Use setContent, insertContent or editor.formatter instead.`)}var Ds=new Map;function Rs(n){if(typeof n!="string"||!n)return;if(Ds.has(n))return Ds.get(n);let e=yS[n]??(n in C?n:void 0);return e?C[e]:void 0}function vS(n){let e=!1,t=!0;return{state:{get active(){return e},get enabled(){return t}},api:{isActive:()=>e,setActive:r=>{e=r,n.core.updateUI()},isEnabled:()=>t,setEnabled:r=>{t=r,n.core.updateUI()},isDisabled:()=>!t,setDisabled:r=>{t=!r,n.core.updateUI()}}}}var Mo=class{constructor(e,t,r,o){S(this,"id");S(this,"core");S(this,"targetElm");S(this,"settings");S(this,"plugins",{});S(this,"initialized",!1);S(this,"removed",!1);S(this,"handlers",new Map);S(this,"dirty",!1);S(this,"teardowns",[]);S(this,"commands",new Map);S(this,"options",{get:e=>this.settings[e],set:(e,t)=>(this.settings[e]=t,e==="disabled"&&this.core.setDisabled(t===!0),!0),isSet:e=>e in this.settings,isRegistered:()=>!0,register:()=>{}});S(this,"mode",{get:()=>this.core.isEditable()?"design":"readonly",set:e=>this.core.setEditable(e!=="readonly"),isReadOnly:()=>!this.core.isEditable()});S(this,"undoManager",{undo:()=>this.core.exec("undo"),redo:()=>this.core.exec("redo"),hasUndo:()=>this.core.can("undo"),hasRedo:()=>this.core.can("redo"),add:()=>null,clear:()=>{},transact:e=>(e(),null),ignore:e=>e()});S(this,"selection",{getContent:(e={})=>e.format==="text"?this.core.selection.getText():this.core.selection.getHTML(),setContent:e=>this.insertContent(e),getNode:()=>this.core.selection.getNode()??this.core.view.dom,getStart:()=>this.selection.getNode(),getEnd:()=>this.selection.getNode(),isCollapsed:()=>this.core.selection.isCollapsed(),collapse:(e=!1)=>this.core.selection.collapse(e),setCursorLocation:(e,t=0)=>{e&&this.core.selection.setCursorLocation(e,t)},select:(e,t=!1)=>this.core.selection.select(e,t),getRng:()=>this.core.selection.getDOMRange(),setRng:e=>{let{view:t}=this.core;if(!e||!t.dom.contains(e.startContainer))return;let r=t.posAtDOM(e.startContainer,e.startOffset),o=t.dom.contains(e.endContainer)?t.posAtDOM(e.endContainer,e.endOffset):r;this.core.selection.setRange(r,o)},getBookmark:()=>this.core.selection.getBookmark(),moveToBookmark:e=>this.core.selection.moveToBookmark(e),scrollIntoView:()=>this.core.selection.scrollIntoView()});S(this,"notificationManager",{open:e=>this.core.ui.notify({text:e.text,...e.type?{type:e.type}:{},...e.timeout!==void 0?{timeout:e.timeout}:{}}),close:()=>{}});S(this,"windowManager",{alert:(e,t)=>{let r=document.createElement("p");r.textContent=e,this.core.ui.openDialog({title:"",body:r,onSubmit:()=>!0,...t?{onClose:t}:{}})},confirm:(e,t)=>{let r=document.createElement("p");r.textContent=e;let o=!1;this.core.ui.openDialog({title:"",body:r,submitLabel:"OK",onSubmit:()=>(o=!0,!0),onClose:()=>t?.(o)})},open:e=>hS(this.core,e,t=>this.windowManager.open(t))});S(this,"ui",{registry:{addIcon:(e,t)=>{Ds.set(e,t)},addButton:(e,t)=>this.addButton(e,t,!1),addToggleButton:(e,t)=>this.addButton(e,t,!0),addMenuButton:(e,t)=>{let r=[];t.fetch(i=>r=i);let o=Rs(t.icon);this.core.ui.registry.addMenuButton(e,{tooltip:t.tooltip??t.text??e,...o?{icon:o}:{text:t.text??e},items:()=>(t.fetch(i=>r=i),r.map((i,s)=>i.type==="separator"?{type:"separator"}:{id:`${e}-${s}`,label:i.text??"",onSelect:()=>i.onAction?.({})}))})},addMenuItem:(e,t)=>{let r=Rs(t.icon);this.core.ui.registry.addMenuItem(e,{text:t.text??e,...r?{icon:r}:{},onAction:()=>t.onAction?.({})})},addContextToolbar:(e,t)=>{this.core.ui.registry.addContextToolbar(e,{label:t.label??e,items:t.items,position:t.position==="node"?"node":"selection",predicate:()=>{let r=this.selection.getNode();return!!r&&this.getBody().contains(r)&&t.predicate(r)}})},addSidebar:(e,t)=>{let r=null,o={element:()=>r},i=Rs(t.icon);this.core.ui.registry.addSidebar(e,{title:t.tooltip??e,...i?{icon:i}:{},render:s=>{r=s;let l=t.onSetup?.(o);return typeof l=="function"?l:void 0},onShow:()=>t.onShow?.(o),onHide:()=>t.onHide?.(o)})},addView:(e,t)=>{this.core.ui.registry.addView(e,{buttons:(Array.isArray(t.buttons)?t.buttons:[]).filter(r=>typeof r?.text=="string").map(r=>({text:r.text,buttonType:r.buttonType==="primary"?"primary":"secondary",onAction:()=>r.onAction?.()})),...t.onShow?{onShow:t.onShow}:{},...t.onHide?{onHide:t.onHide}:{}})},addContextForm:()=>{console.warn("[nova] tinymce-compat: addContextForm is not supported yet")},getAll:()=>({})}});S(this,"dom",{select:(e,t)=>[...(t??this.getBody()).querySelectorAll(e)],get:e=>typeof e=="string"?this.getBody().querySelector(`#${CSS.escape(e)}`):e,getParent:(e,t)=>{let r=e instanceof Element?e:e?.parentElement??null;for(;r&&r!==this.getBody();){if(typeof t=="string"?r.matches(t):t(r))return r;r=r.parentElement}return null},getParents:(e,t)=>{let r=[],o=e instanceof Element?e:e?.parentElement??null;for(;o&&o!==this.getBody();)(!t||o.matches(t))&&r.push(o),o=o.parentElement;return r},is:(e,t)=>!!e?.matches(t),getAttrib:(e,t,r="")=>e?.getAttribute(t)??r,hasClass:(e,t)=>!!e?.classList.contains(t),getStyle:(e,t)=>e instanceof HTMLElement?e.style.getPropertyValue(t):"",getRoot:()=>this.getBody(),encode:e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`),decode:e=>{let t=document.createElement("textarea");return t.innerHTML=e,t.value},create:(e,t={},r)=>{let o=document.createElement(e);for(let[i,s]of Object.entries(t))i.startsWith("on")||o.setAttribute(i,s);return r!==void 0&&(o.textContent=r),o},uniqueId:(e="mce_")=>`${e}${Math.random().toString(36).slice(2,10)}`,setAttrib:()=>So("setAttrib"),addClass:()=>So("addClass"),removeClass:()=>So("removeClass"),setStyle:()=>So("setStyle"),remove:()=>So("remove")});S(this,"formatter",{apply:(e,t={})=>this.applyFormat(e,t,"apply"),remove:e=>this.applyFormat(e,{},"remove"),toggle:(e,t={})=>this.applyFormat(e,t,this.formatter.match(e)?"remove":"apply"),match:e=>{if(this.core.formatter.has(e))return this.core.formatter.match(e);let t=e.toLowerCase();if(bS.has(t))return this.blockMatches(t);let r=bd[t];if(r)return this.core.isActive(r);let o=kd[t];if(!o)return!1;let{state:i}=this.core.view,{from:s,to:l,empty:a}=i.selection,c=i.schema.marks[o];return a||!c?kt(i,o)!==null:i.doc.rangeHasMark(s,l,c)},canApply:e=>this.core.formatter.has(e)||e.toLowerCase()in bd||e.toLowerCase()in kd,register:(e,t)=>{let r=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[o,i]of r){let s=Ls(i);s.length?this.core.formatter.register(o,s):console.warn(`[nova] tinymce-compat: format "${o}" is not supported yet`)}},unregister:e=>this.core.formatter.unregister(e),get:e=>this.core.formatter.get(e)});this.core=e,this.targetElm=t,this.id=r,this.settings=o,setTimeout(()=>{Oy().catch(()=>{})},0)}getContent(e={}){let t={format:e.format??"html",content:""};return t.content=t.format==="text"?this.core.getText():this.core.getHTML({fullPage:e.fullpagehtml!==!1}),(e.prettify===!0||this.settings.advcode_prettify_getcontent===!0&&this.core.hasPlugin("advcode"))&&t.format!=="text"&&(t.content=Ns(t.content)),this.fire("GetContent",t),t.content}setContent(e,t={}){let r={content:e,...t};return this.fire("BeforeSetContent",r),this.core.setContent(r.content,{fullPage:t.fullpagehtml!==!1}),this.fire("SetContent",r),r.content}insertContent(e){this.core.insertContent(e)}resetContent(e){this.core.setContent(e??this.settings.__initialContent??"",{addToHistory:!1}),this.setDirty(!1)}getBody(){return this.core.view.dom}getElement(){return this.targetElm}getContainer(){return this.core.root}getContentAreaContainer(){return this.core.view.dom.parentElement??this.core.root}getDoc(){return this.core.root.ownerDocument}getWin(){return this.core.root.ownerDocument.defaultView}queryCommandValue(e){return e.toLowerCase()==="togglesidebar"?this.core.ui.sidebar.active??"":e.toLowerCase()==="toggleview"?this.core.ui.view.active??"":""}execCommand(e,t,r){let o=e.toLowerCase(),i=!1;if(Ps[o])i=this.core.exec(Ps[o]);else if(o==="formatblock"||o==="mcetoggleformat"){let s=gS[String(r??"").toLowerCase()];i=s?this.core.exec(s):!1}else if(o==="mceinsertcontent"||o==="inserthtml")this.insertContent(String(r??"")),i=!0;else if(o==="toggleview")this.core.ui.view.toggle(String(r??"")),i=!0;else if(o==="togglesidebar")this.core.ui.sidebar.toggle(String(r??"")),i=!0;else if((o==="mceaidialog"||o==="mceaidialogclose")&&this.core.hasPlugin("ai")){let s=r&&typeof r=="object"?r:{},l={...typeof s.prompt=="string"?{prompt:s.prompt}:{},...s.generate===!0?{generate:!0}:{},...s.display===!1?{display:!1}:{}};this.core.root.dispatchEvent(o==="mceaidialog"?new CustomEvent("nova-ai-dialog",{detail:l}):new CustomEvent("nova-ai-dialog-close")),i=!0}else if(o==="mcesetcontent")this.setContent(String(r??"")),i=!0;else if(o==="mceinserttoc"||o==="mceupdatetoc"){let s=this.core.ui.registry.get(o==="mceinserttoc"?"tableofcontents":"tableofcontentsupdate");s?.type==="button"&&(s.onAction(this.core),i=!0)}else if(Ny[o]&&this.core.hasPlugin("advtable"))this.core.root.dispatchEvent(new CustomEvent("nova-advtable",{detail:Ny[o](r)})),i=!0;else if(mS.has(o))i=this.accordionCommand(o,r);else if(o==="mceinserttemplate"&&this.core.hasPlugin("template"))this.core.root.dispatchEvent(new CustomEvent("nova-insert-template",{detail:String(r??"")})),i=!0;else if(Ty.has(o)&&this.core.hasPlugin("spellchecker"))i=this.spellcheckCommand(o);else if(wo[o]||o==="mcetogglestickyformatpainter")i=this.pluginCommand(o);else if(o==="codesample"){let s=this.core.ui.registry.get("codesample");s?.type==="button"&&(s.onAction(this.core),i=!0)}else if(o==="selectall"){let{state:s,dispatch:l}=this.core.view;l(s.tr.setSelection(new de(s.doc))),i=!0}else if(o==="mcecleanup")i=!0;else{let s=this.commands.get(o);s&&(s(t,r),i=!0)}return i&&this.fire("ExecCommand",{command:e,ui:t,value:r}),i}spellcheckCommand(e){if(e==="mcespellcheckdialogclose")return this.core.ui.closeOverlays(),!0;if(e==="mcespellcheckupdate")return!0;let t=this.core.ui.registry.get("spellchecker");if(!t)return!1;let r=!!t.isActive?.(this.core);return e==="mcespellcheckenable"!==r&&t.onAction(this.core),!0}accordionCommand(e,t){let{view:r}=this.core,{state:o}=r,i=o.selection.$from,s=null;for(let u=i.depth;u>0&&!s;u--){let d=i.node(u);d.type.name==="details"&&(s={pos:i.before(u),open:d.attrs.open!==!1})}if(e==="insertaccordion"||e==="removeaccordion"){if(e==="removeaccordion"!=!!s)return!1;let u=this.core.ui.registry.get("accordion");return u?.type!=="button"?!1:(u.onAction(this.core),!0)}let l=[];if(e==="toggleaccordion"?s&&l.push(s):o.doc.descendants((u,d)=>(u.type.name==="details"&&l.push({pos:d,open:u.attrs.open!==!1}),!u.isTextblock)),!l.length)return!1;let a=typeof t=="boolean"?t:!l.every(u=>u.open),c=o.tr;for(let u of l)c.setNodeAttribute(u.pos,"open",a);return r.dispatch(c.setMeta("addToHistory",!1)),!0}pluginCommand(e){let{registry:t}=this.core.ui;if(e==="mcetogglestickyformatpainter"){let o=t.get("formatpainter"),i=t.getMenuItem("formatpainter");return o?.type!=="button"||!i?!1:(i.isActive?.(this.core)?i.onAction(this.core):(o.onAction(this.core),o.onAction(this.core)),!0)}let r=t.getMenuItem(wo[e]);return!r||e!=="mcesave"&&r.isEnabled?.(this.core)===!1?!1:(r.onAction(this.core),!0)}queryCommandState(e){let t=e.toLowerCase(),r=Ps[t];return r?this.core.isActive(r):t==="mcetoggleformatpainter"||t==="mcetogglepermanentpen"?!!this.core.ui.registry.getMenuItem(wo[t])?.isActive?.(this.core):!1}queryCommandSupported(e){let t=e.toLowerCase();return t in Ps||["formatblock","mceinsertcontent","mcesetcontent"].includes(t)||t in wo&&!!this.core.ui.registry.getMenuItem(wo[t])||t==="mcetogglestickyformatpainter"&&this.core.ui.registry.has("formatpainter")||Ty.has(t)&&this.core.hasPlugin("spellchecker")||(t==="mceaidialog"||t==="mceaidialogclose")&&this.core.hasPlugin("ai")||this.commands.has(t)}addCommand(e,t){this.commands.set(e.toLowerCase(),t)}on(e,t,r=!1){for(let o of e.toLowerCase().split(/\s+/).filter(Boolean)){let i=this.handlers.get(o)??new Set;r?this.handlers.set(o,new Set([t,...i])):this.handlers.set(o,i.add(t))}return this}off(e,t){if(!e)return this.handlers.clear(),this;for(let r of e.toLowerCase().split(/\s+/).filter(Boolean))t?this.handlers.get(r)?.delete(t):this.handlers.delete(r);return this}once(e,t){let r=o=>(this.off(e,r),t(o));return this.on(e,r)}fire(e,t={}){let r=Object.assign(t,{type:e.toLowerCase(),target:this});for(let o of[...this.handlers.get(e.toLowerCase())??[]])try{o(r)}catch(i){console.error(`[nova] tinymce-compat: "${e}" handler failed`,i)}return r}fireNative(e,t){for(let r of[...this.handlers.get(e)??[]])try{r(t)}catch(o){console.error(`[nova] tinymce-compat: "${e}" handler failed`,o)}}static registerIcon(e,t){Ds.set(e,t)}dispatch(e,t){return this.fire(e,t)}hasEventListeners(e){return(this.handlers.get(e.toLowerCase())?.size??0)>0}isDirty(){return this.dirty}setDirty(e){let t=this.dirty!==e;this.dirty=e,t&&e&&this.fire("Dirty")}save(){let e=this.getContent(),t=this.fire("SaveContent",{content:e});return this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.value=String(t.content)),this.setDirty(!1),String(t.content)}focus(){this.core.focus()}hasFocus(){return this.core.view.hasFocus()}hide(){this.core.root.hidden=!0,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!1)}show(){this.core.root.hidden=!1,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!0)}isHidden(){return this.core.root.hidden===!0}getParam(e,t){return e in this.settings?this.settings[e]:t}addButton(e,t,r){let{api:o,state:i}=vS(this);t.enabled===!1&&o.setEnabled(!1),t.active&&o.setActive(!0);let s=Rs(t.icon);if(this.core.ui.registry.addButton(e,{tooltip:t.tooltip??t.text??e,...s?{icon:s}:{text:t.text??e},isEnabled:()=>i.enabled,...r?{isActive:()=>i.active}:{},onAction:()=>t.onAction?.(o)}),t.onSetup){let l=()=>{let a=t.onSetup(o);typeof a=="function"&&this.teardowns.push(a)};this.initialized?l():this.once("init",l)}}blockMatches(e){let{$from:t}=this.core.view.state.selection;for(let o=t.depth;o>0;o-=1){let i=t.node(o),s=i.type.name;if(e==="blockquote"&&s==="blockquote")return!0;if(o===t.depth){if(e==="p")return s==="paragraph";if(e==="pre")return s==="code_block";if(/^h[1-6]$/.test(e))return s==="heading"&&i.attrs.level===Number(e[1])}}let r=null;if(this.core.view.state.doc.descendants(o=>r||!o.isTextblock?!r:(r={name:o.type.name,level:o.attrs.level},!1)),!t.depth&&r){let o=r;if(e==="p")return o.name==="paragraph";if(e==="pre")return o.name==="code_block";if(/^h[1-6]$/.test(e))return o.name==="heading"&&o.level===Number(e[1])}return!1}applyFormat(e,t,r){if(this.core.formatter.has(e)){r==="apply"?this.core.formatter.apply(e):this.core.formatter.remove(e);return}let o=e.toLowerCase(),i=bd[o];if(i){let l=this.formatter.match(o);kS.has(o)?r==="apply"?this.core.exec(i):l&&this.core.exec("paragraph"):r==="apply"!==l&&this.core.exec(i);return}let s=kd[o];if(s){this.core.exec(Ht(s,r==="apply"?t.value??null:null));return}console.warn(`[nova] tinymce-compat: format "${e}" is not supported yet`)}remove(){if(this.removed)return;this.fire("remove"),this.save(),this.teardowns.splice(0).forEach(t=>t()),this.removed=!0,this.core.destroy(),this.core.root.remove(),this.settings.__wrapper?.remove(),this.targetElm.hidden=!1,this.off()}destroy(){this.remove()}};var Ly=new Set;function xd(n){Ly.has(n)||(Ly.add(n),console.warn(`[nova] tinymce-compat: ${n}`))}var xS=0,_s=n=>typeof n=="number"?`${n}px`:String(n);function wS(){Nu(xy);let n=[],e=new Map,t=null;async function r(i,s){var _;let l=n.find(N=>N.targetElm===i&&!N.removed);if(l)return l;let{options:a,unknown:c,missingPlugins:u}=Ay(s);c.length&&xd(`options not supported yet: ${c.join(", ")}`);let d=String(Array.isArray(s.plugins)?s.plugins.join(" "):s.plugins??"").split(/[\s,]+/).filter(N=>e.has(N)),p=u.filter(N=>!e.has(N));p.length&&xd(`plugins not available: ${p.join(", ")}`);let f=i.id||`mce_${++xS}`;i.id||(i.id=f);let h=i instanceof HTMLTextAreaElement,m=h?i.value:i.innerHTML,g={...s,__initialContent:m},k;s.inline===!0&&!h?(i.replaceChildren(),k=i):(k=document.createElement("div"),k.className="nova-compat",i.after(k),i.hidden=!0,g.__wrapper=k);let x,M=N=>{let $=N;if(!$||typeof $.start!="string")return null;if(typeof $.replacement=="string")return{start:$.start,replacement:$.replacement};let K=(Array.isArray($.format)?$.format:[$.format]).filter(Ae=>typeof Ae=="string"),se=typeof $.cmd=="string"?$.cmd:null;return!se&&!K.length?null:{start:$.start,...typeof $.end=="string"&&$.end?{end:$.end}:{},...$.trigger==="enter"?{trigger:"enter"}:{},value:$.value,command:(Ae,ot)=>{if(se)x.execCommand(se,!1,ot);else for(let Ve of K)x.formatter.apply(Ve)}}};Array.isArray(s.text_patterns)&&(a.textPatterns=s.text_patterns.map(M));let L=s.text_patterns_lookup;typeof L=="function"&&(a.textPatternsLookup=N=>{let $=L(N);return Array.isArray($)?$.map(M):[]},a.textPatterns||(a.textPatterns=[]));let O=s.save_onsavecallback,B=s.save_oncancelcallback,J={...s.save_enablewhendirty!==void 0?{enableWhenDirty:s.save_enablewhendirty!==!1}:{},...typeof O=="function"?{onSave:()=>(x.save(),O(x))}:{},...typeof B=="function"?{onCancel:()=>B(x)}:{}},P=s.ai_request,G=typeof P=="function"?{...a.pluginOptions?.ai,async*request(N){let{tinyAiRequest:$}=await import(__novaChunk("tinymce-chunks/ai-e0658729.js") );yield*$(P,(K,se)=>x?.fire(K,se))(N)}}:null,y={...a.pluginOptions,...Object.keys(J).length?{save:J}:{},...G?{ai:G}:{}},v=Ts({...a,...Object.keys(y).length?{pluginOptions:y}:{},element:k,content:m,setup:N=>{x=new Mo(N,i,f,g);for(let $ of d)try{let K=e.get($)(x,"");x.plugins[$]=K&&typeof K=="object"?K:{}}catch(K){console.error(`[nova] tinymce-compat: plugin "${$}" failed`,K)}s.setup?.(x)}});s.height!==void 0&&(v.root.style.height=_s(s.height)),s.min_height!==void 0&&(v.root.style.minHeight=_s(s.min_height)),s.max_height!==void 0&&(v.root.style.maxHeight=_s(s.max_height)),s.width!==void 0&&(v.root.style.width=_s(s.width));let b=!1;v.on("change",()=>{x.setDirty(!0),b=!0,x.fire("input")}),v.on("selectionChange",()=>{x.fire("NodeChange",{element:x.selection.getNode(),selectionChange:!0})}),v.on("focus",()=>{t=x,b=!1,x.fire("focus")}),v.on("blur",()=>{b&&x.fire("change",{level:{content:x.getContent()}}),b=!1,x.fire("blur")});for(let N of["keydown","keyup","keypress","click","dblclick","mousedown","mouseup","paste","copy","cut","drop"])v.view.dom.addEventListener(N,$=>x.fireNative(N,$));if(v.root.addEventListener("nova-ai-dialogopen",()=>x.fire("AIDialogOpen")),v.root.addEventListener("nova-ai-dialogclose",()=>x.fire("AIDialogClose")),v.root.addEventListener("nova-autocorrect-toggle",N=>{let{feature:$,on:K}=N.detail;x.fire(($==="capitalize"?"Capitalize":"Autocorrect")+(K?"Start":"End"))}),(h?i.form:i.closest("form"))?.addEventListener("submit",()=>x.save()),x.on("remove",()=>{let N=n.indexOf(x);N>=0&&n.splice(N,1),t===x&&(t=n[0]??null)}),n.push(x),t??(t=x),await v.ready,x.removed)return x;for(let N of My(s,$=>v.hasPlugin($)))(_=x.plugins)[N]??(_[N]={});return x.plugins.inlinecss&&(x.plugins.inlinecss.getContent=async()=>{x.fire("InlineCSS");let{emailHTML:N}=await import(__novaChunk("tinymce-chunks/email-1926dd8a.js") );return{html:await N(v,{document:!1})}}),x.initialized=!0,x.fire("init"),s.init_instance_callback?.(x),typeof s.view_show=="string"&&s.view_show?v.ui.view.show(s.view_show):typeof s.sidebar_show=="string"&&s.sidebar_show&&v.ui.sidebar.show(s.sidebar_show),x}return{majorVersion:"7",minorVersion:"0.0",novaprose:!0,get activeEditor(){return t},get editors(){return[...n]},async init(i){document.readyState==="loading"&&await new Promise(a=>document.addEventListener("DOMContentLoaded",a,{once:!0})),typeof i.language=="string"&&await cl(i.language.replace("_","-")).catch(a=>(console.warn("[nova] tinymce-compat: language pack failed to load",a),!1));let s=i.target?[i.target]:i.selector?[...document.querySelectorAll(i.selector)]:[];s.length||xd(`no elements match "${i.selector??""}"`);let l=[];for(let a of s)l.push(await r(a,i));return l},get:(i=>i===void 0?[...n]:typeof i=="number"?n[i]??null:n.find(s=>s.id===i)??null),remove(i){(i===void 0?[...n]:typeof i=="string"?n.filter(l=>l.id===i.replace(/^#/,"")||l.targetElm.matches(i)):[i]).forEach(l=>l.remove())},triggerSave(){n.forEach(i=>i.save())},execCommand(i,s,l){return t?.execCommand(i,s,l)??!1},PluginManager:{add:(i,s)=>{e.set(i,s)},get:i=>e.get(i),requireLangPack:()=>{},urls:{}},IconManager:{add:(i,s)=>{for(let[l,a]of Object.entries(s.icons??{}))Mo.registerIcon(l,a)}},util:{I18n:{translate:i=>i}}}}var Py=wS();Vt("ru",()=>import(__novaChunk("tinymce-chunks/ru-982f3476.js") ));Vt("de",()=>import(__novaChunk("tinymce-chunks/de-21549c7e.js") ));Vt("es",()=>import(__novaChunk("tinymce-chunks/es-1de93a3f.js") ));Vt("fr",()=>import(__novaChunk("tinymce-chunks/fr-6fbcca9f.js") ));Vt("it",()=>import(__novaChunk("tinymce-chunks/it-ca70815f.js") ));Vt("pt-BR",()=>import(__novaChunk("tinymce-chunks/pt-BR-f6958ec0.js") ));var Ry=document.currentScript;if(Ry?.src&&!document.querySelector("link[data-novaprose-css]")){let n=document.createElement("link");n.rel="stylesheet",n.href=Ry.src.replace(/[^/]*$/,"novaprose.css"),n.setAttribute("data-novaprose-css",""),document.head.append(n)}window.tinymce=Py;var V=globalThis.__novaprose_tinymce={};V["node_modules/.pnpm/prosemirror-history@1.5.2/node_modules/prosemirror-history/dist/index.js"]=Pc;V["node_modules/.pnpm/prosemirror-inputrules@1.7.0/node_modules/prosemirror-inputrules/dist/index.js"]=fu;V["node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.js"]=na;V["node_modules/.pnpm/prosemirror-model@1.25.13/node_modules/prosemirror-model/dist/index.js"]=Js;V["node_modules/.pnpm/prosemirror-schema-list@1.6.1/node_modules/prosemirror-schema-list/dist/index.js"]=ka;V["node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js"]=il;V["node_modules/.pnpm/prosemirror-transform@1.12.7/node_modules/prosemirror-transform/dist/index.js"]=tl;V["node_modules/.pnpm/prosemirror-view@1.43.1/node_modules/prosemirror-view/dist/index.js"]=Zl;V["node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js"]=ea;V["packages/core/src/blocks.ts"]=_c;V["packages/core/src/code-language.ts"]=Ra;V["packages/core/src/commands.ts"]=Fc;V["packages/core/src/comments.ts"]=la;V["packages/core/src/content-css.ts"]=Wc;V["packages/core/src/document.ts"]=Ou;V["packages/core/src/editor.ts"]=dd;V["packages/core/src/element-id.ts"]=yl;V["packages/core/src/image.ts"]=au;V["packages/core/src/language.ts"]=Da;V["packages/core/src/link.ts"]=yu;V["packages/core/src/mark-views.ts"]=ld;V["packages/core/src/page.ts"]=$u;V["packages/core/src/parser.ts"]=Hu;V["packages/core/src/plugins.ts"]=Fs;V["packages/core/src/plugins/accordion.ts"]=gl;V["packages/core/src/plugins/advtable.ts"]=Xa;V["packages/core/src/plugins/comments.ts"]=fa;V["packages/core/src/plugins/footnotes.ts"]=wc;V["packages/core/src/plugins/fullpagehtml.ts"]=dc;V["packages/core/src/plugins/index.ts"]=gm;V["packages/core/src/plugins/math.ts"]=vl;V["packages/core/src/plugins/media.ts"]=Wa;V["packages/core/src/plugins/mediaembed.ts"]=oc;V["packages/core/src/plugins/mentions.ts"]=ua;V["packages/core/src/plugins/mergetags.ts"]=ga;V["packages/core/src/plugins/pageembed.ts"]=Ja;V["packages/core/src/plugins/pagelayout.ts"]=yc;V["packages/core/src/plugins/shared.ts"]=ul;V["packages/core/src/plugins/suggestions.ts"]=La;V["packages/core/src/plugins/tableofcontents.ts"]=Sl;V["packages/core/src/pretty-html.ts"]=fd;V["packages/core/src/schema.ts"]=qa;V["packages/core/src/search.ts"]=Ku;V["packages/core/src/serializer.ts"]=sc;V["packages/core/src/tables.ts"]=Eu;V["packages/core/src/ui/builtins.ts"]=Zu;V["packages/core/src/ui/dialog.ts"]=Xc;V["packages/core/src/ui/dom.ts"]=ll;V["packages/core/src/ui/file-picker.ts"]=Jc;V["packages/core/src/ui/icons.ts"]=al;V["packages/core/src/ui/link-bubble.ts"]=nd;V["packages/core/src/ui/menu.ts"]=Bu;V["packages/core/src/ui/popover.ts"]=Qu;V["packages/core/src/ui/views.ts"]=Gu;V["packages/core/src/url.ts"]=Pa;})();
41
48
  //# sourceMappingURL=tinymce.global.js.map