@panphora/clayjs 1.15.2 → 1.17.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 (551) hide show
  1. package/README.md +4 -5
  2. package/THIRD-PARTY-NOTICES.md +16 -0
  3. package/compat/highlight-11.9.0.min.js +1213 -0
  4. package/compat/highlight-LICENSE +29 -0
  5. package/compat/journal-assets.lock.json +22 -0
  6. package/compat/overtype-2.6.1.min.js +116 -0
  7. package/compat/overtype-LICENSE +21 -0
  8. package/dist/all.js +90 -0
  9. package/dist/clay-dom.js +84 -0
  10. package/dist/clay-events.js +103 -0
  11. package/dist/clay-internals.js +85 -0
  12. package/dist/clay-options.js +93 -0
  13. package/dist/clay-router.js +98 -0
  14. package/dist/clay-ui.js +95 -0
  15. package/dist/clay-utils.js +84 -0
  16. package/dist/clay.js +146 -0
  17. package/dist/clay.standalone.js +84291 -57611
  18. package/dist/m/attrs/add-from-T5LJXFFI.js +1 -0
  19. package/dist/m/attrs/onaftersave-OKSWEJQF.js +1 -0
  20. package/dist/m/attrs/refetch-on-save-ZUE7PSCI.js +1 -0
  21. package/dist/m/attrs/save-freeze-MYNVXREN.js +1 -0
  22. package/dist/m/c-2AZDZWCK.js +1 -0
  23. package/dist/m/c-2SPVQSHC.js +1 -0
  24. package/dist/m/c-2YYDMLNZ.js +1 -0
  25. package/dist/m/c-336SGU5W.js +1 -0
  26. package/dist/m/c-33JJ6CBX.js +2 -0
  27. package/dist/m/c-3GJ4SDE2.js +1 -0
  28. package/dist/m/c-3H6BZDNJ.js +6 -0
  29. package/dist/m/c-3OWDMNJR.js +2 -0
  30. package/dist/m/c-3RUU4TPX.js +91 -0
  31. package/dist/m/c-3XIRD4NU.js +1 -0
  32. package/dist/m/c-46XYM55L.js +1 -0
  33. package/dist/m/c-4DFEJ2PO.js +3 -0
  34. package/dist/m/c-4JZDZFF6.js +1 -0
  35. package/dist/m/c-4L3BTFRK.js +1 -0
  36. package/dist/m/c-4Q2XTQ2N.js +2 -0
  37. package/dist/m/c-4WKFKEKF.js +1 -0
  38. package/dist/m/c-56QRZTZH.js +1 -0
  39. package/dist/m/c-5J4E7O4Y.js +4 -0
  40. package/dist/m/c-5LKDWQTL.js +19 -0
  41. package/dist/m/c-5QWQ7A5L.js +1 -0
  42. package/dist/m/c-5RJFTLSF.js +1 -0
  43. package/dist/m/c-5V3MOVJT.js +1 -0
  44. package/dist/m/c-5VYOWDTI.js +1 -0
  45. package/dist/m/c-5YIHJ3TJ.js +1 -0
  46. package/dist/m/c-6AZOGAPE.js +1 -0
  47. package/dist/m/c-6CRUUXOX.js +5 -0
  48. package/dist/m/c-6HMB24EV.js +1 -0
  49. package/dist/m/c-6KEVEQ7L.js +1 -0
  50. package/dist/m/c-6NC5I2TV.js +1 -0
  51. package/dist/m/c-74MGYWZF.js +1 -0
  52. package/dist/m/c-7DJDKPGL.js +1 -0
  53. package/dist/m/c-7OLLJPWP.js +1 -0
  54. package/dist/m/c-7SWMYKAI.js +1 -0
  55. package/dist/m/c-A3E3NIMC.js +1 -0
  56. package/dist/m/c-A7LS5UZW.js +1 -0
  57. package/dist/m/c-AMSNPOCX.js +1 -0
  58. package/dist/m/c-AQLFEATB.js +1 -0
  59. package/dist/m/c-B3JM5ZXC.js +1 -0
  60. package/dist/m/c-BBVGTQG7.js +1 -0
  61. package/dist/m/c-BPF2NSPV.js +1 -0
  62. package/dist/m/c-BQ6LOBEE.js +1 -0
  63. package/dist/m/c-BTDI4Y23.js +1 -0
  64. package/dist/m/c-BWFVSBDF.js +1 -0
  65. package/dist/m/c-BYTKL6UX.js +1 -0
  66. package/dist/m/c-CFHW5AMY.js +6 -0
  67. package/dist/m/c-CJ3A7ZKE.js +1 -0
  68. package/dist/m/c-CQHPGKX2.js +1 -0
  69. package/dist/m/c-CYWLPPUS.js +1 -0
  70. package/dist/m/c-CZUSOB7V.js +1 -0
  71. package/dist/m/c-DCFSEJZG.js +1 -0
  72. package/dist/m/c-DCXOXBF3.js +1 -0
  73. package/dist/m/c-DFS4XZJV.js +2 -0
  74. package/dist/m/c-DNENWY4O.js +1 -0
  75. package/dist/m/c-DNZ5IFM6.js +1 -0
  76. package/dist/m/c-E4LIR5X5.js +1 -0
  77. package/dist/m/c-EJTGYSLN.js +1 -0
  78. package/dist/m/c-EVCQ3BKA.js +1 -0
  79. package/dist/m/c-EZU56NQV.js +34 -0
  80. package/dist/m/c-FDNHHZY5.js +1 -0
  81. package/dist/m/c-FILLTJA7.js +1 -0
  82. package/dist/m/c-FRLHSY7E.js +1 -0
  83. package/dist/m/c-FROJUZMV.js +1 -0
  84. package/dist/m/c-G2JPKCTP.js +1 -0
  85. package/dist/m/c-GB6TU7WV.js +1 -0
  86. package/dist/m/c-GFJJEBTU.js +1 -0
  87. package/dist/m/c-GJAEGGXY.js +1 -0
  88. package/dist/m/c-GOWBDM6J.js +1 -0
  89. package/dist/m/c-GQ6F6IDK.js +1 -0
  90. package/dist/m/c-GSFIGKOP.js +1 -0
  91. package/dist/m/c-GY422N3Q.js +1 -0
  92. package/dist/m/c-H4LG442Q.js +1 -0
  93. package/dist/m/c-HA6INT6J.js +1 -0
  94. package/dist/m/c-HAWFNBYG.js +1 -0
  95. package/dist/m/c-HDDEEL77.js +1 -0
  96. package/dist/m/c-HFKUVACH.js +1 -0
  97. package/dist/m/c-HHDFCNHV.js +1 -0
  98. package/dist/m/c-HPURYVZS.js +2 -0
  99. package/dist/m/c-I2ZATQCD.js +2 -0
  100. package/dist/m/c-IEM4NTCS.js +1 -0
  101. package/dist/m/c-IJUK2GPW.js +1 -0
  102. package/dist/m/c-IW6GGOU2.js +1 -0
  103. package/dist/m/c-JAX2667S.js +6 -0
  104. package/dist/m/c-JDCX26UP.js +25 -0
  105. package/dist/m/c-JRKY44DK.js +1 -0
  106. package/dist/m/c-JU3NK25H.js +1 -0
  107. package/dist/m/c-KAU6E43D.js +1 -0
  108. package/dist/m/c-KBS3UV6B.js +1 -0
  109. package/dist/m/c-KGVGROZT.js +1 -0
  110. package/dist/m/c-KI7M4AY3.js +1 -0
  111. package/dist/m/c-KIPQJX4B.js +1 -0
  112. package/dist/m/c-KQ6TYJAP.js +135 -0
  113. package/dist/m/c-KU3ZFADW.js +1 -0
  114. package/dist/m/c-L4WQSC27.js +1 -0
  115. package/dist/m/c-LFPHCXY3.js +1 -0
  116. package/dist/m/c-LRPUO2MX.js +1 -0
  117. package/dist/m/c-LWLBHLVC.js +3 -0
  118. package/dist/m/c-LZJPNR2W.js +1 -0
  119. package/dist/m/c-M2L47S2X.js +7 -0
  120. package/dist/m/c-MFP2ZWD4.js +1 -0
  121. package/dist/m/c-MKSQ4Y57.js +1 -0
  122. package/dist/m/c-MTQHWQC3.js +1 -0
  123. package/dist/m/c-N326R2JD.js +1 -0
  124. package/dist/m/c-N7JPUPGC.js +1 -0
  125. package/dist/m/c-NRPJEVJS.js +1 -0
  126. package/dist/m/c-NUFFJVVJ.js +1 -0
  127. package/dist/m/c-NUHP2XDB.js +1 -0
  128. package/dist/m/c-NUHSPT5P.js +1 -0
  129. package/dist/m/c-O72HVYSA.js +1 -0
  130. package/dist/m/c-OCSZ4QGN.js +1 -0
  131. package/dist/m/c-OIBUTDXI.js +1 -0
  132. package/dist/m/c-OIDRZKAF.js +1 -0
  133. package/dist/m/c-OW5QIGG3.js +1 -0
  134. package/dist/m/c-P7KNDG34.js +1 -0
  135. package/dist/m/c-PGRCK73F.js +1 -0
  136. package/dist/m/c-PQ5LK6QE.js +993 -0
  137. package/dist/m/c-PS5ARVWR.js +9 -0
  138. package/dist/m/c-PZ4XEPUP.js +2 -0
  139. package/dist/m/c-Q622NS2Y.js +1 -0
  140. package/dist/m/c-Q7NQD65V.js +1 -0
  141. package/dist/m/c-QH63LQOS.js +1 -0
  142. package/dist/m/c-QHIWXHRO.js +1 -0
  143. package/dist/m/c-QHWJ5ZIJ.js +1 -0
  144. package/dist/m/c-QICP2YR5.js +1 -0
  145. package/dist/m/c-QJ4OM3G6.js +1 -0
  146. package/dist/m/c-QNKREOL6.js +1 -0
  147. package/dist/m/c-R3L7ZJGB.js +2 -0
  148. package/dist/m/c-R7IWVINQ.js +1 -0
  149. package/dist/m/c-RM7J7BV2.js +1 -0
  150. package/dist/m/c-RSMOODDU.js +1 -0
  151. package/dist/m/c-RVMWGXEJ.js +1 -0
  152. package/dist/m/c-RYUXUUBX.js +1 -0
  153. package/dist/m/c-S4ZEH46B.js +9 -0
  154. package/dist/m/c-S7H2DRCB.js +1 -0
  155. package/dist/m/c-S7LK4KUE.js +1 -0
  156. package/dist/m/c-SDAXDM2D.js +1 -0
  157. package/dist/m/c-SGIA4IEQ.js +188 -0
  158. package/dist/m/c-SMBZG5X4.js +1 -0
  159. package/dist/m/c-SMGU7RT3.js +235 -0
  160. package/dist/m/c-SPIORRYS.js +1 -0
  161. package/dist/m/c-SWLRT66R.js +1 -0
  162. package/dist/m/c-SZGYW5HT.js +1 -0
  163. package/dist/m/c-TCCA5BZN.js +2 -0
  164. package/dist/m/c-TCJTVAFN.js +1 -0
  165. package/dist/m/c-TJ6WOJL3.js +67 -0
  166. package/dist/m/c-TQEMVJCS.js +1 -0
  167. package/dist/m/c-TRS6TM6O.js +1 -0
  168. package/dist/m/c-TYLXX4NF.js +21 -0
  169. package/dist/m/c-U62OB4BT.js +1 -0
  170. package/dist/m/c-U6YWUAR3.js +8 -0
  171. package/dist/m/c-UDCSU5G5.js +2 -0
  172. package/dist/m/c-UDUUJPFZ.js +1 -0
  173. package/dist/m/c-UGHH4MB3.js +1 -0
  174. package/dist/m/c-UL2YUY52.js +1 -0
  175. package/dist/m/c-VAK7SG37.js +1 -0
  176. package/dist/m/c-VDSS4K3Z.js +1 -0
  177. package/dist/m/c-VE6ZMYMC.js +1 -0
  178. package/dist/m/c-VG5XIN4T.js +1 -0
  179. package/dist/m/c-VHM5XQHK.js +1 -0
  180. package/dist/m/c-VHNSBD2M.js +1 -0
  181. package/dist/m/c-VI5RMSVY.js +1 -0
  182. package/dist/m/c-VKEDWYDF.js +1 -0
  183. package/dist/m/c-VRZN56XY.js +1 -0
  184. package/dist/m/c-W5MCHEGA.js +1 -0
  185. package/dist/m/c-WDC5GVKU.js +1 -0
  186. package/dist/m/c-WN5AY3OZ.js +1 -0
  187. package/dist/m/c-WNYBLIOZ.js +1 -0
  188. package/dist/m/c-WRBKEJD4.js +1 -0
  189. package/dist/m/c-WWXIDH4O.js +28 -0
  190. package/dist/m/c-WYFDLITL.js +1 -0
  191. package/dist/m/c-XCNTK76U.js +1 -0
  192. package/dist/m/c-XMS6DPBR.js +1 -0
  193. package/dist/m/c-XN6MBKI6.js +67 -0
  194. package/dist/m/c-XPELB6E5.js +1 -0
  195. package/dist/m/c-XQXZAO7N.js +1 -0
  196. package/dist/m/c-Y5HBBIQ4.js +1 -0
  197. package/dist/m/c-ZE46QDIH.js +1 -0
  198. package/dist/m/c-ZUCOKOHT.js +1 -0
  199. package/dist/m/c-ZVPVXTJF.js +4 -0
  200. package/dist/m/c-ZVRKXKM7.js +1 -0
  201. package/dist/m/c-ZWIOJGMT.js +1 -0
  202. package/dist/m/core/admin-attrs-QHOKPJ7W.js +1 -0
  203. package/dist/m/core/autosave-HRYGUWV6.js +1 -0
  204. package/dist/m/core/conflict-notice-6MROJN2L.js +1 -0
  205. package/dist/m/core/draft-mode-WSQAT67S.js +1 -0
  206. package/dist/m/core/host-permission-FNXVEFNE.js +1 -0
  207. package/dist/m/core/is-edit-mode-KTWA3O5N.js +1 -0
  208. package/dist/m/core/persist-JFYRHMRJ.js +3 -0
  209. package/dist/m/core/recovery-FLTCC2OC.js +1 -0
  210. package/dist/m/core/save-HQZ4S667.js +1 -0
  211. package/dist/m/core/save-core-KGQWFUNH.js +1 -0
  212. package/dist/m/core/snapshot-EGQZNT45.js +1 -0
  213. package/dist/m/core/unsaved-warning-IDJLD66H.js +1 -0
  214. package/dist/m/dom/all-APS5ZSKP.js +1 -0
  215. package/dist/m/dom/dom-helpers-L7OSR6S4.js +1 -0
  216. package/dist/m/events/index-RN2JNGBV.js +1 -0
  217. package/dist/m/internals/index-PVXGPUDA.js +1 -0
  218. package/dist/m/lib/cache-bust-MUMFXZK6.js +1 -0
  219. package/dist/m/lib/region-policy-SB2AWVG5.js +1 -0
  220. package/dist/m/loader-S4I7GKXR.js +1 -0
  221. package/dist/m/manifest-4C419D67.js +1 -0
  222. package/dist/m/manifest-edit-B077F288.js +1 -0
  223. package/dist/m/manifest.json +3988 -0
  224. package/dist/m/options/options-EJMS3K24.js +1 -0
  225. package/dist/m/page/editor-NNJA4OKD.js +202 -0
  226. package/dist/m/plugins/ai-edit-QN4PMMNL.js +6 -0
  227. package/dist/m/plugins/bind-text-NX46N5UV.js +1 -0
  228. package/dist/m/plugins/cms-HP3LSTPN.js +2293 -0
  229. package/dist/m/plugins/demo-RM5IR6AO.js +1 -0
  230. package/dist/m/plugins/derive-UAAA4V4S.js +1 -0
  231. package/dist/m/plugins/indicator-URDBBOQO.js +1 -0
  232. package/dist/m/plugins/live-HFWD4OIH.js +1 -0
  233. package/dist/m/plugins/menu-3HIEQSI6.js +138 -0
  234. package/dist/m/plugins/message-LQ6EDH4V.js +1 -0
  235. package/dist/m/plugins/page-JOKB6XPR.js +2 -0
  236. package/dist/m/plugins/page-view-NXOJHNW6.js +1 -0
  237. package/dist/m/plugins/people-SGPJKANK.js +1 -0
  238. package/dist/m/plugins/quickcrop-QNY3PKLD.js +26 -0
  239. package/dist/m/plugins/quickcrop-QNY3PKLD.js.LEGAL.txt +7 -0
  240. package/dist/m/plugins/richclay-NRQDSWX6.js +517 -0
  241. package/dist/m/plugins/richclay-NRQDSWX6.js.LEGAL.txt +1 -0
  242. package/dist/m/plugins/sortable-GWT4PWDV.js +1 -0
  243. package/dist/m/plugins/source-4ZRSAIYM.js +1 -0
  244. package/dist/m/plugins/undo-VDA5P7FH.js +1 -0
  245. package/dist/m/plugins/unsent-HJFLQJ2O.js +1 -0
  246. package/dist/m/plugins/upgrade-W7FG5VFG.js +1 -0
  247. package/dist/m/plugins/upload-WLYKK6TL.js +1 -0
  248. package/dist/m/plugins/visitor-drafts-LIDY7NH6.js +21 -0
  249. package/dist/m/plugins/visitor-drafts-owner-ZXCKBZE7.js +1 -0
  250. package/dist/m/plugins/wire-4N6GYAF6.js +1 -0
  251. package/dist/m/reader-core-DXYCURFF.js +68 -0
  252. package/dist/m/route/route-KOCZSEGN.js +1 -0
  253. package/dist/m/sync/live-sync-J7VMYTKS.js +1 -0
  254. package/dist/m/ui/index-3JLVI27O.js +1 -0
  255. package/dist/m/utils/index-4TJCVLT7.js +1 -0
  256. package/dist/m/vendor/Sortable.vendor-A755ITLN.js +3 -0
  257. package/dist/m/vendor/Sortable.vendor-A755ITLN.js.LEGAL.txt +1 -0
  258. package/dist/m/vendor/sap-core.vendor-A7BMUYZT.js +6 -0
  259. package/dist/offline-manifest.json +4034 -0
  260. package/dist/page/themes/light-1.css +430 -0
  261. package/dist/server/core.cjs +23748 -22855
  262. package/dist/server/offline-runtime.cjs +4954 -0
  263. package/dist/server/offline-runtime.mjs +4923 -0
  264. package/dist/server/rooms.mjs +9 -0
  265. package/docs/guide.md +1078 -669
  266. package/entries/all.js +2 -0
  267. package/entries/clay-data.js +1 -1
  268. package/entries/clay-dom.js +2 -0
  269. package/entries/clay-events.js +2 -0
  270. package/entries/clay-internals.js +2 -0
  271. package/entries/clay-options.js +2 -0
  272. package/entries/clay-router.js +2 -0
  273. package/entries/clay-ui.js +2 -0
  274. package/entries/clay-utils.js +2 -0
  275. package/entries/clay.js +2 -0
  276. package/entries/sap.js +6 -6
  277. package/fonts/ibm-plex-mono-LICENSE +93 -0
  278. package/fonts/ibm-plex-mono-latin-300-normal.woff2 +0 -0
  279. package/fonts/ibm-plex-mono-latin-400-italic.woff2 +0 -0
  280. package/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  281. package/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  282. package/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  283. package/fonts/ibm-plex-sans-LICENSE +93 -0
  284. package/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  285. package/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  286. package/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  287. package/fonts/ibm-plex.css +71 -0
  288. package/fonts/inter-LICENSE +93 -0
  289. package/fonts/inter-cyrillic-ext-wght-normal.woff2 +0 -0
  290. package/fonts/inter-cyrillic-wght-normal.woff2 +0 -0
  291. package/fonts/inter-greek-ext-wght-normal.woff2 +0 -0
  292. package/fonts/inter-greek-wght-normal.woff2 +0 -0
  293. package/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
  294. package/fonts/inter-latin-wght-normal.woff2 +0 -0
  295. package/fonts/inter-vietnamese-wght-normal.woff2 +0 -0
  296. package/fonts/inter.css +62 -0
  297. package/fonts/newsreader-LICENSE +93 -0
  298. package/fonts/newsreader-latin-ext-opsz-normal.woff2 +0 -0
  299. package/fonts/newsreader-latin-opsz-normal.woff2 +0 -0
  300. package/fonts/newsreader-vietnamese-opsz-normal.woff2 +0 -0
  301. package/fonts/newsreader.css +26 -0
  302. package/fonts/work-sans-LICENSE +93 -0
  303. package/fonts/work-sans-latin-wght-normal.woff2 +0 -0
  304. package/fonts/work-sans.css +8 -0
  305. package/package.json +20 -3
  306. package/packed-contract.json +1 -0
  307. package/src/attrs/add-from.js +27 -4
  308. package/src/attrs/save-freeze.js +7 -52
  309. package/src/core/admin-attrs.js +119 -12
  310. package/src/core/admin-contenteditable.js +12 -10
  311. package/src/core/admin-inputs.js +14 -15
  312. package/src/core/admin-onclick.js +2 -0
  313. package/src/core/autosave.js +74 -21
  314. package/src/core/boot-phase.js +2 -1
  315. package/src/core/conflict-download.js +19 -23
  316. package/src/core/conflict-notice-ui.js +1173 -0
  317. package/src/core/conflict-notice.js +140 -697
  318. package/src/core/download.js +32 -0
  319. package/src/core/edit-mode.js +147 -14
  320. package/src/core/etag.js +30 -12
  321. package/src/core/host-meta.js +90 -8
  322. package/src/core/host-permission.js +29 -0
  323. package/src/core/is-edit-mode.js +145 -12
  324. package/src/core/mode-key.js +125 -0
  325. package/src/core/mode-lifecycle.js +544 -0
  326. package/src/core/mode-receipt.js +30 -0
  327. package/src/core/mode-refusal.js +13 -0
  328. package/src/core/mode-resources.js +52 -0
  329. package/src/core/mode-support.js +82 -0
  330. package/src/core/mode-switch.js +259 -0
  331. package/src/core/mode-transition.js +112 -0
  332. package/src/core/page-data-write.js +305 -0
  333. package/src/core/page-data.js +26 -227
  334. package/src/core/page-format-wire.js +4 -0
  335. package/src/core/page-format.js +58 -0
  336. package/src/core/persist.js +37 -9
  337. package/src/core/preserve-authored.js +114 -0
  338. package/src/core/recovery.js +772 -0
  339. package/src/core/runtime-url.js +105 -0
  340. package/src/core/save-core.js +113 -12
  341. package/src/core/save-replace.js +72 -0
  342. package/src/core/save-size-notice.js +134 -0
  343. package/src/core/save-size.js +140 -0
  344. package/src/core/save.js +806 -119
  345. package/src/core/snapshot.js +159 -11
  346. package/src/core/source-map.js +157 -9
  347. package/src/core/unsaved-warning.js +14 -4
  348. package/src/core/upgrade-run.js +408 -0
  349. package/src/core/version.js +18 -0
  350. package/src/lib/assets.js +30 -0
  351. package/src/lib/autosave-debug-gate.js +50 -0
  352. package/src/lib/autosave-scheduler.js +140 -0
  353. package/src/lib/boot-imports.js +8 -0
  354. package/src/lib/derived.js +3 -1
  355. package/src/lib/dirty-gate.js +15 -0
  356. package/src/lib/doc-storage.js +33 -0
  357. package/src/lib/effect.js +9 -4
  358. package/src/lib/mutation.js +4 -2
  359. package/src/lib/offline-runtime.js +226 -0
  360. package/src/lib/preload.js +48 -0
  361. package/src/lib/root-attrs.js +1 -1
  362. package/src/lib/trash.js +18 -0
  363. package/src/lib/undo/capture-move.js +152 -0
  364. package/src/live/local-channel.js +61 -0
  365. package/src/live/local-lane.js +60 -9
  366. package/src/live/server-lane.js +6 -3
  367. package/src/loader-logic.js +76 -15
  368. package/src/loader.js +218 -30
  369. package/src/page/adopt-boot.js +76 -22
  370. package/src/page/adopt.js +25 -4
  371. package/src/page/awareness.js +230 -0
  372. package/src/page/blocks.js +113 -6
  373. package/src/page/blocksel.js +20 -4
  374. package/src/page/board-face.js +13 -0
  375. package/src/page/board-panel.js +5 -17
  376. package/src/page/board-style.js +2 -13
  377. package/src/page/board-view.js +1 -11
  378. package/src/page/board-views.js +3 -0
  379. package/src/page/board.js +2 -2
  380. package/src/page/boot-pack.js +26 -0
  381. package/src/page/boot.js +237 -0
  382. package/src/page/chart-tables.js +11 -0
  383. package/src/page/chart.js +6 -10
  384. package/src/page/checklist.js +1 -1
  385. package/src/page/checkpoint-proof.js +289 -0
  386. package/src/page/chrome.js +431 -63
  387. package/src/page/csv-import.js +17 -2
  388. package/src/page/document-title-dom.js +52 -0
  389. package/src/page/document-title-runtime.js +90 -0
  390. package/src/page/document-title.js +12 -0
  391. package/src/page/drag.js +48 -13
  392. package/src/page/drop.js +2 -1
  393. package/src/page/editor.js +399 -90
  394. package/src/page/emoji-data.js +162 -0
  395. package/src/page/feature-loader.js +72 -0
  396. package/src/page/features/board.js +21 -0
  397. package/src/page/features/chart.js +11 -0
  398. package/src/page/features/code.js +13 -0
  399. package/src/page/features/dates.js +180 -0
  400. package/src/page/features/emoji.js +187 -0
  401. package/src/page/features/media.js +290 -0
  402. package/src/page/features/mentions.js +188 -0
  403. package/src/page/features/registry.js +28 -0
  404. package/src/page/features/table.js +383 -0
  405. package/src/page/{tool-view.js → features/tool.js} +33 -2
  406. package/src/page/format-codec.js +215 -0
  407. package/src/page/format-command.js +9 -0
  408. package/src/page/format-gate.js +179 -0
  409. package/src/page/format-host.js +54 -0
  410. package/src/page/format-level.js +157 -0
  411. package/src/page/format-native-commands.js +142 -0
  412. package/src/page/format-native.js +42 -0
  413. package/src/page/highlight-slot.js +23 -0
  414. package/src/page/highlight.js +30 -16
  415. package/src/page/history-intent.js +78 -0
  416. package/src/page/inline.js +45 -28
  417. package/src/page/items.js +67 -14
  418. package/src/page/link.js +1 -0
  419. package/src/page/markdown.js +112 -3
  420. package/src/page/media-views.js +3 -0
  421. package/src/page/media.js +33 -245
  422. package/src/page/mention-picker.js +99 -0
  423. package/src/page/merge.js +1 -1
  424. package/src/page/outline-cache.js +11 -0
  425. package/src/page/placeholder.js +27 -7
  426. package/src/page/projection.js +240 -51
  427. package/src/page/reader-patch.js +306 -0
  428. package/src/page/recover.js +1 -1
  429. package/src/page/rich/page-tool.js +1 -4
  430. package/src/page/runtime-owner.js +27 -0
  431. package/src/page/save-projection.js +46 -4
  432. package/src/page/save-states.js +1 -1
  433. package/src/page/schema.js +47 -0
  434. package/src/page/table-rect-key.js +3 -0
  435. package/src/page/table-select.js +4 -3
  436. package/src/page/table-style.js +1 -1
  437. package/src/page/table-views.js +3 -0
  438. package/src/page/table.js +8 -293
  439. package/src/page/themes/content.css +25 -1
  440. package/src/page/themes/light-1.css +163 -2
  441. package/src/page/themes/light-1.source.css +269 -0
  442. package/src/page/tool-capability.js +3 -0
  443. package/src/page/tool-views.js +3 -0
  444. package/src/page/view-hooks.js +32 -0
  445. package/src/page/view.js +390 -107
  446. package/src/page/ybind/awareness.js +172 -0
  447. package/src/page/ybind/binding.js +40 -5
  448. package/src/page/ybind/bridge.js +50 -47
  449. package/src/page/ybind/decode.js +52 -19
  450. package/src/page/ybind/doc.js +27 -2
  451. package/src/page/ybind/group.js +12 -3
  452. package/src/page/ybind/index.js +2 -0
  453. package/src/page/ybind/lineage.js +71 -0
  454. package/src/page/ybind/marks.js +26 -1
  455. package/src/page/ybind/migrate.js +48 -13
  456. package/src/page/ybind/moves.js +32 -21
  457. package/src/page/ybind/positions.js +50 -0
  458. package/src/page/ybind/provider.js +97 -24
  459. package/src/page/ybind/recovery-proof.js +191 -0
  460. package/src/page/ybind/recovery-replay.js +488 -0
  461. package/src/page/ybind/tokens.js +15 -6
  462. package/src/page/ybind/walk.js +10 -3
  463. package/src/page/ybind/writer.js +48 -4
  464. package/src/plugins/ai-edit.js +167 -32
  465. package/src/plugins/bind-text.js +218 -0
  466. package/src/plugins/cms.js +93 -0
  467. package/src/plugins/indicator.js +57 -5
  468. package/src/plugins/live.js +319 -35
  469. package/src/plugins/menu/claygoo.svg.js +1 -0
  470. package/src/plugins/menu/seo-head.js +323 -0
  471. package/src/plugins/menu/seo.js +849 -0
  472. package/src/plugins/menu.js +425 -0
  473. package/src/plugins/page-view.js +131 -0
  474. package/src/plugins/page.js +1131 -270
  475. package/src/plugins/people.js +158 -31
  476. package/src/plugins/richclay.js +119 -9
  477. package/src/plugins/sortable.js +370 -60
  478. package/src/plugins/source.js +189 -366
  479. package/src/plugins/undo.js +289 -19
  480. package/src/plugins/unsent.js +132 -0
  481. package/src/plugins/upgrade-run.js +1 -0
  482. package/src/plugins/upgrade.js +210 -0
  483. package/src/plugins/upload-task.js +571 -0
  484. package/src/plugins/upload-ui.js +265 -0
  485. package/src/plugins/upload.js +34 -153
  486. package/src/plugins/visitor-drafts/inert.js +32 -0
  487. package/src/plugins/visitor-drafts/intro.js +2 -1
  488. package/src/plugins/visitor-drafts/owner-chip.js +3 -0
  489. package/src/plugins/visitor-drafts/prompt.js +2 -2
  490. package/src/plugins/visitor-drafts-owner.js +85 -0
  491. package/src/plugins/visitor-drafts.js +31 -42
  492. package/src/plugins/wire.js +82 -1
  493. package/src/reader-core.js +26 -0
  494. package/src/recovery/conflicts.js +287 -0
  495. package/src/recovery/identity.js +154 -0
  496. package/src/recovery/store.js +792 -0
  497. package/src/recovery/undo.js +257 -0
  498. package/src/server/checkpoint/index.js +68 -4
  499. package/src/server/offline-runtime/index.js +214 -0
  500. package/src/server/rooms/index.js +2 -1
  501. package/src/server/rooms/live-data-rooms.js +2 -2
  502. package/src/server/rooms/page-admission.js +33 -0
  503. package/src/server/rooms/page-lineage.js +56 -0
  504. package/src/server/rooms/page-rebase.js +11 -5
  505. package/src/server/rooms/page-state.js +2 -0
  506. package/src/server/rooms/page-write-admission.js +9 -3
  507. package/src/source/session.js +705 -0
  508. package/src/sync/conflict-revert.js +5 -4
  509. package/src/sync/conflicts-edit.js +119 -0
  510. package/src/sync/conflicts-facade.js +49 -0
  511. package/src/sync/conflicts.js +99 -1
  512. package/src/sync/editing-marker.js +37 -6
  513. package/src/sync/editing-sender.js +8 -1
  514. package/src/sync/live-sync-edit.js +63 -0
  515. package/src/sync/live-sync.js +364 -119
  516. package/src/sync/local-presence.js +187 -0
  517. package/src/sync/merge-declarations.js +10 -0
  518. package/src/sync/merge-engine.js +12 -0
  519. package/src/sync/presence-store.js +412 -0
  520. package/src/sync/presence-target.js +243 -0
  521. package/src/sync/presence.js +72 -41
  522. package/src/sync/saved-handoff.js +200 -0
  523. package/src/sync/saved-stream.js +544 -0
  524. package/src/sync/version-guard.js +92 -0
  525. package/src/sync/wire-profile.js +81 -0
  526. package/src/ui/bevel-controls.js +2 -8
  527. package/src/ui/page-scheme.js +7 -0
  528. package/src/ui/skins/cms.js +1 -1
  529. package/src/ui/theme-config.js +150 -0
  530. package/src/ui/theme.js +6 -138
  531. package/src/ui/toast-lazy.js +11 -0
  532. package/src/vendor/LICENSES-optional.md +253 -0
  533. package/src/vendor/highlight.vendor.js +3 -0
  534. package/src/vendor/hljs-bash.vendor.js +2 -0
  535. package/src/vendor/hljs-css.vendor.js +2 -0
  536. package/src/vendor/hljs-javascript.vendor.js +2 -0
  537. package/src/vendor/hljs-json.vendor.js +2 -0
  538. package/src/vendor/hljs-python.vendor.js +2 -0
  539. package/src/vendor/hljs-xml.vendor.js +2 -0
  540. package/src/vendor/hyper-html-api-data.vendor.js +1 -1
  541. package/src/vendor/hyper-html-api-upgrade.vendor.js +5 -0
  542. package/src/vendor/hyper-morph-identity.vendor.js +2 -0
  543. package/src/vendor/hyper-morph-json.vendor.js +3 -0
  544. package/src/vendor/hyper-morph.vendor.js +6 -6
  545. package/src/vendor/hyper-undo.vendor.js +1 -1
  546. package/src/vendor/hypercms.vendor.js +169 -84
  547. package/src/vendor/marked.vendor.js +68 -0
  548. package/src/vendor/overtype.vendor.js +994 -0
  549. package/src/vendor/richclay.vendor.js +17 -17
  550. package/src/vendor/sap-core.vendor.js +5 -5
  551. package/src/vendor/sap-ownership.vendor.js +11 -7
@@ -0,0 +1,28 @@
1
+ var ka=Object.defineProperty,pt=(t,e)=>{for(var n in e)ka(t,n,{get:e[n],enumerable:!0})},ft={};pt(ft,{ContentMatch:()=>re,DOMParser:()=>To,DOMSerializer:()=>qe,Fragment:()=>v,Mark:()=>E,MarkType:()=>Eo,Node:()=>Et,NodeRange:()=>Bs,NodeType:()=>co,ReplaceError:()=>se,ResolvedPos:()=>so,Schema:()=>Fa,Slice:()=>k});function J(t){this.content=t}J.prototype={constructor:J,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,i=o.find(t),s=o.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new J(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new J(n)},addToStart:function(t,e){return new J([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new J(n)},addBefore:function(t,e,n){var o=this.remove(e),i=o.content.slice(),s=o.find(t);return i.splice(s==-1?i.length:s,0,e,n),new J(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=J.from(t),t.size?new J(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=J.from(t),t.size?new J(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=J.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};J.from=function(t){if(t instanceof J)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new J(e)};var Si=J;function Ns(t,e,n){for(let o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(o),s=e.child(o);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){let r=i.text,l=s.text,a=0;for(;r[a]==l[a];a++)n++;return a&&a<r.length&&a<l.length&&Es(r.charCodeAt(a-1))&&Ds(r.charCodeAt(a))&&n--,n}if(i.content.size||s.content.size){let r=Ns(i.content,s.content,n+1);if(r!=null)return r}n+=i.nodeSize}}function As(t,e,n,o){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:o};let r=t.child(--i),l=e.child(--s),a=r.nodeSize;if(r==l){n-=a,o-=a;continue}if(!r.sameMarkup(l))return{a:n,b:o};if(r.isText&&r.text!=l.text){let c=r.text,h=l.text,d=c.length,f=h.length;for(;d>0&&f>0&&c[d-1]==h[f-1];)d--,f--,n--,o--;return d&&f&&d<c.length&&Es(c.charCodeAt(d-1))&&Ds(c.charCodeAt(d))&&(n++,o++),{a:n,b:o}}if(r.content.size||l.content.size){let c=As(r.content,l.content,n-1,o-1);if(c)return c}n-=a,o-=a}}function Ds(t){return t>=56320&&t<57344}function Es(t){return t>=55296&&t<56320}var v=class G{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,n,o,i=0,s){for(let r=0,l=0;l<n;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&o(a,i+l,s||null,r)!==!1&&a.content.size){let h=l+1;a.nodesBetween(Math.max(0,e-h),Math.min(a.content.size,n-h),o,i+h)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,o,i){let s="",r=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(r?r=!1:s+=o),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,o=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(o)&&(i[i.length-1]=n.withText(n.text+o.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new G(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let o=[],i=0;if(n>e)for(let s=0,r=0;r<n;s++){let l=this.content[s],a=r+l.nodeSize;a>e&&((r<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,n-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,n-r-1))),o.push(l),i+=l.nodeSize),r=a}return new G(o,i)}cutByIndex(e,n){return e==n?G.empty:e==0&&n==this.content.length?this:new G(this.content.slice(e,n))}replaceChild(e,n){let o=this.content[e];if(o==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-o.nodeSize;return i[e]=n,new G(i,s)}addToStart(e){return new G([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new G(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,o=0;n<this.content.length;n++){let i=this.content[n];e(i,o,n),o+=i.nodeSize}}findDiffStart(e,n=0){return Ns(this,e,n)}findDiffEnd(e,n=this.size,o=e.size){return As(this,e,n,o)}findIndex(e){if(e==0)return cn(0,e);if(e==this.size)return cn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,o=0;;n++){let i=this.child(n),s=o+i.nodeSize;if(s>=e)return s==e?cn(n+1,s):cn(n,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return G.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return G.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return G.empty;let n,o=0;for(let i=0;i<e.length;i++){let s=e[i];o+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new G(n||e,o)}static from(e){if(!e)return G.empty;if(e instanceof G)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new G([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};v.empty=new v([],0);var qn={index:0,offset:0};function cn(t,e){return qn.index=t,qn.offset=e,qn}function kn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let o=0;o<t.length;o++)if(!kn(t[o],e[o]))return!1}else{for(let o in t)if(!(o in e)||!kn(t[o],e[o]))return!1;for(let o in e)if(!(o in t))return!1}return!0}var E=class oo{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,o=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!o&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),o=!0),n&&n.push(s)}}return n||(n=e.slice()),o||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&kn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let o=e.marks[n.type];if(!o)throw new RangeError(`There is no mark type ${n.type} in this schema`);return o.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(n[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return oo.none;if(e instanceof oo)return[e];let n=e.slice();return n.sort((o,i)=>o.type.rank-i.type.rank),n}};E.none=[];var se=class extends Error{},k=class Zt{constructor(e,n,o){this.content=e,this.openStart=n,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let o=$s(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return o&&new Zt(o,this.openStart,this.openEnd)}removeBetween(e,n){return new Zt(Ts(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Zt.empty;let o=n.openStart||0,i=n.openEnd||0;if(typeof o!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Zt(v.fromJSON(e,n.content),o,i)}static maxOpen(e,n=!0){let o=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)o++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Zt(e,o,i)}};k.empty=new k(v.empty,0,0);function Ts(t,e,n){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o),{index:r,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(r).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=r)throw new RangeError("Removing non-flat range");return t.replaceChild(o,s.copy(Ts(s.content,e-i-1,n-i-1)))}function $s(t,e,n,o,i,s){let{index:r,offset:l}=t.findIndex(e),a=t.maybeChild(r);if(l==e||a.isText)return s&&o<=0&&i<=0&&!s.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=$s(a.content,e-l-1,n,r==0?o-1:0,r==t.childCount-1?i-1:0,a);return c&&t.replaceChild(r,a.copy(c))}function xa(t,e,n){if(n.openStart>t.depth)throw new se("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new se("Inconsistent open depths");return Rs(t,e,n,0)}function Rs(t,e,n,o){let i=t.index(o),s=t.node(o);if(i==e.index(o)&&o<t.depth-n.openStart){let r=Rs(t,e,n,o+1);return s.copy(s.content.replaceChild(i,r))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==o&&e.depth==o){let r=t.parent,l=r.content;return Lt(r,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=Sa(n,t);return Lt(s,Ps(t,r,l,e,o))}else return Lt(s,xn(t,e,o))}function Is(t,e){if(!e.type.compatibleContent(t.type))throw new se("Cannot join "+e.type.name+" onto "+t.type.name)}function io(t,e,n){let o=t.node(n);return Is(o,e.node(n)),o}function jt(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function De(t,e,n,o){let i=(e||t).node(n),s=0,r=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(jt(t.nodeAfter,o),s++));for(let l=s;l<r;l++)jt(i.child(l),o);e&&e.depth==n&&e.textOffset&&jt(e.nodeBefore,o)}function Lt(t,e){if(!t.type.validContent(e))throw new se("Invalid content for node "+t.type.name);return t.copy(e)}function Ps(t,e,n,o,i){let s=t.depth>i&&io(t,e,i+1),r=o.depth>i&&io(n,o,i+1),l=[];return De(null,t,i,l),s&&r&&e.index(i)==n.index(i)?(Is(s,r),jt(Lt(s,Ps(t,e,n,o,i+1)),l)):(s&&jt(Lt(s,xn(t,e,i+1)),l),De(e,n,i,l),r&&jt(Lt(r,xn(n,o,i+1)),l)),De(o,null,i,l),new v(l)}function xn(t,e,n){let o=[];if(De(null,t,n,o),t.depth>n){let i=io(t,e,n+1);jt(Lt(i,xn(t,e,n+1)),o)}return De(e,null,n,o),new v(o)}function Sa(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(v.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}var so=class ro{constructor(e,n,o){this.pos=e,this.path=n,this.parentOffset=o,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],i=e.child(n);return o?e.child(n).cut(o):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let o=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=o.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return E.none;if(this.textOffset)return e.child(n).marks;let o=e.maybeChild(n-1),i=e.maybeChild(n);if(!o){let l=o;o=i,i=l}let s=o.marks;for(var r=0;r<s.length;r++)s[r].type.spec.inclusive===!1&&(!i||!s[r].isInSet(i.marks))&&(s=s[r--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let o=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<o.length;s++)o[s].type.spec.inclusive===!1&&(!i||!o[s].isInSet(i.marks))&&(o=o[s--].removeFromSet(o));return o}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!n||n(this.node(o))))return new Bs(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let o=[],i=0,s=n;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(s),c=s-a;if(o.push(r,l,i+a),!c||(r=r.child(l),r.isText))break;s=c-1,i+=a+1}return new ro(n,o,s)}static resolveCached(e,n){let o=Oi.get(e);if(o)for(let s=0;s<o.elts.length;s++){let r=o.elts[s];if(r.pos==n)return r}else Oi.set(e,o=new Oa);let i=o.elts[o.i]=ro.resolve(e,n);return o.i=(o.i+1)%Ma,i}},Oa=class{constructor(){this.elts=[],this.i=0}},Ma=12,Oi=new WeakMap,Bs=class{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}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)}},Ca=Object.create(null),Et=class lo{constructor(e,n,o,i=E.none){this.type=e,this.attrs=n,this.marks=i,this.content=o||v.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,o,i=0){this.content.nodesBetween(e,n,o,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,o,i){return this.content.textBetween(e,n,o,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,o){return this.type==e&&kn(this.attrs,n||e.defaultAttrs||Ca)&&E.sameSet(this.marks,o||E.none)}copy(e=null){return e==this.content?this:new lo(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new lo(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,o=!1){if(e==n)return k.empty;let i=this.resolve(e),s=this.resolve(n),r=o?0:i.sharedDepth(n),l=i.start(r),a=i.node(r).content.cut(i.pos-l,s.pos-l);return new k(a,i.depth-r,s.depth-r)}replace(e,n,o){return xa(this.resolve(e),this.resolve(n),o)}nodeAt(e){for(let n=this;;){let{index:o,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(o),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(n),index:n,offset:o};let i=this.content.child(n-1);return{node:i,index:n-1,offset:o-i.nodeSize}}resolve(e){return so.resolveCached(this,e)}resolveNoCache(e){return so.resolve(this,e)}rangeHasMark(e,n,o){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(o.isInSet(s.marks)&&(i=!0),!i)),i}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()+")"),zs(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,o=v.empty,i=0,s=o.childCount){let r=this.contentMatchAt(e).matchFragment(o,i,s),l=r&&r.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,n,o,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(o),r=s&&s.matchFragment(this.content,n);return r?r.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),Mi(this.type.attrs,this.attrs,"node",this.type.name);let e=E.none;for(let n=0;n<this.marks.length;n++){let o=this.marks[n];Mi(o.type.attrs,o.attrs,"mark",o.type.name),e=o.addToSet(e)}if(!E.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let o;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,o)}let i=v.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,o)}};Et.prototype.text=void 0;var Na=class ao extends Et{constructor(e,n,o,i){if(super(e,n,null,i),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zs(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new ao(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ao(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function zs(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function Mi(t,e,n,o){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${o}`);for(let i in t)t[i].validate&&t[i].validate(e[i])}var re=class Vs{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let o=new Aa(e,n);if(o.next==null)return Vs.empty;let i=Fs(o);o.next&&o.err("Unexpected trailing text");let s=Pa(Ia(i));return Ba(s,o),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,o=e.childCount){let i=this;for(let s=n;i&&s<o;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let o=0;o<e.next.length;o++)if(this.next[n].type==e.next[o].type)return!0;return!1}fillBefore(e,n=!1,o=0){let i=[this];function s(r,l){let a=r.matchFragment(e,o);if(a&&(!n||a.validEnd))return v.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:h,next:d}=r.next[c];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(h));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let i=o.shift(),s=i.match;if(s.matchType(e)){let r=[];for(let l=i;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<s.next.length;r++){let{type:l,next:a}=s.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(o){e.push(o);for(let i=0;i<o.next.length;i++)e.indexOf(o.next[i].next)==-1&&n(o.next[i].next)}return n(this),e.map((o,i)=>{let s=i+(o.validEnd?"*":" ")+" ";for(let r=0;r<o.next.length;r++)s+=(r?", ":"")+o.next[r].type.name+"->"+e.indexOf(o.next[r].next);return s}).join(`
2
+ `)}};re.empty=new re(!0);var Aa=class{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}};function Fs(t){let e=[];do e.push(Da(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Da(t){let e=[];do e.push(Ea(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ea(t){let e=Ra(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Ta(t,e);else break;return e}function Ci(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Ta(t,e){let n=Ci(t),o=n;return t.eat(",")&&(t.next!="}"?o=Ci(t):o=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:e}}function $a(t,e){let n=t.nodeTypes,o=n[e];if(o)return[o];let i=[];for(let s in n){let r=n[s];r.isInGroup(e)&&i.push(r)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function Ra(t){if(t.eat("(")){let e=Fs(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=$a(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Ia(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function o(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function i(r,l){r.forEach(a=>a.to=l)}function s(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=s(r.exprs[a],l);if(a==r.exprs.length-1)return c;i(c,l=n())}else if(r.type=="star"){let a=n();return o(l,a),i(s(r.expr,a),a),[o(a)]}else if(r.type=="plus"){let a=n();return i(s(r.expr,l),a),i(s(r.expr,a),a),[o(a)]}else{if(r.type=="opt")return[o(l)].concat(s(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let h=n();i(s(r.expr,a),h),a=h}if(r.max==-1)i(s(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let h=n();o(a,h),i(s(r.expr,a),h),a=h}return[o(a)]}else{if(r.type=="name")return[o(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function js(t,e){return e-t}function Ni(t,e){let n=[];return o(e),n.sort(js);function o(i){let s=t[i];if(s.length==1&&!s[0].term)return o(s[0].to);n.push(i);for(let r=0;r<s.length;r++){let{term:l,to:a}=s[r];!l&&n.indexOf(a)==-1&&o(a)}}}function Pa(t){let e=Object.create(null);return n(Ni(t,0));function n(o){let i=[];o.forEach(r=>{t[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let h=0;h<i.length;h++)i[h][0]==l&&(c=i[h][1]);Ni(t,a).forEach(h=>{c||i.push([l,c=[]]),c.indexOf(h)==-1&&c.push(h)})})});let s=e[o.join(",")]=new re(o.indexOf(t.length-1)>-1);for(let r=0;r<i.length;r++){let l=i[r][1].sort(js);s.next.push({type:i[r][0],next:e[l.join(",")]||n(l)})}return s}}function Ba(t,e){for(let n=0,o=[t];n<o.length;n++){let i=o[n],s=!i.validEnd,r=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];r.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),o.indexOf(c)==-1&&o.push(c)}s&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ls(t){let e=Object.create(null);for(let n in t){let o=t[n];if(!o.hasDefault)return null;e[n]=o.default}return e}function Js(t,e){let n=Object.create(null);for(let o in t){let i=t[o],s=e&&e[o];if(s===void 0)if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+o);else i.validate&&i.validate(s);n[o]=s}return n}function qs(t,e){let n=Object.create(null);if(e)for(let o in e)n[o]=new Va(t,o,e[o]);return n}var co=class Ws{constructor(e,n,o){this.name=e,this.schema=n,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=qs(e,o.attrs),this.defaultAttrs=Ls(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==re.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:Js(this.attrs,e)}create(e=null,n,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(e),v.from(n),E.setFrom(o))}createChecked(e=null,n,o){return n=v.from(n),this.checkContent(n),new Et(this,this.computeAttrs(e),n,E.setFrom(o))}createAndFill(e=null,n,o){if(e=this.computeAttrs(e),n=v.from(n),n.size){let r=this.contentMatch.fillBefore(n);if(!r)return null;n=r.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(v.empty,!0);return s?new Et(this,e,n.append(s),E.setFrom(o)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).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 n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?n&&n.push(e[o]):n||(n=e.slice(0,o));return n?n.length?n:E.none:e}static compile(e,n){let o=Object.create(null);e.forEach((s,r)=>o[s]=new Ws(s,n,r));let i=n.spec.topNode||"doc";if(!o[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let s in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};function za(t,e,n){let o=n.split("|");return i=>{let s=i===null?"null":typeof i;if(o.indexOf(s)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${t}, got ${s}`)}}var Va=class{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?za(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Eo=class Ks{constructor(e,n,o,i){this.name=e,this.rank=n,this.schema=o,this.spec=i,this.attrs=qs(e,i.attrs),this.excluded=null;let s=Ls(this.attrs);this.instance=s?new E(this,s):null}create(e=null){return!e&&this.instance?this.instance:new E(this,Js(this.attrs,e))}static compile(e,n){let o=Object.create(null),i=0;return e.forEach((s,r)=>o[s]=new Ks(s,i++,n,r)),o}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}},Fa=class{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let o in t)e[o]=t[o];e.nodes=Si.from(t.nodes),e.marks=Si.from(t.marks||{}),this.nodes=co.compile(this.spec.nodes,this),this.marks=Eo.compile(this.spec.marks,this);let n=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||"",r=i.spec.marks;if(i.contentMatch=n[s]||(n[s]=re.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=r=="_"?null:r?Ai(this,r.split(" ")):r==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Ai(this,s.split(" "))}this.nodeFromJSON=o=>Et.fromJSON(this,o),this.markFromJSON=o=>E.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,e=null,n,o){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof co){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(e,n,o)}text(t,e){let n=this.nodes.text;return new Na(n,n.defaultAttrs,t,E.setFrom(e))}mark(t,e){return typeof t=="string"&&(t=this.marks[t]),t.create(e)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}};function Ai(t,e){let n=[];for(let o=0;o<e.length;o++){let i=e[o],s=t.marks[i],r=s;if(s)n.push(s);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return n}function ja(t){return t.tag!=null}function La(t){return t.style!=null}var To=class ho{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let o=this.matchedStyles=[];n.forEach(i=>{if(ja(i))this.tags.push(i);else if(La(i)){let s=/[^=]*/.exec(i.style)[0];o.indexOf(s)<0&&o.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let o=new Ei(this,n,!1);return o.addAll(e,E.none,n.from,n.to),o.finish()}parseSlice(e,n={}){let o=new Ei(this,n,!0);return o.addAll(e,E.none,n.from,n.to),k.maxOpen(o.finish())}matchTag(e,n,o){for(let i=o?this.tags.indexOf(o)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Wa(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let r=s.getAttrs(e);if(r===!1)continue;s.attrs=r||void 0}return s}}}matchStyle(e,n,o,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let r=this.styles[s],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!o.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(r.getAttrs){let a=r.getAttrs(n);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let n=[];function o(i){let s=i.priority==null?50:i.priority,r=0;for(;r<n.length;r++){let l=n[r];if((l.priority==null?50:l.priority)<s)break}n.splice(r,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(r=>{o(r=Ti(r)),r.mark||r.ignore||r.clearMark||(r.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(r=>{o(r=Ti(r)),r.node||r.ignore||r.mark||(r.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ho(e,ho.schemaRules(e)))}},Hs={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},Ja={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Us={ol:!0,ul:!0},Be=1,po=2,Ee=4;function Di(t,e,n){return e!=null?(e?Be:0)|(e==="full"?po:0):t&&t.whitespace=="pre"?Be|po:n&~Ee}var hn=class{constructor(t,e,n,o,i,s){this.type=t,this.attrs=e,this.marks=n,this.solid=o,this.options=s,this.content=[],this.activeMarks=E.none,this.match=i||(s&Ee?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(v.from(t));if(e)this.match=this.type.contentMatch.matchFragment(e);else{let n=this.type.contentMatch,o;return(o=n.findWrapping(t.type))?(this.match=n,o):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Be)){let n=this.content[this.content.length-1],o;if(n&&n.isText&&(o=/[ \t\r\n\u000c]+$/.exec(n.text))){let i=n;n.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 e=v.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(v.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Hs.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}},Ei=class{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o=e.topNode,i,s=Di(null,e.preserveWhitespace,0)|(n?Ee:0);o?i=new hn(o.type,o.attrs,E.none,!0,e.topMatch||o.type.contentMatch,s):n?i=new hn(null,null,E.none,!0,null,s):i=new hn(t.schema.topNodeType,null,E.none,!0,null,s),this.nodes=[i],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){t.nodeType==3?this.addTextNode(t,e):t.nodeType==1&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,o=this.top,i=o.options&po?"full":this.localPreserveWS||(o.options&Be)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(i)if(i==="full")n=n.replace(/\r\n?/g,`
3
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(s.linebreakReplacement.create())){let r=n.split(/\r?\n|\r/);for(let l=0;l<r.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),e,!0),r[l]&&this.insertNode(s.text(r[l]),e,!/\S/.test(r[l]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let r=o.content[o.content.length-1],l=t.previousSibling;(!r||l&&l.nodeName=="BR"||r.isText&&/[ \t\r\n\u000c]$/.test(r.text))&&(n=n.slice(1))}n&&this.insertNode(s.text(n),e,!/\S/.test(n)),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let o=this.localPreserveWS,i=this.top;(t.tagName=="PRE"||/pre/.test(t.style&&t.style.whiteSpace))&&(this.localPreserveWS=!0);let s=t.nodeName.toLowerCase(),r;Us.hasOwnProperty(s)&&this.parser.normalizeLists&&qa(t);let l=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(r=this.parser.matchTag(t,this,n));t:if(l?l.ignore:Ja.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t,e);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(t=l.skip);let a,c=this.needsBlock;if(Hs.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),a=!0,i.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t,e);break t}let h=l&&l.skip?e:this.readStyles(t,e);h&&this.addAll(t,h),a&&this.sync(i),this.needsBlock=c}else{let a=this.readStyles(t,e);a&&this.addElementByRule(t,l,a,l.consuming===!1?r:void 0)}this.localPreserveWS=o}leafFallback(t,e){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
4
+ `),e)}ignoreFallback(t,e){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),e,!0)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=n.getPropertyValue(i);if(s)for(let r=void 0;;){let l=this.parser.matchStyle(i,s,this,r);if(!l)break;if(l.ignore)return null;if(l.clearMark?e=e.filter(a=>!l.clearMark(a)):e=e.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)r=l;else break}}return e}addElementByRule(t,e,n,o){let i,s;if(e.node)if(s=this.parser.schema.nodes[e.node],s.isLeaf)this.insertNode(s.create(e.attrs),n,t.nodeName=="BR")||this.leafFallback(t,n);else{let l=this.enter(s,e.attrs||null,n,e.preserveWhitespace);l&&(i=!0,n=l)}else{let l=this.parser.schema.marks[e.mark];n=n.concat(l.create(e.attrs))}let r=this.top;if(s&&s.isLeaf)this.findInside(t);else if(o)this.addElement(t,n,o);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l,n,!1));else{let l=t;typeof e.contentElement=="string"?l=t.querySelector(e.contentElement):typeof e.contentElement=="function"?l=e.contentElement(t):e.contentElement&&(l=e.contentElement),this.findAround(t,l,!0),this.addAll(l,n),this.findAround(t,l,!1)}i&&this.sync(r)&&this.open--}addAll(t,e,n,o){let i=n||0;for(let s=n?t.childNodes[n]:t.firstChild,r=o==null?null:t.childNodes[o];s!=r;s=s.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(s,e);this.findAtPoint(t,i)}findPlace(t,e,n){let o,i;for(let s=this.open,r=0;s>=0;s--){let l=this.nodes[s],a=l.findWrapping(t);if(a&&(!o||o.length>a.length+r)&&(o=a,i=l,!a.length))break;if(l.solid){if(n)break;r+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)e=this.enterInner(o[s],null,e,!1);return e}insertNode(t,e,n){if(t.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(e=this.enterInner(i,null,e))}let o=this.findPlace(t,e,n);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(t.type));let s=E.none;for(let r of o.concat(t.marks))(i.type?i.type.allowsMarkType(r.type):$i(r.type,t.type))&&(s=r.addToSet(s));return i.content.push(t.mark(s)),!0}return!1}enter(t,e,n,o){let i=this.findPlace(t.create(e),n,!1);return i&&(i=this.enterInner(t,e,n,!0,o)),i}enterInner(t,e,n,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(t);let r=Di(t,i,s.options);s.options&Ee&&s.content.length==0&&(r|=Ee);let l=E.none;return n=n.filter(a=>(s.type?s.type.allowsMarkType(a.type):$i(a.type,t))?(l=a.addToSet(l),!1):!0),this.nodes.push(new hn(t,e,l,o,null,r)),this.open++,n}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(t){for(let e=this.open;e>=0;e--){if(this.nodes[e]==t)return this.open=e,!0;this.localPreserveWS&&(this.nodes[e].options|=Be)}return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let o=n.length-1;o>=0;o--)t+=n[o].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].pos==null&&t.nodeType==1&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&t.nodeType==1&&t.contains(this.find[o].node)&&e.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,o=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(o?0:1),s=(r,l)=>{for(;r>=0;r--){let a=e[r];if(a==""){if(r==e.length-1||r==0)continue;for(;l>=i;l--)if(s(r-1,l))return!0;return!1}else{let c=l>0||l==0&&o?this.nodes[l].type:n&&l>=i?n.node(l-i).type:null;if(!c||c.name!=a&&!c.isInGroup(a))return!1;l--}}return!0};return s(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let n=this.parser.schema.nodes[e];if(n.isTextblock&&n.defaultAttrs)return n}}};function qa(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Us.hasOwnProperty(o)&&n?(n.appendChild(e),e=n):o=="li"?n=e:o&&(n=null)}}function Wa(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ti(t){let e={};for(let n in t)e[n]=t[n];return e}function $i(t,e){let n=e.schema.nodes;for(let o in n){let i=n[o];if(!i.allowsMarkType(t))continue;let s=[],r=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:h}=l.edge(a);if(c==e||s.indexOf(h)<0&&r(h))return!0}};if(r(i.contentMatch))return!0}}var qe=class Gs{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},o){o||(o=dn(n).createDocumentFragment());let i=o,s=[];return e.forEach(r=>{if(s.length||r.marks.length){let l=0,a=0;for(;l<s.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],h=this.serializeMark(c,r.isInline,n);h&&(s.push([c,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(r,n))}),o}serializeNodeInner(e,n){if(e.isText)return dn(n).createTextNode(e.text);let{dom:o,contentDOM:i}=mn(dn(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return o}serializeNode(e,n={}){let o=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(o),o=s.dom)}return o}serializeMark(e,n,o={}){let i=this.marks[e.type.name];return i&&mn(dn(o),i(e,n),null,e.attrs)}static renderSpec(e,n,o=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:mn(e,n,o,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Gs(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Ri(e.nodes);return n.text||(n.text=o=>o.text),n}static marksFromSchema(e){return Ri(e.marks)}};function Ri(t){let e={};for(let n in t){let o=t[n].spec.toDOM;o&&(e[n]=o)}return e}function dn(t){return t.document||window.document}var Ii=new WeakMap;function Ka(t){let e=Ii.get(t);return e===void 0&&Ii.set(t,e=Ha(t)),e}function Ha(t){let e=null;function n(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let i=0;i<o.length;i++)n(o[i]);else for(let i in o)n(o[i])}return n(t),e}function mn(t,e,n,o){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(s=Ka(o))&&s.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 r=i.indexOf(" ");r>0&&(n=i.slice(0,r),i=i.slice(r+1));let l,a=n?t.createElementNS(n,i):t.createElement(i),c=e[1],h=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){h=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=h;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:u,contentDOM:p}=mn(t,f,n,o);if(a.appendChild(u),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var $o={};pt($o,{AllSelection:()=>at,EditorState:()=>yc,NodeSelection:()=>O,Plugin:()=>pe,PluginKey:()=>Lo,Selection:()=>C,SelectionRange:()=>On,TextSelection:()=>A,Transaction:()=>pr});var he={};pt(he,{AddMarkStep:()=>Dn,AddNodeMarkStep:()=>En,AttrStep:()=>Fo,DocAttrStep:()=>jo,MapResult:()=>Sn,Mapping:()=>Ro,RemoveMarkStep:()=>de,RemoveNodeMarkStep:()=>ze,ReplaceAroundStep:()=>ht,ReplaceStep:()=>ot,Step:()=>j,StepMap:()=>$t,StepResult:()=>K,Transform:()=>ar,TransformError:()=>Wt,canJoin:()=>Ut,canSplit:()=>Te,dropPoint:()=>Vo,findWrapping:()=>Bo,insertPoint:()=>or,joinPoint:()=>zo,liftTarget:()=>We,replaceStep:()=>Ke});var _s=65535,Ys=Math.pow(2,16);function Ua(t,e){return t+e*Ys}function Pi(t){return t&_s}function Ga(t){return(t-(t&_s))/Ys}var Qs=1,Zs=2,gn=4,Xs=8,Sn=class{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(this.delInfo&Xs)>0}get deletedBefore(){return(this.delInfo&(Qs|gn))>0}get deletedAfter(){return(this.delInfo&(Zs|gn))>0}get deletedAcross(){return(this.delInfo&gn)>0}},$t=class Xt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Xt.empty)return Xt.empty}recover(e){let n=0,o=Pi(e);if(!this.inverted)for(let i=0;i<o;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[o*3]+n+Ga(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,o){let i=0,s=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],h=this.ranges[l+r],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,u=a+i+(f<0?0:h);if(o)return u;let p=e==(n<0?a:d)?null:Ua(l/3,e-a),m=0;return c&&(m|=e==a?Zs:e==d?Qs:gn,(n<0?e!=a:e!=d)&&(m|=Xs)),new Sn(u,m,p)}i+=h-c}return o?e+i:new Sn(e+i,0,null)}touches(e,n){let o=0,i=Pi(n),s=this.inverted?2:1,r=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+s],h=a+c;if(e<=h&&l==i*3)return!0;o+=this.ranges[l+r]-c}return!1}forEach(e){let n=this.inverted?2:1,o=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let r=this.ranges[i],l=r-(this.inverted?s:0),a=r+(this.inverted?0:s),c=this.ranges[i+n],h=this.ranges[i+o];e(l,l+c,a,a+h),s+=h-c}}invert(){return new Xt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Xt.empty:new Xt(e<0?[0,-e,0]:[0,0,e])}};$t.empty=new $t([]);var Ro=class fo{constructor(e,n,o=0,i=e?e.length:0){this.mirror=n,this.from=o,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new fo(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,o=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?o+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,o=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?o-i-1:void 0)}}invert(){let e=new fo;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let o=this.from;o<this.to;o++)e=this._maps[o].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,o){let i=0;for(let s=this.from;s<this.to;s++){let r=this._maps[s],l=r.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return o?e:new Sn(e,i,null)}},Wn=Object.create(null),j=class{getMap(){return $t.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Wn[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Wn)throw new RangeError("Duplicate use of step JSON ID "+t);return Wn[t]=e,e.prototype.jsonID=t,e}},K=class we{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new we(e,null)}static fail(e){return new we(null,e)}static fromReplace(e,n,o,i){try{return we.ok(e.replace(n,o,i))}catch(s){if(s instanceof se)return we.fail(s.message);throw s}}};function Io(t,e,n){let o=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Io(s.content,e,s))),s.isInline&&(s=e(s,n,i)),o.push(s)}return v.fromArray(o)}var Dn=class be extends j{constructor(e,n,o){super(),this.from=e,this.to=n,this.mark=o}apply(e){let n=e.slice(this.from,this.to),o=e.resolve(this.from),i=o.node(o.sharedDepth(this.to)),s=new k(Io(n.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),i),n.openStart,n.openEnd);return K.fromReplace(e,this.from,this.to,s)}invert(){return new de(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new be(n.pos,o.pos,this.mark)}merge(e){return e instanceof be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new be(n.from,n.to,e.markFromJSON(n.mark))}};j.jsonID("addMark",Dn);var de=class ve extends j{constructor(e,n,o){super(),this.from=e,this.to=n,this.mark=o}apply(e){let n=e.slice(this.from,this.to),o=new k(Io(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return K.fromReplace(e,this.from,this.to,o)}invert(){return new Dn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),o=e.mapResult(this.to,-1);return n.deleted&&o.deleted||n.pos>=o.pos?null:new ve(n.pos,o.pos,this.mark)}merge(e){return e instanceof ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ve(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ve(n.from,n.to,e.markFromJSON(n.mark))}};j.jsonID("removeMark",de);var En=class ke extends j{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return K.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return K.fromReplace(e,this.pos,this.pos+1,new k(v.from(o),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let o=this.mark.addToSet(n.marks);if(o.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(o))return new ke(this.pos,n.marks[i]);return new ke(this.pos,this.mark)}}return new ze(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ke(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ke(n.pos,e.markFromJSON(n.mark))}};j.jsonID("addNodeMark",En);var ze=class uo extends j{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return K.fail("No node at mark step's position");let o=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return K.fromReplace(e,this.pos,this.pos+1,new k(v.from(o),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new En(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new uo(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new uo(n.pos,e.markFromJSON(n.mark))}};j.jsonID("removeNodeMark",ze);var ot=class Ot extends j{constructor(e,n,o,i=!1){super(),this.from=e,this.to=n,this.slice=o,this.structure=i}apply(e){return this.structure&&mo(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $t([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ot(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),o=this.from==this.to&&Ot.MAP_BIAS<0?n:e.mapResult(this.from,1);return o.deletedAcross&&n.deletedAcross?null:new Ot(o.pos,Math.max(o.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ot)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?k.empty:new k(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ot(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?k.empty:new k(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ot(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ot(n.from,n.to,k.fromJSON(e,n.slice),!!n.structure)}};ot.MAP_BIAS=1;j.jsonID("replace",ot);var ht=class yn extends j{constructor(e,n,o,i,s,r,l=!1){super(),this.from=e,this.to=n,this.gapFrom=o,this.gapTo=i,this.slice=s,this.insert=r,this.structure=l}apply(e){if(this.structure&&(mo(e,this.from,this.gapFrom)||mo(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return K.fail("Gap is not a flat range");let o=this.slice.insertAt(this.insert,n.content);return o?K.fromReplace(e,this.from,this.to,o):K.fail("Content does not fit in gap")}getMap(){return new $t([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new yn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),o=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return n.deletedAcross&&o.deletedAcross||i<n.pos||s>o.pos?null:new yn(n.pos,o.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new yn(n.from,n.to,n.gapFrom,n.gapTo,k.fromJSON(e,n.slice),n.insert,!!n.structure)}};j.jsonID("replaceAround",ht);function mo(t,e,n){let o=t.resolve(e),i=n-e,s=o.depth;for(;i>0&&s>0&&o.indexAfter(s)==o.node(s).childCount;)s--,i--;if(i>0){let r=o.node(s).maybeChild(o.indexAfter(s));for(;i>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,i--}}return!1}function _a(t,e,n,o){let i=[],s=[],r,l;t.doc.nodesBetween(e,n,(a,c,h)=>{if(!a.isInline)return;let d=a.marks;if(!o.isInSet(d)&&h.type.allowsMarkType(o.type)){let f=Math.max(c,e),u=Math.min(c+a.nodeSize,n),p=o.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(r&&r.to==f&&r.mark.eq(d[m])?r.to=u:i.push(r=new de(f,u,d[m])));l&&l.to==f?l.to=u:s.push(l=new Dn(f,u,o))}}),i.forEach(a=>t.step(a)),s.forEach(a=>t.step(a))}function Ya(t,e,n,o){let i=[],s=0;t.doc.nodesBetween(e,n,(r,l)=>{if(!r.isInline)return;s++;let a=null;if(o instanceof Eo){let c=r.marks,h;for(;h=o.isInSet(c);)(a||(a=[])).push(h),c=h.removeFromSet(c)}else o?o.isInSet(r.marks)&&(a=[o]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,n);for(let h=0;h<a.length;h++){let d=a[h],f;for(let u=0;u<i.length;u++){let p=i[u];p.step==s-1&&d.eq(i[u].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(r=>t.step(new de(r.from,r.to,r.style)))}function Po(t,e,n,o=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),h=l+c.nodeSize,d=o.matchType(c.type);if(!d)r.push(new ot(l,h,k.empty));else{o=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new de(l,h,c.marks[f]));if(i&&c.isText&&n.whitespace!="pre"){let f,u=/\r?\n|\r/g,p;for(;f=u.exec(c.text);)p||(p=new k(v.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),r.push(new ot(l+f.index,l+f.index+f[0].length,p))}}l=h}if(!o.validEnd){let a=o.fillBefore(v.empty,!0);t.replace(l,l,new k(a,0,0))}for(let a=r.length-1;a>=0;a--)t.step(r[a])}function Qa(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function We(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,o=0,i=0;;--n){let s=t.$from.node(n),r=t.$from.index(n)+o,l=t.$to.indexAfter(n)-i;if(n<t.depth&&s.canReplace(r,l,e))return n;if(n==0||s.type.spec.isolating||!Qa(s,r,l))break;r&&(o=1),l<s.childCount&&(i=1)}return null}function Za(t,e,n){let{$from:o,$to:i,depth:s}=e,r=o.before(s+1),l=i.after(s+1),a=r,c=l,h=v.empty,d=0;for(let p=s,m=!1;p>n;p--)m||o.index(p)>0?(m=!0,h=v.from(o.node(p).copy(h)),d++):a--;let f=v.empty,u=0;for(let p=s,m=!1;p>n;p--)m||i.after(p+1)<i.end(p)?(m=!0,f=v.from(i.node(p).copy(f)),u++):c++;t.step(new ht(a,c,r,l,new k(h.append(f),d,u),h.size-d,!0))}function Bo(t,e,n=null,o=t){let i=Xa(t,e),s=i&&tc(o,e);return s?i.map(Bi).concat({type:e,attrs:n}).concat(s.map(Bi)):null}function Bi(t){return{type:t,attrs:null}}function Xa(t,e){let{parent:n,startIndex:o,endIndex:i}=t,s=n.contentMatchAt(o).findWrapping(e);if(!s)return null;let r=s.length?s[0]:e;return n.canReplaceWith(o,i,r)?s:null}function tc(t,e){let{parent:n,startIndex:o,endIndex:i}=t,s=n.child(o),r=e.contentMatch.findWrapping(s.type);if(!r)return null;let l=(r.length?r[r.length-1]:e).contentMatch;for(let a=o;l&&a<i;a++)l=l.matchType(n.child(a).type);return!l||!l.validEnd?null:r}function ec(t,e,n){let o=v.empty;for(let r=n.length-1;r>=0;r--){if(o.size){let l=n[r].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=v.from(n[r].type.create(n[r].attrs,o))}let i=e.start,s=e.end;t.step(new ht(i,s,i,s,new k(o,0,0),n.length,!0))}function nc(t,e,n,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(r,l)=>{let a=typeof i=="function"?i(r):i;if(r.isTextblock&&!r.hasMarkup(o,a)&&oc(t.doc,t.mapping.slice(s).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let u=o.whitespace=="pre",p=!!o.contentMatch.matchType(o.schema.linebreakReplacement);u&&!p?c=!1:!u&&p&&(c=!0)}c===!1&&er(t,r,l,s),Po(t,t.mapping.slice(s).map(l,1),o,void 0,c===null);let h=t.mapping.slice(s),d=h.map(l,1),f=h.map(l+r.nodeSize,1);return t.step(new ht(d,f,d+1,f-1,new k(v.from(o.create(a,null,r.marks)),0,0),1,!0)),c===!0&&tr(t,r,l,s),!1}})}function tr(t,e,n,o){e.forEach((i,s)=>{if(i.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(i.text);){let a=t.mapping.slice(o).map(n+1+s+r.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function er(t,e,n,o){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let r=t.mapping.slice(o).map(n+1+s);t.replaceWith(r,r+1,e.type.schema.text(`
5
+ `))}})}function oc(t,e,n){let o=t.resolve(e),i=o.index();return o.parent.canReplaceWith(i,i+1,n)}function ic(t,e,n,o,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let r=n.create(o,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,r);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ht(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new k(v.from(r),0,0),1,!0))}function Te(t,e,n=1,o){let i=t.resolve(e),s=i.depth-n,r=o&&o[o.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!r.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,h=n-2;c>s;c--,h--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let u=d.content.cutByIndex(f,d.childCount),p=o&&o[h+1];p&&(u=u.replaceChild(0,p.type.create(p.attrs)));let m=o&&o[h]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(u))return!1}let l=i.indexAfter(s),a=o&&o[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function sc(t,e,n=1,o){let i=t.doc.resolve(e),s=v.empty,r=v.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){s=v.from(i.node(l).copy(s));let h=o&&o[c];r=v.from(h?h.type.create(h.attrs,r):i.node(l).copy(r))}t.step(new ot(e,e,new k(s.append(r),n,n),!0))}function Ut(t,e){let n=t.resolve(e),o=n.index();return nr(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function rc(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:o}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),r=s.type==o?t.type.schema.nodes.text:s.type;if(n=n.matchType(r),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function nr(t,e){return!!(t&&e&&!t.isLeaf&&rc(t,e))}function zo(t,e,n=-1){let o=t.resolve(e);for(let i=o.depth;;i--){let s,r,l=o.index(i);if(i==o.depth?(s=o.nodeBefore,r=o.nodeAfter):n>0?(s=o.node(i+1),l++,r=o.node(i).maybeChild(l)):(s=o.node(i).maybeChild(l-1),r=o.node(i+1)),s&&!s.isTextblock&&nr(s,r)&&o.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?o.before(i):o.after(i)}}function lc(t,e,n){let o=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),r=s.node().type;if(i&&r.inlineContent){let h=r.whitespace=="pre",d=!!r.contentMatch.matchType(i);h&&!d?o=!1:!h&&d&&(o=!0)}let l=t.steps.length;if(o===!1){let h=t.doc.resolve(e+n);er(t,h.node(),h.before(),l)}r.inlineContent&&Po(t,e+n-1,r,s.node().contentMatchAt(s.index()),o==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new ot(c,a.map(e+n,-1),k.empty,!0)),o===!0){let h=t.doc.resolve(c);tr(t,h.node(),h.before(),t.steps.length)}return t}function or(t,e,n){let o=t.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),n))return e;if(o.parentOffset==0)for(let i=o.depth-1;i>=0;i--){let s=o.index(i);if(o.node(i).canReplaceWith(s,s,n))return o.before(i+1);if(s>0)return null}if(o.parentOffset==o.parent.content.size)for(let i=o.depth-1;i>=0;i--){let s=o.indexAfter(i);if(o.node(i).canReplaceWith(s,s,n))return o.after(i+1);if(s<o.node(i).childCount)return null}return null}function Vo(t,e,n){let o=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let r=o.depth;r>=0;r--){let l=r==o.depth?0:o.pos<=(o.start(r+1)+o.end(r+1))/2?-1:1,a=o.index(r)+(l>0?1:0),c=o.node(r),h=!1;if(s==1)h=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);h=d&&c.canReplaceWith(a,a,d[0])}if(h)return l==0?o.pos:l<0?o.before(r+1):o.after(r+1)}return null}function Ke(t,e,n=e,o=k.empty){if(e==n&&!o.size)return null;let i=t.resolve(e),s=t.resolve(n);return ir(i,s,o)?new ot(e,n,o):new ac(i,s,o).fit()}function ir(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}var ac=class{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=v.empty;for(let o=0;o<=t.depth;o++){let i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}for(let o=t.depth;o>0;o--)this.placed=v.from(t.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let i=this.placed,s=n.depth,r=o.depth;for(;s&&r&&i.childCount==1;)i=i.firstChild.content,s--,r--;let l=new k(i,s,r);return t>-1?new ht(n.pos,t,this.$to.pos,this.$to.end(),l,e):l.size||n.pos!=this.$to.pos?new ot(n.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<t;n++){let i=e.firstChild;if(e.childCount>1&&(o=0),i.type.spec.isolating&&o<=n){t=n;break}e=i.content}for(let e=1;e<=2;e++)for(let n=e==1?t:this.unplaced.openStart;n>=0;n--){let o,i=null;n?(i=zi(this.unplaced.content,n-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let r=this.depth;r>=0;r--){let{type:l,match:a}=this.frontier[r],c,h=null;if(e==1&&(s?a.matchType(s.type)||(h=a.fillBefore(v.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:r,parent:i,inject:h};if(e==2&&s&&(c=a.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:r,parent:i,wrap:c};if(i&&a.matchType(i.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced;return Vi(t,-1)<=e?!1:(this.unplaced.size>1&&Vi(t,1)>n&&n++,this.unplaced=new k(t,e+1,n),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,o=zi(t,e);if(o.childCount<=1&&e>0){let i=t.size-e<=e+o.size;this.unplaced=new k(xe(t,e-1,1),e-1,i?e-1:n)}else this.unplaced=new k(xe(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:o,wrap:i}){for(;this.depth>e;)this.closeFrontierNode();if(i)for(let p=0;p<i.length;p++)this.openFrontierNode(i[p]);let s=this.unplaced,r=n?n.content:s.content,l=s.openStart-t,a=0,c=[],{match:h,type:d}=this.frontier[e];if(o){for(let p=0;p<o.childCount;p++)c.push(o.child(p));h=h.matchFragment(o)}let f=r.size+t-(s.content.size-s.openEnd);for(;a<r.childCount;){let p=r.child(a),m=h.matchType(p.type);if(!m)break;a++,(a>1||l==0||p.content.size)&&(h=m,c.push(sr(p.mark(d.allowedMarks(p.marks)),a==1?l:0,a==r.childCount?f:-1)))}let u=a==r.childCount;u||(f=-1),this.placed=Se(this.placed,e,v.from(c)),this.frontier[e].match=h,u&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let p=0,m=r;p<f;p++){let g=m.lastChild;this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),m=g.content}this.unplaced=u?t==0?k.empty:new k(xe(s.content,t-1,1),t-1,f<0?s.openEnd:t-1):new k(xe(s.content,t,a),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],e;if(!t.type.isTextblock||!Kn(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:o}=this.frontier[e],i=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),s=Kn(t,e,o,n,i);if(s){for(let r=e-1;r>=0;r--){let{match:l,type:a}=this.frontier[r],c=Kn(t,r,a,l,!0);if(!c||c.childCount)continue t}return{depth:e,fit:s,move:i?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=Se(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let o=t.node(n),i=o.type.contentMatch.fillBefore(o.content,!0,t.index(n));this.openFrontierNode(o.type,o.attrs,i)}return t}openFrontierNode(t,e=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Se(this.placed,this.depth,v.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(v.empty,!0);t.childCount&&(this.placed=Se(this.placed,this.frontier.length,t))}};function xe(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(xe(t.firstChild.content,e-1,n)))}function Se(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Se(t.lastChild.content,e-1,n)))}function zi(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function sr(t,e,n){if(e<=0)return t;let o=t.content;return e>1&&(o=o.replaceChild(0,sr(o.firstChild,e-1,o.childCount==1?n-1:0))),e>0&&(o=t.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(v.empty,!0)))),t.copy(o)}function Kn(t,e,n,o,i){let s=t.node(e),r=i?t.indexAfter(e):t.index(e);if(r==s.childCount&&!n.compatibleContent(s.type))return null;let l=o.fillBefore(s.content,!0,r);return l&&!cc(n,s.content,r)?l:null}function cc(t,e,n){for(let o=n;o<e.childCount;o++)if(!t.allowsMarks(e.child(o).marks))return!0;return!1}function hc(t){return t.spec.defining||t.spec.definingForContent}function Vi(t,e){for(let n=0;;n++){let o=e<0?t.firstChild:t.lastChild;if(!o||o.isAtom)return n;t=o.content}}function dc(t,e,n,o){if(!o.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(ir(i,s,o))return t.step(new ot(e,n,o));let r=lr(i,s);r[r.length-1]==0&&r.pop();let l=-(i.depth+1);r.unshift(l);for(let f=i.depth,u=i.pos-1;f>0;f--,u--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;r.indexOf(f)>-1?l=f:i.before(f)==u&&r.splice(1,0,-f)}let a=r.indexOf(l),c=[],h=o.openStart;for(let f=o.content,u=0;;u++){let p=f.firstChild;if(c.push(p),u==o.openStart)break;f=p.content}for(let f=h-1;f>=0;f--){let u=c[f],p=hc(u.type);if(p&&!u.sameMarkup(i.node(Math.abs(l)-1)))h=f;else if(p||!u.type.isTextblock)break}for(let f=o.openStart;f>=0;f--){let u=(f+h+1)%(o.openStart+1),p=c[u];if(p)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let y=i.node(g-1),w=i.index(g-1);if(y.canReplaceWith(w,w,p.type,p.marks))return t.replace(i.before(g),b?s.after(g):n,new k(rr(o.content,0,o.openStart,u),u,o.openEnd))}}let d=t.steps.length;for(let f=r.length-1;f>=0&&(t.replace(e,n,o),!(t.steps.length>d));f--){let u=r[f];u<0||(e=i.before(u),n=s.after(u))}}function rr(t,e,n,o,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(rr(s.content,e+1,n,o,s)))}if(e>o){let s=i.contentMatchAt(0),r=s.fillBefore(t).append(t);t=r.append(s.matchFragment(r).fillBefore(v.empty,!0))}return t}function pc(t,e,n,o){if(!o.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=or(t.doc,e,o.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new k(v.from(o),0,0))}function fc(t,e,n){let o=t.doc.resolve(e),i=t.doc.resolve(n);if(o.parent.isTextblock&&i.parent.isTextblock&&o.start()!=i.start()&&o.parentOffset==0&&i.parentOffset==0){let r=o.sharedDepth(n),l=!1;for(let a=o.depth;a>r;a--)o.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>r;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=o.depth;a>0&&e==o.start(a);a--)e=o.before(a);for(let a=i.depth;a>0&&n==i.start(a);a--)n=i.before(a);o=t.doc.resolve(e),i=t.doc.resolve(n)}}let s=lr(o,i);for(let r=0;r<s.length;r++){let l=s[r],a=r==s.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return t.delete(o.start(l),i.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),i.indexAfter(l-1))))return t.delete(o.before(l),i.after(l))}for(let r=1;r<=o.depth&&r<=i.depth;r++)if(e-o.start(r)==o.depth-r&&n>o.end(r)&&i.end(r)-n!=i.depth-r&&o.start(r-1)==i.start(r-1)&&o.node(r-1).canReplace(o.index(r-1),i.index(r-1)))return t.delete(o.before(r),n);t.delete(e,n)}function lr(t,e){let n=[],o=Math.min(t.depth,e.depth);for(let i=o;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}var Fo=class wn extends j{constructor(e,n,o){super(),this.pos=e,this.attr=n,this.value=o}apply(e){let n=e.nodeAt(this.pos);if(!n)return K.fail("No node at attribute step's position");let o=Object.create(null);for(let s in n.attrs)o[s]=n.attrs[s];o[this.attr]=this.value;let i=n.type.create(o,null,n.marks);return K.fromReplace(e,this.pos,this.pos+1,new k(v.from(i),0,n.isLeaf?0:1))}getMap(){return $t.empty}invert(e){return new wn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new wn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new wn(n.pos,n.attr,n.value)}};j.jsonID("attr",Fo);var jo=class go extends j{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let o=e.type.create(n,e.content,e.marks);return K.ok(o)}getMap(){return $t.empty}invert(e){return new go(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new go(n.attr,n.value)}};j.jsonID("docAttr",jo);var Wt=class extends Error{};Wt=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Wt.prototype=Object.create(Error.prototype);Wt.prototype.constructor=Wt;Wt.prototype.name="TransformError";var ar=class{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Ro}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Wt(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}changedRange(){let t=1e9,e=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let o=this.mapping.maps[n];n&&(t=o.map(t,1),e=o.map(e,-1)),o.forEach((i,s,r,l)=>{t=Math.min(t,r),e=Math.max(e,l)})}return t==1e9?null:{from:t,to:e}}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=k.empty){let o=Ke(this.doc,t,e,n);return o&&this.step(o),this}replaceWith(t,e,n){return this.replace(t,e,new k(v.from(n),0,0))}delete(t,e){return this.replace(t,e,k.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return dc(this,t,e,n),this}replaceRangeWith(t,e,n){return pc(this,t,e,n),this}deleteRange(t,e){return fc(this,t,e),this}lift(t,e){return Za(this,t,e),this}join(t,e=1){return lc(this,t,e),this}wrap(t,e){return ec(this,t,e),this}setBlockType(t,e=t,n,o=null){return nc(this,t,e,n,o),this}setNodeMarkup(t,e,n=null,o){return ic(this,t,e,n,o),this}setNodeAttribute(t,e,n){return this.step(new Fo(t,e,n)),this}setDocAttribute(t,e){return this.step(new jo(t,e)),this}addNodeMark(t,e){return this.step(new En(t,e)),this}removeNodeMark(t,e){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(e instanceof E)e.isInSet(n.marks)&&this.step(new ze(t,e));else{let o=n.marks,i,s=[];for(;i=e.isInSet(o);)s.push(new ze(t,i)),o=i.removeFromSet(o);for(let r=s.length-1;r>=0;r--)this.step(s[r])}return this}split(t,e=1,n){return sc(this,t,e,n),this}addMark(t,e,n){return _a(this,t,e,n),this}removeMark(t,e,n){return Ya(this,t,e,n),this}clearIncompatible(t,e,n){return Po(this,t,e,n),this}},Hn=Object.create(null),C=class{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new On(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=k.empty){let n=e.content.lastChild,o=null;for(let r=0;r<e.openEnd;r++)o=n,n=n.lastChild;let i=t.steps.length,s=this.ranges;for(let r=0;r<s.length;r++){let{$from:l,$to:a}=s[r],c=t.mapping.slice(i);t.replaceRange(c.map(l.pos),c.map(a.pos),r?k.empty:e),r==0&&Li(t,i,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:r}=o[i],l=t.mapping.slice(n),a=l.map(s.pos),c=l.map(r.pos);i?t.deleteRange(a,c):(t.replaceRangeWith(a,c,e),Li(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let o=t.parent.inlineContent?new A(t):te(t.node(0),t.parent,t.pos,t.index(),e,n);if(o)return o;for(let i=t.depth-1;i>=0;i--){let s=e<0?te(t.node(0),t.node(i),t.before(i+1),t.index(i),e,n):te(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,e,n);if(s)return s}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new at(t.node(0))}static atStart(t){return te(t,t,0,0,1)||new at(t)}static atEnd(t){return te(t,t,t.content.size,t.childCount,-1)||new at(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Hn[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Hn)throw new RangeError("Duplicate use of selection JSON ID "+t);return Hn[t]=e,e.prototype.jsonID=t,e}getBookmark(){return A.between(this.$anchor,this.$head).getBookmark()}};C.prototype.visible=!0;var On=class{constructor(t,e){this.$from=t,this.$to=e}},Fi=!1;function ji(t){!Fi&&!t.parent.inlineContent&&(Fi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var A=class Oe extends C{constructor(e,n=e){ji(e),ji(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let o=e.resolve(n.map(this.head));if(!o.parent.inlineContent)return C.near(o);let i=e.resolve(n.map(this.anchor));return new Oe(i.parent.inlineContent?i:o,o)}replace(e,n=k.empty){if(super.replace(e,n),n==k.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof Oe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new cr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Oe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,o=n){let i=e.resolve(n);return new this(i,o==n?i:e.resolve(o))}static between(e,n,o){let i=e.pos-n.pos;if((!o||i)&&(o=i>=0?1:-1),!n.parent.inlineContent){let s=C.findFrom(n,o,!0)||C.findFrom(n,-o,!0);if(s)n=s.$head;else return C.near(n,o)}return e.parent.inlineContent||(i==0?e=n:(e=(C.findFrom(e,-o,!0)||C.findFrom(e,o,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Oe(e,n)}};C.jsonID("text",A);var cr=class hr{constructor(e,n){this.anchor=e,this.head=n}map(e){return new hr(e.map(this.anchor),e.map(this.head))}resolve(e){return A.between(e.resolve(this.anchor),e.resolve(this.head))}},O=class Me extends C{constructor(e){let n=e.nodeAfter,o=e.node(0).resolve(e.pos+n.nodeSize);super(e,o),this.node=n}map(e,n){let{deleted:o,pos:i}=n.mapResult(this.anchor),s=e.resolve(i);return o?C.near(s):new Me(s)}content(){return new k(v.from(this.node),0,0)}eq(e){return e instanceof Me&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new uc(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Me(e.resolve(n.anchor))}static create(e,n){return new Me(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};O.prototype.visible=!1;C.jsonID("node",O);var uc=class dr{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:o}=e.mapResult(this.anchor);return n?new cr(o,o):new dr(o)}resolve(e){let n=e.resolve(this.anchor),o=n.nodeAfter;return o&&O.isSelectable(o)?new O(n):C.near(n)}},at=class bn extends C{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=k.empty){if(n==k.empty){e.delete(0,e.doc.content.size);let o=C.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new bn(e)}map(e){return new bn(e)}eq(e){return e instanceof bn}getBookmark(){return mc}};C.jsonID("all",at);var mc={map(){return this},resolve(t){return new at(t)}};function te(t,e,n,o,i,s=!1){if(e.inlineContent)return A.create(t,n);for(let r=o-(i>0?0:1);i>0?r<e.childCount:r>=0;r+=i){let l=e.child(r);if(l.isAtom){if(!s&&O.isSelectable(l))return O.create(t,n-(i<0?l.nodeSize:0))}else{let a=te(t,l,n+i,i<0?l.childCount:0,i,s);if(a)return a}n+=l.nodeSize*i}return null}function Li(t,e,n){let o=t.steps.length-1;if(o<e)return;let i=t.steps[o];if(!(i instanceof ot||i instanceof ht))return;let s=t.mapping.maps[o],r;s.forEach((l,a,c,h)=>{r==null&&(r=h)}),t.setSelection(C.near(t.doc.resolve(r),n))}var Ji=1,pn=2,qi=4,pr=class extends ar{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ji)&~pn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ji)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=pn,this}ensureMarks(t){return E.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&pn)>0}addStep(t,e){super.addStep(t,e),this.updated=this.updated&~pn,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||E.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let o=this.doc.type.schema;if(e==null)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(n==null&&(n=e),!t)return this.deleteRange(e,n);let i=this.storedMarks;if(!i){let s=this.doc.resolve(e);i=n==e?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,o.text(t,i)),!this.selection.empty&&this.selection.to==e+t.length&&this.setSelection(C.near(this.selection.$to)),this}}setMeta(t,e){return this.meta[typeof t=="string"?t:t.key]=e,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=qi,this}get scrolledIntoView(){return(this.updated&qi)>0}};function Wi(t,e){return!e||!t?t:t.bind(e)}var Ce=class{constructor(t,e,n){this.name=t,this.init=Wi(e.init,n),this.apply=Wi(e.apply,n)}},gc=[new Ce("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ce("selection",{init(t,e){return t.selection||C.atStart(e.doc)},apply(t){return t.selection}}),new Ce("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,o){return o.selection.$cursor?t.storedMarks:null}}),new Ce("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})],Un=class{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gc.slice(),e&&e.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Ce(n.key,n.spec.state,n))})}},yc=class Ne{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let o=0;o<this.config.plugins.length;o++)if(o!=n){let i=this.config.plugins[o];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],o=this.applyInner(e),i=null;for(;;){let s=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=i?i[r].n:0,c=i?i[r].state:this,h=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,o);if(h&&o.filterTransaction(h,r)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<r?{state:o,n:n.length}:{state:this,n:0})}n.push(h),o=o.applyInner(h),s=!0}i&&(i[r]={state:o,n:n.length})}}if(!s)return{state:o,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Ne(this.config),o=this.config.fields;for(let i=0;i<o.length;i++){let s=o[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new pr(this)}static create(e){let n=new Un(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new Ne(n);for(let i=0;i<n.fields.length;i++)o[n.fields[i].name]=n.fields[i].init(e,o);return o}reconfigure(e){let n=new Un(this.schema,e.plugins),o=n.fields,i=new Ne(n);for(let s=0;s<o.length;s++){let r=o[s].name;i[r]=this.hasOwnProperty(r)?this[r]:o[s].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[o],s=i.spec.state;s&&s.toJSON&&(n[o]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,o){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Un(e.schema,e.plugins),s=new Ne(i);return i.fields.forEach(r=>{if(r.name=="doc")s.doc=Et.fromJSON(e.schema,n.doc);else if(r.name=="selection")s.selection=C.fromJSON(s.doc,n.selection);else if(r.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[r.name]=c.fromJSON.call(a,e,n[l],s);return}}s[r.name]=r.init(e,s)}}),s}};function fr(t,e,n){for(let o in t){let i=t[o];i instanceof Function?i=i.bind(e):o=="handleDOMEvents"&&(i=fr(i,e,{})),n[o]=i}return n}var pe=class{constructor(t){this.spec=t,this.props={},t.props&&fr(t.props,this,this.props),this.key=t.key?t.key.key:ur("plugin")}getState(t){return t[this.key]}},Gn=Object.create(null);function ur(t){return t in Gn?t+"$"+ ++Gn[t]:(Gn[t]=0,t+"$")}var Lo=class{constructor(t="key"){this.key=ur(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}},wc={};pt(wc,{Decoration:()=>Pt,DecorationSet:()=>nt,EditorView:()=>nl,__endComposition:()=>nd,__parseFromClipboard:()=>ed});var z=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},le=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},yo=null,yt=function(t,e,n){let o=yo||(yo=document.createRange());return o.setEnd(t,n??t.nodeValue.length),o.setStart(t,e||0),o},bc=function(){yo=null},Kt=function(t,e,n,o){return n&&(Ki(t,e,n,o,-1)||Ki(t,e,n,o,1))},vc=/^(img|br|input|textarea|hr)$/i;function Ki(t,e,n,o,i){for(var s;;){if(t==n&&e==o)return!0;if(e==(i<0?0:W(t))){let r=t.parentNode;if(!r||!x(r)||He(t)||vc.test(t.nodeName)||t.contentEditable=="false")return!1;e=z(t)+(i<0?0:1),t=r}else if(x(t)){let r=t.childNodes[e+(i<0?-1:0)];if(x(r)&&r.contentEditable=="false")if(!((s=r.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=r,e=i<0?W(t):0}else return!1}}function W(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function x(t){return t.nodeType==1}function I(t){return t.nodeType==3}function Ht(t,e){return e?t.contains(x(e)?e:e.parentNode):!1}function kc(t,e){for(;;){if(I(t)&&e)return t;if(x(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=W(t)}else if(t.parentNode&&!He(t))e=z(t),t=t.parentNode;else return null}}function xc(t,e){for(;;){if(I(t)&&e<t.nodeValue.length)return t;if(x(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!He(t))e=z(t)+1,t=t.parentNode;else return null}}function Sc(t,e,n){for(let o=e==0,i=e==W(t);o||i;){if(t==n)return!0;let s=z(t);if(t=t.parentNode,!t)return!1;o=o&&s==0,i=i&&s==W(t)}}function He(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}var Tn=function(t){return t.focusNode&&Kt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function zt(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Oc(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Mc(t,e,n){if(t.caretPositionFromPoint)try{let o=t.caretPositionFromPoint(e,n);if(o)return{node:o.offsetNode,offset:Math.min(W(o.offsetNode),o.offset)}}catch{}if(t.caretRangeFromPoint){let o=t.caretRangeFromPoint(e,n);if(o)return{node:o.startContainer,offset:Math.min(W(o.startContainer),o.startOffset)}}}var dt=typeof navigator<"u"?navigator:null,Hi=typeof document<"u"?document:null,It=dt&&dt.userAgent||"",wo=/Edge\/(\d+)/.exec(It),mr=/MSIE \d/.exec(It),bo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(It),Z=!!(mr||bo||wo),Tt=mr?document.documentMode:bo?+bo[1]:wo?+wo[1]:0,X=!Z&&/gecko\/(\d+)/i.test(It);X&&+(/Firefox\/(\d+)/.exec(It)||[0,0])[1];var vo=!Z&&/Chrome\/(\d+)/.exec(It),V=!!vo,gr=vo?+vo[1]:0,H=!Z&&!!dt&&/Apple Computer/.test(dt.vendor),ae=H&&(/Mobile\/\w+/.test(It)||!!dt&&dt.maxTouchPoints>2),tt=ae||(dt?/Mac/.test(dt.platform):!1),yr=dt?/Win/.test(dt.platform):!1,wt=/Android \d/.test(It),$n=!!Hi&&"webkitFontSmoothing"in Hi.documentElement.style,Cc=$n?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nc(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function gt(t,e){return typeof t=="number"?t:t[e]}function Ac(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,o=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*o}}function Ui(t,e,n){if(!ko(e)&&e.left==0)return;let o=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let r=n||t.dom;r;){if(!x(r)){r=le(r);continue}let l=r==s.body,a=l?Nc(s):Ac(r),c=0,h=0;if(e.top<a.top+gt(o,"top")?h=-(a.top-e.top+gt(i,"top")):e.bottom>a.bottom-gt(o,"bottom")&&(h=e.bottom-e.top>a.bottom-a.top?e.top+gt(i,"top")-a.top:e.bottom-a.bottom+gt(i,"bottom")),e.left<a.left+gt(o,"left")?c=-(a.left-e.left+gt(i,"left")):e.right>a.right-gt(o,"right")&&(c=e.right-a.right+gt(i,"right")),c||h)if(l)s.defaultView.scrollBy(c,h);else{let f=r.scrollLeft,u=r.scrollTop;h&&(r.scrollTop+=h),c&&(r.scrollLeft+=c);let p=r.scrollLeft-f,m=r.scrollTop-u;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(r).position;if(/^(fixed|sticky)$/.test(d))break;r=d=="absolute"?r.offsetParent:le(r)}}function Dc(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),o,i;for(let s=(e.left+e.right)/2,r=n+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=t.root.elementFromPoint(s,r);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){o=l,i=a.top;break}}return{refDOM:o,refTop:i,stack:wr(t.dom)}}function wr(t){let e=[],n=t.ownerDocument;for(let o=t;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),t!=n);o=le(o));return e}function Ec({refDOM:t,refTop:e,stack:n}){let o=t?t.getBoundingClientRect().top:0;br(n,o==0?0:o-e)}function br(t,e){for(let n=0;n<t.length;n++){let{dom:o,top:i,left:s}=t[n];o.scrollTop!=i+e&&(o.scrollTop=i+e),o.scrollLeft!=s&&(o.scrollLeft=s)}}var Yt=null;function Tc(t){if(t.setActive)return t.setActive();if(Yt)return t.focus(Yt);let e=wr(t);t.focus(Yt==null?{get preventScroll(){return Yt={preventScroll:!0},!0}}:void 0),Yt||(Yt=!1,br(e,0))}function vr(t,e){let n,o=2e8,i,s=0,r=e.top,l=e.top,a,c;for(let h=t.firstChild,d=0;h;h=h.nextSibling,d++){let f;if(x(h))f=h.getClientRects();else if(I(h))f=yt(h).getClientRects();else continue;for(let u=0;u<f.length;u++){let p=f[u];if(p.top<=r&&p.bottom>=l){r=Math.max(p.bottom,r),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<o){n=h,o=m,i=m&&I(n)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,x(h)&&m&&(s=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=h,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!n&&a&&(n=a,i=c,o=0),n&&I(n)?$c(n,i):!n||o?{node:t,offset:s}:vr(n,i)}function $c(t,e){let n=t.nodeValue.length,o=document.createRange(),i;for(let s=0;s<n;s++){o.setEnd(t,s+1),o.setStart(t,s);let r=Mt(o,1);if(r.top!=r.bottom&&Jo(e,r)){i={node:t,offset:s+(e.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),i||{node:t,offset:0}}function Jo(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Rc(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Ic(t,e,n){let{node:o,offset:i}=vr(e,n),s=-1;if(x(o)&&!o.firstChild){let r=o.getBoundingClientRect();s=r.left!=r.right&&n.left>(r.left+r.right)/2?1:-1}return t.docView.posFromDOM(o,i,s)}function Pc(t,e,n,o){let i=-1;for(let s=e,r=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0),a;if(!l)return null;if(x(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)&&(!r&&a.left>o.left||a.top>o.top?i=l.posBefore:(!r&&a.right<o.left||a.bottom<o.top)&&(i=l.posAfter),r=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function kr(t,e,n){let o=t.childNodes.length;if(o&&n.top<n.bottom)for(let i=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let r=t.childNodes[s];if(x(r)){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Jo(e,c))return kr(r,e,c)}}if((s=(s+1)%o)==i)break}return t}function Bc(t,e){let n=t.dom.ownerDocument,o,i=0,s=Mc(n,e.left,e.top);s&&({node:o,offset:i}=s);let r=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!r||!t.dom.contains(r)){let c=t.dom.getBoundingClientRect();if(!Jo(e,c)||(r=kr(t.dom,e,c),!r))return null}if(H)for(let c=r;o&&c;c=le(c))c.draggable&&(o=void 0);if(r=Rc(r,e),o){if(X&&x(o)&&(i=Math.min(i,o.childNodes.length),i<o.childNodes.length)){let h=o.childNodes[i],d;h.nodeName=="IMG"&&(d=h.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;$n&&i&&x(o)&&x(c=o.childNodes[i-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,o==t.dom&&i==o.childNodes.length-1&&x(o.lastChild)&&e.top>o.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||!x(o)||o.childNodes[i-1].nodeName!="BR")&&(l=Pc(t,o,i,e))}l==null&&(l=Ic(t,r,e));let a=t.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ko(t){return t.top<t.bottom||t.left<t.right}function Mt(t,e){let n=t.getClientRects();if(n.length){let o=n[e<0?0:n.length-1];if(ko(o))return o}return Array.prototype.find.call(n,ko)||t.getBoundingClientRect()}var zc=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function xr(t,e,n){let{node:o,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),r=$n||X;if(I(o))if(r&&(zc.test(o.nodeValue)||(n<0?!i:i==o.nodeValue.length))){let l=Mt(yt(o,i,i),n);if(X&&i&&/\s/.test(o.nodeValue[i-1])&&i<o.nodeValue.length){let a=Mt(yt(o,i-1,i-1),-1);if(a.top==l.top){let c=Mt(yt(o,i,i+1),-1);if(c.top!=l.top)return ge(c,c.left<a.left)}}return l}else{let l=i,a=i,c=n<0?1:-1;return n<0&&!i?(a++,c=-1):n>=0&&i==o.nodeValue.length?(l--,c=1):n<0?l--:a++,ge(Mt(yt(o,l,a),c),c<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==W(o))){let l=o.childNodes[i-1];if(x(l))return _n(l.getBoundingClientRect(),!1)}if(s==null&&i<W(o)){let l=o.childNodes[i];if(x(l))return _n(l.getBoundingClientRect(),!0)}return _n(o.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==W(o))){let l=o.childNodes[i-1],a=I(l)?yt(l,W(l)-(r?0:1)):x(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(a)return ge(Mt(a,1),!1)}if(s==null&&i<W(o)){let l=o.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let a=l?I(l)?yt(l,0,r?0:1):x(l)?l:null:null;if(a)return ge(Mt(a,-1),!0)}return ge(Mt(I(o)?yt(o):o,-n),n>=0)}function ge(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function _n(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Sr(t,e,n){let o=t.state,i=t.root.activeElement;o!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{o!=e&&t.updateState(o),i!=t.dom&&i&&i.focus()}}function Vc(t,e,n){let o=e.selection,i=n=="up"?o.$from:o.$to;return Sr(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let r=xr(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(x(l))a=l.getClientRects();else if(I(l))a=yt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let h=a[c];if(h.bottom>h.top+1&&(n=="up"?r.top-h.top>(h.bottom-r.top)*2:h.bottom-r.bottom>(r.bottom-h.top)*2))return!1}}return!0})}var Fc=/[\u0590-\u08ac]/;function jc(t,e,n){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let i=o.parentOffset,s=!i,r=i==o.parent.content.size,l=t.domSelection();return l?!Fc.test(o.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:r:Sr(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:h,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let u=o.depth?t.docView.domAfterPos(o.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!Ht(u,p)||a==p&&c==m;try{l.collapse(h,d),a&&(a!=h||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):o.pos==o.start()||o.pos==o.end()}var Gi=null,_i=null,Yi=!1;function Lc(t,e,n){return Gi==e&&_i==n?Yi:(Gi=e,_i=n,Yi=n=="up"||n=="down"?Vc(t,e,n):jc(t,e,n))}var et=0,Qi=1,Vt=2,it=3,Ue=class{constructor(t,e,n,o){this.parent=t,this.children=e,this.dom=n,this.contentDOM=o,this.dirty=et,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(t){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let o=this.children[e];if(o==t)return n;n+=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(t,e,n){if(this.contentDOM&&Ht(this.contentDOM,t))if(n<0){let i,s;if(t==this.contentDOM)i=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.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(t==this.contentDOM)i=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;i=t.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(t==this.dom&&this.contentDOM)o=e>z(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=!!(t.compareDocumentPosition(this.contentDOM)&4);else if(this.dom.firstChild){if(e==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&e==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!e||i.node))if(n&&(s=i.nodeDOM)&&!(x(s)?Ht(s,t):s==t))n=!1;else return i}}getDesc(t){let e=t.pmViewDesc;for(let n=e;n;n=n.parent)if(n==this)return e}posFromDOM(t,e,n){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let o=this.children[e],i=n+o.size;if(n==t&&i!=n){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let r=o.children[s];if(r.size){o=r;break}}return o}if(t<i)return o.descAt(t-n-o.border);n=i}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,o=0;for(let i=0;n<this.children.length;n++){let s=this.children[n],r=i+s.size;if(r>t){o=t-i;break}i=r}if(o)return this.children[n].domFromPos(o-this.children[n].border,e);for(;n>0;n--){let i=this.children[n-1];if(i.size||!(i instanceof Ar||i instanceof Or&&i.side>=0))break}if(e<=0){let i,s=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,s=!1);return i&&e&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,e):{node:this.contentDOM,offset:i?z(i.dom)+1:0}}else{let i,s=!0;for(;i=n<this.children.length?this.children[n]:null,!(!i||i.dom.parentNode==this.contentDOM);n++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,e):{node:this.contentDOM,offset:i?z(i.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(this.children.length==0)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=n,r=0;;r++){let l=this.children[r],a=s+l.size;if(o==-1&&t<=a){let c=s+l.border;if(t>=c&&e<=a-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,e,c);t=s;for(let h=r;h>0;h--){let d=this.children[h-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=z(d.dom)+1;break}t-=d.size}o==-1&&(o=0)}if(o>-1&&(a>e||r==this.children.length-1)){e=a;for(let c=r+1;c<this.children.length;c++){let h=this.children[c];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=z(h.dom);break}e+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=a}return{node:this.contentDOM,from:t,to:e,fromOffset:o,toOffset:i}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return e.size==0||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(!x(e)||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,o=!1){let i=Math.min(t,e),s=Math.max(t,e);for(let f=0,u=0;f<this.children.length;f++){let p=this.children[f],m=u+p.size;if(i>u&&s<m)return p.setSelection(t-u-p.border,e-u-p.border,n,o);u=m}let r=this.domFromPos(t,t?-1:1),l=e==t?r:this.domFromPos(e,e?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),h=!1;if((X||H)&&t==e){let{node:f,offset:u}=r;if(I(f)){if(h=!!(u&&f.nodeValue[u-1]==`
6
+ `),h&&u==f.nodeValue.length)for(let p=f,m;p;p=p.parentNode){if(m=p.nextSibling){m.nodeName=="BR"&&(r=l={node:m.parentNode,offset:z(m)+1});break}let g=p.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let p=f.childNodes[u-1];h=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(X&&c.focusNode&&c.focusNode!=l.node&&x(c.focusNode)){let f=c.focusNode.childNodes[c.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||h&&H)&&Kt(r.node,r.offset,c.anchorNode,c.anchorOffset)&&Kt(l.node,l.offset,c.focusNode,c.focusOffset))return;let d=!1;if((a.extend||t==e)&&!(h&&X)){a.collapse(r.node,r.offset);try{t!=e&&a.extend(l.node,l.offset),d=!0}catch{}}if(!d){if(t>e){let u=r;r=l,l=u}let f=document.createRange();f.setEnd(l.node,l.offset),f.setStart(r.node,r.offset),a.removeAllRanges(),a.addRange(f)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,o=0;o<this.children.length;o++){let i=this.children[o],s=n+i.size;if(n==s?t<=s&&e>=n:t<s&&e>n){let r=n+i.border,l=s-i.border;if(t>=r&&e<=l){this.dirty=t==n||e==s?Vt:Qi,t==r&&e==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=it:i.markDirty(t-r,e-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Vt:it}n=s}this.dirty=Vt}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=t==1?Vt:Qi;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(t){return!1}},Or=class extends Ue{constructor(t,e,n,o){let i,s=e.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!e.type.spec.raw){let r=x(s)?s:document.createElement("span");r!=s&&r.appendChild(s),r.hasAttribute("contenteditable")||(r.contentEditable="false"),r.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=e,this.widget=e,i=this}matchesWidget(t){return this.dirty==et&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return e?e(t):!1}ignoreMutation(t){return t.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}},Jc=class extends Ue{constructor(t,e,n,o){super(t,[],e,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}},$e=class xo extends Ue{constructor(e,n,o,i,s){super(e,[],o,i),this.mark=n,this.spec=s}static create(e,n,o,i){let s=i.nodeViews[n.type.name],r=s&&s(n,i,o);return(!r||!r.dom)&&(r=qe.renderSpec(document,n.type.spec.toDOM(n,o),null,n.attrs)),new xo(e,n,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&it||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=it&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=et){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=et}}slice(e,n,o){let i=xo.create(this.parent,this.mark,!0,o),s=this.children,r=this.size;n<r&&(s=Oo(s,n,r,o)),e>0&&(s=Oo(s,0,e,o));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},ie=class Mr extends Ue{constructor(e,n,o,i,s,r,l){super(e,[],s,r),this.node=n,this.outerDeco=o,this.innerDeco=i,this.nodeDOM=l}static create(e,n,o,i,s,r){let l=s.nodeViews[n.type.name],a,c=l&&l(n,s,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},o,i),h=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(!I(h))throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:d}=qe.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let f=h;return h=Tr(h,o,n),c?a=new qc(e,n,o,i,h,d||null,f,c):n.isText?new Cr(e,n,o,i,h,f):new Mr(e,n,o,i,h,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let o=this.children.length-1;o>=0;o--){let i=this.children[o];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let o=e&&e.find(i=>x(i)&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));o?n.contentElement=o:n.getContent=()=>v.empty}}return n}matchesNode(e,n,o){return this.dirty==et&&e.eq(this.node)&&Mn(n,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let o=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,r=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Kc(this,r&&r.node,e),c=this.node.inlineContent,h=c&&this.node.isBlock;Gc(this.node,this.innerDeco,(d,f,u)=>{d.spec.marks?a.syncToMarks(d.spec.marks,o,e,f):d.type.side>=0&&!u&&a.syncToMarks(f==this.node.childCount?E.none:this.node.child(f).marks,o,e,f),a.placeWidget(d,e,i)},(d,f,u,p)=>{a.syncToMarks(d.marks,o,e,p),h&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,f,u,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(d,f,u,m,e)||a.updateNextNode(d,f,u,e,p,i)||a.addNode(d,f,u,e,i),i+=d.nodeSize,c&&(h=d.isAtom&&!d.isText)}),a.syncToMarks([],o,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Vt)&&(r&&this.protectLocalComposition(e,r),Dr(this.contentDOM,this.children,e),ae&&_c(this.dom))}localCompositionInfo(e,n){let{from:o,to:i}=e.state.selection;if(!(e.state.selection instanceof A)||o<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let r=s.nodeValue,l=Yc(this.node.content,r,o-n,i-n);return l<0?null:{node:s,pos:l,text:r}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:o,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let r=new Jc(this,s,n,i);e.input.compositionNodes.push(r),this.children=Oo(this.children,o,o+i.length,e,r)}update(e,n,o,i){return this.dirty==it||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,o,i),!0)}updateInner(e,n,o,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=et}updateOuterDeco(e){if(Mn(e,this.outerDeco))return;let n=!x(this.nodeDOM),o=this.dom;this.dom=Er(this.dom,this.nodeDOM,So(this.outerDeco,this.node,n),So(e,this.node,n)),this.dom!=o&&(o.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){x(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){x(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 Zi(t,e,n,o,i){Tr(o,e,t);let s=new ie(void 0,t,e,n,o,o,o);return s.contentDOM&&s.updateChildren(i,0),s}var Cr=class Nr extends ie{constructor(e,n,o,i,s,r){super(e,n,o,i,s,null,r)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,o,i){return this.dirty==it||this.dirty!=et&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=et||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=et,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,o){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,o)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,o){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new Nr(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=it)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ar=class extends Ue{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==et&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},qc=class extends ie{constructor(t,e,n,o,i,s,r,l){super(t,e,n,o,i,s,r),this.spec=l}update(t,e,n,o){if(this.dirty==it)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let i=this.spec.update(t,e,n);return i&&this.updateInner(t,e,n,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,e,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,o){this.spec.setSelection?this.spec.setSelection(t,e,n.root):super.setSelection(t,e,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}};function Dr(t,e,n){let o=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let r=e[s],l=r.dom;if(l.parentNode==t){for(;l!=o;)o=Xi(o),i=!0;o=o.nextSibling}else i=!0,t.insertBefore(l,o);if(r instanceof $e){let a=o?o.previousSibling:t.lastChild;Dr(r.contentDOM,r.children,n),o=a?a.nextSibling:t.firstChild}}for(;o;)o=Xi(o),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}var Re=function(t){t&&(this.nodeName=t)};Re.prototype=Object.create(null);var Ft=[new Re];function So(t,e,n){if(t.length==0)return Ft;let o=n?Ft[0]:new Re,i=[o];for(let s=0;s<t.length;s++){let r=t[s].type.attrs;if(r){r.nodeName&&i.push(o=new Re(r.nodeName));for(let l in r){let a=r[l];a!=null&&(n&&i.length==1&&i.push(o=new Re(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+a:l=="style"?o.style=(o.style?o.style+";":"")+a:l!="nodeName"&&(o[l]=a))}}}return i}function Er(t,e,n,o){if(n==Ft&&o==Ft)return e;let i=e;for(let s=0;s<o.length;s++){let r=o[s],l=n[s];if(s){let a;l&&l.nodeName==r.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=Ft[0]),i=a}Wc(i,l||Ft[0],r)}return i}function Wc(t,e,n){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in n)&&t.removeAttribute(o);for(let o in n)o!="class"&&o!="style"&&o!="nodeName"&&n[o]!=e[o]&&t.setAttribute(o,n[o]);if(e.class!=n.class){let o=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<o.length;s++)i.indexOf(o[s])==-1&&t.classList.remove(o[s]);for(let s=0;s<i.length;s++)o.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=o.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Tr(t,e,n){return Er(t,t,Ft,So(e,n,!x(t)))}function Mn(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Xi(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}var Kc=class{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=Hc(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n,o){let i=0,s=this.stack.length>>1,r=Math.min(s,t.length);for(;i<r&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(t[i])&&t[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=et,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<t.length;){this.stack.push(this.top,this.index+1);let l=-1,a=this.top.children.length;o<this.preMatch.index&&(a=Math.min(this.index+3,a));for(let c=this.index;c<a;c++){let h=this.top.children[c];if(h.matchesMark(t[s])&&!this.isLocked(h.dom)){l=c;break}}if(l<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof $e&&c.dirty!=it&&c.mark.type==t[s].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(t[s])&&(c.mark=t[s],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=$e.create(this.top,t[s],e,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,s++}}findNodeMatch(t,e,n,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,e,n))i=this.top.children.indexOf(s,this.index);else for(let r=this.index,l=Math.min(this.top.children.length,r+5);r<l;r++){let a=this.top.children[r];if(a.matchesNode(t,e,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,e,n,o,i){let s=this.top.children[o];return s.dirty==it&&s.dom==s.contentDOM&&(s.dirty=Vt),s.update(t,e,n,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let n=t.pmViewDesc;if(n){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==n)return o}return-1}t=e}}updateNextNode(t,e,n,o,i,s){for(let r=this.index;r<this.top.children.length;r++){let l=this.top.children[r];if(l instanceof ie){let a=this.preMatch.matched.get(l);if(a!=null&&a!=i)return!1;let c=l.dom,h,d=this.isLocked(c)&&!(t.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==t.text&&l.dirty!=it&&Mn(e,l.outerDeco));if(!d&&l.update(t,e,n,o))return this.destroyBetween(this.index,r),l.dom!=c&&(this.changed=!0),this.index++,!0;if(!d&&(h=this.recreateWrapper(l,t,e,n,o,s)))return this.destroyBetween(this.index,r),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=Vt,h.updateChildren(o,s+1),h.dirty=et),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,o,i,s){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content)||!Mn(n,t.outerDeco)||!o.eq(t.innerDeco))return null;let r=ie.create(this.top,e,n,o,i,s);if(r.contentDOM){r.children=t.children,t.children=[];for(let l of r.children)l.parent=r}return t.destroy(),r}addNode(t,e,n,o,i){let s=ie.create(this.top,t,e,n,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(t,e,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(t)&&(t==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Or(this.top,t,e,n);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof $e;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof Cr)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((H||V)&&t&&t.dom.contentEditable=="false"&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);t=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),t=="BR"&&(n.className="ProseMirror-trailingBreak");let o=new Ar(this.top,[],n,null);e!=this.top?e.children.push(o):e.children.splice(this.index++,0,o),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||x(t)&&t.contains(this.lock.parentNode))}};function Hc(t,e){let n=e,o=n.children.length,i=t.childCount,s=new Map,r=[];t:for(;i>0;){let l;for(;;)if(o){let c=n.children[o-1];if(c instanceof $e)n=c,o=c.children.length;else{l=c,o--;break}}else{if(n==e)break t;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,s.set(l,i),r.push(l)}}return{index:i,matched:s,matches:r.reverse()}}function Uc(t,e){return t.type.side-e.type.side}function Gc(t,e,n,o){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let h=t.child(c);o(h,i,e.forChild(s,h),c),s+=h.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let h,d;for(;r<i.length&&i[r].to==s;){let g=i[r++];g.widget&&(h?(d||(d=[h])).push(g):h=g)}if(h)if(d){d.sort(Uc);for(let g=0;g<d.length;g++)n(d[g],c,!!a)}else n(h,c,!!a);let f,u;if(a)u=-1,f=a,a=null;else if(c<t.childCount)u=c,f=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;r<i.length&&i[r].from<=s&&i[r].to>s;)l.push(i[r++]);let p=s+f.nodeSize;if(f.isText){let g=p;r<i.length&&i[r].from<g&&(g=i[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<p&&(a=f.cut(g-s),f=f.cut(0,g-s),p=g,u=-1)}else for(;r<i.length&&i[r].to<p;)r++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();o(f,m,e.forChild(s,f),u),s=p}}function _c(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function Yc(t,e,n,o){for(let i=0,s=0;i<t.childCount&&s<=o;){let r=t.child(i++),l=s;if(s+=r.nodeSize,!r.isText)continue;let a=r.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=n){if(s>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function Oo(t,e,n,o,i){let s=[];for(let r=0,l=0;r<t.length;r++){let a=t[r],c=l,h=l+=a.size;c>=n||h<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,o)),i&&(s.push(i),i=void 0),h>n&&s.push(a.slice(n-c,a.size,o)))}return s}function qo(t,e=null){let n=t.domSelectionRange(),o=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,r=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(r<0)return null;let l=o.resolve(r),a,c;if(Tn(n)){for(a=r;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&O.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Sc(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new O(r==d?l:o.resolve(d))}else if(X&&e=="key"&&r>t.state.selection.to&&x(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>t.state.selection.to)for(let d=n.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=C.findFrom(o.resolve(i.posAtStart),1);break}if(d==i.dom||d.nextSibling||!d.parentNode||!x(d.parentNode))break}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=r,f=r;for(let u=0;u<n.rangeCount;u++){let p=n.getRangeAt(u);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,r]=f==t.state.selection.anchor?[f,d]:[d,f],l=o.resolve(r)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let h=o.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;c=Wo(t,h,l,d)}return c}function $r(t){return t.editable?t.hasFocus():Ir(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vt(t,e=!1){let n=t.state.selection;if(Rr(t,n),!$r(t))return;let o=t.input.mouseDown;if(!e&&V&&o){let i=t.domSelectionRange(),s=t.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Kt(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&o.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Zc(t);else{let{anchor:i,head:s}=n,r,l;ts&&!(n instanceof A)&&(n.$from.parent.inlineContent||(r=es(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=es(t,n.to))),t.docView.setSelection(i,s,t,e),ts&&(r&&ns(r),l&&ns(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Qc(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}var ts=H||V&&gr<63;function es(t,e){let{node:n,offset:o}=t.docView.domFromPos(e,0),i=o<n.childNodes.length?n.childNodes[o]:null,s=o?n.childNodes[o-1]:null;if(H&&i&&i.contentEditable=="false")return Yn(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Yn(i);if(s)return Yn(s)}}function Yn(t){return t.contentEditable="true",H&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ns(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Qc(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),o=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=o||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!$r(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Zc(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,o=n.nodeName=="IMG";o?e.collapse(n.parentNode,z(n)+1):e.collapse(n,0),!o&&!t.state.selection.visible&&Z&&Tt<=11&&(n.disabled=!0,n.disabled=!1)}function Rr(t,e){if(e instanceof O){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(is(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else is(t)}function is(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Wo(t,e,n,o){return t.someProp("createSelectionBetween",i=>i(t,e,n))||A.between(e,n,o)}function ss(t){return t.editable&&!t.hasFocus()?!1:Ir(t)}function Ir(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return Ht(t.dom,e.anchorNode)&&(t.editable||Ht(t.dom,e.focusNode))}catch{return!1}}function Xc(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Kt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Mo(t,e){let{$anchor:n,$head:o}=t.selection,i=e>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&C.findFrom(s,e)}function At(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function rs(t,e,n){let o=t.state.selection;if(o instanceof A)if(n.indexOf("s")>-1){let{$head:i}=o,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let r=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return At(t,new A(o.$anchor,r))}else if(o.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Mo(t.state,e);return i&&i instanceof O?At(t,i):!1}else if(!(tt&&n.indexOf("m")>-1)){let i=o.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,r;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(r=t.docView.descAt(l))&&!r.contentDOM?O.isSelectable(s)?At(t,new O(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):At(t,new A(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1}}else return!1;else{if(o instanceof O&&o.node.isInline)return At(t,new A(e>0?o.$to:o.$from));{let i=Mo(t.state,e);return i?At(t,i):!1}}}function Ie(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):x(t)&&t.contentEditable=="false"}function Qt(t,e){return e<0?th(t):eh(t)}function th(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let i,s,r=!1;for(X&&x(n)&&o<W(n)&&Ie(n.childNodes[o],-1)&&(r=!0);;)if(o>0){if(!x(n))break;let l=n.childNodes[o-1];if(Ie(l,-1))i=n,s=--o;else if(I(l))n=l,o=n.nodeValue.length;else break}else{if(Pr(n))break;{let l=n.previousSibling;for(;l&&Ie(l,-1);)i=n.parentNode,s=z(l),l=l.previousSibling;if(l)n=l,o=W(n);else{if(n=n.parentNode,n==t.dom)break;o=0}}}r?Co(t,n,o):i&&Co(t,i,s)}function eh(t){let e=t.domSelectionRange(),n=e.focusNode,o=e.focusOffset;if(!n)return;let i=W(n),s,r;for(;;)if(o<i){if(!x(n))break;let l=n.childNodes[o];if(Ie(l,1))s=n,r=++o;else break}else{if(Pr(n))break;{let l=n.nextSibling;for(;l&&Ie(l,1);)s=l.parentNode,r=z(l)+1,l=l.nextSibling;if(l)n=l,o=0,i=W(n);else{if(n=n.parentNode,n==t.dom)break;o=i=0}}}s&&Co(t,s,r)}function Pr(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function nh(t,e){for(;t&&e==t.childNodes.length&&!He(t);)e=z(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(I(n))return n;if(x(n)&&n.contentEditable=="false")break;t=n,e=0}}function oh(t,e){for(;t&&!e&&!He(t);)e=z(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(I(n))return n;if(x(n)&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Co(t,e,n){if(!I(e)){let s,r;(r=nh(e,n))?(e=r,n=0):(s=oh(e,n))&&(e=s,n=s.nodeValue.length)}let o=t.domSelection();if(!o)return;if(Tn(o)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),o.removeAllRanges(),o.addRange(s)}else o.extend&&o.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&vt(t)},50)}function ls(t,e){let n=t.state.doc.resolve(e);if(!(V||yr)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function as(t,e,n){let o=t.state.selection;if(o instanceof A&&!o.empty||n.indexOf("s")>-1||tt&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=o;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let r=Mo(t.state,e);if(r&&r instanceof O)return At(t,r)}if(!i.parent.inlineContent){let r=e<0?i:s,l=o instanceof at?C.near(r,e):C.findFrom(r,e);return l?At(t,l):!1}return!1}function cs(t,e){if(!(t.state.selection instanceof A))return!0;let{$head:n,$anchor:o,empty:i}=t.state.selection;if(!n.sameParent(o))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=t.state.tr;return e<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),t.dispatch(r),!0}return!1}function hs(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ih(t){if(!H||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&x(e)&&n==0&&e.firstChild&&x(e.firstChild)&&e.firstChild.contentEditable=="false"){let o=e.firstChild;hs(t,o,"true"),setTimeout(()=>hs(t,o,"false"),20)}return!1}function sh(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function rh(t,e){let n=e.keyCode,o=sh(e);if(n==8||tt&&n==72&&o=="c")return cs(t,-1)||Qt(t,-1);if(n==46&&!e.shiftKey||tt&&n==68&&o=="c")return cs(t,1)||Qt(t,1);if(n==13||n==27)return!0;if(n==37||tt&&n==66&&o=="c"){let i=n==37?ls(t,t.state.selection.from)=="ltr"?-1:1:-1;return rs(t,i,o)||Qt(t,i)}else if(n==39||tt&&n==70&&o=="c"){let i=n==39?ls(t,t.state.selection.from)=="ltr"?1:-1:1;return rs(t,i,o)||Qt(t,i)}else{if(n==38||tt&&n==80&&o=="c")return as(t,-1,o)||Qt(t,-1);if(n==40||tt&&n==78&&o=="c")return ih(t)||as(t,1,o)||Qt(t,1);if(o==(tt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Ko(t,e){t.someProp("transformCopied",u=>{e=u(e,t)});let n=[],{content:o,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&o.childCount==1&&o.firstChild.childCount==1;){i--,s--;let u=o.firstChild;n.push(u.type.name,u.attrs!=u.type.defaultAttrs?u.attrs:null),o=u.content}let r=t.someProp("clipboardSerializer")||qe.fromSchema(t.state.schema),l=jr(),a=l.createElement("div");a.appendChild(r.serializeFragment(o,{document:l}));let c=a.firstChild,h,d=0;for(;c&&x(c)&&(h=Fr[c.nodeName.toLowerCase()]);){for(let u=h.length-1;u>=0;u--){let p=l.createElement(h[u]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&x(c)&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",u=>u(e,t))||e.content.textBetween(0,e.content.size,`
7
+
8
+ `);return{dom:a,text:f,slice:e}}function Ho(t,e,n,o,i){let s=i.parent.type.spec.code,r,l;if(!n&&!e)return null;let a=!!e&&(o||s||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,s||o,t)}),s)return l=new k(v.from(t.state.schema.text(e.replace(/\r\n?/g,`
9
+ `))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",f=>f(e,i,o,t));if(d)l=d;else{let f=i.marks(),{schema:u}=t.state,p=qe.fromSchema(u);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(u.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),r=hh(n),$n&&dh(r);let c=r&&r.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let d=+h[3];d>0;d--){let f=r.firstChild;for(;f&&!x(f);)f=f.nextSibling;if(!f)break;r=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||To.fromSchema(t.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||h),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!lh.test(d.parentNode.nodeName)?{ignore:!0}:null}})),h)l=ph(ds(l,+h[1],+h[2]),h[4]);else if(l=k.maxOpen(ah(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let u=l.content.firstChild;d<l.openStart&&!u.type.spec.isolating;d++,u=u.firstChild);for(let u=l.content.lastChild;f<l.openEnd&&!u.type.spec.isolating;f++,u=u.lastChild);l=ds(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}var lh=/^(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 ah(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(r=>{if(!s)return;let l=o.findWrapping(r.type),a;if(!l)return s=null;if(a=s.length&&i.length&&zr(l,i,r,s[s.length-1],0))s[s.length-1]=a;else{s.length&&(s[s.length-1]=Vr(s[s.length-1],i.length));let c=Br(r,l);s.push(c),o=o.matchType(c.type),i=l}}),s)return v.from(s)}return t}function Br(t,e,n=0){for(let o=e.length-1;o>=n;o--)t=e[o].create(null,v.from(t));return t}function zr(t,e,n,o,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=zr(t,e,n,o.lastChild,i+1);if(s)return o.copy(o.content.replaceChild(o.childCount-1,s));if(o.contentMatchAt(o.childCount).matchType(i==t.length-1?n.type:t[i+1]))return o.copy(o.content.append(v.from(Br(n,t,i+1))))}}function Vr(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Vr(t.lastChild,e-1)),o=t.contentMatchAt(t.childCount).fillBefore(v.empty,!0);return t.copy(n.append(o))}function No(t,e,n,o,i,s){let r=e<0?t.firstChild:t.lastChild,l=r.content;return t.childCount>1&&(s=0),i<o-1&&(l=No(l,e,n,o,i+1,s)),i>=n&&(l=e<0?r.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(v.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,r.copy(l))}function ds(t,e,n){return e<t.openStart&&(t=new k(No(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new k(No(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}var Fr={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function jr(){return document.implementation.createHTMLDocument("title")}var ye=null;function ch(t){let e=window.trustedTypes;if(!e)return t;if(!ye){if(ye=e.defaultPolicy)try{return ye.createHTML(t)}catch{}ye=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return ye.createHTML(t)}function hh(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=jr(),o=n.body,i=/<([a-z][^>\s]+)/i.exec(t),s;if((s=i&&Fr[i[1].toLowerCase()])&&(t=s.map(r=>"<"+r+">").join("")+t+s.map(r=>"</"+r+">").reverse().join("")),o.innerHTML=ch(t),s)for(let r=0;r<s.length;r++)o=o.querySelector(s[r])||o;for(let r=0;r<n.styleSheets.length;r++){let l=n.styleSheets[r];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let h=o.querySelectorAll(c.selectorText);for(let d=0;d<h.length;d++)h[d].style.cssText+=c.style.cssText}}}return o}function dh(t){let e=t.querySelectorAll(V?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let o=e[n];o.childNodes.length==1&&o.textContent=="\xA0"&&o.parentNode&&o.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),o)}}function ph(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,o;try{o=JSON.parse(e)}catch{return t}let{content:i,openStart:s,openEnd:r}=t;for(let l=o.length-2;l>=0;l-=2){let a=n.nodes[o[l]];if(!a||a.hasRequiredAttrs())break;try{i=v.from(a.create(o[l+1],i))}catch{break}s++,r++}return new k(i,s,r)}var _={},Y={},fh={touchstart:!0,touchmove:!0},uh=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function mh(t){for(let e in _){let n=_[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=o=>{yh(t,o)&&!Uo(t,o)&&(t.editable||!(o.type in Y))&&n(t,o)},fh[e]?{passive:!0}:void 0)}H&&t.dom.addEventListener("input",()=>null),Ao(t)}function bt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function gh(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Ao(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=o=>Uo(t,o))})}function Uo(t,e){return t.someProp("handleDOMEvents",n=>{let o=n[e.type];return o?o(t,e)||e.defaultPrevented:!1})}function yh(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function wh(t,e){!Uo(t,e)&&_[e.type]&&(t.editable||!(e.type in Y))&&_[e.type](t,e)}Y.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Wr(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(wt&&V&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ae&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let o=Date.now();t.input.lastIOSEnter=o,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==o&&(t.someProp("handleKeyDown",i=>i(t,zt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",o=>o(t,n))||rh(t,n)?n.preventDefault():bt(t,"key")};Y.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Y.keypress=(t,e)=>{let n=e;if(Wr(t)||!n.charCode||n.ctrlKey&&!n.altKey||tt&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let o=t.state.selection;if(!(o instanceof A)||!o.$from.sameParent(o.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",r=>r(t,o.$from.pos,o.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function Ge(t){return{left:t.clientX,top:t.clientY}}function bh(t,e){let n=e.x-t.clientX,o=e.y-t.clientY;return n*n+o*o<100}function Go(t,e,n,o,i){if(o==-1)return!1;let s=t.state.doc.resolve(o);for(let r=s.depth+1;r>0;r--)if(t.someProp(e,l=>r>s.depth?l(t,n,s.nodeAfter,s.before(r),i,!0):l(t,n,s.node(r),s.before(r),i,!1)))return!0;return!1}function _e(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let o=t.state.tr.setSelection(e);o.setMeta("pointer",!0),t.dispatch(o)}function vh(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),o=n.nodeAfter;return o&&o.isAtom&&O.isSelectable(o)?(_e(t,new O(n)),!0):!1}function kh(t,e){if(e==-1)return!1;let n=t.state.selection,o,i;n instanceof O&&(o=n.node);let s=t.state.doc.resolve(e);for(let r=s.depth+1;r>0;r--){let l=r>s.depth?s.nodeAfter:s.node(r);if(O.isSelectable(l)){o&&n.$from.depth>0&&r>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(r);break}}return i!=null?(_e(t,O.create(t.state.doc,i)),!0):!1}function xh(t,e,n,o,i){return Go(t,"handleClickOn",e,n,o)||t.someProp("handleClick",s=>s(t,e,o))||(i?kh(t,n):vh(t,n))}function Sh(t,e,n,o){return Go(t,"handleDoubleClickOn",e,n,o)||t.someProp("handleDoubleClick",i=>i(t,e,o))}function Oh(t,e,n,o){return Go(t,"handleTripleClickOn",e,n,o)||t.someProp("handleTripleClick",i=>i(t,e,o))||Mh(t,n,o)}function Mh(t,e,n){if(n.button!=0)return!1;let o=Lr(t,e,!0),i=t.state.doc;return o?(_e(t,o),o instanceof A&&i.eq(t.state.doc)&&(t.input.mouseDown=new Nh(t,o)),!0):!1}function Lr(t,e,n){let o=t.state.doc;if(e==-1)return o.inlineContent?A.create(o,0,o.content.size):null;let i=o.resolve(e);for(let s=i.depth+1;s>0;s--){let r=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(r.inlineContent)return A.create(o,l+1,l+1+r.content.size);if(n&&O.isSelectable(r))return O.create(o,l)}return null}function _o(t){return Ve(t)}var Jr=tt?"metaKey":"ctrlKey";_.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let o=_o(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&bh(n,t.input.lastClick)&&!n[Jr]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let r=t.posAtCoords(Ge(n));r&&(s=="singleClick"?t.input.mouseDown=new Ch(t,r,n,!!o):(s=="doubleClick"?Sh:Oh)(t,r.pos,r.inside,n)?n.preventDefault():bt(t,"pointer"))};var qr=class{constructor(t){this.view=t,this.mightDrag=null,t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(t){this.done()}move(t){t.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Ch=class extends qr{constructor(t,e,n,o){super(t),this.pos=e,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=t.state.doc,this.selectNode=!!n[Jr],this.allowDefault=n.shiftKey;let i,s;if(e.inside>-1)i=t.state.doc.nodeAt(e.inside),s=e.inside;else{let c=t.state.doc.resolve(e.pos);i=c.parent,s=c.depth?c.before():0}let r=o?null:n.target,l=r?t.docView.nearestDesc(r,!0):null;this.target=l&&x(l.nodeDOM)?l.nodeDOM:null;let{selection:a}=t.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||a instanceof O&&a.from<=s&&a.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&X&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),bt(t,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||vt(this.view)})}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(Ge(t))),this.updateAllowDefault(t),this.allowDefault||!e?bt(this.view,"pointer"):xh(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||H&&this.mightDrag&&!this.mightDrag.node.isAtom||V&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(_e(this.view,C.near(this.view.state.doc.resolve(e.pos))),t.preventDefault()):bt(this.view,"pointer")}move(t){this.updateAllowDefault(t),bt(this.view,"pointer"),super.move(t)}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Nh=class extends qr{constructor(t,e){super(t),this.startSelection=e,this.startDoc=t.state.doc}move(t){if(t.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}t.preventDefault(),bt(this.view,"pointer");let e=this.view.posAtCoords(Ge(t)),n=e&&Lr(this.view,e.inside,!1);if(!n)return;let{doc:o}=this.view.state,i=this.startSelection,[s,r]=n.from<i.from?[i.to,n.from]:[i.from,n.to];_e(this.view,A.create(o,s,r))}};_.touchstart=t=>{t.input.lastTouch=Date.now(),_o(t),bt(t,"pointer")};_.touchmove=t=>{t.input.lastTouch=Date.now(),bt(t,"pointer")};_.contextmenu=t=>_o(t);function Wr(t,e){return t.composing?!0:H&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}var Ah=wt?5e3:-1;Y.compositionstart=Y.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof A&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||V&&yr&&Dh(t)))t.markCursor=t.state.storedMarks||n.marks(),Ve(t,!0),t.markCursor=null;else if(Ve(t,!e.selection.empty),X&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let o=t.domSelectionRange();for(let i=o.focusNode,s=o.focusOffset;i&&x(i)&&s!=0;){let r=s<0?i.lastChild:i.childNodes[s-1];if(!r)break;if(I(r)){let l=t.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else i=r,s=-1}}t.input.composing=!0}Kr(t,Ah)};function Dh(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||!x(e)||n>=e.childNodes.length)return!1;let o=e.childNodes[n];return x(o)&&o.contentEditable=="false"}Y.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Kr(t,20))};function Kr(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Ve(t),e))}function Hr(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Eh(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=kc(e.focusNode,e.focusOffset),o=xc(e.focusNode,e.focusOffset);if(n&&o&&n!=o){let i=o.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||o==s)return s;if(!i||!i.isText(o.nodeValue))return o;if(t.input.compositionNode==o){let r=n.pmViewDesc;if(!(!r||!r.isText(n.nodeValue)))return o}}return n||o}function Ve(t,e=!1){if(!(wt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Hr(t),e||t.docView&&t.docView.dirty){let n=qo(t),o=t.state.selection;return n&&!n.eq(o)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function Th(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),o.removeAllRanges(),o.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}var Fe=Z&&Tt<15||ae&&Cc<604;_.copy=Y.cut=(t,e)=>{let n=e,o=t.state.selection,i=n.type=="cut";if(o.empty)return;let s=Fe?null:n.clipboardData,r=o.content(),{dom:l,text:a}=Ko(t,r);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Th(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function $h(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Rh(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,o=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),o.parentNode&&o.parentNode.removeChild(o),n?je(t,o.value,null,i,e):je(t,o.textContent,o.innerHTML,i,e)},50)}function je(t,e,n,o,i){let s=Ho(t,e,n,o,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,s||k.empty)))return!0;if(!s)return!1;let r=$h(s),l=r?t.state.tr.replaceSelectionWith(r,o):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ur(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Y.paste=(t,e)=>{let n=e;if(t.composing&&!wt)return;let o=Fe?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;o&&je(t,Ur(o),o.getData("text/html"),i,n)?n.preventDefault():Rh(t,n)};var Gr=class{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}},Ih=tt?"altKey":"ctrlKey";function _r(t,e){let n;return t.someProp("dragCopies",o=>{n=n||o(e)}),n!=null?!n:!e[Ih]}_.dragstart=(t,e)=>{let n=e,o=t.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(Ge(n)),r;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof O?i.to-1:i.to))){if(o&&o.mightDrag)r=O.create(t.state.doc,o.mightDrag.pos);else if(n.target&&x(n.target)){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(r=O.create(t.state.doc,d.posBefore))}}let l=(r||t.state.selection).content(),{dom:a,text:c,slice:h}=Ko(t,l);(!n.dataTransfer.files.length||!V||gr>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Fe?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Fe||n.dataTransfer.setData("text/plain",c),t.dragging=new Gr(h,_r(t,n),r)};_.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Y.dragover=Y.dragenter=(t,e)=>e.preventDefault();Y.drop=(t,e)=>{try{Ph(t,e,t.dragging)}finally{t.dragging=null}};function Ph(t,e,n){if(!e.dataTransfer)return;let o=t.posAtCoords(Ge(e));if(!o)return;let i=t.state.doc.resolve(o.pos),s=n&&n.slice;s?t.someProp("transformPasted",u=>{s=u(s,t,!1)}):s=Ho(t,Ur(e.dataTransfer),Fe?null:e.dataTransfer.getData("text/html"),!1,i);let r=!!(n&&_r(t,e));if(t.someProp("handleDrop",u=>u(t,e,s||k.empty,r))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Vo(t.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let a=t.state.tr;if(r){let{node:u}=n;u?u.replace(a):a.deleteSelection()}let c=a.mapping.map(l),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=a.doc;if(h?a.replaceRangeWith(c,c,s.content.firstChild):a.replaceRange(c,c,s),a.doc.eq(d))return;let f=a.doc.resolve(c);if(h&&O.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new O(f));else{let u=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,b)=>u=b),a.setSelection(Wo(t,f,a.doc.resolve(u)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}_.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&vt(t)},20))};_.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};_.beforeinput=(t,e)=>{if(wt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:n}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=n||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,zt(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in Y)_[t]=Y[t];function Le(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}var ps=class Yr{constructor(e,n){this.toDOM=e,this.spec=n||Jt,this.side=this.spec.side||0}map(e,n,o,i){let{pos:s,deleted:r}=e.mapResult(n.from+i,this.side<0?-1:1);return r?null:new Pt(s-o,s-o,this)}valid(){return!0}eq(e){return this==e||e instanceof Yr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Le(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Pe=class Do{constructor(e,n){this.attrs=e,this.spec=n||Jt}map(e,n,o,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-o,r=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-o;return s>=r?null:new Pt(s,r,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Do&&Le(this.attrs,e.attrs)&&Le(this.spec,e.spec)}static is(e){return e.type instanceof Do}destroy(){}},Bh=class Qr{constructor(e,n){this.attrs=e,this.spec=n||Jt}map(e,n,o,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let r=e.mapResult(n.to+i,-1);return r.deleted||r.pos<=s.pos?null:new Pt(s.pos-o,r.pos-o,this)}valid(e,n){let{index:o,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(o)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof Qr&&Le(this.attrs,e.attrs)&&Le(this.spec,e.spec)}destroy(){}},Pt=class Ae{constructor(e,n,o){this.from=e,this.to=n,this.type=o}copy(e,n){return new Ae(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,o){return this.type.map(e,this,n,o)}static widget(e,n,o){return new Ae(e,e,new ps(n,o))}static inline(e,n,o,i){return new Ae(e,n,new Pe(o,i))}static node(e,n,o,i){return new Ae(e,n,new Bh(o,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Pe}get widget(){return this.type instanceof ps}},ee=[],Jt={},nt=class Ct{constructor(e,n){this.local=e.length?e:ee,this.children=n.length?n:ee}static create(e,n){return n.length?Cn(n,e,0,Jt):q}find(e,n,o){let i=[];return this.findInner(e??0,n??1e9,i,0,o),i}findInner(e,n,o,i,s){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&o.push(l.copy(l.from+i,l.to+i))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<n&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,n-l,o,i+l,s)}}map(e,n,o){return this==q||e.maps.length==0?this:this.mapInner(e,n,0,0,o||Jt)}mapInner(e,n,o,i,s){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,o,i);a&&a.type.valid(n,a)?(r||(r=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?zh(this.children,r||[],e,n,o,i,s):r?new Ct(r.sort(qt),ee):q}add(e,n){return n.length?this==q?Ct.create(e,n):this.addInner(e,n,0):this}addInner(e,n,o){let i,s=0;e.forEach((l,a)=>{let c=a+o,h;if(h=tl(n,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,h,c+1):i.splice(s,0,a,a+l.nodeSize,Cn(h,l,c+1,Jt)),s+=3}});let r=Xr(s?el(n):n,-o);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new Ct(r.length?this.local.concat(r).sort(qt):this.local,i||this.children)}remove(e){return e.length==0||this==q?this:this.removeInner(e,0)}removeInner(e,n){let o=this.children,i=this.local;for(let s=0;s<o.length;s+=3){let r,l=o[s]+n,a=o[s+1]+n;for(let h=0,d;h<e.length;h++)(d=e[h])&&d.from>l&&d.to<a&&(e[h]=null,(r||(r=[])).push(d));if(!r)continue;o==this.children&&(o=this.children.slice());let c=o[s+2].removeInner(r,l+1);c!=q?o[s+2]=c:(o.splice(s,3),s-=3)}if(i.length){for(let s=0,r;s<e.length;s++)if(r=e[s])for(let l=0;l<i.length;l++)i[l].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return o==this.children&&i==this.local?this:i.length||o.length?new Ct(i,o):q}forChild(e,n){if(this==q)return this;if(n.isLeaf)return Ct.empty;let o,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(o=this.children[l+2]);break}let s=e+1,r=s+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>s&&a.type instanceof Pe){let c=Math.max(s,a.from)-s,h=Math.min(r,a.to)-s;c<h&&(i||(i=[])).push(a.copy(c,h))}}if(i){let l=new Ct(i.sort(qt),ee);return o?new Zr([l,o]):l}return o||q}eq(e){if(this==e)return!0;if(!(e instanceof Ct)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Yo(this.localsInner(e))}localsInner(e){if(this==q)return ee;if(e.inlineContent||!this.local.some(Pe.is))return this.local;let n=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof Pe||n.push(this.local[o]);return n}forEachSet(e){e(this)}};nt.empty=new nt([],[]);nt.removeOverlap=Yo;var q=nt.empty,Zr=class ne{constructor(e){this.members=e}map(e,n){let o=this.members.map(i=>i.map(e,n,Jt));return ne.from(o)}forChild(e,n){if(n.isLeaf)return nt.empty;let o=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=q&&(s instanceof ne?o=o.concat(s.members):o.push(s))}return ne.from(o)}eq(e){if(!(e instanceof ne)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,o=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{o&&(n=n.slice(),o=!1);for(let r=0;r<s.length;r++)n.push(s[r])}}return n?Yo(o?n:n.sort(qt)):ee}static from(e){switch(e.length){case 0:return q;case 1:return e[0];default:return new ne(e.every(n=>n instanceof nt)?e:e.reduce((n,o)=>n.concat(o instanceof nt?o:o.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}};function zh(t,e,n,o,i,s,r){let l=t.slice();for(let c=0,h=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,u,p,m)=>{let g=m-p-(u-f);for(let b=0;b<l.length;b+=3){let y=l[b+1];if(y<0||f>y+h-d)continue;let w=l[b]+h-d;u>=w?l[b+1]=f<=w?-2:-1:f>=h&&g&&(l[b]+=g,l[b+1]+=g)}d+=g}),h=n.maps[c].map(h,-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 h=n.map(t[c]+s),d=h-i;if(d<0||d>=o.content.size){a=!0;continue}let f=n.map(t[c+1]+s,-1),u=f-i,{index:p,offset:m}=o.content.findIndex(d),g=o.maybeChild(p);if(g&&m==d&&m+g.nodeSize==u){let b=l[c+2].mapInner(n,g,h+1,t[c]+s+1,r);b!=q?(l[c]=d,l[c+1]=u,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Vh(l,t,e,n,i,s,r),h=Cn(c,o,0,r);e=h.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<h.children.length;d+=3){let u=h.children[d];for(;f<l.length&&l[f]<u;)f+=3;l.splice(f,0,h.children[d],h.children[d+1],h.children[d+2])}}return new nt(e.sort(qt),l)}function Xr(t,e){if(!e||!t.length)return t;let n=[];for(let o=0;o<t.length;o++){let i=t[o];n.push(new Pt(i.from+e,i.to+e,i.type))}return n}function Vh(t,e,n,o,i,s,r){function l(a,c){for(let h=0;h<a.local.length;h++){let d=a.local[h].map(o,i,c);d?n.push(d):r.onRemove&&r.onRemove(a.local[h].spec)}for(let h=0;h<a.children.length;h+=3)l(a.children[h+2],a.children[h]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+s+1);return n}function tl(t,e,n){if(e.isLeaf)return null;let o=n+e.nodeSize,i=null;for(let s=0,r;s<t.length;s++)(r=t[s])&&r.from>n&&r.to<o&&((i||(i=[])).push(r),t[s]=null);return i}function el(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Cn(t,e,n,o){let i=[],s=!1;e.forEach((l,a)=>{let c=tl(t,l,a+n);if(c){s=!0;let h=Cn(c,l,n+a+1,o);h!=q&&i.push(a,a+l.nodeSize,h)}});let r=Xr(s?el(t):t,-n).sort(qt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(o.onRemove&&o.onRemove(r[l].spec),r.splice(l--,1));return r.length||i.length?new nt(r,i):q}function qt(t,e){return t.from-e.from||t.to-e.to}function Yo(t){let e=t;for(let n=0;n<e.length-1;n++){let o=e[n];if(o.from!=o.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==o.from){s.to!=o.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,o.to),fs(e,i+1,s.copy(o.to,s.to)));continue}else{s.from<o.to&&(e==t&&(e=t.slice()),e[n]=o.copy(o.from,s.from),fs(e,i,o.copy(s.from,o.to)));break}}}return e}function fs(t,e,n){for(;e<t.length&&qt(n,t[e])>0;)e++;t.splice(e,0,n)}function Qn(t){let e=[];return t.someProp("decorations",n=>{let o=n(t.state);o&&o!=q&&e.push(o)}),t.cursorWrapper&&e.push(nt.create(t.state.doc,[t.cursorWrapper.deco])),Zr.from(e)}var Fh={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jh=Z&&Tt<=11,Lh=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}},Jh=class{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Lh,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let o=0;o<n.length;o++)this.queue.push(n[o]);Z&&Tt<=11&&n.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():H&&t.composing&&n.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(t.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),jh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Fh)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ss(this.view)){if(this.suppressingSelectionUpdates)return vt(this.view);if(Z&&Tt<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&Kt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e=new Set,n;for(let i=t.focusNode;i;i=le(i))e.add(i);for(let i=t.anchorNode;i;i=le(i))if(e.has(i)){n=i;break}let o=n&&this.view.docView.nearestDesc(n);if(o&&o.ignoreMutation({type:"selection",target:I(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ss(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,r=!1,l=[];if(t.editable)for(let c=0;c<e.length;c++){let h=this.registerMutation(e[c],l);h&&(i=i<0?h.from:Math.min(h.from,i),s=s<0?h.to:Math.max(h.to,s),h.typeOver&&(r=!0))}if(l.some(c=>c.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||V&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&e.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of l)if(c.nodeName=="BR"&&c.parentNode){let h=c.nextSibling;for(;h&&x(h);){if(h.contentEditable=="false"){c.parentNode.removeChild(c);break}h=h.firstChild}}}else if(X&&l.length){let c=l.filter(h=>h.nodeName=="BR");if(c.length==2){let[h,d]=c;h.parentNode&&h.parentNode.parentNode==d.parentNode?d.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let d of c){let f=d.parentNode;f&&f.nodeName=="LI"&&(!h||Kh(t,h)!=f)&&d.remove()}}}let a=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Tn(n)&&(a=qo(t))&&a.eq(C.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,vt(t),this.currentSelection.set(n),t.scrollToSelection()):(i>-1||o)&&(i>-1&&(t.docView.markDirty(i,s),qh(t)),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Hh(t,l)),this.handleDOMChange(i,s,r,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||vt(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let c=0;c<t.addedNodes.length;c++){let h=t.addedNodes[c];e.push(h),I(h)&&(this.lastChangedTextNode=h)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let o=t.previousSibling,i=t.nextSibling;if(Z&&Tt<=11&&t.addedNodes.length)for(let c=0;c<t.addedNodes.length;c++){let{previousSibling:h,nextSibling:d}=t.addedNodes[c];(!h||Array.prototype.indexOf.call(t.addedNodes,h)<0)&&(o=h),(!d||Array.prototype.indexOf.call(t.addedNodes,d)<0)&&(i=d)}let s=o&&o.parentNode==t.target?z(o)+1:0,r=n.localPosFromDOM(t.target,s,-1),l=i&&i.parentNode==t.target?z(i):t.target.childNodes.length,a=n.localPosFromDOM(t.target,l,1);return{from:r,to:a}}else return t.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}},us=new WeakMap,ms=!1;function qh(t){if(!us.has(t)&&(us.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=X,ms)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."),ms=!0}}function gs(t,e){let n=e.startContainer,o=e.startOffset,i=e.endContainer,s=e.endOffset,r=t.domAtPos(t.state.selection.anchor);return Kt(r.node,r.offset,i,s)&&([n,o,i,s]=[i,s,n,o]),{anchorNode:n,anchorOffset:o,focusNode:i,focusOffset:s}}function Wh(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return gs(t,i)}let n;function o(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",o,!0),n?gs(t,n):null}function Kh(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let o=t.docView.nearestDesc(n,!0);if(o&&o.node.isBlock)return n}return null}function Hh(t,e){var n;let{focusNode:o,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let r=s.nextSibling;for(;r&&r.nodeName!="TD"&&r.nodeName!="TH";)r=r.nextSibling;if(r){let l=r;for(;;){let a=l.firstChild;if(!a||!x(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),o==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Uh(t,e,n,o){let{node:i,fromOffset:s,toOffset:r,from:l,to:a}=t.docView.parseRange(e,n),c=t.domSelectionRange(),h,d=c.anchorNode;if(d&&Ht(t.dom,d)&&(h=[{node:d,offset:c.anchorOffset}],Tn(c)||h.push({node:c.focusNode,offset:c.focusOffset})),V&&t.input.lastKeyCode===8)for(let b=r;b>s;b--){let y=i.childNodes[b-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){r=b;break}if(!w||w.size)break}let f=t.state.doc,u=t.someProp("domParser")||To.fromSchema(t.state.schema),p=f.resolve(l),m=null,g=u.parse(i,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:r,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:Gh(o),context:p});if(h&&h[0].pos!=null){let b=h[0].pos,y=h[1]&&h[1].pos;y==null&&(y=b),m={anchor:b+l,head:y+l}}return{doc:g,sel:m,from:l,to:a}}var Gh=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(H&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let o=document.createElement("div");return o.appendChild(document.createElement("li")),{skip:o}}else if(e.parentNode.lastChild==e||H&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},_h=/^(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 Yh(t,e,n,o,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let M=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=qo(t,M);if(D&&!t.state.selection.eq(D)){if(V&&wt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",va=>va(t,zt(13,"Enter"))))return;let P=t.state.tr.setSelection(D);M=="pointer"?P.setMeta("pointer",!0):M=="key"&&P.scrollIntoView(),s&&P.setMeta("composition",s),t.dispatch(P)}return}let r=t.state.doc.resolve(e),l=r.sharedDepth(n);e=r.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=Uh(t,e,n,i),h=t.state.doc,d=h.slice(c.from,c.to),f,u;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,u="end"):(f=t.state.selection.from,u="start"),t.input.lastKeyCode=null;let p=td(d.content,c.doc.content,c.from,f,u);if(p&&t.input.domChangeCount++,(ae&&t.input.lastIOSEnter>Date.now()-225||wt)&&i.some(M=>x(M)&&!_h.test(M.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",M=>M(t,zt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(o&&a instanceof A&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let M=ys(t,t.state.doc,c.sel);if(M&&!M.eq(t.state.selection)){let D=t.state.tr.setSelection(M);s&&D.setMeta("composition",s),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof A&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Z&&Tt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=h.resolve(p.start),y=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA;if((ae&&t.input.lastIOSEnter>Date.now()-225&&(!y||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!y&&Xh(c.doc,m.pos,g.pos))&&t.someProp("handleKeyDown",M=>M(t,zt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Zh(h,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",M=>M(t,zt(8,"Backspace")))){wt&&V&&t.domObserver.suppressSelectionUpdates();return}V&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),wt&&!y&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(M){return M(t,zt(13,"Enter"))})},20));let w=p.start,S=p.endA,T=M=>{let D=M||t.state.tr.replace(w,S,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let P=ys(t,D.doc,c.sel);P&&!(V&&t.composing&&P.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(P.head==w||P.head==D.mapping.map(S)-1)||Z&&P.empty&&P.head==w)&&D.setSelection(P)}return s&&D.setMeta("composition",s),D.scrollIntoView()},rt;if(y)if(m.pos==g.pos){Z&&Tt<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>vt(t),20));let M=T(t.state.tr.delete(w,S)),D=h.resolve(p.start).marksAcross(h.resolve(p.endA));D&&M.ensureMarks(D),t.dispatch(M)}else if(p.endA==p.endB&&(rt=Qh(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let M=T(t.state.tr);rt.type=="add"?M.addMark(w,S,rt.mark):M.removeMark(w,S,rt.mark),t.dispatch(M)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,g.parentOffset),D=()=>T(t.state.tr.insertText(M,w,S));t.someProp("handleTextInput",P=>P(t,w,S,M,D))||t.dispatch(D())}else t.dispatch(T());else t.dispatch(T())}function ys(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Wo(t,e.resolve(n.anchor),e.resolve(n.head))}function Qh(t,e){let n=t.firstChild.marks,o=e.firstChild.marks,i=n,s=o,r,l,a;for(let h=0;h<o.length;h++)i=o[h].removeFromSet(i);for(let h=0;h<n.length;h++)s=n[h].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],r="add",a=h=>h.mark(l.addToSet(h.marks));else if(i.length==0&&s.length==1)l=s[0],r="remove",a=h=>h.mark(l.removeFromSet(h.marks));else return null;let c=[];for(let h=0;h<e.childCount;h++)c.push(a(e.child(h)));if(v.from(c).eq(t))return{mark:l,type:r}}function Zh(t,e,n,o,i){if(n-e<=i.pos-o.pos||Zn(o,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!o.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let r=t.resolve(Zn(s,!0,!0));return!r.parent.isTextblock||r.pos>n||Zn(r,!0,!1)<n?!1:o.parent.content.cut(o.parentOffset).eq(r.parent.content)}function Xh(t,e,n){let o=0,i=0;return t.nodesBetween(e,n,(s,r)=>{s.isTextblock&&r>=e&&r<n?o++:(s.isText?/\S/.test(s.text.slice(Math.max(0,e-r),Math.min(s.nodeSize,n-r))):s.isLeaf)&&i++}),i==0&&o==1}function Zn(t,e,n){let o=t.depth,i=e?t.end():t.pos;for(;o>0&&(e||t.indexAfter(o)==t.node(o).childCount);)o--,i++,e=!1;if(n){let s=t.node(o).maybeChild(t.indexAfter(o));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function td(t,e,n,o,i){let s=t.findDiffStart(e,n),r=n+t.size,l=n+e.size;if(s==null)return null;let{a,b:c}=t.findDiffEnd(e,r,l);if(i=="end"){let h=Math.max(0,s-Math.min(a,c));o-=a+h-s}if(a<s&&r<l){let h=o<=s&&o>=a?s-o:0;s-=h,c=s+(c-a),a=s}else if(c<s){let h=o<=s&&o>=c?s-o:0;s-=h,a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}var ed=Ho,nd=Ve,nl=class{constructor(t,e){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 uh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(xs),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=vs(this),bs(this),this.nodeViews=ks(this),this.docView=Zi(this.state.doc,ws(this),Qn(this),this.dom,this),this.domObserver=new Jh(this,(n,o,i,s)=>Yh(this,n,o,i,s)),this.domObserver.start(),mh(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Ao(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(xs),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let n in this._props)e[n]=this._props[n];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let o=this.state,i=!1,s=!1;t.storedMarks&&this.composing&&(Hr(this),s=!0),this.state=t;let r=o.plugins!=t.plugins||this._props.plugins!=e.plugins;if(r||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let f=ks(this);id(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(r||e.handleDOMEvents!=this._props.handleDOMEvents)&&Ao(this),this.editable=vs(this),bs(this);let l=Qn(this),a=ws(this),c=o.plugins!=t.plugins&&!o.doc.eq(t.doc)?"reset":t.scrollToSelection>o.scrollToSelection?"to selection":"preserve",h=i||!this.docView.matchesNode(t.doc,a,l);(h||!t.selection.eq(o.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Dc(this);if(s){this.domObserver.stop();let f=h&&(Z||V)&&!this.composing&&!o.selection.empty&&!t.selection.empty&&od(o.selection,t.selection);if(h){let p=V?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Eh(this)),(i||!this.docView.update(t.doc,a,l,this))&&(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Zi(t.doc,a,l,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}let u=this.input.mouseDown;f||!(u&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Xc(this)&&u.delaySelUpdate())?vt(this,f):(Rr(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((n=this.dragging)===null||n===void 0)&&n.node&&!o.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,o),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&Ec(d)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!Ht(this.dom,t))&&!this.someProp("handleScrollToSelection",e=>e(this)))if(this.state.selection instanceof O){let e=this.docView.domAfterPos(this.state.selection.from);x(e)&&Ui(this,e.getBoundingClientRect(),t)}else Ui(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let n=this.directPlugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let n=this.state.plugins[e];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}}updateDraggedNode(t,e){let n=t.node,o=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let i=n.from+(this.state.doc.content.size-e.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==n.node&&(o=i)}this.dragging=new Gr(t.slice,t.move,o<0?void 0:O.create(this.state.doc,o))}someProp(t,e){let n=this._props&&this._props[t],o;if(n!=null&&(o=e?e(n):n))return o;for(let s=0;s<this.directPlugins.length;s++){let r=this.directPlugins[s].props[t];if(r!=null&&(o=e?e(r):r))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let r=i[s].props[t];if(r!=null&&(o=e?e(r):r))return o}}hasFocus(){if(Z){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if(t.contentEditable=="false")return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Tc(this.dom),vt(this),this.domObserver.start()}get root(){let t=this._root;if(t==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return t||document}updateRoot(){this._root=null}posAtCoords(t){return Bc(this,t)}coordsAtPos(t,e=1){return xr(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let o=this.docView.posFromDOM(t,e,n);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(t,e){return Lc(this,e||this.state,t)}pasteHTML(t,e){return je(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return je(this,t,null,!0,e||new ClipboardEvent("paste"))}serializeForClipboard(t){return Ko(this,t)}destroy(){this.docView&&(gh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,bc())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return wh(this,t)}domSelectionRange(){let t=this.dom.isConnected!==!1&&this.domSelection();return t?H&&this.root.nodeType===11&&Oc(this.dom.ownerDocument)==this.dom&&Wh(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};nl.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function ws(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let o in n)o=="class"?e.class+=" "+n[o]:o=="style"?e.style=(e.style?e.style+";":"")+n[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(n[o]))}),e.translate||(e.translate="no"),[Pt.node(0,t.state.doc.content.size,e)]}function bs(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Pt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function vs(t){return!t.someProp("editable",e=>e(t.state)===!1)}function od(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function ks(t){let e=Object.create(null);function n(o){for(let i in o)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=o[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function id(t,e){let n=0,o=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)o++;return n!=o}function xs(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var sd={};pt(sd,{closeHistory:()=>fd,history:()=>ud,isHistoryTransaction:()=>bd,redo:()=>al,redoDepth:()=>wd,redoNoScroll:()=>gd,undo:()=>ll,undoDepth:()=>yd,undoNoScroll:()=>md});var Nn=200,F=function(){};F.prototype.append=function(t){return t.length?(t=F.from(t),!this.length&&t||t.length<Nn&&this.leafAppend(t)||this.length<Nn&&t.leafPrepend(this)||this.appendInner(t)):this};F.prototype.prepend=function(t){return t.length?F.from(t).append(this):this};F.prototype.appendInner=function(t){return new rd(this,t)};F.prototype.slice=function(t,e){return t===void 0&&(t=0),e===void 0&&(e=this.length),t>=e?F.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,e))};F.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};F.prototype.forEach=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length),e<=n?this.forEachInner(t,e,n,0):this.forEachInvertedInner(t,e,n,0)};F.prototype.map=function(t,e,n){e===void 0&&(e=0),n===void 0&&(n=this.length);var o=[];return this.forEach(function(i,s){return o.push(t(i,s))},e,n),o};F.from=function(t){return t instanceof F?t:t&&t.length?new ol(t):F.empty};var ol=(function(t){function e(o){t.call(this),this.values=o}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,r){for(var l=i;l<s;l++)if(o(this.values[l],r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,r){for(var l=i-1;l>=s;l--)if(o(this.values[l],r+l)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Nn)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Nn)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(F);F.empty=new ol([]);var rd=(function(t){function e(n,o){t.call(this),this.left=n,this.right=o,this.length=n.length+o.length,this.depth=Math.max(n.depth,o.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,o,i,s){var r=this.left.length;if(o<r&&this.left.forEachInner(n,o,Math.min(i,r),s)===!1||i>r&&this.right.forEachInner(n,Math.max(o-r,0),Math.min(this.length,i)-r,s+r)===!1)return!1},e.prototype.forEachInvertedInner=function(n,o,i,s){var r=this.left.length;if(o>r&&this.right.forEachInvertedInner(n,o-r,Math.max(i,r)-r,s+r)===!1||i<r&&this.left.forEachInvertedInner(n,Math.min(o,r),i,s)===!1)return!1},e.prototype.sliceInner=function(n,o){if(n==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(n,o):n>=i?this.right.slice(n-i,o-i):this.left.slice(n,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(n){var o=this.right.leafAppend(n);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(n){var o=this.left.leafPrepend(n);if(o)return new e(o,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(F),il=F,ld=500,Je=class oe{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let i,s;n&&(i=this.remapping(o,this.items.length),s=i.maps.length);let r=e.tr,l,a,c=[],h=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(o,f+1),s=i.maps.length),s--,h.push(d);return}if(i){h.push(new St(d.map));let u=d.step.map(i.slice(s)),p;u&&r.maybeStep(u).doc&&(p=r.mapping.maps[r.mapping.maps.length-1],c.push(new St(p,void 0,void 0,c.length+h.length))),s--,p&&i.appendMap(p,s)}else r.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new oe(this.items.slice(0,o).append(h.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,n,o,i){let s=[],r=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let h=0;h<e.steps.length;h++){let d=e.steps[h].invert(e.docs[h]),f=new St(e.mapping.maps[h],d,n),u;(u=a&&a.merge(f))&&(f=u,h?s.pop():l=l.slice(0,l.length-1)),s.push(f),n&&(r++,n=void 0),i||(a=f)}let c=r-o.depth;return c>cd&&(l=ad(l,c),r-=c),new oe(l.append(s),r)}remapping(e,n){let o=new Ro;return this.items.forEach((i,s)=>{let r=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?o.maps.length-i.mirrorOffset:void 0;o.appendMap(i.map,r)},e,n),o}addMaps(e){return this.eventCount==0?this:new oe(this.items.append(e.map(n=>new St(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let o=[],i=this.items.length-n,s=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=n;this.items.forEach(f=>{let u=s.getMirror(--a);if(u==null)return;r=Math.min(r,u);let p=s.maps[u];if(f.step){let m=e.steps[u].invert(e.docs[u]),g=f.selection&&f.selection.map(s.slice(a+1,u));g&&l++,o.push(new St(p,m,g))}else o.push(new St(p))},i);let c=[];for(let f=n;f<r;f++)c.push(new St(s.maps[f]));let h=this.items.slice(0,i).append(c).append(o),d=new oe(h,l);return d.emptyItemCount()>ld&&(d=d.compress(this.items.length-o.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),o=n.maps.length,i=[],s=0;return this.items.forEach((r,l)=>{if(l>=e)i.push(r),r.selection&&s++;else if(r.step){let a=r.step.map(n.slice(o)),c=a&&a.getMap();if(o--,c&&n.appendMap(c,o),a){let h=r.selection&&r.selection.map(n.slice(o));h&&s++;let d=new St(c.invert(),a,h),f,u=i.length-1;(f=i.length&&i[u].merge(d))?i[u]=f:i.push(d)}}else r.map&&o--},this.items.length,0),new oe(il.from(i.reverse()),s)}};Je.empty=new Je(il.empty,0);function ad(t,e){let n;return t.forEach((o,i)=>{if(o.selection&&e--==0)return n=i,!1}),t.slice(n)}var St=class sl{constructor(e,n,o,i){this.map=e,this.step=n,this.selection=o,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new sl(n.getMap().invert(),n,this.selection)}}},Dt=class{constructor(t,e,n,o,i){this.done=t,this.undone=e,this.prevRanges=n,this.prevTime=o,this.prevComposition=i}},cd=20;function hd(t,e,n,o){let i=n.getMeta(ct),s;if(i)return i.historyState;n.getMeta(rl)&&(t=new Dt(t.done,t.undone,null,0,-1));let r=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(r&&r.getMeta(ct))return r.getMeta(ct).redo?new Dt(t.done.addTransform(n,void 0,o,vn(e)),t.undone,Ss(n.mapping.maps),t.prevTime,t.prevComposition):new Dt(t.done,t.undone.addTransform(n,void 0,o,vn(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!r&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-o.newGroupDelay||!dd(n,t.prevRanges)),c=r?Xn(t.prevRanges,n.mapping):Ss(n.mapping.maps);return new Dt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,o,vn(e)),Je.empty,c,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Dt(t.done.rebased(n,s),t.undone.rebased(n,s),Xn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Dt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Xn(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function dd(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((o,i)=>{for(let s=0;s<e.length;s+=2)o<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function Ss(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((o,i,s,r)=>e.push(s,r));return e}function Xn(t,e){if(!t)return null;let n=[];for(let o=0;o<t.length;o+=2){let i=e.map(t[o],1),s=e.map(t[o+1],-1);i<=s&&n.push(i,s)}return n}function pd(t,e,n){let o=vn(e),i=ct.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,o);if(!s)return null;let r=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,o),a=new Dt(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(r).setMeta(ct,{redo:n,historyState:a})}var to=!1,Os=null;function vn(t){let e=t.plugins;if(Os!=e){to=!1,Os=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){to=!0;break}}return to}function fd(t){return t.setMeta(rl,!0)}var ct=new Lo("history"),rl=new Lo("closeHistory");function ud(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new pe({key:ct,state:{init(){return new Dt(Je.empty,Je.empty,null,0,-1)},apply(e,n,o){return hd(n,o,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let o=n.inputType,i=o=="historyUndo"?ll:o=="historyRedo"?al:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Rn(t,e){return(n,o)=>{let i=ct.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(o){let s=pd(i,n,t);s&&o(e?s.scrollIntoView():s)}return!0}}var ll=Rn(!1,!0),al=Rn(!0,!0),md=Rn(!1,!1),gd=Rn(!0,!1);function yd(t){let e=ct.getState(t);return e?e.done.eventCount:0}function wd(t){let e=ct.getState(t);return e?e.undone.eventCount:0}function bd(t){return t.getMeta(ct)!=null}var vd={};pt(vd,{keydownHandler:()=>Qo,keymap:()=>Ad});var Rt={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:"'"},An={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},kd=typeof navigator<"u"&&/Mac/.test(navigator.platform),xd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for($=0;$<10;$++)Rt[48+$]=Rt[96+$]=String($);var $;for($=1;$<=24;$++)Rt[$+111]="F"+$;var $;for($=65;$<=90;$++)Rt[$]=String.fromCharCode($+32),An[$]=String.fromCharCode($);var $;for(fn in Rt)An.hasOwnProperty(fn)||(An[fn]=Rt[fn]);var fn;function Sd(t){var e=kd&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||xd&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?An:Rt)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}var Od=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Md=typeof navigator<"u"&&/Win/.test(navigator.platform);function Cd(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let o,i,s,r;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))o=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Od?r=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(n="Alt-"+n),i&&(n="Ctrl-"+n),r&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Nd(t){let e=Object.create(null);for(let n in t)e[Cd(n)]=t[n];return e}function eo(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Ad(t){return new pe({props:{handleKeyDown:Qo(t)}})}function Qo(t){let e=Nd(t);return function(n,o){let i=Sd(o),s,r=e[eo(i,o)];if(r&&r(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(o.shiftKey){let l=e[eo(i,o,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(Md&&o.ctrlKey&&o.altKey)&&(s=Rt[o.keyCode])&&s!=i){let l=e[eo(s,o)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Dd={};pt(Dd,{autoJoin:()=>Wd,baseKeymap:()=>Hd,chainCommands:()=>In,createParagraphNear:()=>wl,deleteSelection:()=>Zo,exitCode:()=>yl,joinBackward:()=>hl,joinDown:()=>Rd,joinForward:()=>ul,joinTextblockBackward:()=>Ed,joinTextblockForward:()=>Td,joinUp:()=>$d,lift:()=>Id,liftEmptyBlock:()=>bl,macBaseKeymap:()=>oi,newlineInCode:()=>gl,pcBaseKeymap:()=>lt,selectAll:()=>kl,selectNodeBackward:()=>pl,selectNodeForward:()=>ml,selectParentNode:()=>Bd,selectTextblockEnd:()=>Ml,selectTextblockStart:()=>Ol,setBlockType:()=>Fd,splitBlock:()=>ni,splitBlockAs:()=>vl,splitBlockKeepMarks:()=>Pd,toggleMark:()=>Jd,wrapIn:()=>Vd});var Zo=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function cl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}var hl=(t,e,n)=>{let o=cl(t,n);if(!o)return!1;let i=Xo(o);if(!i){let r=o.blockRange(),l=r&&We(r);return l==null?!1:(e&&e(t.tr.lift(r,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(xl(t,i,e,-1))return!0;if(o.parent.content.size==0&&(ce(s,"end")||O.isSelectable(s)))for(let r=o.depth;;r--){let l=Ke(t.doc,o.before(r),o.after(r),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(ce(s,"end")?C.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):O.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||o.node(r-1).childCount>1)break}return s.isAtom&&i.depth==o.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Ed=(t,e,n)=>{let o=cl(t,n);if(!o)return!1;let i=Xo(o);return i?dl(t,i,e):!1},Td=(t,e,n)=>{let o=fl(t,n);if(!o)return!1;let i=ti(o);return i?dl(t,i,e):!1};function dl(t,e,n){let o=e.nodeBefore,i=o,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let r=e.nodeAfter,l=r,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let h=l.firstChild;if(!h)return!1;l=h}let c=Ke(t.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof ot&&c.slice.size>=a-s)return!1;if(n){let h=t.tr.step(c);h.setSelection(A.create(h.doc,s)),n(h.scrollIntoView())}return!0}function ce(t,e,n=!1){for(let o=t;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&o.childCount!=1)return!1}return!1}var pl=(t,e,n)=>{let{$head:o,empty:i}=t.selection,s=o;if(!i)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):o.parentOffset>0)return!1;s=Xo(o)}let r=s&&s.nodeBefore;return!r||!O.isSelectable(r)?!1:(e&&e(t.tr.setSelection(O.create(t.doc,s.pos-r.nodeSize)).scrollIntoView()),!0)};function Xo(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function fl(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}var ul=(t,e,n)=>{let o=fl(t,n);if(!o)return!1;let i=ti(o);if(!i)return!1;let s=i.nodeAfter;if(xl(t,i,e,1))return!0;if(o.parent.content.size==0&&(ce(s,"start")||O.isSelectable(s))){let r=Ke(t.doc,o.before(),o.after(),k.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=t.tr.step(r);l.setSelection(ce(s,"start")?C.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):O.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==o.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},ml=(t,e,n)=>{let{$head:o,empty:i}=t.selection,s=o;if(!i)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):o.parentOffset<o.parent.content.size)return!1;s=ti(o)}let r=s&&s.nodeAfter;return!r||!O.isSelectable(r)?!1:(e&&e(t.tr.setSelection(O.create(t.doc,s.pos)).scrollIntoView()),!0)};function ti(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}var $d=(t,e)=>{let n=t.selection,o=n instanceof O,i;if(o){if(n.node.isTextblock||!Ut(t.doc,n.from))return!1;i=n.from}else if(i=zo(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);o&&s.setSelection(O.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Rd=(t,e)=>{let n=t.selection,o;if(n instanceof O){if(n.node.isTextblock||!Ut(t.doc,n.to))return!1;o=n.to}else if(o=zo(t.doc,n.to,1),o==null)return!1;return e&&e(t.tr.join(o).scrollIntoView()),!0},Id=(t,e)=>{let{$from:n,$to:o}=t.selection,i=n.blockRange(o),s=i&&We(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},gl=(t,e)=>{let{$head:n,$anchor:o}=t.selection;return!n.parent.type.spec.code||!n.sameParent(o)?!1:(e&&e(t.tr.insertText(`
10
+ `).scrollIntoView()),!0)};function ei(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var yl=(t,e)=>{let{$head:n,$anchor:o}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let i=n.node(-1),s=n.indexAfter(-1),r=ei(i.contentMatchAt(s));if(!r||!i.canReplaceWith(s,s,r))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,r.createAndFill());a.setSelection(C.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},wl=(t,e)=>{let n=t.selection,{$from:o,$to:i}=n;if(n instanceof at||o.parent.inlineContent||i.parent.inlineContent)return!1;let s=ei(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let r=(!o.parentOffset&&i.index()<i.parent.childCount?o:i).pos,l=t.tr.insert(r,s.createAndFill());l.setSelection(A.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},bl=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(Te(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let o=n.blockRange(),i=o&&We(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)};function vl(t){return(e,n)=>{if(e.selection instanceof O&&e.selection.node.isBlock){let{$from:u}=e.selection;return!u.parentOffset||!Te(e.doc,u.pos)?!1:(n&&n(e.tr.split(u.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let o=e.tr;!e.selection.empty&&(e.selection instanceof A||e.selection instanceof at)&&o.deleteSelection();let{$from:i}=o.selection,s=o.steps.length,r=[],l,a,c=!1,h=!1;for(let u=i.depth;;u--)if(i.node(u).isBlock){c=i.end(u)==i.pos+(i.depth-u),h=i.start(u)==i.pos-(i.depth-u),a=ei(i.node(u-1).contentMatchAt(i.indexAfter(u-1)));let p=t&&t(i.parent,c,i);r.unshift(p||(c&&a?{type:a}:null)),l=u;break}else{if(u==1)return!1;r.unshift(null)}let d=i.pos,f=Te(o.doc,d,r.length,r);if(f||(r[0]=a?{type:a}:null,f=Te(o.doc,d,r.length,r)),!f)return!1;if(o.split(d,r.length,r),!c&&h&&i.node(l).type!=a){let u=o.mapping.slice(s),p=u.map(i.before(l)),m=o.doc.resolve(p);a&&i.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&o.setNodeMarkup(u.map(i.before(l)),a)}return n&&n(o.scrollIntoView()),!0}}var ni=vl(),Pd=(t,e)=>ni(t,e&&(n=>{let o=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();o&&n.ensureMarks(o),e(n)})),Bd=(t,e)=>{let{$from:n,to:o}=t.selection,i,s=n.sharedDepth(o);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(O.create(t.doc,i))),!0)},kl=(t,e)=>(e&&e(t.tr.setSelection(new at(t.doc))),!0);function zd(t,e,n){let o=e.nodeBefore,i=e.nodeAfter,s=e.index();return!o||!i||!o.type.compatibleContent(i.type)?!1:!o.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Ut(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function xl(t,e,n,o){let i=e.nodeBefore,s=e.nodeAfter,r,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&zd(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(r[0]||s.type).validEnd){if(n){let u=e.pos+s.nodeSize,p=v.empty;for(let b=r.length-1;b>=0;b--)p=v.from(r[b].create(null,p));p=v.from(i.copy(p));let m=t.tr.step(new ht(e.pos-1,u,e.pos,u,new k(p,1,0),r.length,!0)),g=m.doc.resolve(u+2*r.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ut(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let h=s.type.spec.isolating||o>0&&a?null:C.findFrom(e,1),d=h&&h.$from.blockRange(h.$to),f=d&&We(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&ce(s,"start",!0)&&ce(i,"end")){let u=i,p=[];for(;p.push(u),!u.isTextblock;)u=u.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(u.canReplace(u.childCount,u.childCount,m.content)){if(n){let b=v.empty;for(let w=p.length-1;w>=0;w--)b=v.from(p[w].copy(b));let y=t.tr.step(new ht(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new k(b,p.length,0),0,!0));n(y.scrollIntoView())}return!0}}return!1}function Sl(t){return function(e,n){let o=e.selection,i=t<0?o.$from:o.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(A.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}var Ol=Sl(-1),Ml=Sl(1);function Vd(t,e=null){return function(n,o){let{$from:i,$to:s}=n.selection,r=i.blockRange(s),l=r&&Bo(r,t,e);return l?(o&&o(n.tr.wrap(r,l).scrollIntoView()),!0):!1}}function Fd(t,e=null){return function(n,o){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:r},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(r,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let h=n.doc.resolve(c),d=h.index();i=h.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(o){let s=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[r];s.setBlockType(l,a,t,e)}o(s.scrollIntoView())}return!0}}function jd(t,e,n,o){for(let i=0;i<e.length;i++){let{$from:s,$to:r}=e[i],l=s.depth==0?t.inlineContent&&t.type.allowsMarkType(n):!1;if(t.nodesBetween(s.pos,r.pos,(a,c)=>{if(l||!o&&a.isAtom&&a.isInline&&c>=s.pos&&c+a.nodeSize<=r.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(n)}),l)return!0}return!1}function Ld(t){let e=[];for(let n=0;n<t.length;n++){let{$from:o,$to:i}=t[n];o.doc.nodesBetween(o.pos,i.pos,(s,r)=>{if(s.isAtom&&s.content.size&&s.isInline&&r>=o.pos&&r+s.nodeSize<=i.pos)return r+1>o.pos&&e.push(new On(o,o.doc.resolve(r+1))),o=o.doc.resolve(r+1+s.content.size),!1}),o.pos<i.pos&&e.push(new On(o,i))}return e}function Jd(t,e=null,n){let o=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,s=!(n&&n.includeWhitespace);return function(r,l){let{empty:a,$cursor:c,ranges:h}=r.selection;if(a&&!c||!jd(r.doc,h,t,i))return!1;if(l)if(c)t.isInSet(r.storedMarks||c.marks())?l(r.tr.removeStoredMark(t)):l(r.tr.addStoredMark(t.create(e)));else{let d,f=r.tr;i||(h=Ld(h)),o?d=!h.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,t)):d=!h.every(u=>{let p=!1;return f.doc.nodesBetween(u.$from.pos,u.$to.pos,(m,g,b)=>{if(p)return!1;p=!t.isInSet(m.marks)&&!!b&&b.type.allowsMarkType(t)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,u.$from.pos-g),Math.min(m.nodeSize,u.$to.pos-g))))}),!p});for(let u=0;u<h.length;u++){let{$from:p,$to:m}=h[u];if(!d)f.removeMark(p.pos,m.pos,t);else{let g=p.pos,b=m.pos,y=p.nodeAfter,w=m.nodeBefore,S=s&&y&&y.isText?/^\s*/.exec(y.text)[0].length:0,T=s&&w&&w.isText?/\s*$/.exec(w.text)[0].length:0;g+S<b&&(g+=S,b-=T),f.addMark(g,b,t.create(e))}}l(f.scrollIntoView())}return!0}}function qd(t,e){return n=>{if(!n.isGeneric)return t(n);let o=[];for(let s=0;s<n.mapping.maps.length;s++){let r=n.mapping.maps[s];for(let l=0;l<o.length;l++)o[l]=r.map(o[l]);r.forEach((l,a,c,h)=>o.push(c,h))}let i=[];for(let s=0;s<o.length;s+=2){let r=o[s],l=o[s+1],a=n.doc.resolve(r),c=a.sharedDepth(l),h=a.node(c);for(let d=a.indexAfter(c),f=a.after(c+1);f<=l;++d){let u=h.maybeChild(d);if(!u)break;if(d&&i.indexOf(f)==-1){let p=h.child(d-1);p.type==u.type&&e(p,u)&&i.push(f)}f+=u.nodeSize}}i.sort((s,r)=>s-r);for(let s=i.length-1;s>=0;s--)Ut(n.doc,i[s])&&n.join(i[s]);t(n)}}function Wd(t,e){let n=Array.isArray(e)?o=>e.indexOf(o.type.name)>-1:e;return(o,i,s)=>t(o,i&&qd(i,n),s)}function In(...t){return function(e,n,o){for(let i=0;i<t.length;i++)if(t[i](e,n,o))return!0;return!1}}var no=In(Zo,hl,pl),Ms=In(Zo,ul,ml),lt={Enter:In(gl,wl,bl,ni),"Mod-Enter":yl,Backspace:no,"Mod-Backspace":no,"Shift-Backspace":no,Delete:Ms,"Mod-Delete":Ms,"Mod-a":kl},oi={"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":Ol,"Ctrl-e":Ml};for(let t in lt)oi[t]=lt[t];var Kd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Hd=Kd?oi:lt,Ud={};pt(Ud,{InputRule:()=>kt,closeDoubleQuote:()=>Nl,closeSingleQuote:()=>Dl,ellipsis:()=>Xd,emDash:()=>Zd,inputRules:()=>Yd,openDoubleQuote:()=>Cl,openSingleQuote:()=>Al,smartQuotes:()=>tp,textblockTypeInputRule:()=>np,undoInputRule:()=>Qd,wrappingInputRule:()=>ep});var kt=class{constructor(t,e,n={}){this.match=t,this.match=t,this.handler=typeof e=="string"?Gd(e):e,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function Gd(t){return function(e,n,o,i){let s=t;if(n[1]){let r=n[0].lastIndexOf(n[1]);s+=n[0].slice(r+n[1].length),o+=r;let l=o-i;l>0&&(s=n[0].slice(r-l,r)+s,o=i)}return e.tr.insertText(s,o,i)}}var _d=500;function Yd({rules:t}){let e=new pe({state:{init(){return null},apply(n,o){return n.getMeta(this)||(n.selectionSet||n.docChanged?null:o)}},props:{handleTextInput(n,o,i,s){return Cs(n,o,i,s,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:o}=n.state.selection;o&&Cs(n,o.pos,o.pos,"",t,e)})}}},isInputRules:!0});return e}function Cs(t,e,n,o,i,s){if(t.composing)return!1;let r=t.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-_d),l.parentOffset,null,"\uFFFC")+o;for(let c=0;c<i.length;c++){let h=i[c];if(!h.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only")continue;let d=h.match.exec(a);if(!d||d[0].length<o.length)continue;let f=e-(d[0].length-o.length);if(!h.inCodeMark){let p=!1;if(r.doc.nodesBetween(f,l.pos,m=>{m.isInline&&m.marks.some(g=>g.type.spec.code)&&(p=!0)}),p)continue}let u=h.handler(r,d,f,n);if(u)return h.undoable&&u.setMeta(s,{transform:u,from:e,to:n,text:o}),t.dispatch(u),!0}return!1}var Qd=(t,e)=>{let n=t.plugins;for(let o=0;o<n.length;o++){let i=n[o],s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){let r=t.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)r.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=r.doc.resolve(s.from).marks();r.replaceWith(s.from,s.to,t.schema.text(s.text,a))}else r.delete(s.from,s.to);e(r)}return!0}}return!1},Zd=new kt(/--$/,"\u2014",{inCodeMark:!1}),Xd=new kt(/\.\.\.$/,"\u2026",{inCodeMark:!1}),Cl=new kt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),Nl=new kt(/"$/,"\u201D",{inCodeMark:!1}),Al=new kt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),Dl=new kt(/'$/,"\u2019",{inCodeMark:!1}),tp=[Cl,Nl,Al,Dl];function ep(t,e,n=null,o){return new kt(t,(i,s,r,l)=>{let a=n instanceof Function?n(s):n,c=i.tr.delete(r,l),h=c.doc.resolve(r),d=h.blockRange(),f=d&&Bo(d,e,a);if(!f)return null;c.wrap(d,f);let u=c.doc.resolve(r-1).nodeBefore;return u&&u.type==e&&Ut(c.doc,r-1)&&(!o||o(s,u))&&c.join(r-1),c})}function np(t,e,n=null){return new kt(t,(o,i,s,r)=>{let l=o.doc.resolve(s),a=n instanceof Function?n(i):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?o.tr.delete(s,r).setBlockType(s,s,e,a):null})}var op={};pt(op,{dropCursor:()=>ip});function ip(t={}){return new pe({view(e){return new sp(e,t)}})}var sp=class{constructor(t,e){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(n=e.width)!==null&&n!==void 0?n:1,this.color=e.color===!1?void 0:e.color||"black",this.class=e.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return t.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:t,handler:e})=>this.editorView.dom.removeEventListener(t,e))}update(t,e){if(this.cursorPos!=null&&e.doc!=t.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),e=!t.parent.inlineContent,n,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,r=i.height/o.offsetHeight;if(e){let h=t.nodeBefore,d=t.nodeAfter;if(h||d){let f=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(f){let u=f.getBoundingClientRect(),p=h?u.bottom:u.top;h&&d&&(p=(p+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*r;n={left:u.left,right:u.right,top:p-m,bottom:p+m}}}}if(!n){let h=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*s;n={left:h.left-d,right:h.left+d,top:h.top,bottom:h.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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",e),this.element.classList.toggle("prosemirror-dropcursor-inline",!e);let a,c;if(!l||l==document.body&&getComputedStyle(l).position=="static")a=-pageXOffset,c=-pageYOffset;else{let h=l.getBoundingClientRect(),d=h.width/l.offsetWidth,f=h.height/l.offsetHeight;a=h.left-l.scrollLeft*d,c=h.top-l.scrollTop*f}this.element.style.left=(n.left-a)/s+"px",this.element.style.top=(n.top-c)/r+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/r+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}computeTarget(t){let e=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=e&&e.inside>=0&&this.editorView.state.doc.nodeAt(e.inside),o=n&&n.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,e,t):o;if(!e||i)return null;let s=e.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let r=Vo(this.editorView.state.doc,s,this.editorView.dragging.slice);r!=null&&(s=r)}return s}dragover(t){if(!this.editorView.editable)return;this.lastDragEvent=t;let e=this.computeTarget(t);e!=null&&(this.setCursor(e),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}},rp={};pt(rp,{GapCursor:()=>Q,gapCursor:()=>hp});var Q=class Nt extends C{constructor(e){super(e,e)}map(e,n){let o=e.resolve(n.map(this.head));return Nt.valid(o)?new Nt(o):C.near(o)}content(){return k.empty}eq(e){return e instanceof Nt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Nt(e.resolve(n.pos))}getBookmark(){return new lp(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!ap(e)||!cp(e))return!1;let o=n.type.spec.allowGapCursor;if(o!=null)return o;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,o=!1){t:for(;;){if(!o&&Nt.valid(e))return e;let i=e.pos,s=null;for(let r=e.depth;;r--){let l=e.node(r);if(n>0?e.indexAfter(r)<l.childCount:e.index(r)>0){s=l.child(n>0?e.indexAfter(r):e.index(r)-1);break}else if(r==0)return null;i+=n;let a=e.doc.resolve(i);if(Nt.valid(a))return a}for(;;){let r=n>0?s.firstChild:s.lastChild;if(!r){if(s.isAtom&&!s.isText&&!O.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),o=!1;continue t}break}s=r,i+=n;let l=e.doc.resolve(i);if(Nt.valid(l))return l}return null}}};Q.prototype.visible=!1;Q.findFrom=Q.findGapCursorFrom;C.jsonID("gapcursor",Q);var lp=class El{constructor(e){this.pos=e}map(e){return new El(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Q.valid(n)?new Q(n):C.near(n)}};function Tl(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function ap(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),o=t.node(e);if(n==0){if(o.type.spec.isolating)return!0;continue}for(let i=o.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Tl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function cp(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),o=t.node(e);if(n==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let i=o.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Tl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function hp(){return new pe({props:{decorations:up,createSelectionBetween(t,e,n){return e.pos==n.pos&&Q.valid(n)?new Q(n):null},handleClick:pp,handleKeyDown:dp,handleDOMEvents:{beforeinput:fp}}})}var dp=Qo({ArrowLeft:un("horiz",-1),ArrowRight:un("horiz",1),ArrowUp:un("vert",-1),ArrowDown:un("vert",1)});function un(t,e){let n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,i,s){let r=o.selection,l=e>0?r.$to:r.$from,a=r.empty;if(r instanceof A){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=o.doc.resolve(e>0?l.after():l.before())}let c=Q.findGapCursorFrom(l,e,a);return c?(i&&i(o.tr.setSelection(new Q(c))),!0):!1}}function pp(t,e,n){if(!t||!t.editable)return!1;let o=t.state.doc.resolve(e);if(!Q.valid(o))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&O.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Q(o))),!0)}function fp(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Q))return!1;let{$from:n}=t.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!o)return!1;let i=v.empty;for(let r=o.length-1;r>=0;r--)i=v.from(o[r].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new k(i,0,0));return s.setSelection(A.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function up(t){if(!(t.selection instanceof Q))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",nt.create(t.doc,[Pt.widget(t.selection.head,e,{key:"gapcursor"})])}var mp=/^(https?:|mailto:|tel:)/i;function Pn(t){let e=String(t??"").trim().replace(/[\u0000-\u001f\u007f]/g,"");return e?e.startsWith("#")||e.startsWith("/")&&!e.startsWith("//")||mp.test(e)?e:/^[a-z][a-z0-9+.-]*:/i.test(e)?null:/^(\/\/)?[\w-]+(\.[\w-]+)+(:\d+)?([/?#]\S*)?$/.test(e)?`https://${e.replace(/^\/\//,"")}`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?`mailto:${e}`:null:null}var eu=t=>t&&/^data:image\/(png|jpeg|gif|webp);/i.test(t)&&t.length<=21e5?t:Pn(t);function ii(t){if(typeof t!="string")return null;let e=Pn(t);return e&&/^(https?:|\/(?!\/))/i.test(e)?e:null}var U={id:{default:null},pos:{default:null},parent:{default:null}},L=(t,e={})=>({"data-id":t.attrs.id,...e}),si=new ft.Schema({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:U,toDOM:t=>["p",L(t),0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{...U,level:{default:2}},toDOM:t=>[`h${t.attrs.level}`,L(t),0]},list_item:{group:"block",content:"inline*",attrs:{...U,kind:{default:"bullet"},indent:{default:0},checked:{default:!1},owner:{default:null},due:{default:null}},toDOM:t=>["div",L(t,{class:"page-li","data-kind":t.attrs.kind,"data-indent":String(t.attrs.indent),"data-checked":t.attrs.checked?"true":"false"}),0]},quote:{group:"block",content:"inline*",attrs:U,toDOM:t=>["blockquote",L(t),0]},callout:{group:"block",content:"inline*",attrs:U,toDOM:t=>["aside",L(t,{class:"page-callout"}),0]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{...U,lang:{default:""}},toDOM:t=>["pre",L(t,{"data-lang":t.attrs.lang}),["code",0]]},toggle:{group:"block",content:"inline*",attrs:{...U,open:{default:!1}},toDOM:t=>["div",L(t,{class:"page-toggle","data-open":t.attrs.open?"true":"false"}),0]},divider:{group:"block",atom:!0,attrs:U,toDOM:t=>["hr",L(t)]},image:{group:"block",atom:!0,draggable:!0,attrs:{...U,src:{default:""},alt:{default:""},caption:{default:""},width:{default:null},align:{default:null}},toDOM:t=>["figure",L(t,{"data-type":"image",...t.attrs.width?{"data-width":String(t.attrs.width)}:{},...t.attrs.align?{"data-align":t.attrs.align}:{}}),["img",{src:t.attrs.src,alt:t.attrs.alt}],["figcaption",t.attrs.caption]]},file:{group:"block",atom:!0,attrs:{...U,src:{default:""},name:{default:""},size:{default:null},mime:{default:null}},toDOM:t=>["div",L(t,{class:"page-file","data-type":"file","data-src":ii(t.attrs.src)??"","data-name":t.attrs.name,"data-size":t.attrs.size==null?"":String(t.attrs.size),"data-mime":t.attrs.mime??""}),["a",{href:ii(t.attrs.src),target:"_blank",rel:"noopener noreferrer"},t.attrs.name||"file"]]},table:{group:"block",content:"table_row+",isolating:!0,attrs:{...U,cols:{default:{}},sort:{default:null}},toDOM:t=>["table",L(t),["tbody",0]]},table_row:{content:"table_cell+",attrs:{id:{default:null},pos:{default:null}},toDOM:t=>["tr",L(t),0]},table_cell:{content:"inline*",isolating:!0,attrs:{col:{default:null}},toDOM:t=>["td",{"data-col":t.attrs.col},0]},chart:{group:"block",atom:!0,attrs:{...U,source:{default:null},kind:{default:"line"},x:{default:null},series:{default:[]},title:{default:""},highlight:{default:null}},toDOM:t=>["figure",L(t,{"data-type":"chart"})]},board:{group:"block",atom:!0,attrs:{...U,columns:{default:{}},cards:{default:{}}},toDOM:t=>["section",L(t,{"data-type":"board"})]},tool:{group:"block",atom:!0,attrs:{...U,artifact:{default:null},rev:{default:null},state:{default:{}}},toDOM:t=>["section",L(t,{"data-type":"tool"})]},preserved:{group:"block",atom:!0,attrs:{...U,html:{default:""}},toDOM:t=>["div",L(t,{"data-type":"preserved"})]},opaque_block:{group:"block",content:"inline*",atom:!0,isolating:!0,selectable:!0,attrs:{...U,raw:{default:null}},toDOM:t=>["div",L(t,{"data-type":"newer-format","data-format":String(t.attrs.raw?.t??""),contenteditable:"false"}),["span",{class:"page-newer-format"},`Newer format: ${String(t.attrs.raw?.t??"")}`],["span",{class:"page-newer-format-text"},t.textContent]]},text:{group:"inline"},hard_break:{group:"inline",inline:!0,selectable:!1,toDOM:()=>["br"]}},marks:{strong:{toDOM:()=>["strong",0]},em:{toDOM:()=>["em",0]},strike:{toDOM:()=>["s",0]},code:{toDOM:()=>["code",0]},link:{attrs:{href:{}},inclusive:!1,toDOM:t=>["a",{href:Pn(t.attrs.href)},0]},mention:{attrs:{id:{}},inclusive:!1,excludes:"mention date link",toDOM:t=>["span",{"data-page-mention":t.attrs.id},0]},date:{attrs:{date:{}},inclusive:!1,excludes:"mention date link",toDOM:t=>["time",{datetime:t.attrs.date,"data-page-date":""},0]},underline:{toDOM:()=>["u",0]},text_color:{attrs:{color:{}},toDOM:t=>["span",{"data-color":t.attrs.color},0]},highlight:{attrs:{color:{}},toDOM:t=>["mark",{"data-color":t.attrs.color},0]}}});var ru=new Set(["underline","text_color","highlight"]),gp=["gray","brown","orange","yellow","green","blue","purple","pink","red"],yp=new Set(gp);function Ye(t,e){let n=e!==null&&typeof e=="object"&&!Array.isArray(e);if(t==="underline")return n&&Object.keys(e).length===0?{}:null;if(t==="text_color"||t==="highlight"){let o=n?Object.keys(e):[];return o.length===1&&o[0]==="color"&&yp.has(e.color)?{color:e.color}:null}return null}function lu(t,e){let{$from:n,$to:o,empty:i}=t.selection;if(i)return n.parent.type.allowsMarkType(e);let s=!1;return t.doc.nodesBetween(n.pos,o.pos,(r,l,a)=>{!s&&r.isText&&a?.type.allowsMarkType(e)&&(s=!0)}),s}var wp='@{"type":"hard_break"}';function xt(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t===null||typeof t!="object"||typeof t.c!="string")return"";let e=[];for(let o of Array.isArray(t.m)?t.m:[])if(!Array.isArray(o))e.push(o);else for(let i=0;i<o[0]&&e.length<t.c.length;i++)e.push(o[1]);let n="";for(let o=0;o<t.c.length;o++)n+=t.c[o]==="\uFFFC"&&e[o]===wp?`
11
+ `:t.c[o];return n}var Bl="opaque_marks",Gt="clay_opaque_code",zl="x",Vl=/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/,$l=32,Rl=1e4,bp=/[A-Za-z]/,Qe=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),ri=t=>t===null||typeof t!="object"?t:JSON.parse(JSON.stringify(t));function Bn(t){let e=0,n=(o,i)=>{if(i>$l)throw new RangeError(`page: inline JSON is deeper than ${$l}`);if(!(o===null||typeof o!="object")){if(Array.isArray(o)){for(let s of o)n(s,i+1);return}for(let s of Object.keys(o)){if(++e>Rl)throw new RangeError(`page: inline JSON has more than ${Rl} keys`);n(o[s],i+1)}}};return n(t,1),t}function vp(t,e){let n=0,o=!1;for(;e<t.length;e++){let i=t[e];if(o)i==="\\"?e++:i==='"'&&(o=!1);else if(i==='"')o=!0;else if(i==="[")n++;else if(i==="]"&&--n===0)return e+1}throw new SyntaxError(`page: unterminated attrs in mark key ${t}`)}var Il=t=>new SyntaxError(`page: malformed mark key ${t}`);function Ze(t){if(typeof t!="string")throw new TypeError("page: a mark key is not a string");let e=[];for(let n=0;n<t.length;){let o=t[n];if(!bp.test(o))throw Il(t);let i=n+1,s=null;if(t[i]==="["&&(i=vp(t,i),s=Bn(JSON.parse(t.slice(n+1,i))),!Array.isArray(s)))throw Il(t);if(o!==zl)e.push({code:o,attrs:s,token:t.slice(n,i)});else{if(!s||s.length!==2||typeof s[0]!="string"||!Vl.test(s[0])||!Qe(s[1]))throw new SyntaxError(`page: the named mark in ${t} is not [name, attrs]`);if(s[0]===Gt)throw new SyntaxError(`page: ${Gt} is reserved`);e.push({name:s[0],attrs:ri(s[1])})}n=i}return e}var kp=(t,e)=>{if(t.name!==e.name)return t.name<e.name?-1:1;let n=JSON.stringify(t.attrs),o=JSON.stringify(e.attrs);return n===o?0:n<o?-1:1};function fe(t){let e=[],n=[],o=new Set;for(let i of t)if(i.name===void 0){if(o.has(i.token))throw new TypeError(`page: duplicate mark descriptor ${i.token}`);o.add(i.token),n.push(i.token)}else{let s=JSON.stringify([i.name,i.attrs]);if(o.has(s))throw new TypeError(`page: duplicate mark descriptor ${s}`);o.add(s),e.push({name:i.name,attrs:ri(i.attrs)})}return e.sort(kp),n.length?[...e,{tokens:n}]:e}function Bt(t){if(!Array.isArray(t))throw new TypeError("page: opaque entries are not a list");let e=[];for(let n of t){if(!Qe(n))throw new TypeError("page: an opaque entry is not an object");if(n.tokens!==void 0){if(Object.keys(n).length!==1||!Array.isArray(n.tokens))throw new TypeError("page: an opaque entry is not { tokens: [...] }");for(let o of n.tokens){let i=Ze(o);if(i.length!==1||i[0].name!==void 0)throw new SyntaxError(`page: malformed mark token ${o}`);e.push(i[0])}}else{if(Object.keys(n).length!==2||typeof n.name!="string"||!Vl.test(n.name)||!Qe(n.attrs))throw new TypeError("page: an opaque entry is not { name, attrs }");if(n.name===Gt)throw new SyntaxError(`page: ${Gt} is reserved`);e.push({name:n.name,attrs:Bn(n.attrs)})}}return fe(e)}function Xe(t){let e="";for(let n of Bt(t))n.tokens?e+=n.tokens.join(""):e+=zl+JSON.stringify([n.name,n.attrs]);return e}var xp=(()=>{let t=new ft.MarkType(Bl,Object.keys(si.marks).length,si,{attrs:{entries:{default:[]}},inclusive:!1,excludes:"",toDOM:()=>["span",0]});return t.excluded=[],t})(),Fl=t=>t.type.name===Bl,jl=t=>xp.create({entries:Bt(t)});function pu(t){let e=Object.create(null);for(let n of Bt(t))n.tokens?e[Gt]={tokens:[...n.tokens]}:e[n.name]=ri(n.attrs);return e}var Sp=t=>t.split("!")[0].split("~")[0],Pl=t=>t.includes("!");function fu(t){let e=new Set;for(let o of Object.keys(t))Pl(o)&&t[o]&&e.add(o.split("!")[0]);let n=[];for(let[o,i]of Object.entries(t)){if(i==null||Pl(o)||e.has(o))continue;let s=Sp(o);if(s===Gt){if(!Qe(i)||Object.keys(i).length!==1||!Array.isArray(i.tokens))throw new TypeError(`page: ${Gt} is not { tokens: [...] }`);n.push({tokens:i.tokens})}else n.push({name:s,attrs:Qe(i)?i:{}})}return Bt(n)}var li="\uFFFC",ql={strong:"b",em:"i",strike:"s",code:"c",link:"a"},Wl=new Set(["underline","text_color","highlight"]),Op=Object.fromEntries(Object.entries(ql).map(([t,e])=>[e,t]));function Mp(t){let e="",n=[];for(let o of t){if(Fl(o)){e+=Xe(o.attrs.entries);continue}let i=ql[o.type.name];if(!i){let r=Ye(o.type.name,o.attrs);if(!r&&Wl.has(o.type.name))throw new TypeError(`page: the mark ${o.type.name} has no key code`);n.push({name:o.type.name,attrs:r??o.attrs});continue}e+=i;let s=Object.keys(o.type.attrs);s.length&&(e+=JSON.stringify(s.map(r=>o.attrs[r])))}return n.length?e+Xe(n):e}var Ll=new WeakMap;function Cp(t,e){if(!e)return ft.Mark.none;let n=Ll.get(t);n||Ll.set(t,n=new Map);let o=n.get(e);if(o)return o;o=[];let i=[];for(let s of Ze(e)){if(s.code===void 0){let c=Ye(s.name,s.attrs),h=t.marks[s.name];c?o=h.create(c).addToSet(o):h&&!Wl.has(s.name)&&Object.keys(s.attrs??{}).every(d=>Object.hasOwn(h.attrs,d))?o=h.create(s.attrs).addToSet(o):i.push(s);continue}let r=Op[s.code];if(!r){i.push(s);continue}let l=t.marks[r];if(!l)throw new TypeError(`page: unknown mark code ${s.code} in ${e}`);let a=s.attrs?Object.fromEntries(Object.keys(l.attrs).map((c,h)=>[c,s.attrs[h]])):null;o=l.create(a).addToSet(o)}return i.length&&(o=jl(fe(i)).addToSet(o)),n.set(e,o),o}function ai(t){let e="",n=[];return t.forEach(o=>{if(o.isText){let i=Mp(o.marks);e+=o.text;for(let s=0;s<o.text.length;s++)n.push(i)}else e+=li,n.push("@"+JSON.stringify(o.toJSON()))}),{c:e,m:n}}function Kl(t){let e=[];for(let n of t){let o=e[e.length-1];o&&o[1]===n?o[0]++:e.push([1,n])}return e}var Np=t=>Array.isArray(t)&&Array.isArray(t[0]);function ci(t,e){if(!Np(t))return t;let n=[];for(let o of t){if(!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<1||typeof o[1]!="string"||n.length+o[0]>e)return null;for(let i=0;i<o[0];i++)n.push(o[1])}return n.length===e?n:null}var Ap=t=>t>=55296&&t<=56319,Jl=t=>t&&t[0]!=="@"?t:"";function hi(t,e,n,o=null){let i=[],s=r=>o?r.filter(l=>o.allowsMarkType(l.type)):r;for(let r=0;r<e.length;){let l=n&&n[r]||"";if(e[r]===li&&l[0]==="@"){i.push(ft.Node.fromJSON(t,JSON.parse(l.slice(1)))),r++;continue}let a=Jl(l),c=r+1;for(;c<e.length&&!(e[c]===li&&(n&&n[c]||"")[0]==="@")&&Jl(n&&n[c]||"")===a;)c++;c<e.length&&Ap(e.charCodeAt(c-1))&&c++,i.push(t.text(e.slice(r,c),s(Cp(t,a)))),r=c}return i}var Dp="clay-page-remote",tn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Ep=/^[0-9A-Za-z]*[1-9A-Za-z]$/,en=t=>typeof t=="string"&&Ep.test(t);function di(t,e){if(e!==null){let i=0;for(;(t[i]||"0")===e[i];)i++;if(i>0)return e.slice(0,i)+di(t.slice(i),e.slice(i))}let n=t?tn.indexOf(t[0]):0,o=e!==null?tn.indexOf(e[0]):tn.length;return o-n>1?tn[Math.round((n+o)/2)]:e!==null&&e.length>1?e.slice(0,1):tn[n]+di(t.slice(1),null)}function Hl(t=null,e=null){if(t!==null&&!en(t))throw new TypeError(`page: invalid order key ${t}`);if(e!==null&&!en(e))throw new TypeError(`page: invalid order key ${e}`);if(t!==null&&e!==null&&t>=e)throw new RangeError(`page: order key ${t} is not before ${e}`);return di(t??"",e)}function ue(t,e,n){if(n<=0)return[];if(n===1)return[Hl(t,e)];let o=Hl(t,e),i=Math.floor(n/2);return[...ue(t,o,i),o,...ue(o,e,n-i-1)]}function pi(t){return Object.keys(t).sort((e,n)=>{let o=t[e].pos??"",i=t[n].pos??"";return o!==i?o<i?-1:1:e<n?-1:e>n?1:0})}function Tp(t="b"){let e=new Uint8Array(4);return globalThis.crypto.getRandomValues(e),`${t}-${Date.now().toString(36)}${Array.from(e,n=>(n%36).toString(36)).join("")}`}var $p=new Set(["id","pos"]),Rp=(t,e)=>JSON.stringify(t)===JSON.stringify(e),Ip=t=>t===null||typeof t!="object"?t:JSON.parse(JSON.stringify(t));function Pp(t){let e={};for(let[n,o]of Object.entries(t.type.spec.attrs||{}))$p.has(n)||Rp(t.attrs[n],o.default)||(e[n]=Ip(t.attrs[n]));return e}function Bp(t){let{c:e,m:n}=ai(t.content);return n.some(Boolean)?{c:e,m:Kl(n)}:e}function zp(t,e){if(e!==null&&typeof e=="object"&&typeof e.c=="string"){let o=ci(e.m,e.c.length);if(o)return hi(t,e.c,o,t.nodes.table_cell)}let n=xt(e);return n?t.text(n):null}function Vp(t){let e={t:t.type.name,pos:t.attrs.pos,...Pp(t)};if(t.type.name==="table"){let n={};t.forEach(o=>{let i={};o.forEach(s=>{i[s.attrs.col]=Bp(s)}),n[o.attrs.id]={pos:o.attrs.pos,cells:i}}),e.rows=n}else if(t.type.spec.content){let{c:n,m:o}=ai(t.content);e.c=n,o.some(Boolean)&&(e.m=o)}return e}function xu(t){let e={};return t.forEach(n=>{e[n.attrs.id]=Vp(n)}),e}function Fp(t,e,n){let{t:o,pos:i,c:s,m:r,w:l,rows:a,...c}=n;if(o==="table"){let f=pi(c.cols||{}),{table_row:u,table_cell:p}=t.nodes,m=pi(a||{}).map(g=>u.createChecked({id:g,pos:a[g].pos},f.map(b=>p.createChecked({col:b},zp(t,a[g].cells?.[b])))));return t.nodes.table.createChecked({...c,id:e,pos:i},m)}let h=t.nodes[o];if(!h)throw new RangeError(`page: unknown block type ${o}`);let d=typeof s=="string"?hi(t,s,ci(r,s.length),h):Array.isArray(s)&&s.length?ft.Fragment.fromJSON(t,s):null;return h.create({...c,id:e,pos:i},d)}function Su(t,e){let n=pi(e).map(o=>Fp(t,o,e[o]));return n.length?t.nodes.doc.create(null,n):t.nodes.doc.createAndFill()}function jp(t){let e=[],n=[],o=new Array(t.length).fill(-1);t.forEach((s,r)=>{if(s===null)return;let l=0,a=e.length;for(;l<a;){let c=l+a>>1;e[c]<s?l=c+1:a=c}l>0&&(o[r]=n[l-1]),e[l]=s,n[l]=r});let i=new Set;for(let s=n[e.length-1]??-1;s>=0;s=o[s])i.add(s);return i}function Ul(t,e){let n=new Map;t.forEach(({id:r,rank:l=0},a)=>{r&&(!n.has(r)||l>(t[n.get(r)].rank??0))&&n.set(r,a)});let o=t.map(({id:r},l)=>!r||n.get(r)!==l),i=jp(t.map(({pos:r},l)=>!o[l]&&en(r)?r:null)),s=t.map(()=>null);for(let r=0;r<t.length;){if(i.has(r)){r++;continue}let l=r;for(;l<t.length&&!i.has(l);)l++;let a=r>0?t[r-1].pos:null,c=l<t.length?t[l].pos:null,h=ue(a,c,l-r);for(let d=r;d<l;d++)s[d]={id:o[d]?Tp(e):t[d].id,pos:h[d-r]};r=l}return s}function Lp(t){for(let e=0;e<t.steps.length;e++){let n=t.steps[e];if(n instanceof he.ReplaceStep){if(n.slice.openStart||n.slice.openEnd)return!1;for(let s=0;s<n.slice.content.childCount;s++)if(!n.slice.content.child(s).isInline)return!1}else if(!(n instanceof he.AddMarkStep||n instanceof he.RemoveMarkStep))return!1;let o=t.docs[e].resolve(n.from),i=t.docs[e].resolve(n.to);if(o.depth!==1||i.depth!==1||o.index(0)!==i.index(0)||!o.parent.isTextblock)return!1}return!0}function Ou(){let t=new WeakSet,e=n=>{let o=new Set,i=null,s=!0;return n.forEach(r=>{if((!r.attrs.id||o.has(r.attrs.id)||!en(r.attrs.pos)||i!==null&&i>=r.attrs.pos)&&(s=!1),o.add(r.attrs.id),i=r.attrs.pos,r.type.name!=="table")return;let l=new Set,a=null;r.forEach(c=>{(!c.attrs.id||l.has(c.attrs.id)||!en(c.attrs.pos)||a!==null&&a>=c.attrs.pos)&&(s=!1),l.add(c.attrs.id),a=c.attrs.pos})}),s};return new $o.Plugin({state:{init(n,o){return e(o.doc)&&t.add(o.doc),null},apply(){return null}},appendTransaction(n,o,i){if(t.has(o.doc)&&n.every(Lp))return t.add(i.doc),null;if(!n.some(u=>u.docChanged&&!u.getMeta(Dp)))return t.has(o.doc)&&e(i.doc)&&t.add(i.doc),null;let s=i.tr,r=(u,p,m)=>{m&&s.setNodeMarkup(p,null,{...u.attrs,...m})},l=new he.Mapping;for(let u of n)l.appendMapping(u.mapping);let a=new Map,c=(u,p)=>{if(!u.attrs.id)return;let m=l.mapResult(p,1);a.set(u.attrs.id,{node:u,at:m.deleted?null:m.pos})};o.doc.forEach((u,p)=>{c(u,p),u.type.name==="table"&&u.forEach((m,g)=>c(m,p+1+g))});let h=(u,p)=>{let m=a.get(u.attrs.id);return m?(m.node.content.eq(u.content)?2:0)+(m.at===p?1:0):0},d=u=>u.map(({node:p,at:m})=>({...p.attrs,rank:h(p,m)})),f=[];i.doc.forEach((u,p)=>f.push({node:u,at:p})),Ul(d(f),"b").forEach((u,p)=>r(f[p].node,f[p].at,u));for(let{node:u,at:p}of f){if(u.type.name!=="table")continue;let m=[];u.forEach((g,b)=>m.push({node:g,at:p+1+b})),Ul(d(m),"r").forEach((g,b)=>r(m[b].node,m[b].at,g))}return s.docChanged||t.add(i.doc),s.docChanged?s:null}})}var fi=class extends Error{constructor(e,n){super(`CSV ${e} at line ${n}`),this.name="CsvError",this.code=e,this.line=n}};function Jp(t){let e=new Map([[",",0],[";",0],[" ",0]]),n=!1;for(let o=0;o<t.length;o++){let i=t[o];if(i==='"')n&&t[o+1]==='"'?o++:n=!n;else{if(!n&&(i==="\r"||i===`
12
+ `))break;!n&&e.has(i)&&e.set(i,e.get(i)+1)}}return[...e].sort((o,i)=>i[1]-o[1])[0][0]}function Nu(t,{delimiter:e}={}){if(t=String(t).replace(/^\uFEFF/,""),e??=Jp(t),typeof e!="string"||e.length!==1||/["\r\n]/.test(e))throw new TypeError("CSV delimiter must be one non-newline character");let n=[],o=[],i="",s=!1,r=1,l=1;for(let d=0;d<t.length;d++){let f=t[d];s?f==='"'?t[d+1]==='"'?(i+='"',d++):s=!1:f==="\r"||f===`
13
+ `?(i+=f,f==="\r"&&t[d+1]===`
14
+ `&&(i+=t[++d]),r++):i+=f:f==='"'&&i===""?(s=!0,l=r):f===e?(o.push(i),i=""):f==="\r"||f===`
15
+ `?(o.push(i),n.push(o),o=[],i="",f==="\r"&&t[d+1]===`
16
+ `&&d++,r++):i+=f}if(s)throw new fi("unterminated-quote",l);if((o.length||i!==""||t&&!/[\r\n]$/.test(t))&&n.push([...o,i]),!n.length)return{header:[],rows:[]};let[a,...c]=n,h=Math.max(a.length,...c.map(d=>d.length));a.length=h;for(let d=0;d<h;d++)a[d]??="";for(let d of c)for(let f=d.length;f<h;f++)d.push("");return{header:a,rows:c}}function ui(t){if(typeof t!="string"||!/^[+-]?(?:0|[1-9]\d*)(?:[.,]\d+)?$/.test(t))return null;let e=Number(t.replace(",","."));return Number.isFinite(e)?e:null}function Gl(t,e){return t.map((n,o)=>{let i=e.map(r=>r[o]??"").filter(r=>r.trim()!=="");return i.length?new Set(i.map(r=>r.includes(",")?",":r.includes(".")?".":null).filter(Boolean)).size<=1&&i.every(r=>ui(r)!==null)?"number":i.every(r=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(r))return!1;let l=new Date(`${r}T00:00:00Z`);return!Number.isNaN(l.getTime())&&l.toISOString().slice(0,10)===r})?"date":"text":"text"})}var qp=Object.freeze(["text","number","date"]);function Au(t,e){return qp.includes(t)?t:Gl([""],e.map(n=>[n]))[0]}function Du({header:t,rows:e},{maxBytes:n=1/0,newId:o}={}){if(typeof o!="function")throw new TypeError("tableFromCsv needs newId");let i=Gl(t,e),s={},r=t.map(()=>o()),l=ue(null,null,t.length);t.forEach((u,p)=>{s[r[p]]={pos:l[p],name:u,kind:i[p]}});let a={},c=ue(null,null,e.length),h=new TextEncoder,d=h.encode(JSON.stringify({cols:s,rows:a})).length,f=0;for(let u=0;u<e.length;u++){let p=o(),m={pos:c[u],cells:Object.fromEntries(r.map((b,y)=>[b,e[u][y]??""]))},g=h.encode(`${f?",":""}${JSON.stringify(p)}:${JSON.stringify(m)}`).length;if(d+g>n)break;a[p]=m,d+=g,f++}return{cols:s,rows:a,truncated:f===e.length?null:{kept:f,total:e.length}}}var _t=t=>String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),R=t=>Number(t.toFixed(2)).toString();function _l(t,e,n){t===e&&(t-=Math.max(Math.abs(t)*.05,1),e+=Math.max(Math.abs(e)*.05,1));let o=(e-t)/(n-1),i=10**Math.floor(Math.log10(o)),s=[1,2,5,10].map(a=>a*i),r=s.find(a=>Math.floor(e/a)-Math.ceil(t/a)+1<=n)??s.at(-1);for(;Math.floor(e/r)-Math.ceil(t/r)+1>n;)r*=2;let l=[];for(let a=Math.ceil(t/r);a<=Math.floor(e/r);a++)l.push(Number((a*r).toPrecision(12)));return l.length?l:[Number(t.toFixed(2)),Number(e.toFixed(2))]}function Yl(t,e){if(!e)return{state:"missing",reason:"table"};let n=e.cols??[],o=e.rows??[];if(!n.find(h=>h.id===t.x)||!t.series?.length||t.series.some(h=>!n.some(d=>d.id===h)))return{state:"missing",reason:"column"};let s=t.series.map((h,d)=>{let f=n.find(p=>p.id===h),u=o.map((p,m)=>({id:`${t.id}:${p.id}:${h}`,rowId:p.id,colId:h,rowIndex:m,xLabel:xt(p.cells?.[t.x]),value:ui(xt(p.cells?.[h])),highlight:p.id===t.highlight}));return{id:h,name:f.name,color:`var(--chart-${d%6+1})`,points:u}}),r=s.flatMap(h=>h.points),l=r.map(h=>h.value).filter(h=>h!==null),a=l.length?l.reduce((h,d)=>Math.min(h,d),1/0):0,c=l.length?l.reduce((h,d)=>Math.max(h,d),-1/0):1;if(t.type==="bar")a=Math.min(a,0),c=Math.max(c,0);else{let h=(c-a||Math.max(Math.abs(c),1))*.05;a-=h,c+=h}return a===c&&(c=a+1),{state:"ok",type:t.type,title:t.title??"",series:s,points:r,xLabels:o.map(h=>xt(h.cells?.[t.x])),yTicks:_l(a,c,6),narrowTicks:_l(a,c,3),domain:[a,c]}}function Ql(t,{width:e=640,height:n=320,narrow:o=!1}={}){if(t.state==="missing")return`<svg xmlns="http://www.w3.org/2000/svg" role="img" width="${e}" height="80" viewBox="0 0 ${e} 80"><title>Chart source missing</title><text x="12" y="44">Chart source missing</text></svg>`;let i={left:52,right:72,top:28,bottom:48},s=Math.max(1,e-i.left-i.right),r=Math.max(1,n-i.top-i.bottom),[l,a]=t.domain,c=p=>i.top+(a-p)/(a-l)*r,h=t.xLabels.length,d=p=>i.left+(h<=1?s/2:p*s/(h-1)),f=[`<svg xmlns="http://www.w3.org/2000/svg" role="img" width="${e}" height="${n}" viewBox="0 0 ${e} ${n}">`,`<title>${_t(t.title)}</title>`],u=t.series.map(p=>{let m=p.points.filter(g=>g.value!==null);return`${p.name}: ${m.length?`${R(m[0].value)} to ${R(m.at(-1).value)}`:"no values"}`}).join("; ");f.push(`<desc>${_t(u)}</desc>`);for(let p of o?t.narrowTicks:t.yTicks){let m=R(c(p));f.push(`<line x1="${i.left}" y1="${m}" x2="${R(i.left+s)}" y2="${m}" stroke="currentColor" opacity="0.15"/><text x="${i.left-8}" y="${R(c(p)+4)}" text-anchor="end">${R(p)}</text>`)}if(t.type==="bar"){let p=s/Math.max(h,1),m=Math.max(1,Math.min(32,p*.7/t.series.length)),g=c(0);t.series.forEach((b,y)=>{b.points.forEach(S=>{if(S.value===null)return;let T=i.left+(S.rowIndex+.5)*p-t.series.length*m/2+y*m,rt=c(S.value);f.push(`<rect data-point="${_t(S.id)}"${S.highlight?' data-highlight="true"':""} x="${R(T)}" y="${R(Math.min(rt,g))}" width="${R(m)}" height="${R(Math.abs(g-rt))}" fill="${b.color}"/>`)});let w=[...b.points].reverse().find(S=>S.value!==null);if(w){let S=i.left+(w.rowIndex+.5)*p-t.series.length*m/2+y*m;f.push(`<text x="${R(S+m/2)}" y="${R(Math.min(c(w.value),g)-7)}" text-anchor="middle">${_t(b.name)}</text>`)}})}else t.series.forEach(p=>{let m=[],g=()=>{m.length>1&&f.push(`<polyline points="${m.join(" ")}" fill="none" stroke="${p.color}" stroke-width="2"/>`),m=[]};p.points.forEach(y=>{if(y.value===null){g();return}m.push(`${R(d(y.rowIndex))},${R(c(y.value))}`),f.push(`<circle data-point="${_t(y.id)}"${y.highlight?' data-highlight="true"':""} cx="${R(d(y.rowIndex))}" cy="${R(c(y.value))}" r="3" fill="${p.color}"/>`)}),g();let b=[...p.points].reverse().find(y=>y.value!==null);b&&f.push(`<text x="${R(d(b.rowIndex)+7)}" y="${R(c(b.value)-5)}">${_t(p.name)}</text>`)});return t.xLabels.forEach((p,m)=>{let g=t.type==="bar"?i.left+(m+.5)*s/Math.max(h,1):d(m);f.push(`<text x="${R(g)}" y="${R(n-14)}" text-anchor="middle">${_t(p)}</text>`)}),f.push("</svg>"),f.join("")}var rn="\uFFFC",wi='@{"type":"hard_break"}',na=["b","i","s","c","a"],Wp={b:"strong",i:"em",s:"s",c:"code"},Kp=["a","b","i","s","c"],Hp=new Set(na),on="data-clay-page-opaque",bi="data-clay-page-value",zn="data-clay-page-marks",Up="data-page-mention",Gp="data-page-date",_p=/^\d{4}-\d{2}-\d{2}$/,vi="1",oa=new Set(["id","t","parent","c","m"]),jn=t=>Object.hasOwn(ln,t),ln={paragraph:{parent:null},heading:{parent:null,level:2},list_item:{parent:null,kind:"bullet",indent:0,checked:!1,owner:null,due:null},callout:{parent:null},quote:{parent:null},code_block:{parent:null,lang:""},toggle:{parent:null,open:!1},divider:{parent:null},image:{parent:null,src:"",alt:"",caption:"",width:null,align:null},file:{parent:null,src:"",name:"",size:null,mime:null},table:{parent:null,cols:{},sort:null},chart:{parent:null,source:null,kind:"line",x:null,series:[],title:"",highlight:null},board:{parent:null,columns:{},cards:{}},tool:{parent:null,artifact:null,rev:null,state:{}},preserved:{parent:null,html:""}},Yp=new Set(["paragraph","heading","list_item","callout","quote","code_block","toggle"]),ia=(t,e)=>mt(t)===mt(e);function an(t){return Object.keys(t).sort((e,n)=>{let o=t[e].pos??"",i=t[n].pos??"";return o!==i?o<i?-1:1:e<n?-1:e>n?1:0})}var Ln=t=>{let e="";for(let n of new TextEncoder().encode(t))e+=String.fromCharCode(n);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},Qp=t=>{let e=atob(String(t).replace(/-/g,"+").replace(/_/g,"/"));return new TextDecoder().decode(Uint8Array.from(e,n=>n.charCodeAt(0)))},gi=t=>t===null||typeof t!="object"?!1:Array.isArray(t)?t.some(gi):Object.keys(t).some(e=>e==="__proto__"||gi(t[e]));function sa(t){let e;try{e=JSON.parse(Qp(t))}catch{throw new SyntaxError("page: an envelope is not readable canonical JSON")}try{Bn(e)}catch(n){throw new SyntaxError(n.message)}if(gi(e))throw new SyntaxError("page: an envelope holds a prototype key");return e}function Zp(t){let e=sa(t);if(e===null||typeof e!="object"||Array.isArray(e))throw new SyntaxError("page: a block envelope is not a record");if("id"in e||"pos"in e)throw new SyntaxError("page: a block envelope holds a structural field");if("t"in e&&(typeof e.t!="string"||!e.t))throw new SyntaxError("page: a block envelope names no type");return e}function ra(t){try{return Bt(sa(t))}catch(e){throw e instanceof SyntaxError?e:new SyntaxError(e.message)}}var Vu=t=>ra(t),la=t=>` ${on}="${vi}" ${bi}="${Jn(Ln(mt(t)))}"`,Zl=t=>t.length?` ${zn}="${Jn(Ln(JSON.stringify(t)))}"`:"",Fu=t=>({[on]:vi,[bi]:Ln(mt(t))}),ju=t=>({[zn]:Ln(JSON.stringify(Bt(t)))});function Vn(t,e){if(!Array.isArray(t))return null;if(!Array.isArray(t[0]))return t.length===e?t:null;let n=[];for(let o of t){if(!Array.isArray(o)||!Number.isInteger(o[0])||o[0]<1||typeof o[1]!="string"||n.length+o[0]>e)return null;for(let i=0;i<o[0];i++)n.push(o[1])}return n.length===e?n:null}function aa(t){let e=[];for(let n of t){let o=e[e.length-1];o&&o[1]===n?o[0]++:e.push([1,n])}return e}function ca(t){let e={},n=[];if(!t||t[0]==="@")return{marks:e,native:[],entries:[]};let o=[];for(let i of Ze(t)){if(i.name===void 0){Hp.has(i.code)?e[i.code]=i.attrs??!0:o.push(i);continue}let s=Ye(i.name,i.attrs);s?n.push({name:i.name,attrs:s}):o.push(i)}return{marks:e,native:n,entries:o.length?fe(o):[]}}var ha=(t,e,n)=>{if(!t)return"";if(t[0]==="@")return t===wi&&e[n]===rn?t:"";let{marks:o,native:i,entries:s}=ca(t);return fa(pa(o),i.length?[...s,...fe(i)]:s)},da=/^(javascript|vbscript|data):/i,pa=t=>(t.a&&da.test(String(t.a[0]).replace(/[\u0000-\u0020]/g,""))&&delete t.a,t);function fa(t,e=[]){let n="";for(let o of na)t[o]&&(n+=o,Array.isArray(t[o])&&(n+=JSON.stringify(t[o])));return e.length?n+Xe(e):n}function st(t,e){if(!t.includes(`
17
+ `)&&!t.includes("\r"))return{c:t,units:e};let n="",o=[];for(let i=0;i<t.length;)if(/\s/.test(t[i])&&t[i]!=="\xA0"){let s=i;for(;s<t.length&&/\s/.test(t[s])&&t[s]!=="\xA0";)s++;let r=t.slice(i,s);/[\n\r]/.test(r)?i>0&&s<t.length&&(n+=" ",o.push(e?e[i]:"")):(n+=r,e?o.push(...e.slice(i,s)):o.push(...r.split("").map(()=>""))),i=s}else n+=t[i],o.push(e?e[i]:""),i++;return{c:n,units:o}}function sn(t,e){let n={c:t};return e&&e.some(Boolean)&&(n.m=aa(e)),n}function Lu(t){let e={};for(let n of t){if(!n||typeof n!="object")continue;let o=n.deleted||{};for(let[i,s]of Object.entries(n.blocks||{})){if(o[i]||!s||typeof s!="object")continue;let{w:r,...l}=s;e[i]=l}}return e}function Xp(t){let e=[],n=[],o=null;for(let i of an(t)){let s=t[i],r=typeof s.t=="string"&&s.t?s.t:null,l=s.parent??null;if(l!==null){let h=n.lastIndexOf(l);h<0&&(l=null),n.length=h<0?0:h+1}else n.length=0;let a=0;if(r==="list_item"){let h=o&&o.t==="list_item"&&o.parent===l,d=Number.isInteger(s.indent)&&s.indent>0?s.indent:0;a=h?Math.min(d,o.indent+1):0}let c={id:i,b:s,t:r,parent:l,indent:a};e.push(c),o=c,r==="toggle"&&n.push(i)}return e}var B=(t,e)=>{let n={};for(let[o,i]of Object.entries(e))(!(o in ln[t])||!ia(i,ln[t][o]))&&(n[o]=i);return n},Fn=t=>typeof t=="number"&&Number.isFinite(t)&&t>0?Math.round(t):null;function tf(t){if(t===null||typeof t!="object"||typeof t.c!="string")return st(xt(t),null).c;let e=Vn(t.m,t.c.length),n=e&&e.map((s,r)=>ha(s,t.c,r));if(!n)return st(xt(t),null).c;let o=st(t.c,n),i=sn(o.c,o.units);return i.m?i:i.c}function ef(t){let e=t.cols&&typeof t.cols=="object"?t.cols:{},n=t.rows&&typeof t.rows=="object"?t.rows:{},o=an(e);return{cols:o.map(i=>({id:i,name:st(String(e[i].name??""),null).c,...e[i].kind!=null?{kind:String(e[i].kind)}:{},...Fn(e[i].width)?{width:Fn(e[i].width)}:{}})),rows:an(n).map(i=>({id:i,cells:Object.fromEntries(o.map(s=>[s,tf(n[i].cells?.[s])]))}))}}function nf(t){let e=t.columns&&typeof t.columns=="object"?t.columns:{},n=t.cards&&typeof t.cards=="object"?t.cards:{},o=an(e),i=[...new Set(Object.values(n).map(l=>String(l.col??"")))].filter(l=>!e[l]).sort(),s=[...o,...i],r=l=>an(Object.fromEntries(Object.entries(n).filter(([,a])=>String(a.col??"")===l)));return{columns:o.map(l=>({id:l,name:st(String(e[l].name??""),null).c})),cards:s.flatMap(l=>r(l).map(a=>{let c=n[a];return{id:a,col:l,title:st(String(c.title??""),null).c,...c.owner!=null?{owner:String(c.owner)}:{},...c.due!=null?{due:String(c.due)}:{}}}))}}var of=t=>{let{t:e,parent:n,id:o,...i}=t;return{t:e,...i}},yi=t=>{let e={};for(let[n,o]of Object.entries(t))!oa.has(n)&&!(jn(t.t)&&Object.hasOwn(ln[t.t],n))&&(e[n]=o);return Object.keys(e).length?la(e):""},sf=(t,e)=>{let n={};for(let[o,i]of Object.entries(e))!oa.has(o)&&o!=="pos"&&!Object.hasOwn(ln[t],o)&&(n[o]=i);return n};function rf({id:t,b:e,t:n,parent:o,indent:i}){if(!n)return{id:t,t:"preserved",html:""};if(!jn(n)){let{t:S,id:T,pos:rt,parent:M,...D}=e;if(typeof D.c=="string"&&D.m!==void 0){let P=Vn(D.m,D.c.length);P&&P.some(Boolean)?D.m=aa(P):delete D.m}return{id:t,t:n,...o?{parent:o}:{},...D}}let{t:s,id:r,pos:l,c:a,m:c,rows:h,cols:d,columns:f,cards:u,parent:p,indent:m,...g}=e,b=sf(n,g);for(let S of Object.keys(b))delete g[S];let y={...g,parent:o};n==="list_item"&&(y.indent=i),n==="heading"&&(y.level=lf(g.level??2)),n==="image"&&y.width!=null&&(y.width=ua(String(y.width))),n==="image"&&(y.align=ma(y.align)),n==="image"&&typeof y.caption=="string"&&(y.caption=st(y.caption,null).c),n==="chart"&&typeof y.title=="string"&&(y.title=st(y.title,null).c),n==="table"?Object.assign(y,ef(e)):n==="board"&&Object.assign(y,nf(e));let w={id:t,t:n,...B(n,y),...b};if(n==="table"&&(w.cols=y.cols,w.rows=y.rows),n==="board"&&(w.columns=y.columns,w.cards=y.cards),Yp.has(n)){let S=typeof a=="string"?a:"",T=Vn(c,S.length),rt=T&&T.map((M,D)=>ha(M,S,D));if(n==="code_block")Object.assign(w,{c:S.replace(/\r\n?/g,`
18
+ `)});else{let M=st(S,rt);Object.assign(w,sn(M.c,M.units))}}return w}var lf=t=>Math.min(6,Math.max(1,Number.isInteger(t)?t:2)),ua=t=>/^\d+$/.test(t)?Number(t):t,ma=t=>t==="left"||t==="right"?t:null;function Ju(t){return Xp(t).map(rf)}var mt=t=>Array.isArray(t)?`[${t.map(mt).join(",")}]`:t&&typeof t=="object"?`{${Object.keys(t).sort().map(e=>JSON.stringify(e)+":"+mt(t[e])).join(",")}}`:JSON.stringify(t??null);function ga(t){let e=2166136261,n=-1623754710;for(let o=0;o<t.length;o++){let i=t.charCodeAt(o);e=Math.imul(e^i,16777619)>>>0,n=Math.imul(n^i,1540483477)>>>0,n=(n^n>>>15)>>>0}return e.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}var qu=t=>ga(mt(t)),ut=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#13;"),Jn=t=>ut(String(t)).replace(/"/g,"&quot;"),N=(t,e)=>e==null?"":` ${t}="${Jn(e)}"`,af={underline:"u",text_color:"span",highlight:"mark"};function ki(t,e,n=!0){let o=Vn(e,t.length)||[],i="",s=[],r=l=>{for(;s.length>l;)i+=`</${s.pop().tag}>`};for(let l=0;l<t.length;){let a=o[l]||"";if(t[l]===rn&&a[0]==="@"){r(0),i+=a===wi?"<br>":`<span data-atom="${Jn(a)}"></span>`,l++;continue}let c=l+1;for(;c<t.length&&(o[c]||"")===a&&!(t[c]===rn&&a[0]==="@");)c++;let{marks:h,native:d,entries:f}=ca(a),u=Kp.filter(y=>h[y]).map(y=>({code:y,sig:y+JSON.stringify(h[y]),tag:y==="a"?"a":Wp[y],href:y==="a"?h.a[0]:null}));for(let y of d)u.push({sig:`native${y.name}${mt(y.attrs)}`,tag:af[y.name],color:y.attrs.color??null});let p=f.find(y=>y.name==="mention"),m=f.find(y=>y.name==="date"),g=m&&_p.test(String(m.attrs.date))?String(m.attrs.date):null;f.length&&n&&u.push({sig:`marks${mt(f)}`,tag:g?"time":"span",entries:f,mention:p?.attrs.id,day:g});let b=0;for(;b<s.length&&b<u.length&&s[b].sig===u[b].sig;)b++;r(b);for(let y of u.slice(b))y.entries?i+=y.day?`<time${N("datetime",y.day)}${N(Gp,"")}${Zl(y.entries)}>`:`<span${Zl(y.entries)}${N(Up,y.mention)}>`:y.tag==="a"?i+=`<a${N("href",y.href)}>`:i+=y.color?`<${y.tag}${N("data-color",y.color)}>`:`<${y.tag}>`,s.push(y);i+=ut(t.slice(l,c)),l=c}return r(0),i}var me=t=>ki(t.c??"",t.m),ya=t=>t.artifact||t.rev||t.state&&Object.keys(t.state).length?`<script type="application/json" data-tool>${mt({artifact:t.artifact??null,rev:t.rev??null,state:t.state??{}}).replace(/</g,"\\u003c")}<\/script>`:"",cf=t=>typeof t=="string"?ut(t):t&&typeof t=="object"?ki(String(t.c??""),t.m):"",hf=t=>Object.entries(t).map(([e,n])=>N(`data-${e}`,n)).join("");function df(t,e,n){let o=N("data-id",t.id);if(!jn(t.t))return`<div${o}${la(of(t))}>${ki(t.c??"",t.m,!1)}</div>`;let i=o+yi(t);switch(t.t){case"paragraph":return`<p${i}>${me(t)}</p>`;case"heading":{let s=`h${t.level??2}`;return`<${s}${i}>${me(t)}</${s}>`}case"callout":return`<aside${i} class="page-callout">${me(t)}</aside>`;case"quote":return`<blockquote${i}>${me(t)}</blockquote>`;case"code_block":return`<pre${i}${N("data-lang",t.lang||null)}><code>${ut(t.c??"")}</code></pre>`;case"divider":return`<hr${i}>`;case"image":return`<figure${i} data-type="image"${N("data-align",t.align??null)}><img${N("src",t.src??"")}${N("alt",t.alt??"")}${N("width",t.width??null)}>${t.caption?`<figcaption>${ut(t.caption)}</figcaption>`:""}</figure>`;case"file":{let s=/^(https?:\/\/|\/(?!\/))/i.test(t.src??"")?t.src:null;return`<div${i} data-type="file"${N("data-src",t.src??"")}${N("data-name",t.name??"")}${N("data-size",t.size??null)}${N("data-mime",t.mime??null)}><a${N("href",s)} rel="noopener noreferrer">${ut(t.name||"file")}</a></div>`}case"table":{let s=t.cols.map(l=>`<th${N("data-col",l.id)}${N("data-kind",l.kind??null)}${N("data-width",l.width??null)}${N("style",l.width?`width:${l.width}px`:null)}>${ut(l.name)}</th>`).join(""),r=t.rows.map(l=>`<tr${N("data-id",l.id)}>${t.cols.map(a=>`<td>${cf(l.cells[a.id])}</td>`).join("")}</tr>`).join(`
19
+ `);return`<table${i}${N("data-sort",t.sort!=null?JSON.stringify(t.sort):null)}>
20
+ <thead><tr>${s}</tr></thead>
21
+ <tbody>
22
+ ${r}
23
+ </tbody>
24
+ </table>`}case"chart":{let s=hf({source:t.source??null,kind:t.kind??null,x:t.x??null,series:t.series?JSON.stringify(t.series):null,highlight:t.highlight??null}),r=Yl({id:t.id,type:t.kind??"line",x:t.x,series:t.series??[],title:t.title??"",highlight:t.highlight},n.get(t.source));return`<figure${i} data-type="chart"${s}>${Ql(r,{width:640,height:320})}<figcaption>${ut(t.title??"")}</figcaption></figure>`}case"board":{let r=[...t.columns.map(l=>({...l,known:!0})),...[...new Set(t.cards.map(l=>l.col))].filter(l=>!t.columns.some(a=>a.id===l)).map(l=>({id:l,known:!1}))].map(l=>{let a=t.cards.filter(c=>c.col===l.id).map(c=>`<li${N("data-id",c.id)}${N("data-owner",c.owner??null)}${N("data-due",c.due??null)}>${ut(c.title)}</li>`).join("");return`<div${N("data-col",l.id)}${l.known?"":" data-missing"}>${l.known?`<h4>${ut(l.name)}</h4>`:""}<ul>${a}</ul></div>`});return`<section${i} data-type="board">
25
+ ${r.join(`
26
+ `)}
27
+ </section>`}case"tool":return`<section${i} data-type="tool">${ya(t)}</section>`;case"preserved":return pf(t,e,i);default:return""}}var pf=(t,e,n=N("data-id",t.id))=>`<div${n} data-type="preserved">${e.preserved(t.html||"")}</div>`,ff={preserved:t=>t,fallback:t=>t};function Wu(t){let e=(n,o)=>{if(!n)return"";let i=t.createElement("template");if(i.innerHTML=n,o){for(let s of i.content.querySelectorAll("script"))s.remove();for(let s of i.content.querySelectorAll("*"))for(let{name:r,value:l}of[...s.attributes])(/^on/i.test(r)||/^(href|src|action|formaction|xlink:href)$/i.test(r)&&da.test(l.replace(/[\u0000-\u0020]/g,"")))&&s.removeAttribute(r)}return i.innerHTML};return{preserved:n=>e(n,!1),fallback:n=>e(n,!0)}}function Ku(t,{fallbackOf:e=()=>"",clean:n=ff}={}){let o=[],i=new Map(t.filter(c=>c.t==="table").map(c=>[c.id,c])),s=[null],r=[],l=c=>{r.length?o[o.length-1]+=c:o.push(c)},a=()=>{for(;r.length;){let c=r[r.length-1];o[o.length-1]+=`</li></${c}>`,r.pop()}};for(let c of t){let h=c.parent??null;for(;s.length>1&&s[s.length-1]!==h;)a(),l("</details>"),s.pop();if(c.t!=="list_item"&&a(),c.t==="list_item"){let d=c.indent??0,f=c.kind==="ordered"?"ol":"ul";for(;r.length>d+1;)l(`</li></${r[r.length-1]}>`),r.pop();r.length===d+1&&(l(r[d]===f?"</li>":`</li></${r[d]}>`),r[d]!==f&&r.pop()),r.length<d+1&&(l(`<${f}>`),r.push(f));let u=c.kind==="check"?`<input type="checkbox" disabled${c.checked?" checked":""}>`:"";l(`<li${N("data-id",c.id)}${N("data-owner",c.owner??null)}${N("data-due",c.due??null)}${yi(c)}>${u}${me(c)}`);continue}if(c.t==="toggle"){l(`<details${N("data-id",c.id)}${yi(c)}${c.open?" open":""}><summary>${me(c)}</summary>`),s.push(c.id);continue}if(c.t==="tool"){l(`<section${N("data-id",c.id)} data-type="tool">${ya(c)}${n.fallback(e(c.id))}</section>`);continue}l(df(c,n,i))}for(a();s.length>1;)l("</details>"),s.pop();return o.join(`
28
+ `)}var wa=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]),Xl=new Set(["A","ABBR","B","BDI","BDO","BR","CITE","CODE","DATA","DEL","DFN","EM","FONT","I","INS","KBD","LABEL","MARK","Q","S","SAMP","SMALL","SPAN","STRIKE","STRONG","SUB","SUP","TIME","U","VAR","WBR"]);function uf(t,e){return t==="u"?{name:"underline",attrs:{}}:t!=="mark"&&t!=="span"||t==="span"&&!e.hasAttribute("data-color")?null:{name:t==="mark"?"highlight":"text_color",attrs:{color:e.getAttribute("data-color")}}}function mi(t,e=()=>!1){let n="",o=[],i=(s,r,l)=>{for(let a of s.childNodes){if(e(a))continue;if(a.nodeType===3){n+=a.data;let f=fa(pa({...r}),l);for(let u=0;u<a.data.length;u++)o.push(f);continue}if(a.nodeType!==1||wa.has(a.tagName))continue;let c=a.tagName.toLowerCase();if(c==="br"){n+=rn,o.push(wi);continue}if(c==="span"&&a.hasAttribute("data-atom")){n+=rn,o.push(a.getAttribute("data-atom"));continue}let h={...r};if((c==="span"||c==="time")&&a.hasAttribute(zn)){i(a,h,Bt([...l,...ra(a.getAttribute(zn))]));continue}c==="strong"||c==="b"?h.b=!0:c==="em"||c==="i"?h.i=!0:c==="s"||c==="del"||c==="strike"?h.s=!0:c==="code"?h.c=!0:c==="a"&&a.hasAttribute("href")&&(h.a=[a.getAttribute("href")]);let d=uf(c,a);i(a,h,d?[...l,d]:l)}};return i(t,{},[]),st(n,o)}var nn=t=>st(t?t.textContent:"",null).c,xi=t=>{if(!t.hasAttribute(on))return null;if(t.getAttribute(on)!==vi)throw new SyntaxError(`page: unknown envelope version ${t.getAttribute(on)}`);let e=t.getAttribute(bi);if(e===null)throw new SyntaxError("page: a block envelope holds no value");return Zp(e)},Hu=t=>xi(t),ta=t=>{let e=xi(t);return e&&typeof e.t!="string"?e:null};function mf(t){let e=[],n=(h,d)=>{let f=null,u=()=>{if(!f)return;let p=mi(f);p.c&&e.push({id:null,t:"paragraph",parent:d,...sn(p.c,p.units)}),f=null};for(let p of[...h.childNodes]){if(p.nodeType===3&&!p.data.trim()){f&&f.appendChild(p.cloneNode());continue}if(!(p.nodeType===8||p.nodeType===1&&wa.has(p.tagName))){if(p.nodeType===3||p.nodeType===1&&Xl.has(p.tagName)){f??=h.ownerDocument.createElement("p"),f.appendChild(p.cloneNode(!0));continue}u(),p.nodeType===1&&r(p,d)}}u()},o=h=>h.getAttribute("data-id")||null,i=(h,d,f,u)=>{let p=ta(h);e.push({id:o(h),t:d,parent:f,...p?{...p,...u}:u})},s=(h,d,f)=>{for(let u of h.children){if(u.tagName!=="LI")continue;let p=[...u.childNodes].find(w=>w.nodeType===1&&w.tagName==="INPUT"&&(w.getAttribute("type")||"").toLowerCase()==="checkbox"),m=[...u.children].filter(w=>w.tagName==="UL"||w.tagName==="OL"),g=mi(u,w=>w===p||m.includes(w)),b=p?"check":h.tagName==="OL"?"ordered":"bullet",y={parent:d,kind:b,indent:f,checked:!!(p&&p.hasAttribute("checked")),owner:u.getAttribute("data-owner"),due:u.getAttribute("data-due")};e.push({id:o(u),t:"list_item",...B("list_item",y),...ta(u)??{},...sn(g.c,g.units)});for(let w of m)s(w,d,f+1)}},r=(h,d)=>{let f=h.tagName,u={parent:d},p=xi(h);if(p&&typeof p.t=="string"){if(jn(p.t)||p.t==="opaque_block")throw new SyntaxError(`page: an envelope names the known block type ${p.t}`);let{t:y,...w}=p;e.push({id:o(h),t:y,parent:d,...w});return}let m=f==="P"&&h.children.length===1&&h.children[0].tagName==="IMG"&&!h.textContent.trim();if(f==="P"&&!m)return i(h,"paragraph",d,{...B("paragraph",u),...l(h)});if(/^H[1-6]$/.test(f))return i(h,"heading",d,{...B("heading",{...u,level:+f[1]}),...l(h)});if(f==="ASIDE")return i(h,"callout",d,{...B("callout",u),...l(h)});if(f==="BLOCKQUOTE")return i(h,"quote",d,{...B("quote",u),...l(h)});if(f==="PRE"){let y=h.querySelector(":scope > code");return i(h,"code_block",d,{...B("code_block",{...u,lang:h.getAttribute("data-lang")||""}),c:(y||h).textContent})}if(f==="HR")return i(h,"divider",d,B("divider",u));if(f==="UL"||f==="OL")return s(h,d,0);if(f==="DETAILS"){let y=h.querySelector(":scope > summary"),w=e.length;i(h,"toggle",d,{...B("toggle",{...u,open:h.hasAttribute("open")}),...l(y)});let S=h.ownerDocument.createElement("div");for(let T of[...h.childNodes])T!==y&&S.appendChild(T.cloneNode(!0));n(S,{ref:w});return}if(f==="FIGURE"&&h.getAttribute("data-type")==="chart"){let y=S=>h.getAttribute(`data-${S}`),w=[];try{w=JSON.parse(y("series")||"[]")}catch{}return i(h,"chart",d,B("chart",{...u,source:y("source"),kind:y("kind")||"line",x:y("x"),series:w,title:nn(h.querySelector(":scope > figcaption")),highlight:y("highlight")}))}if(f==="DIV"&&h.getAttribute("data-type")==="file"){let y=h.getAttribute("data-size");return i(h,"file",d,B("file",{...u,src:h.getAttribute("data-src")||"",name:h.getAttribute("data-name")||"",size:y===null||y===""||!Number.isFinite(+y)?null:+y,mime:h.getAttribute("data-mime")||null}))}let g=f==="IMG"?h:f==="FIGURE"||m?h.querySelector(":scope > img"):null;if(g){let y=g.getAttribute("width");return i(h,"image",d,B("image",{...u,src:g.getAttribute("src")||"",alt:g.getAttribute("alt")||"",caption:f==="FIGURE"?nn(h.querySelector(":scope > figcaption")):"",width:y===null?null:ua(y),align:f==="FIGURE"?ma(h.getAttribute("data-align")):null}))}if(f==="TABLE")return i(h,"table",d,a(h,u));if(f==="SECTION"&&h.getAttribute("data-type")==="board")return i(h,"board",d,c(h,u));if(f==="SECTION"&&h.getAttribute("data-type")==="tool"){let y=h.querySelector(':scope > script[type="application/json"][data-tool]'),w={};try{w=y?JSON.parse(y.textContent):{}}catch{}return i(h,"tool",d,B("tool",{...u,artifact:w.artifact??null,rev:w.rev??null,state:w.state??{}}))}if(f==="DIV"&&h.getAttribute("data-type")==="preserved")return i(h,"preserved",d,B("preserved",{...u,html:h.innerHTML}));if(f==="DIV"&&[...h.children].every(y=>Xl.has(y.tagName)))return i(h,"paragraph",d,{...B("paragraph",u),...l(h)});let b=h.cloneNode(!0);return b.removeAttribute("data-id"),i(h,"preserved",d,B("preserved",{...u,html:b.outerHTML}))},l=h=>{let d=h?mi(h):{c:"",units:[]};return sn(d.c,d.units)},a=(h,d)=>{let f=h.querySelector(":scope > thead > tr")||null,p=(f?[...f.children]:[]).map(w=>({id:w.getAttribute("data-col"),name:nn(w),...w.hasAttribute("data-kind")?{kind:w.getAttribute("data-kind")}:{},...Fn(Number(w.getAttribute("data-width")))?{width:Fn(Number(w.getAttribute("data-width")))}:{}})),m=[...h.querySelectorAll(":scope > tbody > tr, :scope > tr")],g=Math.max(p.length,...m.map(w=>w.children.length),0);for(;p.length<g;)p.push({id:null,name:""});let b=m.map(w=>({id:w.getAttribute("data-id"),cellsAt:[...w.children].map(S=>{let T=l(S);return T.m?T:T.c})})),y=null;try{y=h.hasAttribute("data-sort")?JSON.parse(h.getAttribute("data-sort")):null}catch{}return{...B("table",{...d,sort:y}),cols:p,rows:b}},c=(h,d)=>{let f=[],u=[];for(let p of h.querySelectorAll(":scope > div[data-col], :scope > div")){let m=p.getAttribute("data-col"),g=p.hasAttribute("data-missing"),b=g?{id:m}:{id:m,name:nn(p.querySelector(":scope > h4"))};g||f.push(b);for(let y of p.querySelectorAll(":scope > ul > li"))u.push({id:y.getAttribute("data-id"),colRef:b,title:nn(y),...y.hasAttribute("data-owner")?{owner:y.getAttribute("data-owner")}:{},...y.hasAttribute("data-due")?{due:y.getAttribute("data-due")}:{}})}return{...B("board",d),columns:f,cards:u}};return n(t,null),e}function gf(t,{seed:e="",known:n=new Map,taken:o=new Set}={}){let i=0,s=h=>`${h}-a${ga(`${e}|${h}|${i++}`).slice(0,12)}`,r=new Map;t.forEach((h,d)=>{h.id&&(r.get(h.id)??r.set(h.id,[]).get(h.id)).push(d)});let l=new Map;for(let[h,d]of r){let f=n.get(h),u=f?d.find(p=>ia(ea(t[p]),ea(f))):void 0;l.set(h,u??d[0])}let a=t.map((h,d)=>h.id&&!/^~|~\d+$/.test(h.id)&&l.get(h.id)===d?h.id:s("b"));return t.map((h,d)=>{let{id:f,parent:u,...p}=h,m=u&&typeof u=="object"?a[u.ref]:u,g={id:a[d],t:p.t,...m?{parent:m}:{},...ba(p,["t"])};if(g.t==="table"){let b=new Set,y=new Set;g.cols=g.cols.map(w=>({...w,id:w.id&&!b.has(w.id)?(b.add(w.id),w.id):s("c")})),g.rows=g.rows.map(w=>({id:w.id&&!y.has(w.id)?(y.add(w.id),w.id):s("r"),cells:Object.fromEntries(g.cols.map((S,T)=>[S.id,w.cellsAt[T]??""]))}))}if(g.t==="board"){let b=new Set,y=new Set;for(let w of g.columns)(!w.id||y.has(w.id))&&(w.id=s("c")),y.add(w.id);g.cards=g.cards.map(({colRef:w,...S})=>({id:S.id&&!b.has(S.id)?(b.add(S.id),S.id):s("k"),col:w.id??"",title:S.title,...S.owner!=null?{owner:S.owner}:{},...S.due!=null?{due:S.due}:{}})),g.columns=g.columns.map(({id:w,name:S})=>({id:w,name:S}))}return g})}var ba=(t,e)=>Object.fromEntries(Object.entries(t).filter(([n])=>!e.includes(n))),ea=t=>ba(t,["id","parent"]);function Uu(t,e={}){return gf(mf(t),e)}export{ft as a,$o as b,he as c,wc as d,sd as e,vd as f,Dd as g,Ud as h,rp as i,Pn as j,eu as k,ii as l,si as m,Bl as n,Fl as o,jl as p,pu as q,fu as r,ru as s,gp as t,Ye as u,lu as v,Mp as w,Cp as x,ai as y,Kl as z,ci as A,hi as B,xt as C,Dp as D,en as E,Hl as F,ue as G,pi as H,Tp as I,Bp as J,zp as K,Vp as L,xu as M,Fp as N,Su as O,Ul as P,Lp as Q,Ou as R,fi as S,Nu as T,ui as U,qp as V,Au as W,Du as X,Yl as Y,Ql as Z,rn as _,wi as $,on as aa,zn as ba,ln as ca,an as da,Vu as ea,Fu as fa,ju as ga,Vn as ha,aa as ia,Lu as ja,Ju as ka,mt as la,ga as ma,qu as na,Wu as oa,Ku as pa,Hu as qa,Uu as ra};