@panphora/clayjs 1.24.1 → 1.25.1

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 (275) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +6060 -4662
  11. package/dist/m/attrs/{refetch-on-save-DPGJJMGN.js → refetch-on-save-5CBFUJUF.js} +1 -1
  12. package/dist/m/attrs/save-freeze-PUYX32AK.js +1 -0
  13. package/dist/m/{c-HIX5H5L7.js → c-2A2ATCIH.js} +1 -1
  14. package/dist/m/{c-BOMQIQ3V.js → c-2EFMJYGJ.js} +1 -1
  15. package/dist/m/{c-MP6S4AZU.js → c-2GB34XL4.js} +2 -2
  16. package/dist/m/c-2TJCFPX4.js +4 -0
  17. package/dist/m/c-33SS5A4Y.js +1 -0
  18. package/dist/m/{c-PCNJETUA.js → c-34J5HC7N.js} +1 -1
  19. package/dist/m/{c-AT7GLQGV.js → c-3AAQJAKJ.js} +1 -1
  20. package/dist/m/c-3F3AADKG.js +1 -0
  21. package/dist/m/{c-HL6BLJNA.js → c-3WX5FABT.js} +1 -1
  22. package/dist/m/c-3XNTQQEJ.js +1 -0
  23. package/dist/m/{c-ZRGEN6QQ.js → c-3Y234AUB.js} +2 -2
  24. package/dist/m/{c-SUXHUL7U.js → c-42RLKGEY.js} +1 -1
  25. package/dist/m/{c-2BLVA6IN.js → c-44WITKWQ.js} +1 -1
  26. package/dist/m/c-47M4QHCK.js +1 -0
  27. package/dist/m/{c-UOUUI265.js → c-4M2T676V.js} +1 -1
  28. package/dist/m/{c-SXGEWPFC.js → c-4NAYDOWH.js} +1 -1
  29. package/dist/m/{c-OCYG4NBQ.js → c-4OZZ7ENT.js} +2 -2
  30. package/dist/m/{c-UOOIF2AL.js → c-5IIEOPIV.js} +1 -1
  31. package/dist/m/{c-YDW4VCHP.js → c-755ZOHOM.js} +1 -1
  32. package/dist/m/c-7Q4XYDF4.js +1 -0
  33. package/dist/m/c-7RHOMAMR.js +1 -0
  34. package/dist/m/{c-7V6MGMX2.js → c-7Z2625LX.js} +1 -1
  35. package/dist/m/{c-CTGRDT6E.js → c-A3OKSYRI.js} +1 -1
  36. package/dist/m/{c-GNI7WHKF.js → c-A5IYL7JI.js} +1 -1
  37. package/dist/m/c-A5LASUEZ.js +1 -0
  38. package/dist/m/c-AQVQKFKB.js +1 -0
  39. package/dist/m/{c-FLEIU6CG.js → c-ASGHHLFX.js} +1 -1
  40. package/dist/m/c-ASMLERFA.js +7 -0
  41. package/dist/m/{c-LUXAB2XI.js → c-AZM34SPO.js} +1 -1
  42. package/dist/m/{c-ZFO5RW6G.js → c-BHLYQGTA.js} +1 -1
  43. package/dist/m/{c-C5AKJVRH.js → c-BJ2RRQBQ.js} +1 -1
  44. package/dist/m/{c-FVPNX2GO.js → c-C27EVUQ6.js} +1 -1
  45. package/dist/m/{c-DFKBGSN2.js → c-C5UGNOC2.js} +1 -1
  46. package/dist/m/c-C6DXZIXD.js +1 -0
  47. package/dist/m/{c-EDE45NM7.js → c-C7SUMNMI.js} +1 -1
  48. package/dist/m/{c-STRI73GQ.js → c-CL5LSATX.js} +1 -1
  49. package/dist/m/c-CPRGR2II.js +1 -0
  50. package/dist/m/{c-NFQFV7OP.js → c-D2OPWOWO.js} +1 -1
  51. package/dist/m/{c-ZKKAF4UT.js → c-D4N4UJCQ.js} +2 -2
  52. package/dist/m/{c-6LEYVQJK.js → c-DAUQ6JZ3.js} +1 -1
  53. package/dist/m/{c-ZGCO4J3H.js → c-DDCYVLGG.js} +1 -1
  54. package/dist/m/{c-KQKKIVLW.js → c-DVMDYRAE.js} +1 -1
  55. package/dist/m/{c-OG6GFSUX.js → c-DYTBSJBI.js} +1 -1
  56. package/dist/m/{c-P2HKMJAW.js → c-EAV7A6BT.js} +1 -1
  57. package/dist/m/{c-X75G43SZ.js → c-EEWPNUM2.js} +1 -1
  58. package/dist/m/c-EHAR4RJJ.js +3 -0
  59. package/dist/m/c-EIDZHQHZ.js +1 -0
  60. package/dist/m/c-ELXMSEN5.js +1 -0
  61. package/dist/m/{c-QQFHEODI.js → c-EQ5NBOGA.js} +1 -1
  62. package/dist/m/c-FC5RUFPR.js +1 -0
  63. package/dist/m/{c-ND3Q2G2I.js → c-GFASNR55.js} +1 -1
  64. package/dist/m/{c-A4L7APIU.js → c-GNFDX6SU.js} +1 -1
  65. package/dist/m/{c-LATNQ6Q5.js → c-H3M6UDNV.js} +1 -1
  66. package/dist/m/{c-YLHTD3KX.js → c-H4M2T4A6.js} +1 -1
  67. package/dist/m/{c-DDS23EY6.js → c-HXGNH6GY.js} +1 -1
  68. package/dist/m/{c-PDBNCJCT.js → c-HYNM5U6B.js} +1 -1
  69. package/dist/m/c-J2YYLEVM.js +1 -0
  70. package/dist/m/c-J2ZW4HMR.js +1 -0
  71. package/dist/m/{c-WCG6AKA7.js → c-JC4RZW4E.js} +1 -1
  72. package/dist/m/c-K2ZHQMPF.js +1 -0
  73. package/dist/m/{c-6IJEVE6B.js → c-KU3PX7LL.js} +1 -1
  74. package/dist/m/{c-YYMZWQLR.js → c-L6KVXPBO.js} +1 -1
  75. package/dist/m/{c-CV4T65JE.js → c-LUBZU4AZ.js} +4 -4
  76. package/dist/m/{c-5FXEKU4Y.js → c-LYNLY3MR.js} +1 -1
  77. package/dist/m/{c-NQAPWM7O.js → c-MHTO3QAD.js} +1 -1
  78. package/dist/m/{c-HDVH3MVC.js → c-MKAUC6DB.js} +1 -1
  79. package/dist/m/c-MLMJUNRV.js +1 -0
  80. package/dist/m/c-MMEVDN6D.js +1 -0
  81. package/dist/m/c-MOP5KBWZ.js +1 -0
  82. package/dist/m/{c-LA2BW7UY.js → c-MZCOGNZL.js} +1 -1
  83. package/dist/m/{c-XW5TIYYB.js → c-N4GEJMXW.js} +1 -1
  84. package/dist/m/{c-RS77ODLY.js → c-NL4I4KNG.js} +1 -1
  85. package/dist/m/{c-2PVGJFI5.js → c-NW4ZFKCY.js} +1 -1
  86. package/dist/m/{c-PYG2NGWU.js → c-O3DPFZCE.js} +1 -1
  87. package/dist/m/c-O4YIDULY.js +1 -0
  88. package/dist/m/{c-LTSPHVAK.js → c-OBMZASYQ.js} +1 -1
  89. package/dist/m/c-OZOACVUD.js +1 -0
  90. package/dist/m/{c-YK2L436K.js → c-OZVK3TFI.js} +1 -1
  91. package/dist/m/c-P73XPAOA.js +1 -0
  92. package/dist/m/c-PP3CUF3U.js +1 -0
  93. package/dist/m/{c-B7GOFGQR.js → c-Q2CB57UG.js} +1 -1
  94. package/dist/m/{c-TWCXBWS3.js → c-QCDVDZIR.js} +1 -1
  95. package/dist/m/{c-LSVN3OLG.js → c-QL4NYM2L.js} +1 -1
  96. package/dist/m/c-RES2S5Q3.js +1 -0
  97. package/dist/m/c-RFGELYEU.js +2 -0
  98. package/dist/m/c-RGFPLQGV.js +1 -0
  99. package/dist/m/c-SMLAJASY.js +1 -0
  100. package/dist/m/{c-MQKSKQHG.js → c-STAPQ2X6.js} +1 -1
  101. package/dist/m/c-SYVF6ZMF.js +1 -0
  102. package/dist/m/{c-SE3SIY7Y.js → c-T5IWJOMW.js} +1 -1
  103. package/dist/m/{c-DD26VXAP.js → c-T7LOTEWO.js} +1 -1
  104. package/dist/m/{c-47IBJGPQ.js → c-TWB5ZQU4.js} +1 -1
  105. package/dist/m/c-U35T5NAY.js +1 -0
  106. package/dist/m/c-U4TWEIKZ.js +1 -0
  107. package/dist/m/c-UW6MMZ4V.js +1 -0
  108. package/dist/m/{c-JWDCQL6J.js → c-V5L6HWVL.js} +1 -1
  109. package/dist/m/c-VGG3UR7I.js +1 -0
  110. package/dist/m/{c-CZHTXGJS.js → c-VO6RSFCO.js} +1 -1
  111. package/dist/m/c-VU4WEWPH.js +4 -0
  112. package/dist/m/c-W7LWCJHD.js +1 -0
  113. package/dist/m/c-WOJ2RTV4.js +1 -0
  114. package/dist/m/{c-T3P3AXEW.js → c-WOWGGNCJ.js} +1 -1
  115. package/dist/m/{c-6RGEQNVV.js → c-XCOQNISP.js} +1 -1
  116. package/dist/m/{c-SGGGCIVD.js → c-XS7G6U3Z.js} +1 -1
  117. package/dist/m/{c-4PO3YGDC.js → c-Y3J5LDKB.js} +1 -1
  118. package/dist/m/c-Y3MPVURA.js +1 -0
  119. package/dist/m/c-Y6HH7LTM.js +1 -0
  120. package/dist/m/{c-RO73MKKR.js → c-YRDKVEGR.js} +1 -1
  121. package/dist/m/{c-FEC6LGFF.js → c-YZGWSCMT.js} +1 -1
  122. package/dist/m/{c-7CM4GMTS.js → c-ZJ7726FO.js} +1 -1
  123. package/dist/m/{c-SKMIR5HQ.js → c-ZPI7M5U5.js} +1 -1
  124. package/dist/m/core/{admin-attrs-ONRWVXPK.js → admin-attrs-43JBA6JB.js} +1 -1
  125. package/dist/m/core/{autosave-TBKAAAFB.js → autosave-HD7Y7UNV.js} +1 -1
  126. package/dist/m/core/{conflict-notice-FOEE6I7E.js → conflict-notice-Y2NTMDGJ.js} +1 -1
  127. package/dist/m/core/draft-mode-M5XNYBMY.js +1 -0
  128. package/dist/m/core/{host-permission-X4BENZEU.js → host-permission-5BYP24GC.js} +1 -1
  129. package/dist/m/core/{is-edit-mode-FFHCQ5DR.js → is-edit-mode-73OXKK5H.js} +1 -1
  130. package/dist/m/core/{persist-6ILUR34S.js → persist-MX3VYVBN.js} +1 -1
  131. package/dist/m/core/{recovery-APWADU4K.js → recovery-VZF7RJZF.js} +1 -1
  132. package/dist/m/core/{save-6HT2LABE.js → save-JZ7R4ET2.js} +1 -1
  133. package/dist/m/core/{save-core-EVMNZQ4V.js → save-core-I4N6S4ED.js} +1 -1
  134. package/dist/m/core/{site-edits-G4BOZMV4.js → site-edits-TIJDPG6H.js} +1 -1
  135. package/dist/m/core/{snapshot-FJP5IJL3.js → snapshot-N5MKDGNI.js} +1 -1
  136. package/dist/m/core/unsaved-warning-BP6ZY3PG.js +1 -0
  137. package/dist/m/events/{index-B6TGDYMG.js → index-YKQIBZE5.js} +1 -1
  138. package/dist/m/internals/index-3LAVREAU.js +1 -0
  139. package/dist/m/lib/{cache-bust-NH7VBWHO.js → cache-bust-BL4KUQAJ.js} +1 -1
  140. package/dist/m/{loader-GLLVDUZA.js → loader-7ORQVRCK.js} +1 -1
  141. package/dist/m/manifest-A27A4278.js +1 -0
  142. package/dist/m/manifest-edit-E8A61EB4.js +1 -0
  143. package/dist/m/manifest.json +1608 -1498
  144. package/dist/m/options/{options-55LQHSJ4.js → options-LKIZ7YTG.js} +1 -1
  145. package/dist/m/page/{editor-KAZDJNND.js → editor-HS2CAV3W.js} +5 -5
  146. package/dist/m/plugins/{ai-edit-LABECCSN.js → ai-edit-WDV2GLDU.js} +2 -2
  147. package/dist/m/plugins/{cms-T2HLI7JG.js → cms-4KET6RZT.js} +9 -9
  148. package/dist/m/plugins/{demo-T7B4RIKL.js → demo-LMCMBILC.js} +1 -1
  149. package/dist/m/plugins/{derive-6LPJOCAV.js → derive-R4USHZ7P.js} +1 -1
  150. package/dist/m/plugins/{indicator-J4ABFARX.js → indicator-OLPZ4WFI.js} +1 -1
  151. package/dist/m/plugins/{live-PGBIEMGB.js → live-CO4VJS46.js} +1 -1
  152. package/dist/m/plugins/{menu-YZL3X2AJ.js → menu-ESEFQARM.js} +1 -1
  153. package/dist/m/plugins/{page-WOCNX2IN.js → page-L3VKIQU2.js} +2 -2
  154. package/dist/m/plugins/{page-view-SJODOOGE.js → page-view-6KNTXABH.js} +1 -1
  155. package/dist/m/plugins/{people-C4TCWFOQ.js → people-EBWE337I.js} +1 -1
  156. package/dist/m/plugins/quickcrop-VNRXGRPC.js +26 -0
  157. package/dist/m/plugins/{richclay-Y2NV44NA.js → richclay-V6WKJTUF.js} +17 -17
  158. package/dist/m/plugins/sortable-BAG3MSWS.js +1 -0
  159. package/dist/m/plugins/{source-YK7MO23W.js → source-OYHDXKTB.js} +1 -1
  160. package/dist/m/plugins/undo-WUK2NLBA.js +1 -0
  161. package/dist/m/plugins/{upgrade-NNTJBSK2.js → upgrade-SZQJYEQQ.js} +1 -1
  162. package/dist/m/plugins/{upload-ZKKJV76X.js → upload-NZET3DNQ.js} +1 -1
  163. package/dist/m/plugins/visitor-drafts-ZE6PCAFP.js +20 -0
  164. package/dist/m/plugins/{visitor-drafts-owner-LHUHFU3L.js → visitor-drafts-owner-TLECTYWS.js} +1 -1
  165. package/dist/m/plugins/{visitor-menu-FY4KM2SW.js → visitor-menu-5XY57JQA.js} +1 -1
  166. package/dist/m/plugins/wire-S5ATC4QI.js +1 -0
  167. package/dist/m/reader-core-AHOAP5DH.js +77 -0
  168. package/dist/m/sync/live-sync-DX4K5GDB.js +1 -0
  169. package/dist/m/ui/index-G7ZJXNMG.js +1 -0
  170. package/dist/m/vendor/sap-core.vendor-5TWOJYVM.js +7 -0
  171. package/dist/offline-manifest.json +844 -784
  172. package/dist/server/core.cjs +4245 -2614
  173. package/dist/server/markdown.cjs +1 -0
  174. package/dist/server/markdown.mjs +7 -0
  175. package/docs/guide.md +27 -37
  176. package/entries/clay-data.js +1 -1
  177. package/entries/sap.js +6 -5
  178. package/package.json +6 -2
  179. package/packed-contract.json +3 -0
  180. package/src/attrs/save-freeze.js +1 -1
  181. package/src/core/admin-contenteditable.js +1 -1
  182. package/src/core/admin-inputs.js +1 -1
  183. package/src/core/admin-onclick.js +1 -1
  184. package/src/core/admin-resources.js +5 -2
  185. package/src/core/conflict-notice-ui.js +59 -34
  186. package/src/core/draft-mode.js +5 -0
  187. package/src/core/save-core.js +10 -10
  188. package/src/core/save.js +10 -10
  189. package/src/core/snapshot.js +56 -43
  190. package/src/core/stale-host-notice.js +20 -7
  191. package/src/lib/dirty-gate.js +19 -0
  192. package/src/page/editor.js +10 -4
  193. package/src/page/import-markdown.js +22 -8
  194. package/src/page/save-projection.js +1 -1
  195. package/src/plugins/menu/visitor.js +33 -1
  196. package/src/plugins/quickcrop.js +128 -69
  197. package/src/plugins/sortable.js +25 -9
  198. package/src/plugins/visitor-drafts/commit.js +50 -3
  199. package/src/plugins/visitor-drafts/idb.js +8 -2
  200. package/src/plugins/visitor-drafts/recovery-menu.js +118 -0
  201. package/src/plugins/visitor-drafts/recovery.js +64 -0
  202. package/src/plugins/visitor-drafts/session.js +61 -13
  203. package/src/plugins/visitor-drafts/store.js +44 -8
  204. package/src/plugins/visitor-drafts.js +34 -5
  205. package/src/server/markdown/index.js +23 -0
  206. package/src/sync/conflicts.js +3 -1
  207. package/src/sync/data-guard-notice.js +137 -18
  208. package/src/sync/live-sync.js +1 -1
  209. package/src/sync/wire-profile.js +9 -4
  210. package/src/ui/bevel-controls.js +4 -1
  211. package/src/ui/dialogs.js +11 -7
  212. package/src/ui/modal.js +9 -7
  213. package/src/ui/toast.js +67 -32
  214. package/src/vendor/hyper-html-api-data.vendor.js +1 -1
  215. package/src/vendor/hyper-html-api-upgrade.vendor.js +2 -2
  216. package/src/vendor/hyper-undo.vendor.js +1 -1
  217. package/src/vendor/hypercms.vendor.js +7 -7
  218. package/src/vendor/richclay.vendor.js +16 -16
  219. package/src/vendor/sap-core.vendor.js +6 -5
  220. package/src/vendor/sap-ownership.vendor.js +181 -11
  221. package/tool-generation/context.md +69 -0
  222. package/tool-generation/system.md +2 -2
  223. package/dist/m/attrs/save-freeze-JZHKRQLR.js +0 -1
  224. package/dist/m/c-277QP5ET.js +0 -1
  225. package/dist/m/c-3UW5EJ77.js +0 -1
  226. package/dist/m/c-42ZNV7LI.js +0 -7
  227. package/dist/m/c-6Q6RGFBF.js +0 -1
  228. package/dist/m/c-APGHGDZM.js +0 -1
  229. package/dist/m/c-BGN7RCTJ.js +0 -1
  230. package/dist/m/c-CJ7QYEWI.js +0 -1
  231. package/dist/m/c-CVSWLX3X.js +0 -1
  232. package/dist/m/c-DXPOFLEJ.js +0 -1
  233. package/dist/m/c-EILLN2H2.js +0 -1
  234. package/dist/m/c-EODTTNVA.js +0 -1
  235. package/dist/m/c-ESK4S67I.js +0 -1
  236. package/dist/m/c-FDWR3FL7.js +0 -1
  237. package/dist/m/c-FYDKYW6E.js +0 -1
  238. package/dist/m/c-HKSLOVU4.js +0 -1
  239. package/dist/m/c-HTLYXCUH.js +0 -1
  240. package/dist/m/c-IUL7PU4P.js +0 -1
  241. package/dist/m/c-JQF2EUCG.js +0 -1
  242. package/dist/m/c-MFOSMAVM.js +0 -3
  243. package/dist/m/c-MQYEDF3Q.js +0 -1
  244. package/dist/m/c-MR75YPRT.js +0 -1
  245. package/dist/m/c-NHXOBD6A.js +0 -1
  246. package/dist/m/c-NVU3DORS.js +0 -1
  247. package/dist/m/c-OYHI67B6.js +0 -1
  248. package/dist/m/c-PWJSJEJU.js +0 -1
  249. package/dist/m/c-QENKN7QI.js +0 -1
  250. package/dist/m/c-R23UHMXG.js +0 -1
  251. package/dist/m/c-SGH3UTF3.js +0 -1
  252. package/dist/m/c-SXNSSHPP.js +0 -1
  253. package/dist/m/c-TFLRT5JX.js +0 -1
  254. package/dist/m/c-U4NTUVDZ.js +0 -1
  255. package/dist/m/c-V2U3F4QX.js +0 -1
  256. package/dist/m/c-VG5XIN4T.js +0 -1
  257. package/dist/m/c-VHSMPITY.js +0 -1
  258. package/dist/m/c-Z4G2UK6T.js +0 -4
  259. package/dist/m/core/draft-mode-4MCL3LYI.js +0 -1
  260. package/dist/m/core/unsaved-warning-ITZDIZ2I.js +0 -1
  261. package/dist/m/internals/index-HS3CQDFW.js +0 -1
  262. package/dist/m/manifest-50FF1C45.js +0 -1
  263. package/dist/m/manifest-edit-BE1A621D.js +0 -1
  264. package/dist/m/plugins/quickcrop-X5MRIBAP.js +0 -26
  265. package/dist/m/plugins/sortable-XCHQG65Z.js +0 -1
  266. package/dist/m/plugins/undo-VLRBQNPN.js +0 -1
  267. package/dist/m/plugins/visitor-drafts-RTZNONHT.js +0 -20
  268. package/dist/m/plugins/wire-M2NR354P.js +0 -1
  269. package/dist/m/reader-core-T2S3JC4E.js +0 -77
  270. package/dist/m/sync/live-sync-Z64YREWQ.js +0 -1
  271. package/dist/m/ui/index-MGTWOW2C.js +0 -1
  272. package/dist/m/vendor/sap-core.vendor-QAEPMETX.js +0 -6
  273. /package/dist/m/{c-QTTJYJMA.js → c-FILLTJA7.js} +0 -0
  274. /package/dist/m/plugins/{quickcrop-X5MRIBAP.js.LEGAL.txt → quickcrop-VNRXGRPC.js.LEGAL.txt} +0 -0
  275. /package/dist/m/plugins/{richclay-Y2NV44NA.js.LEGAL.txt → richclay-V6WKJTUF.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as r}from"../c-LA2BW7UY.js";import"../c-IJUK2GPW.js";import{a as o,b as i,c as u,d as s}from"../c-S7LK4KUE.js";import"../c-VG5XIN4T.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function m(e){if(e.parentNode){r.pause();try{e.remove()}finally{r.resume()}}}function p(e){let a=o(e);if(!a||s(e))return;let t=new URL(e.getAttribute(a),location.href);t.searchParams.set("v",Date.now());let f=t.origin===location.origin?t.pathname+t.search:t.href;r.pause();try{let n=document.createElement(e.tagName);for(let{name:d,value:l}of e.attributes)n.setAttribute(d,l);i(n,a,f),u(e),e.insertAdjacentElement("afterend",n),n.onload=()=>m(e),setTimeout(()=>m(e),2e3)}finally{r.resume()}}function c(){document.addEventListener("clay:save-saved",()=>{document.querySelectorAll("[refetch-on-save]").forEach(p)})}c();var g=c;export{g as default};
1
+ import{a as r}from"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import{a as o,b as i,c as u,d as s}from"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";function m(e){if(e.parentNode){r.pause();try{e.remove()}finally{r.resume()}}}function p(e){let a=o(e);if(!a||s(e))return;let t=new URL(e.getAttribute(a),location.href);t.searchParams.set("v",Date.now());let f=t.origin===location.origin?t.pathname+t.search:t.href;r.pause();try{let n=document.createElement(e.tagName);for(let{name:d,value:l}of e.attributes)n.setAttribute(d,l);i(n,a,f),u(e),e.insertAdjacentElement("afterend",n),n.onload=()=>m(e),setTimeout(()=>m(e),2e3)}finally{r.resume()}}function c(){document.addEventListener("clay:save-saved",()=>{document.querySelectorAll("[refetch-on-save]").forEach(p)})}c();var g=c;export{g as default};
@@ -0,0 +1 @@
1
+ import{a}from"../c-OZVK3TFI.js";import"../c-QCDVDZIR.js";import"../c-MZCOGNZL.js";import"../c-IJUK2GPW.js";import"../c-UW6MMZ4V.js";import"../c-XQXZAO7N.js";import"../c-S7LK4KUE.js";import"../c-MOP5KBWZ.js";import"../c-2YYDMLNZ.js";import"../c-HA6INT6J.js";import"../c-ICMAOOGK.js";import"../c-WRBKEJD4.js";import"../c-VHNSBD2M.js";export{a as default};
@@ -1 +1 @@
1
- import{c as A}from"./c-Q6BG3ZLO.js";import{j as b}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as x}from"./c-ZRGEN6QQ.js";import"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as h}from"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
1
+ import{c as A}from"./c-Q6BG3ZLO.js";import{j as b}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as x}from"./c-3Y234AUB.js";import"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as h}from"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";function S(o){let s=String(o??""),n=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter("en",{granularity:"grapheme"}):null;return n?[...n.segment(s)].map(a=>a.segment):[...s]}var I=o=>S(o).length===1&&!/^\s*$/.test(String(o??""));function L(o){let s=[];for(let[n,a]of Object.entries(o??{}))for(let u of Array.isArray(a)?a:[]){let[f,m,d=""]=u??[];typeof f!="string"||typeof m!="string"||s.push({id:`${n}:${m}`,char:f,name:`${f} ${m}`,keywords:`${m} ${d}`})}return s}var P=(o,s)=>{let n=String(s??"").trim().toLowerCase();return n?o.filter(a=>a.char===n||a.keywords.toLowerCase().includes(n)):o};function T(o=()=>import("./c-SZGYW5HT.js")){let s=null;return()=>(s??=Promise.resolve().then(()=>o()).then(n=>L(n.EMOJI)).catch(n=>{throw s=null,n}),s)}function w({view:o=null,load:s=()=>import("./c-SZGYW5HT.js")}={}){if(!o)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let n=o.dom.ownerDocument,a=T(s),u=null;function f(t){let e=o.state,r=e.selection;if(r.from!==t.from||r.to!==t.to||t.from<0||t.to>e.doc.content.size)return null;let c=e.doc.resolve(t.from),i=e.doc.resolve(t.to);return!c.parent.isTextblock||c.parent!==i.parent?null:{from:t.from,to:t.to}}function m(t){try{let e=o.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=o.coordsAtPos(t.from);return{x:Math.max(8,r.left-e.left),y:r.bottom+6-e.top}}catch{return null}}function d(t){let e=t.picker.activeId();e?o.dom.setAttribute("aria-activedescendant",e):o.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&o.dom.removeAttribute("aria-activedescendant")}function l(){let t=u;if(t){u=null;for(let[e,r,c,i]of t.listen)e.removeEventListener(r,c,i);o.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&o.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function j(t,e){let r=o.state.tr.insertText(e,t.from,t.to);return r.setSelection(h.TextSelection.create(r.doc,t.from+e.length)),o.dispatch(x(r)),o.focus(),{ok:!0,emoji:e}}function p(t){let e=u;if(!e)return{ok:!1,code:"not-editing"};let r=e.picker.personAt(t),c=f(e);return!r||c===null||!I(r.char)?(l(),r?c===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-emoji"}:{ok:!1,code:"no-emoji"}):(l(),j(c,r.char))}function E(t){let e=u;if(!e||b(t,o))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),e.picker.move(t.key==="ArrowDown"?1:-1),d(e)):t.key==="Enter"?(r(),p(e.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),l())}async function $(t={}){l();let e={from:o.state.selection.from,to:o.state.selection.to,picker:null,listen:[]};e.picker=A({document:n,label:"Insert an emoji",empty:"No emoji found",onPick:i=>p(i)}),u=e;let r=(i,k,g,y)=>{i.addEventListener(k,g,y),e.listen.push([i,k,g,y])};r(n,"keydown",i=>E(i),!0),r(o.dom,"input",()=>l()),r(n,"mousedown",i=>{e.picker.el.contains(i.target)||l()},!0),(o.dom.parentElement??n.body).appendChild(e.picker.el);let c;try{c=await a()}catch(i){return l(),{ok:!1,code:"unavailable",error:i}}return u!==e?{ok:!1,code:"not-editing"}:f(e)===null?(l(),{ok:!1,code:"stale-target"}):(e.picker.show(P(c,t?.query),m(e)),d(e),{ok:!0,picker:!0})}return{async run(t){return $(t)},dispose(){l()}}}export{w as createFeature,L as emojiEntries,T as emojiLibrary,P as filterEmoji,S as graphemes,I as isEmojiText};
@@ -1 +1 @@
1
- import{b as n,c as i,d as t}from"./c-WCG6AKA7.js";import{a as o}from"./c-5KXDKC5G.js";import"./c-VHNSBD2M.js";var r={error:["Couldn't save","error"],offline:["Offline, will retry","warning"]},s=!1,f=()=>!(o.chip||o.toasts||window.clay?.saveFeedback==="own");function m(){f()&&i()}function p(e){if(!(!r[e]||!f())){s=!0;for(let[a,[c]]of Object.entries(r))a!==e&&t(c);n(...r[e])}}function d(){if(s){s=!1;for(let[e]of Object.values(r))t(e)}}export{d as clearFailures,p as reportFailure,m as warm};
1
+ import{b as n,c as i,d as t}from"./c-JC4RZW4E.js";import{a as o}from"./c-5KXDKC5G.js";import"./c-VHNSBD2M.js";var r={error:["Couldn't save","error"],offline:["Offline, will retry","warning"]},s=!1,f=()=>!(o.chip||o.toasts||window.clay?.saveFeedback==="own");function m(){f()&&i()}function p(e){if(!(!r[e]||!f())){s=!0;for(let[a,[c]]of Object.entries(r))a!==e&&t(c);n(...r[e])}}function d(){if(s){s=!1;for(let[e]of Object.values(r))t(e)}}export{d as clearFailures,p as reportFailure,m as warm};
@@ -1,6 +1,6 @@
1
- import{c as E}from"./c-Q6BG3ZLO.js";import{i as x,j as I}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C}from"./c-ZRGEN6QQ.js";import{A,d as f,x as y}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var D=`
1
+ import{c as E}from"./c-Q6BG3ZLO.js";import{i as x,j as I}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C}from"./c-3Y234AUB.js";import{A,d as f,x as y}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var D=`
2
2
  [data-blockeditor-heading]{display:block}
3
3
  [data-blockeditor-heading]>span[data-blockeditor-icon]{display:inline-block;font-size:34px;line-height:1;margin-block-end:.2em}
4
4
  [data-blockeditor-heading]>img[data-blockeditor-cover]{display:block;width:100%;height:180px;object-fit:cover;border-radius:var(--blockeditor-image-radius, 6px);margin-block-end:.6em}
5
5
  [data-blockeditor-heading]>h1{font-family:var(--blockeditor-font-display);font-size:var(--blockeditor-h1-size);font-weight:var(--blockeditor-h1-weight);letter-spacing:var(--blockeditor-h1-tracking);line-height:var(--blockeditor-h1-line);color:var(--blockeditor-ink-strong);margin-block:0 .6em}
6
- `,v=null,P=()=>v??=import("./c-HIX5H5L7.js").catch(r=>{throw v=null,r});function z(r){let t=typeof r=="string"?r:"";return!t.trim()||typeof Intl>"u"||typeof Intl.Segmenter!="function"||[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(t)].length!==1?!1:[...t].length<=32&&new TextEncoder().encode(t).length<=128}function S(r){let t=0;for(let a=0;a<r.childCount;a++){let i=r.child(a);if(i.type===f.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:a,at:t,node:i};t+=i.nodeSize}return null}function L(r,t){let a=r.createElement("img");return a.setAttribute("data-blockeditor-cover",""),a.setAttribute("src",t.pageCoverSrc),a.setAttribute("alt",t.pageCoverAlt??""),a.setAttribute("style",`object-position:${t.pageCoverX}% ${t.pageCoverY}%`),a}var m=class{constructor(t,a){this.node=t,this.decorated=!!(t.attrs.pageIcon||t.attrs.pageCoverSrc);let i=a.dom.ownerDocument,u=i.createElement(`h${t.attrs.level}`);if(u.setAttribute("data-id",t.attrs.id),this.dom=this.contentDOM=u,!this.decorated)return;let l=i.createElement("header");if(l.setAttribute("data-id",t.attrs.id),l.setAttribute("data-blockeditor-heading","1"),u.removeAttribute("data-id"),t.attrs.pageCoverSrc&&l.append(L(i,t.attrs)),t.attrs.pageIcon){let s=i.createElement("span");s.setAttribute("data-blockeditor-icon",""),s.setAttribute("aria-hidden","true"),s.textContent=t.attrs.pageIcon,l.append(s)}l.append(u),this.dom=l}update(t){return this.decorated!==!!(t.attrs.pageIcon||t.attrs.pageCoverSrc)||!t.sameMarkup(this.node)?!1:(this.node=t,!0)}ignoreMutation(t){return!this.contentDOM.contains(t.target)}};function W({view:r=null}={}){if(!r)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let t=r.dom.ownerDocument,a=null,i=null;function u(){try{let o=r.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},e=r.coordsAtPos(r.state.selection.from);return{x:Math.max(8,e.left-o.left),y:e.bottom+6-o.top}}catch{return null}}function l(o){let e=o.picker.activeId();e?r.dom.setAttribute("aria-activedescendant",e):r.dom.getAttribute("aria-activedescendant")?.startsWith(o.picker.el.id)&&r.dom.removeAttribute("aria-activedescendant")}function s(){let o=i;if(o){i=null;for(let[e,n,p,d]of o.listen)e.removeEventListener(n,p,d);r.dom.getAttribute("aria-activedescendant")?.startsWith(`${o.picker.el.id}-`)&&r.dom.removeAttribute("aria-activedescendant"),o.picker.destroy()}}function j(o,e){let n=S(r.state.doc);if((n?n.node.attrs.id:null)!==o.owner)return{ok:!1,code:"stale-target"};let d=r.state.tr;if(n)d.setNodeMarkup(n.at,null,{...n.node.attrs,pageIcon:e});else{let c=r.state.doc.maybeChild(0);d.insert(0,f.nodes.heading.create({id:A(),pos:y(null,c?.attrs.pos??null),parent:null,level:1,pageIcon:e}))}return r.dispatch(C(d)),{ok:!0,icon:e}}async function k(o){let e=i;if(!e)return{ok:!1,code:"not-editing"};let n=e.picker.personAt(o);return s(),n?z(n.char)?x(r,()=>j(e,n.char)):{ok:!1,code:"invalid-icon"}:{ok:!1,code:"no-emoji"}}function w(o){let e=i;if(!e||I(o,r))return;let n=()=>{o.preventDefault(),o.stopPropagation()};o.key==="ArrowDown"||o.key==="ArrowUp"?(n(),e.picker.move(o.key==="ArrowDown"?1:-1),l(e)):o.key==="Enter"?(n(),k(e.picker.index())):(o.key==="Escape"||o.key==="Tab")&&(n(),s())}async function M(o){s();let e={owner:S(r.state.doc)?.node.attrs.id??null,picker:null,listen:[]};e.picker=E({document:t,label:"Choose a page icon",empty:"No emoji found",onPick:c=>k(c)}),i=e;let n=(c,g,h,b)=>{c.addEventListener(g,h,b),e.listen.push([c,g,h,b])};n(t,"keydown",c=>w(c),!0),n(r.dom,"input",()=>s()),n(t,"mousedown",c=>{e.picker.el.contains(c.target)||s()},!0),(r.dom.parentElement??t.body).appendChild(e.picker.el);let p,d;try{let c=await P();d=c.filterEmoji,a??=c.emojiLibrary(),p=await a()}catch(c){return s(),{ok:!1,code:"unavailable",error:c}}return i!==e?{ok:!1,code:"not-editing"}:(e.picker.show(d(p,o?.query),u()),l(e),{ok:!0,picker:!0})}return{nodeViews:{heading:(o,e)=>new m(o,e)},css:D,async run(o){return M(o)},dispose(){s()}}}export{W as createFeature,z as isIconGlyph,S as titleOf};
6
+ `,v=null,P=()=>v??=import("./c-2A2ATCIH.js").catch(r=>{throw v=null,r});function z(r){let t=typeof r=="string"?r:"";return!t.trim()||typeof Intl>"u"||typeof Intl.Segmenter!="function"||[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(t)].length!==1?!1:[...t].length<=32&&new TextEncoder().encode(t).length<=128}function S(r){let t=0;for(let a=0;a<r.childCount;a++){let i=r.child(a);if(i.type===f.nodes.heading&&i.attrs.level===1&&i.attrs.parent==null)return{index:a,at:t,node:i};t+=i.nodeSize}return null}function L(r,t){let a=r.createElement("img");return a.setAttribute("data-blockeditor-cover",""),a.setAttribute("src",t.pageCoverSrc),a.setAttribute("alt",t.pageCoverAlt??""),a.setAttribute("style",`object-position:${t.pageCoverX}% ${t.pageCoverY}%`),a}var m=class{constructor(t,a){this.node=t,this.decorated=!!(t.attrs.pageIcon||t.attrs.pageCoverSrc);let i=a.dom.ownerDocument,u=i.createElement(`h${t.attrs.level}`);if(u.setAttribute("data-id",t.attrs.id),this.dom=this.contentDOM=u,!this.decorated)return;let l=i.createElement("header");if(l.setAttribute("data-id",t.attrs.id),l.setAttribute("data-blockeditor-heading","1"),u.removeAttribute("data-id"),t.attrs.pageCoverSrc&&l.append(L(i,t.attrs)),t.attrs.pageIcon){let s=i.createElement("span");s.setAttribute("data-blockeditor-icon",""),s.setAttribute("aria-hidden","true"),s.textContent=t.attrs.pageIcon,l.append(s)}l.append(u),this.dom=l}update(t){return this.decorated!==!!(t.attrs.pageIcon||t.attrs.pageCoverSrc)||!t.sameMarkup(this.node)?!1:(this.node=t,!0)}ignoreMutation(t){return!this.contentDOM.contains(t.target)}};function W({view:r=null}={}){if(!r)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let t=r.dom.ownerDocument,a=null,i=null;function u(){try{let o=r.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},e=r.coordsAtPos(r.state.selection.from);return{x:Math.max(8,e.left-o.left),y:e.bottom+6-o.top}}catch{return null}}function l(o){let e=o.picker.activeId();e?r.dom.setAttribute("aria-activedescendant",e):r.dom.getAttribute("aria-activedescendant")?.startsWith(o.picker.el.id)&&r.dom.removeAttribute("aria-activedescendant")}function s(){let o=i;if(o){i=null;for(let[e,n,p,d]of o.listen)e.removeEventListener(n,p,d);r.dom.getAttribute("aria-activedescendant")?.startsWith(`${o.picker.el.id}-`)&&r.dom.removeAttribute("aria-activedescendant"),o.picker.destroy()}}function j(o,e){let n=S(r.state.doc);if((n?n.node.attrs.id:null)!==o.owner)return{ok:!1,code:"stale-target"};let d=r.state.tr;if(n)d.setNodeMarkup(n.at,null,{...n.node.attrs,pageIcon:e});else{let c=r.state.doc.maybeChild(0);d.insert(0,f.nodes.heading.create({id:A(),pos:y(null,c?.attrs.pos??null),parent:null,level:1,pageIcon:e}))}return r.dispatch(C(d)),{ok:!0,icon:e}}async function k(o){let e=i;if(!e)return{ok:!1,code:"not-editing"};let n=e.picker.personAt(o);return s(),n?z(n.char)?x(r,()=>j(e,n.char)):{ok:!1,code:"invalid-icon"}:{ok:!1,code:"no-emoji"}}function w(o){let e=i;if(!e||I(o,r))return;let n=()=>{o.preventDefault(),o.stopPropagation()};o.key==="ArrowDown"||o.key==="ArrowUp"?(n(),e.picker.move(o.key==="ArrowDown"?1:-1),l(e)):o.key==="Enter"?(n(),k(e.picker.index())):(o.key==="Escape"||o.key==="Tab")&&(n(),s())}async function M(o){s();let e={owner:S(r.state.doc)?.node.attrs.id??null,picker:null,listen:[]};e.picker=E({document:t,label:"Choose a page icon",empty:"No emoji found",onPick:c=>k(c)}),i=e;let n=(c,g,h,b)=>{c.addEventListener(g,h,b),e.listen.push([c,g,h,b])};n(t,"keydown",c=>w(c),!0),n(r.dom,"input",()=>s()),n(t,"mousedown",c=>{e.picker.el.contains(c.target)||s()},!0),(r.dom.parentElement??t.body).appendChild(e.picker.el);let p,d;try{let c=await P();d=c.filterEmoji,a??=c.emojiLibrary(),p=await a()}catch(c){return s(),{ok:!1,code:"unavailable",error:c}}return i!==e?{ok:!1,code:"not-editing"}:(e.picker.show(d(p,o?.query),u()),l(e),{ok:!0,picker:!0})}return{nodeViews:{heading:(o,e)=>new m(o,e)},css:D,async run(o){return M(o)},dispose(){s()}}}export{W as createFeature,z as isIconGlyph,S as titleOf};
@@ -0,0 +1,4 @@
1
+ import{b as h,c as p}from"./c-Y6HH7LTM.js";import{a as m,b as A}from"./c-RHMPKZZ7.js";function E(t){return(t.getAttribute("type")||"text").toLowerCase()}function y(t,a=t){let u=t.tagName;if(u==="INPUT"){let n=E(t);n==="checkbox"||n==="radio"?a.checked?t.hasAttribute("checked")||t.setAttribute("checked",""):t.removeAttribute("checked"):a.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",a.value);return}if(u==="TEXTAREA"){let n=a.value.startsWith(`
2
+ `)?`
3
+ `+a.value:a.value;t.textContent!==n&&(t.textContent=n),t.removeAttribute("data-value");return}if(u==="SELECT"){let n=t.options,d=a.options;for(let i=0;i<n.length;i++)d[i]&&d[i].selected?n[i].hasAttribute("selected")||n[i].setAttribute("selected",""):n[i].removeAttribute("selected")}}var S={label:"Earlier drafts",intro:"This page kept your earlier drafts aside, listed by time."};function D({store:t,session:a,getHTML:u=()=>window.clay.getHTML(),download:n=A}){let d=r=>a.recoveryRecord(r),i=r=>r?.savedAt??r?.ops?.at(-1)?.savedAt??(r?.at?new Date(r.at).toISOString():null);async function b(){return(await a.listRecovery()).map(({mark:o,copy:e})=>{let s=d(e),c=e?.ops?new Set(e.ops.flatMap(l=>Object.keys(l.keys??{}))).size:Object.keys(s?.data??{}).length;return{mark:o,copy:e,savedAt:i(e),fields:c,available:!!s}}).sort((o,e)=>(Date.parse(e.savedAt)||0)-(Date.parse(o.savedAt)||0))}function v(r){let o=d(r);if(!o)throw new Error("This draft cannot be opened by this version.");let e=new DOMParser().parseFromString(u(),"text/html");if(p(e,t.seed(),t.rules),p(e,o.data,t.rules),!t.fitsInto(o.data,h(e,t.rules)))throw new Error("This draft no longer fits the page. Its saved copy is still kept.");let s=o.blockeditor?o:t.servedUnit(),c=e.querySelector("article[data-blockeditor]");if(s){if(!c)throw new Error("This draft's page editor is no longer available.");for(let l of e.querySelectorAll('script[type="application/json"][merge][clay~="live"]'))l.remove();for(let[l,k]of Object.entries(s.live)){let f=e.createElement("script");f.type="application/json",f.setAttribute("merge",l),f.setAttribute("clay","live"),f.textContent=JSON.stringify(k).replace(/</g,"\\u003c"),c.before(f)}c.setAttribute("data-rev",s.blockeditor.rev),c.innerHTML=s.blockeditor.html}for(let l of e.querySelectorAll('input:not([type="password"]):not([type="file"]), textarea, select'))y(l);return`<!DOCTYPE html>
4
+ `+e.documentElement.outerHTML}async function w(r){if(!await n({html:v(r),name:m()+".htmlclay"}))throw new Error("The download could not be made. Try again.");return!0}async function T(r){let o=(await b()).find(e=>e.mark===r);if(!o)throw new Error("That draft is no longer available. Open the list again.");return v(o.copy),a.restoreRecovery(r)}return{list:b,html:v,download:w,restore:T,remove:r=>a.removeRecovery(r)}}export{S as a,D as b};
@@ -0,0 +1 @@
1
+ import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p}from"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import{a}from"./c-4JZDZFF6.js";import"./c-5RZNFTWD.js";import{a as b,b as c}from"./c-PKCCHJ5X.js";import"./c-NUHP2XDB.js";import"./c-VHNSBD2M.js";export{d as RUNTIME_ONLY,i as bevelBox,f as bevelButton,h as bevelCornerClose,g as bevelIconButton,o as bevelInput,k as bevelSurface,m as bevelText,l as bevelWell,a as pageScheme,n as paintInput,c as paintLook,e as protectIcon,j as restyleBox,p as setShown,b as uiLook};
@@ -1 +1 @@
1
- import"./c-VHNSBD2M.js";var M="data-write",E="Waiting for the page data write to finish";function n(e,t,r){let a=new Error(t);return a.code=e,a.details=r,a}async function U(e){if(typeof e.json=="function")return e.json();let t=await e.text();return t?JSON.parse(t):null}async function R(e){let t={};try{t=await U(e)||{}}catch{}let r=t.message||t.error||e.statusText||`Request failed (${e.status})`,a=new Error(r);return a.status=e.status,a.error=t.error,a.details=t.details,a}function F(e){let t=e.headers?.get?.("ETag");return typeof t=="string"&&t?t:null}function q(e,t){let r=`${t.origin}${t.pathname}`;return e!==void 0?`${r}?data=${encodeURIComponent(JSON.stringify(e))}`:`${t.origin}/_/api${t.pathname}`}function D(e){return!!e&&!e.isDestroyed&&e.sse?.readyState===1}function x(e,t){let r=[],a=null,o=null,c=null,p=i=>i?.source==="disk"&&(a===null||i.etag===a),P=i=>i?.source==="disk"&&(i.etag==null||a===null||i.etag===a),d=()=>{clearTimeout(c),e.removeEventListener("clay:sync-applied",w)},w=i=>{if(r.push(i.detail),!o||!P(i.detail))return;let u=o;o=null,d(),u(!0)};return e.addEventListener("clay:sync-applied",w),{waitFor(i){return a=i,r.some(p)?(d(),Promise.resolve(!0)):new Promise(u=>{o=u,c=setTimeout(()=>{o=null,d(),u(!1)},t)})},cancel:d}}function $(e){let t=new AbortController,r,a=new Promise((c,p)=>{r=p}),o=setTimeout(()=>{let c=new Error("The page data write timed out.");c.name="TimeoutError",t.abort(c),r(c)},e);return{signal:t.signal,waitFor(c){return Promise.race([c,a])},cancel(){clearTimeout(o)}}}async function j(){let[e,t,r,a,o]=await Promise.all([import("./core/save-6HT2LABE.js"),import("./core/save-core-EVMNZQ4V.js"),import("./c-STRI73GQ.js"),import("./core/unsaved-warning-ITZDIZ2I.js"),import("./core/is-edit-mode-FFHCQ5DR.js")]);return{...e,...t,...r,...a,...o}}async function H(){let{isDraftMode:e}=await import("./core/is-edit-mode-FFHCQ5DR.js");return e?n("DataUnavailableInDraft","Page data is kept in this browser for this visitor."):null}function N({supports:e,token:t,fetchImpl:r,getLocation:a,eventTarget:o,getLiveSync:c,loadWriteModules:p=j,syncTimeoutMs:P=12e3,httpTimeoutMs:d=3e4}){let w=!1,i=!1;function u(l,{checkHold:m=!0}={}){if(l.savesAdmitted&&!l.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(i)throw n("DataWriteOutcomeUnknown","A previous page data write has an unknown outcome. Reload before writing again.");if(w)throw n("DataWriteInProgress","Another page data write is already running.");if(l.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(l.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(m&&(l.savesHeld()||l.isSaveConflicted()))throw n("SavesHeld","The page cannot write data while another save hold is active.");if(l.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.")}async function A(l){l.baselineSettled()||await new Promise(m=>o.addEventListener("clay:baseline-settled",m,{once:!0}))}async function I(l,{rules:m,ifMatch:O}={}){let b=await H();if(b)throw b;if(!await e(M))throw n("DataWriteUnsupported","This host does not support writing page data.");let s=await p();if(!s.isEditMode)throw n("DataWriteUnavailable","Page data writes require an editable page.");await A(s),u(s);let v=O;if(v==null&&(v=s.lastSeenEtag()||await s.seedEtag()),typeof v!="string"||v==="")throw n("DataWriteVersionRequired","Page data writes require a trustworthy document ETag.");u(s),w=!0,s.holdAllSaves(E);let g=null;try{if(s.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(s.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(s.isSaveConflicted())throw n("SavesHeld","The page cannot write data while another save hold is active.");if(s.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(s.savesAdmitted&&!s.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.");let W={"Content-Type":"application/json","If-Match":v},k=t();k&&(W["Save-Token"]=k);let _=JSON.stringify(l);g=x(o,P);let h=$(d),y;try{y=await h.waitFor(r(q(m,a()),{method:"POST",credentials:"same-origin",redirect:"error",headers:W,body:_,signal:h.signal}))}catch(T){throw h.cancel(),i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data write has an unknown outcome. Do not retry automatically."),{cause:T,unknownOutcome:!0})}let S;try{if(!y.ok)throw await h.waitFor(R(y));S=await h.waitFor(U(y))}catch(T){throw T?.status?T:(i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data was written, but its response could not be read."),{cause:T,unknownOutcome:!0}))}finally{h.cancel()}let f=F(y);if(f&&f===s.lastSeenEtag())return g.cancel(),g=null,{data:S,etag:f};let C=await g.waitFor(f);return g=null,C?{data:S,etag:f}:{data:S,etag:f,pageUpdatePending:!0,message:"Written, page update pending."}}finally{g?.cancel(),w=!1,s.releaseAllSaves({reason:E})}}return{writeData:I}}export{N as createPageDataWrite};
1
+ import"./c-VHNSBD2M.js";var M="data-write",E="Waiting for the page data write to finish";function n(e,t,r){let a=new Error(t);return a.code=e,a.details=r,a}async function U(e){if(typeof e.json=="function")return e.json();let t=await e.text();return t?JSON.parse(t):null}async function R(e){let t={};try{t=await U(e)||{}}catch{}let r=t.message||t.error||e.statusText||`Request failed (${e.status})`,a=new Error(r);return a.status=e.status,a.error=t.error,a.details=t.details,a}function F(e){let t=e.headers?.get?.("ETag");return typeof t=="string"&&t?t:null}function q(e,t){let r=`${t.origin}${t.pathname}`;return e!==void 0?`${r}?data=${encodeURIComponent(JSON.stringify(e))}`:`${t.origin}/_/api${t.pathname}`}function D(e){return!!e&&!e.isDestroyed&&e.sse?.readyState===1}function x(e,t){let r=[],a=null,o=null,c=null,p=i=>i?.source==="disk"&&(a===null||i.etag===a),P=i=>i?.source==="disk"&&(i.etag==null||a===null||i.etag===a),d=()=>{clearTimeout(c),e.removeEventListener("clay:sync-applied",w)},w=i=>{if(r.push(i.detail),!o||!P(i.detail))return;let u=o;o=null,d(),u(!0)};return e.addEventListener("clay:sync-applied",w),{waitFor(i){return a=i,r.some(p)?(d(),Promise.resolve(!0)):new Promise(u=>{o=u,c=setTimeout(()=>{o=null,d(),u(!1)},t)})},cancel:d}}function $(e){let t=new AbortController,r,a=new Promise((c,p)=>{r=p}),o=setTimeout(()=>{let c=new Error("The page data write timed out.");c.name="TimeoutError",t.abort(c),r(c)},e);return{signal:t.signal,waitFor(c){return Promise.race([c,a])},cancel(){clearTimeout(o)}}}async function j(){let[e,t,r,a,o]=await Promise.all([import("./core/save-JZ7R4ET2.js"),import("./core/save-core-I4N6S4ED.js"),import("./c-CL5LSATX.js"),import("./core/unsaved-warning-BP6ZY3PG.js"),import("./core/is-edit-mode-73OXKK5H.js")]);return{...e,...t,...r,...a,...o}}async function H(){let{isDraftMode:e}=await import("./core/is-edit-mode-73OXKK5H.js");return e?n("DataUnavailableInDraft","Page data is kept in this browser for this visitor."):null}function N({supports:e,token:t,fetchImpl:r,getLocation:a,eventTarget:o,getLiveSync:c,loadWriteModules:p=j,syncTimeoutMs:P=12e3,httpTimeoutMs:d=3e4}){let w=!1,i=!1;function u(l,{checkHold:m=!0}={}){if(l.savesAdmitted&&!l.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(i)throw n("DataWriteOutcomeUnknown","A previous page data write has an unknown outcome. Reload before writing again.");if(w)throw n("DataWriteInProgress","Another page data write is already running.");if(l.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(l.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(m&&(l.savesHeld()||l.isSaveConflicted()))throw n("SavesHeld","The page cannot write data while another save hold is active.");if(l.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.")}async function A(l){l.baselineSettled()||await new Promise(m=>o.addEventListener("clay:baseline-settled",m,{once:!0}))}async function I(l,{rules:m,ifMatch:O}={}){let b=await H();if(b)throw b;if(!await e(M))throw n("DataWriteUnsupported","This host does not support writing page data.");let s=await p();if(!s.isEditMode)throw n("DataWriteUnavailable","Page data writes require an editable page.");await A(s),u(s);let v=O;if(v==null&&(v=s.lastSeenEtag()||await s.seedEtag()),typeof v!="string"||v==="")throw n("DataWriteVersionRequired","Page data writes require a trustworthy document ETag.");u(s),w=!0,s.holdAllSaves(E);let g=null;try{if(s.isSaveInProgress())throw n("SaveInProgress","The page is already being saved.");if(s.saveFateIsUnknown())throw n("SaveOutcomeUnknown","The page's last save has an unknown outcome.");if(s.isSaveConflicted())throw n("SavesHeld","The page cannot write data while another save hold is active.");if(s.hasUnsavedChanges())throw n("UnsavedChanges","Save or discard the page's unsaved changes before writing data.");if(s.savesAdmitted&&!s.savesAdmitted())throw n("ModeTransition","The page is switching modes. Write page data again when it has settled.");if(!D(c()))throw n("SyncRequired","Page data writes require the sync plugin to be connected.");let W={"Content-Type":"application/json","If-Match":v},k=t();k&&(W["Save-Token"]=k);let _=JSON.stringify(l);g=x(o,P);let h=$(d),y;try{y=await h.waitFor(r(q(m,a()),{method:"POST",credentials:"same-origin",redirect:"error",headers:W,body:_,signal:h.signal}))}catch(T){throw h.cancel(),i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data write has an unknown outcome. Do not retry automatically."),{cause:T,unknownOutcome:!0})}let S;try{if(!y.ok)throw await h.waitFor(R(y));S=await h.waitFor(U(y))}catch(T){throw T?.status?T:(i=!0,Object.assign(n("DataWriteOutcomeUnknown","The page data was written, but its response could not be read."),{cause:T,unknownOutcome:!0}))}finally{h.cancel()}let f=F(y);if(f&&f===s.lastSeenEtag())return g.cancel(),g=null,{data:S,etag:f};let C=await g.waitFor(f);return g=null,C?{data:S,etag:f}:{data:S,etag:f,pageUpdatePending:!0,message:"Written, page update pending."}}finally{g?.cancel(),w=!1,s.releaseAllSaves({reason:E})}}return{writeData:I}}export{N as createPageDataWrite};
@@ -1,4 +1,4 @@
1
- import{a as L,c as u,d as m,e as C,g as D,h as B,i as d,j as S,k as $,l as k,m as P}from"./c-DD26VXAP.js";import{C as h,d as N}from"./c-ZRGEN6QQ.js";import{a as M,d as A}from"./c-OH2FPYSY.js";import{c as R}from"./c-FSQXFG5T.js";import{d as y}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var c=new WeakMap;var{Decoration:U,DecorationSet:F}=y,at=A.nodes,H=new Set(["timeout","network","error","bad-response"]),I=`
1
+ import{a as L,c as u,d as m,e as C,g as D,h as B,i as d,j as S,k as $,l as k,m as P}from"./c-T7LOTEWO.js";import{C as h,d as N}from"./c-3Y234AUB.js";import{a as M,d as A}from"./c-OH2FPYSY.js";import{c as R}from"./c-FSQXFG5T.js";import{d as y}from"./c-RETTCOWO.js";import"./c-VHNSBD2M.js";var c=new WeakMap;var{Decoration:U,DecorationSet:F}=y,at=A.nodes,H=new Set(["timeout","network","error","bad-response"]),I=`
2
2
  .blockeditor-editor .blockeditor-image { margin-inline: 0; }
3
3
  .blockeditor-image-frame { position: relative; margin: 0 auto; max-width: 100%; }
4
4
  .blockeditor-image-frame img { display: block; width: 100%; height: auto; border-radius: var(--blockeditor-image-radius, 6px); }
@@ -0,0 +1 @@
1
+ import{a as d}from"./c-Y3J5LDKB.js";import"./c-PZ4XEPUP.js";import"./c-SFKI6OLM.js";import"./c-Q3XOWZEV.js";import"./c-RHMPKZZ7.js";import{c as m,h as v,j as x,m as s}from"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import{a as p}from"./c-4JZDZFF6.js";import{e as f}from"./c-5RZNFTWD.js";import{b as w}from"./c-PKCCHJ5X.js";import{b as c}from"./c-NUHP2XDB.js";import{f as l}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-UW6MMZ4V.js";import"./c-XQXZAO7N.js";import"./c-S7LK4KUE.js";import"./c-MOP5KBWZ.js";import"./c-2YYDMLNZ.js";import"./c-HA6INT6J.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var $="Download a copy, then reduce its size; saving still works.",b="Download a copy to keep your work.",t=null,r=null,i=null,a=null;function h(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"an unknown size":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.max(1,Math.round(e/1024))} KB`:`${e} bytes`}function y({bytes:e,maxBytes:n,state:S}){let u=`At the last save attempt: ${h(e)} of ${h(n)}.`;return S==="over"?`This host can't save a file this size. ${u} ${b}`:`This file is getting large. ${u} ${$}`}function o(){if(!t)return;let e=window.visualViewport,n=e?Math.max(0,window.innerHeight-e.height-e.offsetTop):0;c(t,"bottom",`calc(${16+n}px + env(safe-area-inset-bottom,0px))`)}async function z(){await d({})}function A(){t=v("div",["position:fixed","left:50%","transform:translateX(-50%)","z-index:2147483000","display:flex","align-items:center","gap:10px 12px","width:max-content","max-width:calc(100vw - 24px)","flex-wrap:wrap","padding:8px 8px 8px 14px","text-align:left",`color-scheme:${p()}`]),t.setAttribute("clay","editor-ui"),t.setAttribute("data-clay-save-size",""),t.setAttribute("role","status"),r=x("span",[],""),i=m("Download my copy",{small:!0,onClick:z}),s(i,!1,"inline-flex"),t.append(r,i),document.body.appendChild(t),o(),window.visualViewport?.addEventListener("resize",o),window.visualViewport?.addEventListener("scroll",o)}function M(e){t||A(),r.textContent=y(e),s(i,e.state==="over","inline-flex"),o(),w(t,{background:f.surface})}function E(){t&&(window.visualViewport?.removeEventListener("resize",o),window.visualViewport?.removeEventListener("scroll",o),t.remove(),t=null,r=null,i=null)}function g(e){let n=e?.detail;n&&(n.state==="near"||n.state==="over"?M(n):E())}function k(){l||L()}function N(e){l&&(a||=new AbortController,document.addEventListener("clay:save-size",g,{signal:a.signal}),document.addEventListener("clay:modechange",k,{signal:a.signal}),e?.type==="clay:save-size"&&g(e))}function L(){a?.abort(),a=null,E()}export{N as start,L as stop};
@@ -1 +1 @@
1
- import{a as j}from"./c-MJ7GVE46.js";import{b as S,c as A,f as C,i as l,j as P,l as L,n as B}from"./c-EDE45NM7.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4NTUVDZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=0,x=[],b=[],d=null,I=!1,E=!1,v=null,M=null,$=15e3,u=()=>P().mode,p=(e,t)=>Object.assign(new Error(`clay.modeLifecycle: ${e}`),{code:t});function U(){document.dispatchEvent(new Event("clay:modechange"))}function h(e,t="idle",o={}){return l({phase:t,reason:e}),{ok:!1,mode:u(),code:e,...o}}function k(e){for(let t of[...e].reverse())try{t.dispose?.()}catch{}}function D(e){try{e?.reclaimArticle?.()}catch{}try{e?.resume?.()}catch{}}function O(e){document.documentElement.setAttribute("editmode",e?"true":"false")}function G(){try{let e=new URL(window.location.href);if(!e.searchParams.has("editmode"))return;e.searchParams.delete("editmode"),window.history.replaceState(window.history.state,"",`${e.pathname}${e.search}${e.hash}`)}catch(e){console.warn("clayjs: the URL could not be rewritten after the mode switch",e)}}var N=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[]];function X(e){let t=[];for(let o of N(e)){let n=j(o);if(n!=="export"&&typeof n!="function")continue;let r=e.loaded?.[o];r&&t.push(typeof n=="function"?n(r):r.modeParticipant?.())}return t}async function _(e){let t=new Set(b.map(({id:n})=>n)),o=n=>{if(typeof n?.id!="string"||typeof n.prepare!="function")throw p("a participant needs an id and a prepare()","unsupported-plugin");t.has(n.id)||(t.add(n.id),b.push(n))};if(e)for(let n of X(e))o(await n);for(let n of B())o(await n);return[...b].sort((n,r)=>(n.order??0)-(r.order??0))}function z(e){let t=b.findIndex(o=>o.id===e);t!==-1&&b.splice(t,1)}L(z);function H(e,t){if(!e||e.bytes===null)return!1;let o=t??{};return typeof e.seq=="number"&&typeof o.seq=="number"&&e.seq!==o.seq?e.seq>o.seq:(e.etag??null)!==(o.etag??null)}async function V(e=null){let t=u(),o=C,n=new AbortController,r={generation:++y,destination:P().destination,signal:n.signal,represented:null,reader:null,initial:!1,isCurrent:()=>r.generation===y&&!n.signal.aborted};l({phase:"entering",generation:r.generation,reason:null}),e||(I=!0,E=!1,v=null);let s=[],c=[],f=null,i=null,w=!1,m=(async()=>{try{if(e){let a=await import("./c-FEC6LGFF.js");i=await a.prepareReader(e,r),c.push(...await a.importPlan(e,e.edit,{signal:n.signal})),await i?.reconcile(),r.represented=i?i.represented:null,r.reader=i,M=r.represented}f=e?.loaded?.["core/save.js"]??await import("./core/save-6HT2LABE.js");for(let a of await _(e)){w=!0;let g=await a.prepare(r);if(g){if(s.push(g),!r.isCurrent())throw p(`"${a.id}" prepared for a stale generation`,"stale-document");if(g.ready&&await g.ready,!r.isCurrent())throw p(`"${a.id}" became ready for a stale generation`,"stale-document")}}if(e||!o){let a=f.adoptEntryBaseline({represented:r.represented});if(a&&a.ok===!1)throw Object.assign(p("the page moved since the last session",a.code||"pending-input"),a);if(H(i?.held??i?.represented,r.represented))throw p("the reader holds a newer file than the session was built from","stale-document")}return!0}catch(a){throw k(s),a}})(),q=null,W=new Promise(a=>{q=setTimeout(()=>{n.abort(),a(!1)},$)}),T;try{T=await Promise.race([m,W])}catch(a){return clearTimeout(q),n.abort(),w?(D(i),h(a?.code||"load-failed","blocked",{message:a?.message})):(D(i),l({phase:"idle",reason:null}),null)}if(clearTimeout(q),!T)return m.catch(()=>{}),k(s.splice(0)),D(i),h("timeout");i?.commit(),l({mode:S?"draft":"edit",isEditMode:!0}),e&&G(),O(!0),f?.setSaveGeneration(r.generation);try{for(let a of s)a.enable()}catch(a){return l({mode:t,isEditMode:o}),O(!1),k(s),n.abort(),e&&(await import("./c-FEC6LGFF.js").catch(()=>null))?.startReader(e,M),h(a?.code||"load-failed","blocked",{message:a?.message})}x=s,l({phase:"idle",reason:null}),U();for(let a of c)e?.announce?.(a);return{ok:!0,mode:u(),changed:t!==u()}}async function J(e){if(!e)return[];let t=[];for(let r of N(e)){let s=j(r);if(s!=="export"&&typeof s!="function")continue;let c=e.loaded?.[r];if(!c)continue;let f=await(typeof s=="function"?s(c):c.modeParticipant?.());if(typeof f?.id!="string"||typeof f.prepare!="function")return null;t.push(f)}t.sort((r,s)=>(r.order??0)-(s.order??0));let o=[],n={generation:y,destination:P().destination,signal:void 0,represented:null,reader:null,initial:!0,isCurrent:()=>!0};for(let r of t){let s=null;try{s=await r.prepare(n)}catch{return null}s&&o.push(s)}return o}async function K(e){return(e?.loaded?.["core/save.js"]??await import("./core/save-6HT2LABE.js").catch(()=>null))?.acceptedReceipt?.(y)??null}var R=Symbol("the exit deadline passed");function Q(){let e=null,t=Date.now()+$;return{expired:new Promise(n=>{e=setTimeout(()=>n(R),$)}),remaining:()=>Math.max(0,t-Date.now()),clear:()=>clearTimeout(e)}}async function Y(e,t){if(!e)return;let n=(await import("./c-FEC6LGFF.js")).importPlan(e,e.view);n.catch(()=>{});let r=await Promise.race([n.then(()=>null,s=>s),t]);if(r&&r!==R)throw r}async function Z(e=null){let t=Q();try{return await ee(e,t)}finally{t.clear()}}async function ee(e,t){let o=I;l({phase:"leaving"});let n=await import("./c-LATNQ6Q5.js").catch(()=>null);if(!n)return h("load-failed");let r=x;if(o&&!E){v??=J(e);let i=await Promise.race([v,t.expired]);if(i===R)return h("timeout");if(!i)return v=null,l({phase:"idle",reason:null}),null;E=!0,r=[...i,...r],x=r}try{await Y(e,t.expired)}catch(i){return h(i?.code||"load-failed","idle",{message:i?.message})}let s=[],c=null;try{if(c=n.claimOperation("mode"),!c)throw p("another document operation is in progress","busy");for(let w of[...r].reverse()){s.push(w);let m=await Promise.race([Promise.resolve(w.quiesce?.()),t.expired]);if(m===R)throw p("the exit deadline passed while a lease quiesced","timeout");if(m&&m.ok===!1)throw Object.assign(p("a lease refused the exit",m.code||"pending-input"),m)}let i=await n.runSaveBarrier({operation:c,timeoutMs:t.remaining()});if(!i.ok)throw Object.assign(p("the exit barrier refused",i.code||"save-failed"),i)}catch(i){for(let w of[...s].reverse())try{w.resume?.()}catch{}return l({phase:"idle",reason:i?.code||"save-failed"}),{ok:!1,mode:u(),code:i?.code||"save-failed",state:i?.state,pending:i?.pending}}finally{c&&n.releaseOperation(c)}k(r),x=[],I=!1,E=!1,v=null;let f=await K(e)??M;return M=null,e&&(await import("./c-FEC6LGFF.js").catch(()=>null))?.startReader(e,f),y++,O(!1),l({mode:"view",isEditMode:!1,phase:"idle",generation:y,reason:null}),G(),U(),{ok:!0,mode:"view",changed:!0}}function F(e,t=null){if(e!=="edit"&&e!=="view")throw new TypeError(`clay.modeLifecycle: unknown mode "${e}"`);if(d)return d.target===e?d.promise:{ok:!1,mode:u(),code:"busy"};if(e===u())return{ok:!0,mode:u(),changed:!1};if(S||e==="edit"&&!A)return{ok:!1,mode:u(),code:"not-allowed"};let o=(e==="edit"?V(t):Z(t)).finally(()=>{d=null});return d={target:e,promise:o},o}async function re(e,t){let o=await import("./c-FEC6LGFF.js").catch(()=>null);return!o||!o.liveAllowed(t)?null:(d||e===u()||e==="edit"&&o.openResources(),F(e,t))}async function oe(){if(u()==="view")return{ok:!0,mode:"view",changed:!1};if(d)return d.promise;let e=V().finally(()=>{d=null});return d={target:"edit",promise:e},e}export{oe as activateInitial,z as forgetParticipant,F as requestMode,re as switchMode};
1
+ import{a as j}from"./c-MJ7GVE46.js";import{b as S,c as A,f as C,i as l,j as P,l as L,n as B}from"./c-C7SUMNMI.js";import"./c-BPF2NSPV.js";import"./c-P7KNDG34.js";import"./c-CYWLPPUS.js";import"./c-U4TWEIKZ.js";import"./c-HA6INT6J.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=0,x=[],b=[],d=null,I=!1,E=!1,v=null,M=null,$=15e3,u=()=>P().mode,p=(e,t)=>Object.assign(new Error(`clay.modeLifecycle: ${e}`),{code:t});function U(){document.dispatchEvent(new Event("clay:modechange"))}function h(e,t="idle",o={}){return l({phase:t,reason:e}),{ok:!1,mode:u(),code:e,...o}}function k(e){for(let t of[...e].reverse())try{t.dispose?.()}catch{}}function D(e){try{e?.reclaimArticle?.()}catch{}try{e?.resume?.()}catch{}}function O(e){document.documentElement.setAttribute("editmode",e?"true":"false")}function G(){try{let e=new URL(window.location.href);if(!e.searchParams.has("editmode"))return;e.searchParams.delete("editmode"),window.history.replaceState(window.history.state,"",`${e.pathname}${e.search}${e.hash}`)}catch(e){console.warn("clayjs: the URL could not be rewritten after the mode switch",e)}}var N=e=>[...e?.edit?.core??[],...e?.edit?.plugins??[],...e?.edit?.late??[]];function X(e){let t=[];for(let o of N(e)){let n=j(o);if(n!=="export"&&typeof n!="function")continue;let r=e.loaded?.[o];r&&t.push(typeof n=="function"?n(r):r.modeParticipant?.())}return t}async function _(e){let t=new Set(b.map(({id:n})=>n)),o=n=>{if(typeof n?.id!="string"||typeof n.prepare!="function")throw p("a participant needs an id and a prepare()","unsupported-plugin");t.has(n.id)||(t.add(n.id),b.push(n))};if(e)for(let n of X(e))o(await n);for(let n of B())o(await n);return[...b].sort((n,r)=>(n.order??0)-(r.order??0))}function z(e){let t=b.findIndex(o=>o.id===e);t!==-1&&b.splice(t,1)}L(z);function H(e,t){if(!e||e.bytes===null)return!1;let o=t??{};return typeof e.seq=="number"&&typeof o.seq=="number"&&e.seq!==o.seq?e.seq>o.seq:(e.etag??null)!==(o.etag??null)}async function V(e=null){let t=u(),o=C,n=new AbortController,r={generation:++y,destination:P().destination,signal:n.signal,represented:null,reader:null,initial:!1,isCurrent:()=>r.generation===y&&!n.signal.aborted};l({phase:"entering",generation:r.generation,reason:null}),e||(I=!0,E=!1,v=null);let s=[],c=[],f=null,i=null,w=!1,m=(async()=>{try{if(e){let a=await import("./c-YZGWSCMT.js");i=await a.prepareReader(e,r),c.push(...await a.importPlan(e,e.edit,{signal:n.signal})),await i?.reconcile(),r.represented=i?i.represented:null,r.reader=i,M=r.represented}f=e?.loaded?.["core/save.js"]??await import("./core/save-JZ7R4ET2.js");for(let a of await _(e)){w=!0;let g=await a.prepare(r);if(g){if(s.push(g),!r.isCurrent())throw p(`"${a.id}" prepared for a stale generation`,"stale-document");if(g.ready&&await g.ready,!r.isCurrent())throw p(`"${a.id}" became ready for a stale generation`,"stale-document")}}if(e||!o){let a=f.adoptEntryBaseline({represented:r.represented});if(a&&a.ok===!1)throw Object.assign(p("the page moved since the last session",a.code||"pending-input"),a);if(H(i?.held??i?.represented,r.represented))throw p("the reader holds a newer file than the session was built from","stale-document")}return!0}catch(a){throw k(s),a}})(),q=null,W=new Promise(a=>{q=setTimeout(()=>{n.abort(),a(!1)},$)}),T;try{T=await Promise.race([m,W])}catch(a){return clearTimeout(q),n.abort(),w?(D(i),h(a?.code||"load-failed","blocked",{message:a?.message})):(D(i),l({phase:"idle",reason:null}),null)}if(clearTimeout(q),!T)return m.catch(()=>{}),k(s.splice(0)),D(i),h("timeout");i?.commit(),l({mode:S?"draft":"edit",isEditMode:!0}),e&&G(),O(!0),f?.setSaveGeneration(r.generation);try{for(let a of s)a.enable()}catch(a){return l({mode:t,isEditMode:o}),O(!1),k(s),n.abort(),e&&(await import("./c-YZGWSCMT.js").catch(()=>null))?.startReader(e,M),h(a?.code||"load-failed","blocked",{message:a?.message})}x=s,l({phase:"idle",reason:null}),U();for(let a of c)e?.announce?.(a);return{ok:!0,mode:u(),changed:t!==u()}}async function J(e){if(!e)return[];let t=[];for(let r of N(e)){let s=j(r);if(s!=="export"&&typeof s!="function")continue;let c=e.loaded?.[r];if(!c)continue;let f=await(typeof s=="function"?s(c):c.modeParticipant?.());if(typeof f?.id!="string"||typeof f.prepare!="function")return null;t.push(f)}t.sort((r,s)=>(r.order??0)-(s.order??0));let o=[],n={generation:y,destination:P().destination,signal:void 0,represented:null,reader:null,initial:!0,isCurrent:()=>!0};for(let r of t){let s=null;try{s=await r.prepare(n)}catch{return null}s&&o.push(s)}return o}async function K(e){return(e?.loaded?.["core/save.js"]??await import("./core/save-JZ7R4ET2.js").catch(()=>null))?.acceptedReceipt?.(y)??null}var R=Symbol("the exit deadline passed");function Q(){let e=null,t=Date.now()+$;return{expired:new Promise(n=>{e=setTimeout(()=>n(R),$)}),remaining:()=>Math.max(0,t-Date.now()),clear:()=>clearTimeout(e)}}async function Y(e,t){if(!e)return;let n=(await import("./c-YZGWSCMT.js")).importPlan(e,e.view);n.catch(()=>{});let r=await Promise.race([n.then(()=>null,s=>s),t]);if(r&&r!==R)throw r}async function Z(e=null){let t=Q();try{return await ee(e,t)}finally{t.clear()}}async function ee(e,t){let o=I;l({phase:"leaving"});let n=await import("./c-H3M6UDNV.js").catch(()=>null);if(!n)return h("load-failed");let r=x;if(o&&!E){v??=J(e);let i=await Promise.race([v,t.expired]);if(i===R)return h("timeout");if(!i)return v=null,l({phase:"idle",reason:null}),null;E=!0,r=[...i,...r],x=r}try{await Y(e,t.expired)}catch(i){return h(i?.code||"load-failed","idle",{message:i?.message})}let s=[],c=null;try{if(c=n.claimOperation("mode"),!c)throw p("another document operation is in progress","busy");for(let w of[...r].reverse()){s.push(w);let m=await Promise.race([Promise.resolve(w.quiesce?.()),t.expired]);if(m===R)throw p("the exit deadline passed while a lease quiesced","timeout");if(m&&m.ok===!1)throw Object.assign(p("a lease refused the exit",m.code||"pending-input"),m)}let i=await n.runSaveBarrier({operation:c,timeoutMs:t.remaining()});if(!i.ok)throw Object.assign(p("the exit barrier refused",i.code||"save-failed"),i)}catch(i){for(let w of[...s].reverse())try{w.resume?.()}catch{}return l({phase:"idle",reason:i?.code||"save-failed"}),{ok:!1,mode:u(),code:i?.code||"save-failed",state:i?.state,pending:i?.pending}}finally{c&&n.releaseOperation(c)}k(r),x=[],I=!1,E=!1,v=null;let f=await K(e)??M;return M=null,e&&(await import("./c-YZGWSCMT.js").catch(()=>null))?.startReader(e,f),y++,O(!1),l({mode:"view",isEditMode:!1,phase:"idle",generation:y,reason:null}),G(),U(),{ok:!0,mode:"view",changed:!0}}function F(e,t=null){if(e!=="edit"&&e!=="view")throw new TypeError(`clay.modeLifecycle: unknown mode "${e}"`);if(d)return d.target===e?d.promise:{ok:!1,mode:u(),code:"busy"};if(e===u())return{ok:!0,mode:u(),changed:!1};if(S||e==="edit"&&!A)return{ok:!1,mode:u(),code:"not-allowed"};let o=(e==="edit"?V(t):Z(t)).finally(()=>{d=null});return d={target:e,promise:o},o}async function re(e,t){let o=await import("./c-YZGWSCMT.js").catch(()=>null);return!o||!o.liveAllowed(t)?null:(d||e===u()||e==="edit"&&o.openResources(),F(e,t))}async function oe(){if(u()==="view")return{ok:!0,mode:"view",changed:!1};if(d)return d.promise;let e=V().finally(()=>{d=null});return d={target:"edit",promise:e},e}export{oe as activateInitial,z as forgetParticipant,F as requestMode,re as switchMode};
@@ -0,0 +1 @@
1
+ import{a as ce,b as Qe,c as ue,e as fe,f as pe,g as nt}from"./c-5IIEOPIV.js";import{a as Ze,b as et,c as de,d as tt}from"./c-LZJPNR2W.js";import{a as A,b as J}from"./c-FILLTJA7.js";import{b as Ke}from"./c-5VYOWDTI.js";import{b as oe,c as ae,d as x,f as he,g as Ve,h as Xe}from"./c-P73XPAOA.js";import{a as q}from"./c-MZCOGNZL.js";import{a as Ge}from"./c-LD6UVV5R.js";import{a as ze,f as We,g as Ye,h as Je}from"./c-PGSBXHUE.js";import{a as se,b as $e,c as P,d as re,e as le,h as je}from"./c-KU3PX7LL.js";import{e as Ue}from"./c-EQ5NBOGA.js";import{d as Pe}from"./c-IJUK2GPW.js";import{f as $,j as te}from"./c-C7SUMNMI.js";import{a as Le}from"./c-BPF2NSPV.js";import{E as Y,F as Ne,H as T,I as Oe,b as D,j as ie,o as W,t as M,z as Be}from"./c-UW6MMZ4V.js";import{a as Re,b as qe,c as Me,e as j,g as z,h as ne}from"./c-MOP5KBWZ.js";import{m as Ie,n as Te}from"./c-HA6INT6J.js";import{a as He,b as Fe,l as Ce,m as Ae}from"./c-ICMAOOGK.js";function it(s){let e=new WeakMap,t=0,i=r=>e.get(r)||null,n=r=>{let l=e.get(r);return l||(l=`${s}:${++t}`,e.set(r,l)),l};return{idOf:i,ensure:n,adopt:(r,l)=>{r&&typeof l=="string"&&l&&e.set(r,l)},exportMap:(r,l)=>{let o={},a=[],h=[],c=(d,_)=>{let g=l(d);g&&(o[_]=n(g));let E=d.children;a.push(E.length),h.push(d.tagName.toLowerCase());for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(r,""),o["~"]=a.join(","),o["^"]=h.join(","),o}}}function st(s,e){let t=new WeakMap;if(!s||!e||typeof e!="object"||Array.isArray(e))return t;let i=e["~"],n=typeof i=="string"?i.split(",").map(Number):null,r=n&&typeof e["^"]=="string"?e["^"].split(","):null,l=d=>Number.isInteger(d)&&d>=0,o=0,a=!1,h=d=>{let _=d;for(;_>0;){let g=n[o++];if(o>n.length||!l(g))return!1;_+=g-1}return!0},c=(d,_)=>{if(a)return;if(n){let f=o++,u=n[f];if(f>=n.length||!l(u)){a=!0;return}let S=!r||r[f]===d.tagName.toLowerCase();if(!S||u!==d.children.length){let w=S&&e[_];typeof w=="string"&&w&&t.set(d,w),h(u)||(a=!0);return}}let g=e[_];typeof g=="string"&&g&&t.set(d,g);let E=d.children;for(let f=0;f<E.length;f++)c(E[f],_===""?String(f):`${_}.${f}`)};return c(s,""),t}function St(s){return e=>{for(let t of s){let i=t(e);if(typeof i=="string"&&i!=="")return i}return null}}var Bt=St([s=>s.getAttribute("data-id"),s=>s.getAttribute("id")]);var Et=/^blockeditor(\.[0-9]+)?$/,rt=s=>[...s.querySelectorAll('script[merge][clay~="live"]')].filter(e=>Et.test(e.getAttribute("merge")));function lt(s,e,t){if(!s.html.includes("data-blockeditor"))return s;let i=u=>W(new DOMParser().parseFromString(u,"text/html")),n=i(s.html),r=n.querySelector("article[data-blockeditor]");if(!r)return s;let l=i(e),o=l.querySelector("article[data-blockeditor]");if(!o)return null;let a=st(n.documentElement,s.identityMap),h=(u,S)=>{let w=n.importNode(S,!0),b=a.get(u);return b&&a.set(w,b),u.replaceWith(w),w},c=h(r,o),d=new Map(rt(n).map(u=>[u.getAttribute("merge"),u]));for(let u of rt(l)){let S=u.getAttribute("merge"),w=d.get(S);w?h(w,u):c.before(n.importNode(u,!0)),d.delete(S)}for(let u of d.values())u.remove();let _=n.querySelector("head > title"),g=l.querySelector("head > title");_&&g?h(_,g):g?n.head.append(n.importNode(g,!0)):_?.remove();let E=n.documentElement,f=t.exportMap(E,u=>{let S=a.get(u);return S?(t.adopt(u,S),u):null});return{...s,html:T(E),identityMap:f}}var wt={"merge-tokens":"tokens","merge-max":"max"};function ot(s,e){if(!e.startsWith("data-")||e==="data-id"||!s?.closest)return null;for(let[t,i]of Object.entries(wt)){let n=s.closest(`[${t}]`);if(n&&n.getAttribute(t).split(/\s+/).includes(e))return i}return null}var m=null,at=null,B=new Map;function V(){return at??=Promise.all([import("./c-O3DPFZCE.js"),import("./c-EJTGYSLN.js")]).then(([s,e])=>{m={...s,beginLineageCapture:e.beginLineageCapture};for(let t of[...B.keys()])B.set(t,s.registerContext(t));return m}),at}var ht=()=>m,I={get size(){return m?m.conflicts.size:0},list(){return m?m.conflicts.list():[]},get(s){return m?m.conflicts.get(s):null},acknowledge(s,e={}){if(m)return m.conflicts.acknowledge(s,e);if(!Array.isArray(s))throw new TypeError("clay.conflicts.acknowledge needs an array of ids");return{removedIds:[],remainingIds:[]}},claim(s,e={}){if(m)return m.conflicts.claim(s,e);if(!e.owner)throw new TypeError("clay.conflicts.claim needs an owner");return{release(){}}},registerContext(s){if(m)return m.conflicts.registerContext(s);if(typeof s!="function")throw new TypeError("clay.conflicts.registerContext needs a resolver function");return B.set(s,null),()=>{let e=B.get(s);B.delete(s),e&&e()}},contextFor(s,e){return m?m.conflicts.contextFor(s,e):null},recoveryOf(s){return m?m.conflicts.recoveryOf(s):null},hasPendingApply(){return m?m.conflicts.hasPendingApply():!1}};var y=null,_e=null;function R(){return _e??=new Promise(s=>setTimeout(s,0)).then(()=>import("./c-HYNM5U6B.js")).then(s=>y=s).catch(s=>{throw _e=null,s}),_e}var ve=null,ge=null;function kt(){return ge??=import("./c-SMLAJASY.js").then(s=>ve=s.presence).catch(s=>{throw ge=null,s}),ge}var ft=te().phase==="entering";$&&!ft&&R().catch(()=>{});$&&V().catch(()=>{});var L=null,ye=null,Q=[];function pt(s){L.presence.update(s),L.editingMarker.update(s)}function xt(){return ye??=Promise.all([import("./c-WOWGGNCJ.js"),import("./c-EEWPNUM2.js")]).then(([s,e])=>{L={presence:s.presence,editingMarker:e.editingMarker};let t=Q;Q=[];for(let i of t)pt(i);return L}).catch(s=>{throw ye=null,s}),ye}function bt(s){if(L){pt(s);return}Q.push(s),xt().catch(()=>{})}var dt=Object.freeze({bytes:null,etag:null,seq:null}),Dt=()=>({msg:"Not in edit mode",msgType:"skipped",code:null,etag:null}),_t=["[editor-ui]",'[clay~="editor-ui"]',"[save-ignore]","[snapshot-remove]","[no-snapshot]","[no-save]","[save-remove]","[freeze] *","[save-freeze] *",'[clay~="no-save"]','[clay~="no-snapshot"]','[clay~="freeze"] *',Ce,He].join(","),gt='[clay~="freeze"], [freeze], [save-freeze]';function X(s){for(let e of s.querySelectorAll(gt))e.replaceChildren();return z()&&Me(s),s}function ut(s){if(s==null)return s;let e=typeof s=="string"?new DOMParser().parseFromString(s,"text/html"):s;return ie(e),W(e),X(e),e}var It=[Ae,'[clay~="no-watch"]',"[no-watch]","[mutations-ignore]"].join(","),Tt=(s,e,t)=>Ie(s,e,t)||Fe.test(e.toLowerCase()),yt=s=>s.getAttribute("data-id")||s.getAttribute("id")||null;function Lt(s){let e=new Map,t=n=>{if(n.matches(_t))return;let r=yt(n);r&&e.set(r,(e.get(r)||0)+1);let l=n.localName==="template"&&n.content?n.content.children:n.children;for(let o of l)t(o)},i=s.nodeType===9?[s.documentElement]:s.nodeType===11?s.children:[s];for(let n of i)n&&n.nodeType===1&&t(n);return e}var Ht=s=>e=>{let t=yt(e);if(!t)return null;let i=e.getRootNode(),n=s.get(i);return n||s.set(i,n=Lt(i)),n.get(t)===1?t:null},me=s=>!!s&&typeof s=="object"&&!Array.isArray(s);function Ft(s){return typeof s!="string"||s===""?null:new DOMParser().parseFromString(s,"text/html").documentElement?.getAttribute("documentetag")||null}function Ct(s,e){e!=="live"||!s||!y||(y.enableContentEditable(s),y.enableOnClick(s),y.enableAdminInputs(s),y.enableAdminResources(s))}function At(){let{forComparison:s,forDirty:e}=Be({flushUndo:!1});return[s,e]}var Rt=1024*1024;function qt(s,e,t,i,n){let r={sender:t,identityMap:i,...n?{etag:n}:{}};return e.length<Rt?JSON.stringify({[s.snapshotKey]:e,...r}):new Blob([`{${JSON.stringify(s.snapshotKey)}:`,JSON.stringify(e),`,${JSON.stringify(r).slice(1)}`],{type:"application/json"})}var Se=class{constructor(){this.sse=null,this.currentFile=null,this.lastHtml=null,this._diskBase=null,this._diskBaseTicket=0,this._agreeSeq=0,this._saveTicket=0,this._peerBaseTicket=0,this._acceptedSaveTicket=0,this._morphTicket=0,this.clientId=this.generateClientId(),this.resumeId=null,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._sendInFlight=!1,this._queuedSend=null,this._profile=null,this._profilePromise=null,this._sharedData=!1,this._sharedSync=!1,this._workerFeatures=["live-data"],this._liveData=!1,this._editing=null,this._presenceLease=null,this._presenceQuiesced=!1,this._ready=null,this._startGen=0,this.isPaused=!1,this.isDestroyed=!1,this.debug=!1,this._lane=$?"live":"saved",this._laneChosen=!1,this._snapshotHandler=null,this._hiddenHandler=null,this.lastSeenSeq=0,this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,this._morphInFlight=!1,this._rafHandle=null,this._represented=dt,this._handoff=null,this._handoffHeld=!1,this._pendingExternal=null,this._lastExternalSeq=0,this._saveEpoch=0,this._saveSavedHandler=null,this._saveConflictHandler=null,this._settledHandler=null,this._lastIdentityMap=null,this._applyGen=0,this._holdRetryPeer=null,this._holdRetryExt=null,this._servedFetchId=0,this._startupRetry=null,this._engineRetry=null,this._heldLive=!1,this._heldExt=!1,this.identity=it(this.clientId),this.onConnect=null,this.onDisconnect=null,this.onUpdate=null,this.onError=null,this.onNotification=null}get unresolvedConflicts(){return I.list().filter(e=>e.kind!=="apply-incomplete")}_log(e,t=null){if(!this.debug)return;let i=`[LiveSync ${new Date().toISOString()}]`;t!==null?console.log(i,e,t):console.log(i,e)}generateClientId(){return Math.random().toString(36).slice(2,11)+Date.now().toString(36)}generateResumeId(){try{let e=new Uint8Array(16);return(globalThis.crypto||window.crypto).getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}catch{return Math.random().toString(36).slice(2)+Date.now().toString(36)}}_seedBases(){if(x())return;let e=M({flushUndo:!1});this._setPeerBase(T(e),this.identity.exportMap(e,D),this._ticket()),this._setDiskBase(Y({emitForSync:!1}).forSave,this._ticket())}get lane(){return this._lane}set lane(e){this._lane=e,this._laneChosen=!0}start(e=null,{lane:t,represented:i}={}){if(this.isDestroyed=!1,(this.sse||this._snapshotHandler)&&this.cleanup(),this.currentFile=e||this.detectCurrentFile(),!this.currentFile){console.warn("[LiveSync] No file detected");return}let n=te().mode==="edit"?"live":"saved",r=this.lane==="live";this._lane=t||(this._laneChosen?this._lane:n),this.lastHtml=null,this._lastIdentityMap=null,this._peerBaseTicket=this._ticket(),this._diskBase=null,this._diskBaseTicket=this._ticket(),this._saveTicket=0,this._savedSnapshot?.abort?.abort(),this._savedSnapshot=null,this._applyGen++,this.lastSeenSeq=0,this._lastExternalSeq=0,this._represented=i?Object.freeze({bytes:i.bytes??null,etag:i.etag??null,seq:i.seq??null}):dt,this._acquireEmptySaved=r&&this.lane==="saved"&&this._represented.bytes===null,this._pendingExternal=null,this.resumeId=this.generateResumeId(),this.lane==="live"&&this._seedBases(),this.lane==="live"&&V().catch(()=>{}),console.log(`[LiveSync] Starting for: ${this.currentFile} (lane=${this.lane})`);let l=++this._startGen;if(this.lane==="live"&&!(y&&y.baselineSettled())){let o=this._applyGen,a=this._morphTicket,h=this._saveEpoch,c=this.lastHtml,d=this._diskBaseTicket,_=this._diskBase!==null;this._settledHandler=()=>{if(this._settledHandler=null,!(this.isDestroyed||this._startGen!==l)&&!Pe()&&!x()&&this._saveTicket===0&&this._morphTicket===a){if(c!==null&&this._applyGen===o&&this._saveEpoch===h&&this.lastHtml===c){let g=M({flushUndo:!1});this._setPeerBase(T(g),this.identity.exportMap(g,D),this._ticket())}_&&this._diskBaseTicket===d&&this._setDiskBase(Y({emitForSync:!1}).forSave,this._ticket())}},document.addEventListener("clay:baseline-settled",this._settledHandler,{once:!0})}this._ready=Promise.all([this.lane==="live"?R():null,this._resolveProfile()]).then(()=>{this.isDestroyed||this._startGen!==l||this.connect()}),this.lane==="live"&&(this.listenForSnapshots(),kt().then(o=>this._startPresence(o,l),()=>{}),this._saveSavedHandler=o=>{this._saveEpoch++;let a=this._saveTicket||this._ticket();this._saveTicket=0,a>this._acceptedSaveTicket&&(this._acceptedSaveTicket=a);let h=y?y.getLastSavedBytes():null;h!=null&&this._setDiskBase(h,a),this._relayCommit(o?.detail?.captureId,h)},document.addEventListener("clay:save-saved",this._saveSavedHandler),this._saveConflictHandler=o=>{let a=o.detail&&o.detail.etag;a&&queueMicrotask(()=>{this.isDestroyed||a===se()&&(y?.conflictResolvedBySync(a),this._saveAfterMerge(x(),!1))})},document.addEventListener("clay:save-conflict",this._saveConflictHandler))}cleanup(){if(this.sse&&(this.sse.close(),this.sse=null),de(),Q=[],L&&(L.presence.clear(),L.editingMarker.clear()),this._editing&&(this._editing.stop(),this._editing=null),this._presenceLease){let e=this._presenceLease;this._presenceLease=null,typeof e.stop=="function"?e.stop():e.detach()}this._lastRoster=null,this._snapshotHandler&&(document.removeEventListener("clay:snapshot-ready",this._snapshotHandler),this._snapshotHandler=null),this._saveSavedHandler&&(document.removeEventListener("clay:save-saved",this._saveSavedHandler),this._saveSavedHandler=null),this._saveConflictHandler&&(document.removeEventListener("clay:save-conflict",this._saveConflictHandler),this._saveConflictHandler=null),this._settledHandler&&(document.removeEventListener("clay:baseline-settled",this._settledHandler),this._settledHandler=null),this._hiddenHandler&&(document.removeEventListener("visibilitychange",this._hiddenHandler),document.removeEventListener("clay:workspace-background",this._hiddenHandler),this._hiddenHandler=null),this._queuedSend=null,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingBy=null,this._pendingExternal=null,this._handoff=null,this._handoffHeld=!1,clearTimeout(this._holdRetryPeer),clearTimeout(this._holdRetryExt),this._holdRetryPeer=null,this._holdRetryExt=null,clearTimeout(this._startupRetry),this._startupRetry=null,clearTimeout(this._engineRetry),this._engineRetry=null,this._servedFetchId++}detectCurrentFile(){let e=window.location.pathname;if(e==="/")return"index.html";e=e.replace(/^\//,"");let t=e.match(/^(.*?\.html(?:clay)?)/);return t?t[1]:e}_resolveProfile(){return this._profilePromise||(this._profilePromise=nt().then(e=>(this._sharedData=e.sharedData,this._sharedSync=e.sharedSync,this._liveData=e.liveData,this._workerFeatures=e.workerFeatures,this._profile=e.profile,this._log(`Wire profile: ${e.profile.name}`),e.profile))),this._profilePromise}_setHeld(e,t,i){let n=e==="live"?"_heldLive":"_heldExt";this[n]!==t&&(this[n]=t,!t&&!this._heldLive&&!this._heldExt&&je({fresh:!0,clearIfMissing:!1}),document.dispatchEvent(new CustomEvent(t?"clay:sync-held":"clay:sync-resumed",{detail:{lane:e,el:i||null}})))}_applyEtagFrame(e){return typeof e.etag!="string"||typeof e.html=="string"?!1:(this._log("Dropping a stamp that arrived with no document: nothing proves this tab holds those bytes"),!0)}connect(){if(this.isDestroyed)return;let t=(this._profile||pe.legacy).streamPath(window.location.href,this.lane,this.resumeId,this.clientId,1);this._hiddenHandler||(this._hiddenHandler=()=>{this._rafHandle==null||!ce()||(this._cancelFrame(this._rafHandle),this._rafHandle=null,this._scheduleNextFrame())},document.addEventListener("visibilitychange",this._hiddenHandler),document.addEventListener("clay:workspace-background",this._hiddenHandler)),this.sse=new Qe(new URL(t,window.location.origin).href,{shared:this._sharedSync,sharedData:this._sharedData,workerFeatures:this._workerFeatures,documentURL:window.location.href,lane:this.lane,clientId:this.clientId,keepAliveWhenHidden:this.lane!=="live"?!1:this._liveData?!0:"shared",startupCheck:!!Le}),this._acquireEmptySaved&&(this._acquireEmptySaved=!1,this._fetchServedDocument(void 0,{repair:!0})),this.sse.onopen=()=>{console.log("[LiveSync] Connected"),this._editing&&this._editing.reconnected(),ve&&ve.reconnect(),this.onConnect&&this.onConnect()},this.sse.addEventListener("open",()=>et({clientId:this.clientId,lane:this.lane})),this.sse.addEventListener("error",()=>de());for(let i of Ze)this.sse.addEventListener(i,n=>{let r;try{r=JSON.parse(n.data)}catch{return}tt(i,r)});this.sse.addEventListener("cursor",i=>{let n;try{n=JSON.parse(i.data)}catch{return}if(!n||n.resync!==!0&&n.startup!==!0)return;let r=n.resync===!0,l=n.startup===!0&&!r;console.log(r?"[LiveSync] Server could not replay everything; refetching the document":"[LiveSync] Checking the served document against the version this tab was served"),this._fetchServedDocument(typeof n.seq=="number"?n.seq:void 0,{repair:r,startup:l})}),this.sse.addEventListener("presence",i=>{let n;try{n=JSON.parse(i.data)}catch{return}bt(n),this._lastRoster=n,this._editing&&this._editing.roster(n)}),this.sse.onmessage=i=>{let n=JSON.parse(i.data),{seq:r}=n;if(typeof r=="number"&&r<=this.lastSeenSeq){this._log(`Dropping stale message: seq=${r}, lastSeen=${this.lastSeenSeq}`);return}if(typeof r=="number"&&(this.lastSeenSeq=r),n.type==="notification"){if(this._maybeAcceptExternalChange(n))return;this.handleNotification(n);return}if(n.error){console.error("[LiveSync] Server error:",n.error),this.onError&&this.onError(new Error(n.error));return}if(this._applyEtagFrame(n))return;let{html:l,sender:o,identityMap:a}=n;if(o===this.clientId){this._log("Ignoring own message (sender matches clientId)");return}if(typeof l!="string"){console.error("[LiveSync] Received invalid html, ignoring");return}let h=typeof n.etag=="string"&&n.etag?n.etag:null;if(this.lane==="live"&&!h&&$e()){this._log(`Dropping an unstamped live frame on a stamping host (seq=${r})`);return}if(this.lane==="saved"&&l===this._represented.bytes){this._represented=Object.freeze({bytes:l,etag:h||null,seq:r??null}),P(h);return}if(h&&l===this.lastHtml){this._log(`Taking the stamp from a peer save of content already applied (seq=${r})`),P(h),y&&y.isSaveConflicted()&&(y.conflictResolvedBySync(h),this._saveAfterMerge(x(),!1));return}this._log(`Received update from: ${o} (my clientId: ${this.clientId}, seq=${r})`),this.applyUpdate(l,r,a,h,n.by),this.onUpdate&&this.onUpdate({html:l,sender:o,seq:r,identityMap:a,etag:h})},this.sse.onerror=()=>{this.sse.readyState===EventSource.CONNECTING?console.log("[LiveSync] Reconnecting..."):this.sse.readyState===EventSource.CLOSED&&(console.log("[LiveSync] Connection closed"),this.onError&&this.onError(new Error("Connection closed"))),this.onDisconnect&&this.onDisconnect()}}listenForSnapshots(){this._snapshotHandler=e=>{if(!e.detail||e.detail.forSave!==!0)return;this._saveTicket=this._ticket();let{documentElement:t}=e.detail;if(!t)return;this._log("snapshot-ready received, preparing to send");let i=this.identity.exportMap(t,D);this._savedSnapshot?.abort?.abort();let n={html:null,steps:null,copy:null,abort:null,identityMap:i,ticket:this._saveTicket,captureId:e.detail.captureId??null};if(e.detail.sliced){n.copy=Oe(t),n.abort=new AbortController;let{signal:r}=n.abort;Promise.all([import("./c-L6KVXPBO.js"),import("./c-ZWBI4HYK.js")]).then(([{serializeForSyncSteps:l},{runSliced:o}])=>{if(r.aborted||typeof n.html=="string")return;let a=(function*(){let h=yield*l(n.copy);n.html=h,n.steps=null})();return n.steps=a,o(a,{signal:r})}).catch(()=>{})}else n.html=T(t);this._savedSnapshot=n},document.addEventListener("clay:snapshot-ready",this._snapshotHandler)}_enqueueSend(e,t,i=null){if(!this._profile){this._queuedSend={html:e,identityMap:t,etag:i},this._resolveProfile().then(()=>this._flushQueuedSend());return}if(this._sendInFlight){this._queuedSend={html:e,identityMap:t,etag:i};return}this._postUpdate(e,t,i)}_flushQueuedSend(){if(this.isDestroyed||this._sendInFlight)return;let e=this._queuedSend;e&&(this._queuedSend=null,this._postUpdate(e.html,e.identityMap,e.etag))}_relayCommit(e=null,t=null){if(this.isDestroyed)return;let i=se(),n=this._savedSnapshot;if(n&&(n.captureId??null)!==(e??null)){this._log("Skipping send - snapshot belongs to a different capture");return}let r=n;if(this._savedSnapshot=null,r?.copy&&typeof r.html!="string")if(r.abort?.abort(),r.steps)for(let c=r.steps.next();!c.done;c=r.steps.next());else r.html=T(r.copy);if(!r||typeof r.html!="string")return;let l=r;if(typeof t=="string"){try{l=lt(r,t,this.identity)}catch(c){this._log(`Skipping send - page relay failed: ${c&&c.message}`);return}if(!l){this._log("Skipping send - accepted capture has no page article");return}}let o=Mt(e)??t,a=typeof o=="string"?We(o):0;l={...l,html:Pt(Ye(l.html,Math.max(Je(),a)),o)};let h=!i&&l.html===this.lastHtml;if(this._setPeerBase(l.html,l.identityMap,l.ticket),h){this._log("Skipping send - HTML unchanged");return}this._enqueueSend(l.html,l.identityMap,i||null)}_postUpdate(e,t,i=null,n=0){this._log(`Sending update (HTML length: ${e.length})`),this._sendInFlight=!0;let r=!1,l=this._profile||pe.legacy;fetch(new URL(l.relayPath,window.location.origin).href,{method:"POST",headers:{"Content-Type":"application/json",[l.documentHeader]:window.location.href,[ze]:String(1)},body:qt(l,e,this.clientId,t,i)}).then(o=>{o.ok||(console.warn("[LiveSync] Save returned status:",o.status),r=o.status>=500||o.status===408||o.status===429)}).catch(o=>{console.error("[LiveSync] Save failed:",o),this.onError&&this.onError(o),r=!0}).finally(()=>{this._sendInFlight=!1;let o=this._queuedSend;if(this._queuedSend=null,o){this._postUpdate(o.html,o.identityMap,o.etag);return}!r||!i||n>=3||this.isDestroyed||(this._sendInFlight=!0,setTimeout(()=>{if(this._sendInFlight=!1,this.isDestroyed)return;let a=this._queuedSend;this._queuedSend=null,a?this._postUpdate(a.html,a.identityMap,a.etag):this._postUpdate(e,t,i,n+1)},500*2**n))})}_startPresence(e,t){return this.isDestroyed||this._startGen!==t||this._presenceLease?null:e.connect({send:i=>this._postPresence(i)}).then(i=>this.isDestroyed||this._startGen!==t?(typeof i?.stop=="function"?i.stop():i?.detach(),null):(this._presenceLease=i||null,Ue("presence-editing")),()=>!1).then(i=>{if(!(!i||this.isDestroyed||this._startGen!==t||this._editing))return R().then(n=>{this.isDestroyed||this._startGen!==t||this._editing||(this._editing=new n.EditingSender({}),this._presenceQuiesced?this._editing.stop():(this._editing.start(),this._editing.roster(this._lastRoster)))})})}_postPresence(e){let t=new URL("/_/presence",window.location.origin);return t.searchParams.set("client-id",this.clientId),fetch(t.href,{method:"POST",headers:{"Content-Type":"application/json","Document-URL":window.location.href},body:JSON.stringify(e)}).then(i=>i.ok,()=>!1)}_maybeAcceptExternalChange(e){if(this.lane!=="live")return!1;let t=e.data;return t&&t.kind==="external-change"?(typeof t.html=="string"?this._enqueueExternal(t.html,e.seq,t.etag,t.by):this._fetchExternalChange(e.seq),!0):typeof e.msg=="string"&&e.msg.endsWith("changed on disk outside this tab")?(this._fetchExternalChange(e.seq),!0):!1}_enqueueExternal(e,t,i,n){if(typeof t=="number"){if(t<=this._lastExternalSeq){this._log(`Dropping replayed external change: seq=${t}`);return}this._lastExternalSeq=t}this._pendingExternal={html:e,seq:t,saveEpoch:this._saveEpoch,etag:typeof i=="string"&&i?i:null,by:n??null},this._scheduleNextFrame()}_fetchExternalChange(e){if(typeof e=="number"){if(e<=this._lastExternalSeq)return;this._lastExternalSeq=e}this._fetchServedDocument(e)}_fetchServedDocument(e,{attempt:t=0,repair:i=!1,startup:n=!1}={}){if(n&&(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null)){this._retryStartup(t);return}let r=this._saveEpoch,l=this._startGen,o=this.lastSeenSeq,a=this._applyGen,h=++this._servedFetchId;i&&typeof e!="number"&&(e=this._lastExternalSeq),fetch(new URL(window.location.href),{cache:"no-store"}).then(c=>c.ok?c.text():null).then(c=>{if(this.isDestroyed||c==null||this._startGen!==l)return;let d=Ft(c),_=n||i&&!!d;if(_){if(h!==this._servedFetchId){i&&this._retryStartup(t+1,{repair:i,startup:n},typeof e=="number"?Math.max(e,this._lastExternalSeq):e);return}if(r!==this._saveEpoch||o!==this.lastSeenSeq||a!==this._applyGen||this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(t+1,{repair:i,startup:n},e);return}if(d){if(d===re()){(i||n)&&this.lane==="saved"&&(this._represented=Object.freeze({bytes:c,etag:d,seq:e??null}));return}}else if(!i)return}else if(typeof e=="number"&&e<this._lastExternalSeq){i&&t<3&&this._fetchServedDocument(this._lastExternalSeq,{attempt:t+1,repair:i,startup:n});return}else if(this._saveEpoch>r){t<3&&(console.log("[LiveSync] Refetching external change: own save landed mid-fetch"),this._fetchServedDocument(e,{attempt:t+1,repair:i,startup:n}));return}this._pendingExternal={html:c,seq:e,saveEpoch:r,etag:d,by:null,fetchOptions:{repair:i,startup:n,attempt:t,versionCheck:_},startGen:l,seenSeq:o,applyGen:a,fetchId:h},this._scheduleNextFrame()}).catch(c=>{this._log("External-change fetch failed",c),typeof e=="number"&&this._lastExternalSeq===e&&(this._lastExternalSeq=e-1)})}_retryStartup(e=0,t={startup:!0},i){this.isDestroyed||e>3||(clearTimeout(this._startupRetry),this._startupRetry=setTimeout(()=>{if(this._startupRetry=null,!this.isDestroyed){if(this._morphInFlight||this._pendingHtml!=null||this._pendingExternal!=null){this._retryStartup(e,t,i);return}this._fetchServedDocument(i,{...t,attempt:e})}},16))}applyUpdate(e,t,i,n,r){this.isDestroyed||(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingEtag=n??null,this._pendingBy=r??null,this._scheduleNextFrame())}prepareHandoff(e={}){return this._handoff?Promise.resolve(this._handoff):this.isDestroyed?Promise.reject(new Error("LiveSync: stopped")):(this._handoffHeld=!0,this._rafHandle!=null&&(this._cancelFrame(this._rafHandle),this._rafHandle=null),import("./c-DAUQ6JZ3.js").then(({engineHandoff:t})=>t(this,e)).then(t=>this._handoff=t))}_scheduleNextFrame(){this.isDestroyed||this._handoffHeld||this._rafHandle==null&&(this._morphInFlight||(this._rafHandle=this._requestFrame(()=>this._runPending())))}async _runPending(){if(this._rafHandle=null,this.isDestroyed)return;if(!A()){this._morphInFlight=!0;try{await J()}catch(r){this._log("Merge engine failed to load",r),this._engineRetry=setTimeout(()=>this._scheduleNextFrame(),2e3);return}finally{this._morphInFlight=!1}if(this.isDestroyed)return}let e=this._pendingExternal,t=e?.fetchOptions||null,i=!!(t?.startup||t?.versionCheck),n=!1;if(e!=null&&(i&&this._pendingHtml!=null?n=!1:this._pendingHtml==null?n=!0:n=!(typeof e.seq=="number"&&typeof this._pendingSeq=="number"&&this._pendingSeq<e.seq)),n)if(this._pendingExternal=null,typeof e.seq=="number"&&e.seq<this._lastExternalSeq)i&&t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded external change at drain");else if(i&&e.startGen!==this._startGen)this._log("Dropping superseded startup check at drain");else if(i&&e.fetchId!==this._servedFetchId)t?.repair?this._retryStartup((t.attempt||0)+1,t,this._lastExternalSeq):this._log("Dropping superseded startup check at drain");else if(i&&(e.saveEpoch!==this._saveEpoch||e.seenSeq!==this.lastSeenSeq||e.applyGen!==this._applyGen))this._retryStartup((t.attempt||0)+1,t,e.seq);else if(i&&e.etag!=null&&e.etag===re())this._log("Startup check found the same version: nothing to apply");else if(!i&&e.saveEpoch!==this._saveEpoch)console.log("[LiveSync] Refetching external change: own save landed after queue"),this._fetchServedDocument(e.seq,t||{});else{this._morphInFlight=!0;try{await this._doApplyExternal(e.html,e.seq,e.etag,e.by,t)}catch(r){console.error("[LiveSync] applyExternal failed:",r)}finally{this._morphInFlight=!1}}else{let r=this._pendingHtml,l=this._pendingSeq,o=this._pendingIdentityMap,a=this._pendingEtag,h=this._pendingBy;if(this._pendingHtml=null,this._pendingSeq=null,this._pendingIdentityMap=null,this._pendingEtag=null,this._pendingBy=null,r==null)return;this._morphInFlight=!0;try{await this._doApplyUpdate(r,l,o,a,h)}catch(c){console.error("[LiveSync] applyUpdate failed:",c)}finally{this._morphInFlight=!1}}!this.isDestroyed&&(this._pendingHtml!=null||this._pendingExternal!=null)&&this._scheduleNextFrame()}_ticket(){return++this._agreeSeq}_setDiskBase(e,t){t<=this._diskBaseTicket||(this._diskBase=e,this._diskBaseTicket=t)}_setPeerBase(e,t,i){return i<this._peerBaseTicket?!1:(this._peerBaseTicket=i,this.lastHtml=e,this._lastIdentityMap=t&&typeof t=="object"&&!Array.isArray(t)?t:null,!0)}_requestFrame(e){if(ce()){if(typeof MessageChannel=="function"){let n=new MessageChannel,r=!0;return n.port1.onmessage=()=>{n.port1.close(),r&&e()},n.port2.postMessage(null),{cancel:()=>{r=!1,n.port1.close()}}}let i=setTimeout(e,0);return{cancel:()=>clearTimeout(i)}}if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){let i=window.requestAnimationFrame(e);return{cancel:()=>window.cancelAnimationFrame?.(i)}}let t=setTimeout(e,16);return{cancel:()=>clearTimeout(t)}}_cancelFrame(e){e?.cancel?.()}async _mergeIncoming(e,t,{base:i,baseIdentityMap:n=null,captureLocal:r,synthetic:l,source:o="peer",seq:a=null,etag:h=null,extra:c={}}){A()||await J();let{beginApply:d,completeApply:_,failApply:g,beginLineageCapture:E}=ht()||await V(),f,u=p=>{f=E(I.list());try{let v=A().HyperMorph.mergeDocument({...p,lineage:f.lineage});return f.returned(),v}catch(v){throw f.invalidate(I.list()),f.finish(I.list()),v}},S=this.identity,w=Te,b=Ht(new WeakMap),N=p=>me(p)?{first:b,map:p,then:b}:b,O=l?p=>b(p)||S.idOf(D(p)||p)||null:b,H=e,we=new Map;if(me(t)){H=new DOMParser().parseFromString(e,"text/html"),ie(H);let p=A().HyperMorph.importMap(H.documentElement,t);for(let v of H.querySelectorAll("[data-id], [id]")){let k=b(v),De=k&&p.get(v);De&&we.set(k,De)}}H=ut(H);let Z={live:document,remote:H,ignore:p=>p.matches(_t),opaque:p=>p.matches(gt)||z()&&qe(p),remoteWins:p=>p.matches(It),ignoreAttribute:(p,v,k)=>Tt(p,v,k)||z()&&Re(k||p,v),attributeMerge:ot,protectFocusedValue:!0,restoreFocus:document.activeElement?.localName!=="clay-editor-ui",keepLiveOnly:o==="peer",scripts:{mergeTags:A().mergeTagRecognizers},hooks:{beforeAttributeUpdated:w},...c},ke=this.lane==="live"&&x(),xe=he(),G,ee=null,C=null;if(i==null)G=u({...Z,base:null,local:{root:X(r()),toLive:D},identity:{local:O,remote:N(t)}});else if(ke){let p=r(),v=p.cloneNode(!0);ee=X(p),C=d({source:o,seq:a,etag:h,root:ee,recoveryRoot:v,domain:o==="disk"?"save":"sync"});try{G=u({...Z,base:ut(i),local:{root:ee,toLive:D},identity:{base:N(n),local:O,remote:N(t)}})}catch(k){throw g(C,k),k}}else{let p=X(r()),v=p.ownerDocument;v.documentElement!==p&&v.replaceChild(p,v.documentElement),G=u({...Z,base:v,local:{root:p,toLive:D},fastPath:!0,identity:{base:O,local:O,remote:N(t)}})}let U=this._ticket();this._morphTicket=U;let F;try{F=await G}catch(p){f.invalidate(I.list());try{C&&g(C,p,{ticket:U})}finally{f.finish(I.list())}throw p}let mt=he().gen!==xe.gen,be;try{f.prepareComplete(F,I.list()),be=C?_(C,F.conflicts,{ticket:U}):[]}finally{f.finish(I.list())}this.lane==="live"&&F.localDiverged?Ve():ke&&!F.localDiverged&&Xe(xe);let vt=new Set(me(t)?Object.values(t):[]);for(let[p,v]of F.identities){let k=vt.has(v)?v:we.get(v);k&&S.adopt(p,k)}return{report:F,ticket:U,typedDuringWait:mt,conflictIds:be}}_saveAfterMerge(e,t){(e||t)&&Ke()&&(y?y.savePageThrottled():Dt())}async _doApplyUpdate(e,t,i,n,r=null){if(ue(e)){await fe();return}this.lane==="live"&&!y&&await R(),this._log("applyUpdate - pausing mutations and morphing"),this.isPaused=!0;let l=window.scrollX,o=window.scrollY;q.pause(),oe();let a=!1,h=!1,c=!1;try{if(this.lane==="live"&&x()&&this.lastHtml===null){console.log("[LiveSync] Holding incoming update: unsaved local edits and no baseline to merge against"),this._setHeld("live",!0,null);let f=this._saveEpoch,u=this.lastSeenSeq;clearTimeout(this._holdRetryPeer),this._holdRetryPeer=setTimeout(()=>{this._holdRetryPeer=null,!(this.isDestroyed||this._pendingHtml!=null)&&this._saveEpoch===f&&this.lastSeenSeq===u&&(this._pendingHtml=e,this._pendingSeq=t,this._pendingIdentityMap=i,this._pendingBy=r,this._scheduleNextFrame())},3e3);return}this._setHeld("live",!1);let{report:d,ticket:_,typedDuringWait:g,conflictIds:E}=await this._mergeIncoming(e,i,{base:this.lastHtml,baseIdentityMap:this._lastIdentityMap,captureLocal:()=>M({flushUndo:!1}),synthetic:!0,source:"peer",seq:t,etag:n});if(a=d.localDiverged,h=g,ne(),window.scrollTo(l,o),this._setPeerBase(e,i,_),this._applyGen++,this._acceptedSaveTicket>_||(typeof n=="string"&&n?(P(n),c=!0):le()),this.lane==="live"&&!a&&!x()){let{forSave:f,forComparison:u,forDirty:S}=Y({emitForSync:!1,flushUndo:!1});y.setLastSavedBaselines(u,S),this._setDiskBase(f,this._ticket())}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:n||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:this.lane==="saved"?"disk":"peer",lane:this.lane,by:r||null,html:e,report:d,unresolved:this.unresolvedConflicts,conflictIds:E}}))}finally{this._log("applyUpdate - morph complete, resuming mutations"),q.resume(),ae(),await new Promise(d=>setTimeout(d,0)),this.isPaused=!1}c&&y?.conflictResolvedBySync(n),this._saveAfterMerge(a,h)}async _doApplyExternal(e,t,i=null,n=null,r=null){if(ue(e)){await fe();return}this.lane==="live"&&!y&&await R();let l=this._diskBase;this._log(`applyExternal - external disk change (seq=${t})`),this.isPaused=!0;let o=window.scrollX,a=window.scrollY;q.pause(),oe();let h=!1,c=!1,d=!1;try{if(this.lane==="live"&&x()&&this._diskBase===null){if(console.log("[LiveSync] Holding external change: unsaved local edits and no baseline to merge against"),this._setHeld("external",!0,null),r?.startup||r?.versionCheck){clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{if(this._holdRetryExt=null,this.isDestroyed)return;let S=typeof t=="number"?Math.max(t,this._lastExternalSeq):t;this._retryStartup(0,r,S)},3e3);return}let u=this._saveEpoch;clearTimeout(this._holdRetryExt),this._holdRetryExt=setTimeout(()=>{this._holdRetryExt=null,!(this.isDestroyed||this._pendingExternal!=null)&&(this._pendingExternal={html:e,seq:t,saveEpoch:u,etag:i,by:n},this._scheduleNextFrame())},3e3);return}this._setHeld("external",!1);let{report:_,ticket:g,typedDuringWait:E,conflictIds:f}=await this._mergeIncoming(e,null,{base:this._diskBase,captureLocal:()=>Ne().saveClone,synthetic:!1,source:"disk",seq:t,etag:i,extra:{beforeApply:u=>Ct(u.documentElement,this.lane)}});if(h=_.localDiverged,c=E,ne(),this._setDiskBase(e,g),window.scrollTo(o,a),this._acceptedSaveTicket>g||(typeof i=="string"&&i?(P(i),d=!0):le()),this.lane==="live"&&!h&&!x()){y.setLastSavedBaselines(...At()),y.setUnsavedChanges(!1);let u=M({flushUndo:!1});this._setPeerBase(T(u),this.identity.exportMap(u,D),g),this._applyGen++}this.lane==="saved"&&(this._represented=Object.freeze({bytes:e,etag:i||null,seq:t??null})),document.dispatchEvent(new CustomEvent("clay:sync-applied",{detail:{seq:t,source:"disk",etag:typeof i=="string"&&i?i:null,by:n||null,html:e,report:_,conflictIds:f,unresolved:this.unresolvedConflicts}}))}finally{this._log("applyExternal - morph complete, resuming mutations"),q.resume(),ae(),await new Promise(_=>setTimeout(_,0)),this.isPaused=!1}d&&y?.conflictResolvedBySync(i),this._saveAfterMerge(h,c),l!=null&&j(l)===j(e)&&y&&y.schedulePaintHeal(()=>this._diskBase==null?null:j(this._diskBase))}handleNotification({msgType:e,msg:t,action:i,persistent:n,data:r}){this._log(`Notification received: ${e} - ${t}`),e==="data-loss"||(n&&window.toastPersistent?window.toastPersistent(t,e):window.toast?window.toast(t,e):console.log(`[LiveSync] Notification: ${t}`)),document.dispatchEvent(new CustomEvent("clay:notification",{detail:{msgType:e,msg:t,action:i,persistent:n,data:r}})),this.onNotification&&this.onNotification({msgType:e,msg:t,action:i,persistent:n,data:r})}stop(){this.cleanup(),this.isDestroyed=!0,console.log("[LiveSync] Stopped")}editParticipant(){return R().then(e=>e.syncParticipant(this))}},K=null;Ge((s,e)=>{K=typeof s=="string"?{html:s,captureId:e?.captureId??null}:null});var Mt=s=>K&&(K.captureId??null)===(s??null)?K.html:null;function Pt(s,e){if(typeof e!="string"||e===s)return s;let t=i=>new DOMParser().parseFromString(i,"text/html").documentElement;return t(s).isEqualNode(t(e))?e:s}var Ee=new Se;typeof window<"u"&&!ft&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ee.start()):Ee.start());var yn=(s,e,t)=>J().then(({morph:i})=>i(s,e,t));var mn=Ee;export{I as a,_t as b,It as c,Se as d,Ee as e,yn as f,mn as g};
@@ -1,4 +1,4 @@
1
1
  import{$ as Xt,A as V,U as Ut,V as ut,W as Ft,Z as Wt,_ as Gt,a as L,b as et,d as T,da as ft,e as nt,h as Rt,k as qt,ka as Qt,m as ct,q as _t,r as Kt,s as Ht,t as jt,v as ot,y as lt,z as dt}from"./c-OH2FPYSY.js";import{a as O,b as D,d as $,e as Z,f as Vt,g as tt}from"./c-RETTCOWO.js";var be=e=>e==="left"||e==="right"?e:null,{Plugin:wt,PluginKey:ke,TextSelection:I,NodeSelection:Yt,Selection:st}=D,M=T.nodes,S=e=>e.type===M.list_item,A=e=>e.type===M.toggle,k=e=>e.attrs.parent??null,Et="blockeditor-step",q="blockeditor-move",Mt=e=>e&&(n=>e(Z.closeHistory(n).setMeta(Et,!0)));function y(e,n=null){let t=[],o=new Map,r=[];e.forEach((s,i)=>{let a=t.length,l=t[a-1],c=k(s),d=c!==null&&o.has(c)?o.get(c):-1,f=d;if(S(s)){for(l&&S(l.node)&&k(l.node)===c||(r=[]);r.length&&t[r[r.length-1]].node.attrs.indent>=s.attrs.indent;)r.pop();r.length&&(f=r[r.length-1]),r.push(a)}else r=[];let p=A(s)&&(s.attrs.open||!!n?.has(s.attrs.id)),u=d>=0&&(t[d].hidden||!t[d].open);t.push({node:s,at:i,end:i+s.nodeSize,i:a,up:f,depth:d>=0?t[d].depth+1:0,hidden:u,open:p,subEnd:a}),A(s)&&s.attrs.id&&o.set(s.attrs.id,a)});for(let s=t.length-1;s>=0;s--){let i=t[s].up;i>=0&&t[s].subEnd>t[i].subEnd&&(t[i].subEnd=t[s].subEnd)}return t}var Jn=(e,n)=>({from:e[n].at,to:e[e[n].subEnd].end});function xe(e,n=null){let t=new Map;n?.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))}),e.forEach(c=>{c.attrs.id&&t.set(c.attrs.id,k(c))});let o=[];e.forEach((c,d)=>o.push({node:c,at:d}));let r=new Array(o.length).fill(null);for(let c=o.length-2;c>=0;c--){let d=k(o[c+1].node);r[c]=d!==k(o[c].node)?d:r[c+1]}let s=[],i=[null],a=null,l=[];return o.forEach(({node:c,at:d},f)=>{let p=k(c),u=new Set;for(;p!==null&&!i.includes(p)&&!u.has(p);)u.add(p),p=t.has(p)?t.get(p):null;i.includes(p)||(p=null);let h=r[f];i.indexOf(h)>i.indexOf(p)&&(p=h);let m=i.slice(0,i.indexOf(p)+1),g=c.attrs.indent;if(S(c)){let E=Number.isInteger(g)&&g>0?g:0,b=a&&S(a.node)&&a.parent===p;for(b||(l=[]);l.length&&l[l.length-1].orig>E;)l.pop();let N=0;if(l.length){let C=l[l.length-1];N=C.shift,C.orig===E&&l.pop()}g=Math.max(0,Math.min(E-N,b?a.indent+1:0)),l.push({orig:E,shift:E-g})}else l=[];(p!==k(c)||S(c)&&g!==c.attrs.indent)&&s.push({at:d,attrs:{...c.attrs,parent:p,...S(c)?{indent:g}:{}}}),a={node:c,parent:p,indent:g},i=A(c)&&c.attrs.id?[...m,c.attrs.id]:m}),s}function Zn(){let e=new WeakSet;return new wt({appendTransaction(n,t,o){if(!n.some(i=>i.docChanged&&!i.getMeta(ot)))return null;if(e.has(t.doc)&&je(t.doc,o.doc))return e.add(o.doc),null;let r=xe(o.doc,t.doc);if(!r.length)return e.add(o.doc),null;let s=o.tr;for(let i of r)s.setNodeMarkup(i.at,null,i.attrs);return s}})}function it(e,n,t){let o=e.resolve(n.from).index(0),r=Math.min(e.resolve(n.to).index(0),t.length-1);return r>o&&n.to<=t[r].at&&r--,[Math.min(o,t.length-1),r]}var ne=it;function z(e,n,t){let o=n;for(;e[o].up>=0&&t>e[e[o].up].subEnd;)o=e[o].up;let r=e[o].up,s=e[o].subEnd;for(;s<t;)s=e[s+1].subEnd;return{lo:o,hi:s,up:r}}var ye=(e,n,t)=>{let o=e.resolve(Math.max(0,Math.min(n,e.content.size)));return o.depth===0?o.pos:t<0?o.before(1):o.after(1)},Jt=e=>({id:e.node.attrs.id,at:e.at,node:e.node}),bt=(e,n)=>n.id?e.node.attrs.id===n.id:e.at===n.at&&e.node.type===n.node.type&&e.node.content.eq(n.node.content);function Ae(e,n,t){let o=[];for(let r=n;r<=t;r=e[r].subEnd+1)o.push(Jt(e[r]));return{roots:o,members:e.slice(n,t+1).map(Jt)}}function Se(e,n){let t=n.roots.map(i=>e.findIndex(a=>bt(a,i))).filter(i=>i>=0);if(!t.length||t.some(i=>e[i].hidden))return null;let o=t[0],r=e[o].up,s=e[o].subEnd;for(let i of t.slice(1)){if(i!==s+1||e[i].up!==r)return null;s=e[i].subEnd}return e.slice(o,s+1).some(i=>!n.members.some(a=>bt(i,a)))?null:{lo:o,hi:s}}var we=(e,n)=>{let t=o=>({...o,at:n.map(o.at,1)});return{roots:e.roots.map(t),members:e.members.map(t)}},x=class e extends st{map(n,t){return this.getBookmark().map(t).resolve(n)}eq(n){return n instanceof e&&n.anchor===this.anchor&&n.head===this.head}toJSON(){return{type:"blockeditor-block",anchor:this.anchor,head:this.head}}static fromJSON(n,t){return new e(n.resolve(t.anchor),n.resolve(t.head))}getBookmark(){let{lo:n,hi:t}=this.span();return new kt(this.anchor,this.head,Ae(y(this.$from.doc),n,t))}span(n=this.$from.doc){return{lo:n.resolve(this.from).index(0),hi:n.resolve(this.to).index(0)-1}}};x.prototype.visible=!1;st.jsonID("blockeditor-block",x);var kt=class e{constructor(n,t,o){this.anchor=n,this.head=t,this.span=o}map(n){let t=this.anchor<=this.head;return new e(n.map(this.anchor,t?1:-1),n.map(this.head,t?-1:1),we(this.span,n))}resolve(n){let t=y(n),o=Se(t,this.span);if(!o){let i=t.find(a=>bt(a,this.span.roots[0]));return st.near(n.resolve(i?.at??ye(n,Math.min(this.anchor,this.head),-1)))}let r=t[o.lo].at,s=t[o.hi].end;return this.anchor<=this.head?new x(n.resolve(r),n.resolve(s)):new x(n.resolve(s),n.resolve(r))}},oe=(e,n)=>{for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return-1};function G(e,n,t,o,r=()=>null){let s=r(e[n])||{},i="parent"in s?s.parent:k(e[n].node),a=null;for(let d=0;d<e.length&&e[d].end<=o;d++)d>=n&&d<=t||k(e[d].node)===i&&(a=e[d].node.attrs.id);let l=[],c={};for(let d=n;d<=t;d++){let f=e[d].node,p=r(e[d]);l.push(f.attrs.id),p&&"indent"in p&&p.indent!==f.attrs.indent&&(c[f.attrs.id]={indent:p.indent})}return{ids:l,afterId:a,parent:i,attrs:c}}function re(e,n,t,o,r,s=()=>null,i=e.selection){let a=n[t].at,l=n[o].end,c=l-a,d=[];for(let h=t;h<=o;h++){let m=n[h].node;d.push(m.type.create({...m.attrs,...s(n[h])||{},pos:null},m.content,m.marks))}let f=e.tr.delete(a,l),p=r>a?r-c:r;f.insert(p,d);let u=p-a;return i instanceof x?f.setSelection(new x(f.doc.resolve(i.anchor+u),f.doc.resolve(i.head+u))):i instanceof Yt?f.setSelection(Yt.create(f.doc,i.from+u)):f.setSelection(I.create(f.doc,i.anchor+u,i.head+u)),f.setMeta(q,G(n,t,o,r,s))}function xt(e,n,t){let o=e[t].node;if(A(o)){let s=o.attrs.id,i=k(o);return a=>k(a.node)===s?{parent:i}:null}let r=o.attrs.indent-e[n].node.attrs.indent;return s=>S(s.node)?{indent:s.node.attrs.indent+r}:null}var Zt=e=>(n,t)=>{t=Mt(t);let o=y(n.doc);if(!o.length)return!1;let[r,s]=it(n.doc,n.selection,o),{lo:i,hi:a,up:l}=z(o,r,s),c,d=()=>null;if(e<0){let f=oe(o,i);if(f>=0)c=o[f].at;else if(l>=0)c=o[l].at,d=xt(o,i,l);else return!0}else{let f=a+1;if(f<o.length&&o[f].up===l)c=o[o[f].subEnd].end;else if(l>=0)c=o[o[l].subEnd].end,d=xt(o,i,l);else return!0}return t&&t(re(n,o,i,a,c,d).scrollIntoView()),!0},Ee=8,rt=(e,n)=>S(e.node)&&S(n.node)&&k(e.node)===k(n.node);function Me(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=it(e.doc,e.selection,t),s=t[o];if(S(s.node)&&o>0&&rt(t[o-1],s)){if(s.node.attrs.indent>t[o-1].node.attrs.indent)return!0;for(let a=o;a<=Math.max(r,s.subEnd);a++)if(t[a].node.attrs.indent>=Ee)return!0;if(n){let a=e.tr,l=r;for(let d=o;d<=l;d++)l=Math.max(l,t[d].subEnd);let c=o-1;for(let d=o;d<=l&&rt(t[d],s);d++)a.setNodeMarkup(t[d].at,null,{...t[d].node.attrs,indent:t[d].node.attrs.indent+1}),c=d;a.setMeta(q,G(t,o,c,t[o].at,d=>d.i>=o&&d.i<=c?{indent:d.node.attrs.indent+1}:null)),n(a)}return!0}let i=oe(t,o);if(i<0||!A(t[i].node)||t[i].subEnd!==o-1)return!0;if(n){let{hi:a}=z(t,o,r),l=e.tr,c=k(s.node),d=t[i].node.attrs.id,f=[];for(let u=o;u<=a;u++)k(t[u].node)===c&&(l.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,parent:d}),f.push(t[u].node.attrs.id));t[i].node.attrs.open||l.setNodeMarkup(t[i].at,null,{...t[i].node.attrs,open:!0});let p=G(t,o,a,t[o].at,u=>u.i>=o&&u.i<=a&&k(u.node)===c?{parent:d}:null);l.setMeta(q,{...p,ids:f,attrs:t[i].node.attrs.open?p.attrs:{...p.attrs,[d]:{open:!0}}}),n(l)}return!0}function vt(e,n){n=Mt(n);let t=y(e.doc);if(!t.length)return!1;let[o,r]=it(e.doc,e.selection,t),s=t[o];if(S(s.node)&&s.node.attrs.indent>0){if(n){let{lo:d,hi:f}=z(t,o,r),p=e.tr,u=new Set;for(let h=o;h<=r;){let m=t[h];if(S(m.node)&&m.node.attrs.indent>0)for(let g=h;g<=m.subEnd;g++)S(t[g].node)&&(p.setNodeMarkup(t[g].at,null,{...t[g].node.attrs,indent:t[g].node.attrs.indent-1}),u.add(g));h=m.subEnd+1}p.setMeta(q,G(t,d,f,t[d].at,h=>u.has(h.i)?{indent:h.node.attrs.indent-1}:null)),n(p)}return!0}if(k(s.node)===null)return!0;let{lo:a,hi:l}=z(t,o,r),c=t[a].up;for(;c>=0&&!A(t[c].node);)c=t[c].up;if(c<0)return!0;if(n){let d=xt(t,a,c),f=t[c].subEnd;if(l===f){let p=e.tr;for(let u=a;u<=l;u++){let h=d(t[u]);h&&p.setNodeMarkup(t[u].at,null,{...t[u].node.attrs,...h})}p.setMeta(q,G(t,a,l,t[a].at,d)),n(p)}else n(re(e,t,a,l,t[f].end,d).scrollIntoView())}return!0}function se(e){let n=e.tr;return e.selection.empty||n.deleteSelection(),n}function ve(e,n){let{$from:t,$to:o,empty:r}=e.selection;if(t.depth!==1||!S(t.parent)||!t.sameParent(o))return!1;if(r&&t.parent.content.size===0){let h=t.parent;return h.attrs.indent>0?vt(e,n):(n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:h.attrs.id,pos:h.attrs.pos,parent:h.attrs.parent})),!0)}let s=se(e),i=s.selection.$from,a=i.parent,l=y(s.doc),c=i.index(0),d=i.parentOffset===0,f=i.parentOffset===a.content.size,p=l[c+1],u=f&&p&&rt(p,l[c])&&p.node.attrs.indent>a.attrs.indent;return d?(s.split(i.pos,1,[{type:M.list_item,attrs:a.attrs}]),s.setNodeMarkup(l[c].at,null,{...a.attrs,checked:!1})):s.split(i.pos,1,[{type:M.list_item,attrs:{...a.attrs,checked:!1,indent:a.attrs.indent+(u?1:0)}}]),n&&n(s.scrollIntoView()),!0}function Te(e,n){let{$from:t,$to:o}=e.selection;if(t.depth!==1||!A(t.parent)||!t.sameParent(o))return!1;let r=se(e),s=r.selection.$from,i=s.parent,a=y(r.doc),l=s.index(0),c=a[l],d=c.subEnd>l;if(i.content.size===0&&!d)return r.setNodeMarkup(c.at,M.paragraph,{id:i.attrs.id,pos:i.attrs.pos,parent:i.attrs.parent}),n&&n(r),!0;if(s.parentOffset===0&&i.content.size>0)return r.insert(c.at,M.paragraph.create({parent:k(i)})),n&&n(r.scrollIntoView()),!0;let f=i.content.cut(s.parentOffset);if(i.attrs.open)r.split(s.pos,1,[{type:M.paragraph,attrs:{parent:i.attrs.id}}]);else{let p=a[c.subEnd].end,u=r.steps.length;r.delete(s.pos,c.end-1);let h=r.mapping.slice(u).map(p);r.insert(h,M.toggle.create({parent:k(i),open:!1},f)),r.setSelection(I.create(r.doc,h+1))}return n&&n(r.scrollIntoView()),!0}function Ne(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parent.type!==M.paragraph||t.parent.content.size)return!1;let r=k(t.parent);if(r===null)return!1;let s=y(e.doc),i=t.index(0),a=s.findIndex(l=>l.node.attrs.id===r);if(a<0||s[a].subEnd!==i)return!1;if(n){let l=s[i].node.attrs.id,c=k(s[a].node),d=i>0?s[i-1].node:null,f=e.tr.setNodeMarkup(s[i].at,null,{...t.parent.attrs,parent:c});f.setMeta(q,{ids:[l],afterId:d?d.attrs.id:null,parent:k(d??s[i].node),attrs:{[l]:{parent:c}}}),n(f)}return!0}function Ie(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!t.parent.isTextblock||t.parent.type.spec.code)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null||t.parentOffset!==r.content.size)return!1;if(n){let s=e.tr.split(t.pos,1,[{type:M.paragraph,attrs:{parent:k(r)}}]);n(s.scrollIntoView())}return!0}function Ce(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!S(t.parent)||t.parentOffset!==0)return!1;if(t.parent.attrs.indent>0)return vt(e,n);let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Oe(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parentOffset!==0)return!1;let r=t.parent;return n&&n(e.tr.setNodeMarkup(t.before(),M.paragraph,{id:r.attrs.id,pos:r.attrs.pos,parent:r.attrs.parent})),!0}function Tt(e,n){if(n<=0||!e[n-1].hidden)return-1;let t=n-1;for(;t>=0&&e[t].hidden;)t--;return t>=0&&A(e[t].node)&&e[t].subEnd>=n-1?t:-1}function Nt(e,n,t,o){let r=e.tr,s=n[o],i=n[t].end-1;return r.delete(s.at,s.end),s.node.content.size&&r.insert(i,s.node.content),r.setSelection(I.create(r.doc,i))}function De(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=y(e.doc),s=t.index(0),i=Tt(r,s);return i<0?!1:(n&&n(Nt(e,r,i,s).scrollIntoView()),!0)}function $e(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||!A(t.parent)||t.parent.attrs.open||t.parentOffset!==t.parent.content.size)return!1;let r=y(e.doc),s=t.index(0),i=r[s].subEnd+1;return i===s+1?!1:(i>=r.length||!r[i].node.isTextblock||n&&n(Nt(e,r,s,i).scrollIntoView()),!0)}function Le(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1)return!1;let r=t.parent,s=t.index(0);if(!r.isTextblock||r.type.spec.code||A(r)||!r.content.size||t.parentOffset!==r.content.size||s+1>=e.doc.childCount||!A(e.doc.child(s+1)))return!1;if(n&&r.type!==M.paragraph)n(e.tr.setSelection(I.create(e.doc,t.after()+1)).scrollIntoView());else if(n){let i=t.before(),a=e.tr.insert(t.after()+1,r.content).delete(i,t.after());n(a.setSelection(I.create(a.doc,i+1+r.content.size)).scrollIntoView())}return!0}var ie=e=>(n,t)=>{let{$from:o,empty:r}=n.selection;if(!r||o.depth!==1||!o.parent.isTextblock)return!1;let s=o.parent,i=o.index(0);if(o.parentOffset!==(e<0?0:s.content.size))return!1;let a=y(n.doc),l=e<0?Tt(a,i):-1,c=l>=0?l:i+e;if(c<0||c>=a.length)return!1;let d=a[c].node;if(!d.isTextblock||!s.type.spec.code&&!d.type.spec.code)return!1;if(!t)return!0;let f=n.tr,p=a[i],u=a[c],h=e<0?u.end-1:u.at+1;return!s.content.size&&!s.type.spec.code?f.delete(p.at,p.end).setSelection(I.create(f.doc,f.mapping.map(h))):!d.content.size&&!d.type.spec.code?f.delete(u.at,u.end):f.setSelection(I.create(f.doc,h)),t(f.scrollIntoView()),!0},Be=ie(-1),Pe=ie(1);function ze(e,n){let{$from:t,empty:o}=e.selection;if(!o||t.depth!==1||t.parentOffset!==0||!t.parent.isTextblock)return!1;let r=t.parent;if(S(r)||A(r)||k(r)===null)return!1;let s=t.index(0);return e.doc.child(s-1).attrs.id!==k(r)?!1:(n&&n(Nt(e,y(e.doc),s-1,s).scrollIntoView()),!0)}var It="blockeditor-reveal";function to(e,n){return n.length?e.setMeta(It,{add:n}):e}function ae(e,n,t,o=y(e.doc)){let r=o[n];return e.tr.setNodeMarkup(r.at,null,{...r.node.attrs,open:t}).setMeta("addToHistory",!1).setMeta(It,{clear:[r.node.attrs.id]})}function Ve(e,n){let{$from:t}=e.selection;return t.depth!==1||!A(t.parent)?!1:(n&&n(ae(e,t.index(0),!t.parent.attrs.open)),!0)}function Re(e){let n=[];for(let t of e)!A(t.node)||t.hidden||t.open||t.subEnd===t.i||n.push({line:t.at+1,sumEnd:t.end-1,from:t.end,to:e[t.subEnd].end});return n}var yt=(e,n)=>n>e.from&&n<e.to;function At(e,n,t,o){if(o>0){let r=t.to;for(;;){let s=st.findFrom(e.resolve(r),1,!0);if(!s)break;let i=n.find(a=>yt(a,s.head));if(!i)return s.head;r=i.to}}return t.sumEnd}function te(e,n,t,o=-1,r=!1){if(!t.length)return null;let{anchor:s,head:i}=n;if(!(n instanceof I)){let c=t.find(d=>n.from>=d.from&&n.from<d.to);return c?I.create(e,c.sumEnd):null}let a=t.find(c=>yt(c,i));a&&(i=At(e,t,a,o));let l=t.find(c=>yt(c,s));if(l&&(s=l.sumEnd),!r&&s!==i){let c=Math.min(s,i),d=Math.max(s,i),f=t.find(p=>(c>p.line||c===p.sumEnd)&&c<p.from&&d>=p.to);if(f){let p=c===f.sumEnd?At(e,t,f,1):f.line;s<i?s=p:i=p}}return s===n.anchor&&i===n.head?null:I.create(e,s,i)}var qe=e=>{let n="";for(;e>0;)e--,n=String.fromCharCode(97+e%26)+n,e=Math.floor(e/26);return n},_e=e=>[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]].reduce((n,[t,o])=>{for(;e>=t;)n+=o,e-=t;return n},"");function Ke(e){let n=new Map,t=[];return e.forEach((o,r)=>{if(!S(o.node)){t=[];return}r>0&&!rt(e[r-1],o)&&(t=[]);let s=o.node.attrs.indent;if(t.length=s+1,o.node.attrs.kind!=="ordered"){t[s]=0;return}t[s]=(t[s]||0)+1;let i=t[s];n.set(r,`${s%3===0?i:s%3===1?qe(i):_e(i)}.`)}),n}var F=new ke("blockeditor-collapse"),He=["id","parent","indent","kind","open"];function je(e,n){if(e.childCount!==n.childCount)return!1;for(let t=0;t<e.childCount;t++){let o=e.child(t),r=n.child(t);if(o!==r){if(o.type!==r.type)return!1;for(let s of He)if(o.attrs[s]!==r.attrs[s])return!1}}return!0}var Ue=new Set;function pt(e,n=Ue){let t=y(e,n);return{decos:Ge(e,t),ranges:Re(t),reveal:n}}var Fe=null,We=()=>Fe??=class extends $.DecorationSet{forChild(e,n){if(n.isLeaf)return $.DecorationSet.empty;let t=this.children,o=0,r=t.length/3;for(;o<r;){let s=o+r>>1;t[s*3]<e?o=s+1:r=s}return o*3<t.length&&t[o*3]===e?t[o*3+2]:$.DecorationSet.empty}};function Ge(e,n=y(e)){let{Decoration:t,DecorationSet:o}=$,r=Ke(n),s=[],i=[];for(let a of n){let l={};if(a.hidden&&(l.class="blockeditor-hidden",l["aria-hidden"]="true"),a.depth&&(l.style=`--blockeditor-depth:${a.depth}`),r.has(a.i)&&(l["data-marker"]=r.get(a.i)),A(a.node)&&(l["data-expanded"]=a.open?"true":"false"),Object.keys(l).length&&s.push(t.node(a.at,a.end,l)),A(a.node)&&!a.hidden){let c=t.widget(0,()=>Xe(a.node,a.open),{side:-1,ignoreSelection:!0,key:`t:${a.node.attrs.id}:${a.open}`});i.push(a.at,a.end,new o([c],[]))}}return!s.length&&!i.length?o.empty:new(We())(s,i)}function Xe(e,n=e.attrs.open){let t=document.createElement("button");return t.type="button",t.className="blockeditor-toggle-button",t.contentEditable="false",t.setAttribute("aria-label",n?"Collapse":"Expand"),t.setAttribute("aria-expanded",n?"true":"false"),t.setAttribute("data-toggle",e.attrs.id||""),t}function eo(){let e=!1;return new wt({key:F,state:{init:(n,t)=>pt(t.doc),apply(n,t,o,r){let s=n.getMeta(It);if(s){let i=new Set(t.reveal);for(let a of s.add??[])i.add(a);for(let a of s.clear??[])i.delete(a);return pt(r.doc,i)}return n.docChanged?pt(r.doc,t.reveal):t}},appendTransaction(n,t,o){if(!n.some(a=>a.docChanged||a.selectionSet))return null;let s=n.some(a=>a.selectionSet)&&o.selection.head>=t.selection.head?1:-1,i=te(o.doc,o.selection,F.getState(o).ranges,s,e);return i?o.tr.setSelection(i):null},props:{decorations:n=>F.getState(n).decos,handleDOMEvents:{mousedown:(n,t)=>{let o=t.target.closest?.(".blockeditor-toggle-button");if(o){t.preventDefault();let i=y(n.state.doc),a=i.findIndex(l=>l.node.attrs.id===o.dataset.toggle);return a>=0&&n.dispatch(ae(n.state,a,!i[a].node.attrs.open,i)),!0}e=!0;let r=n.dom.ownerDocument.defaultView,s=()=>{e=!1,r.removeEventListener("mouseup",s,!0);let i=te(n.state.doc,n.state.selection,F.getState(n.state).ranges,1,!1);i&&n.dispatch(n.state.tr.setSelection(i))};return r.addEventListener("mouseup",s,!0),!1}},handleKeyDown(n,t){let o={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1}[t.key];if(!o||t.altKey||t.metaKey||t.ctrlKey)return!1;let{head:r}=n.state.selection,i=t.key==="ArrowDown"||t.key==="ArrowUp"?o>0?"down":"up":o>0?"forward":"backward";if(!n.endOfTextblock(i))return!1;let a=y(n.state.doc),{ranges:l}=F.getState(n.state),d=n.state.doc.resolve(r).index(0),f=null;if(o>0){let u=l.find(h=>h.from===a[d].end);u&&(f=At(n.state.doc,l,u,1))}else{let u=Tt(a,d);u>=0&&(f=t.shiftKey?a[u].at+1:a[u].end-1)}if(f===null||f===r)return!1;let p=t.shiftKey?n.state.selection.anchor:f;return n.dispatch(n.state.tr.setSelection(I.create(n.state.doc,p,f)).scrollIntoView()),!0}}})}var ee=/^([ \t]*)(?:([-*+•])|(\d+)[.)])[ \t]+(?:\[([ xX])\][ \t]+)?(.*)$/;function Qe(e){let n=e.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `);if(!n.some(r=>ee.test(r)))return null;let t=[],o=[];for(let r of n){if(!r.trim())continue;let s=ee.exec(r);if(!s){t.length=0,o.push(M.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let i=s[1].replace(/\t/g," ").length;for(;t.length&&t[t.length-1]>i;)t.pop();(!t.length||t[t.length-1]<i)&&t.push(i);let a=Math.min(t.length-1,o.length&&S(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=s[4]!==void 0?"check":s[3]!==void 0?"ordered":"bullet";o.push(M.list_item.create({kind:l,indent:a,checked:s[4]==="x"||s[4]==="X"},s[5]?T.text(s[5]):null))}return new O.Slice(O.Fragment.from(o),0,0)}var ht=new Set(["UL","OL"]),mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function Ye(e){let n=e.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(n)return{check:!0,checked:n.checked||n.hasAttribute("checked")};if(e.getAttribute("role")==="checkbox"||e.hasAttribute("aria-checked"))return{check:!0,checked:e.getAttribute("aria-checked")==="true"};if(e.hasAttribute("data-checked"))return{check:!0,checked:e.getAttribute("data-checked")==="true"};let o=e.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||e.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!e.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function Je(e){let n=(e.getAttribute("style")||"")+";"+(e.parentElement?.getAttribute("style")||""),t=/list-style-type\s*:\s*([a-z-]+)/i.exec(e.getAttribute("style")||"")?.[1];return t?/decimal|alpha|roman|latin|greek/.test(t)?"ordered":"bullet":e.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ze(e,n=globalThis.document){let t=n.createElement("div");t.innerHTML=e;for(let u of t.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))u.replaceWith(...u.childNodes);let o=0,r=n.createElement("div"),s=u=>{let h=parseInt(u.getAttribute("aria-level"),10);if(h>0)return h-1;let m=-1;for(let g=u.parentElement;g&&g!==t;g=g.parentElement)ht.has(g.tagName)&&m++;return Math.max(0,m)},i=[];function a(u,h,m){let g=n.createElement("div"),{check:E,checked:b}=Ye(u);g.setAttribute("data-blockeditor-li",""),g.setAttribute("data-kind",E?"check":Je(u)),g.setAttribute("data-checked",b?"true":"false"),g.dataset.depth=String(s(u)),h&&g.setAttribute("data-blockeditor-parent",h);let N=!0,C=[];for(let w of[...u.childNodes]){if(w.nodeType===1&&ht.has(w.tagName)){C.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&mt.has(w.tagName)){N||g.appendChild(n.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||g.appendChild(P);N=!1;continue}g.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(N=!1)}}m.appendChild(g),i.push(g);for(let w of C)l(w,h,m)}function l(u,h,m){let g=null,E=b=>{g||(g=n.createElement("p"),h&&g.setAttribute("data-blockeditor-parent",h),m.appendChild(g)),g.appendChild(b)};for(let b of[...u.childNodes])if(!(b.nodeType===1&&(b.tagName==="META"||b.tagName==="STYLE"))){if(b.nodeType===1&&b.tagName==="BR"){g=null;continue}if(b.nodeType!==1){b.nodeType===3&&(g||b.textContent.trim())&&E(b);continue}if(!mt.has(b.tagName)&&b.tagName!=="ASIDE"){E(b);continue}if(g=null,ht.has(b.tagName)){l(b,h,m);continue}if(b.tagName==="LI"){a(b,h,m);continue}if(b.tagName==="DETAILS"){let N=`paste-${++o}`,C=b.querySelector(":scope > summary"),w=n.createElement("div");w.setAttribute("data-blockeditor-toggle",N),b.hasAttribute("open")&&w.setAttribute("data-open","true"),h&&w.setAttribute("data-blockeditor-parent",h);let P=C?.querySelector(":scope > h1, :scope > h2, :scope > h3");P?(w.setAttribute("data-level",P.tagName[1]),w.append(...P.childNodes)):C&&w.append(...C.childNodes),m.appendChild(w);for(let Pt of[...b.childNodes])if(Pt!==C){let zt=n.createElement("div");zt.appendChild(Pt),l(zt,N,m)}continue}if(b.tagName==="DIV"&&!b.hasAttribute("data-blockeditor-li")&&[...b.children].some(N=>mt.has(N.tagName))){l(b,h,m);continue}h&&b.setAttribute("data-blockeditor-parent",h),m.appendChild(b)}}l(t,null,r);let c=i.length?Math.min(...i.map(u=>+u.dataset.depth)):0,d=null;for(let u of i){let h=+u.dataset.depth-c,m=d&&u.previousElementSibling===d?+d.getAttribute("data-indent")+1:0;u.setAttribute("data-indent",String(Math.min(h,m))),u.removeAttribute("data-depth"),d=u}let f=u=>{if(u.nodeType!==1||u.tagName==="IMG")return[u.cloneNode(!0)];let h=[],m=u.cloneNode(!1);for(let g of u.childNodes)for(let E of f(g))E.nodeType===1&&E.tagName==="IMG"?(m.hasChildNodes()&&h.push(m),h.push(E),m=u.cloneNode(!1)):m.appendChild(E);return(m.hasChildNodes()||!h.length)&&h.push(m),h};for(let u of[...r.children]){if(!u.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-blockeditor-li], div.blockeditor-li")||!u.querySelector("img"))continue;let h=f(u),m=u.getAttribute("data-blockeditor-parent");if(m)for(let g of h)g.setAttribute("data-blockeditor-parent",m);u.replaceWith(...h)}let p=t.querySelector("[data-pm-slice]");return p&&r.firstElementChild?.setAttribute("data-pm-slice",p.dataset.pmSlice),r.innerHTML}var gt=(e,n=0)=>e!==null&&e!==""&&Number.isInteger(+e)&&+e>=n?+e:null,v=e=>e.getAttribute("data-blockeditor-parent")||null,tn=Rt([]).type,en=Object.create(T,{marks:{value:{...T.marks,[nt]:tn}}}),ce=e=>{let n;try{n=Qt(e)}catch{return null}return!n||typeof n.t!="string"||n.t==="opaque_block"||Object.hasOwn(Ft,n.t)?null:n},nn=e=>{let n=ce(e);return n?{raw:n,parent:v(e)}:!1},on=e=>{let n=ce(e);if(!n||typeof n.c!="string"||!n.c)return O.Fragment.empty;let t=Ht(n.m,n.c.length);return O.Fragment.from(jt(T,n.c,t,T.nodes.opaque_block))},rn=e=>{try{return{entries:Wt(e.getAttribute(ut))}}catch{return!1}},X=null,sn=()=>import("./c-SE3SIY7Y.js").then(e=>{X=e},()=>{}),an=new O.DOMParser(en,[{tag:"table",node:"table",getAttrs:e=>X?.table(e)??!1,getContent:e=>X.rows(e)},{tag:`div[${Ut}]`,node:"opaque_block",getAttrs:nn,getContent:on},{tag:`span[${ut}]`,mark:nt,getAttrs:rn},{tag:"div[data-blockeditor-li]",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div.blockeditor-li",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div[data-blockeditor-toggle]",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-blockeditor-toggle"),open:e.getAttribute("data-open")==="true",parent:v(e),level:ft(Number(e.getAttribute("data-level")))})},{tag:"div.blockeditor-toggle",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-id"),open:e.getAttribute("data-open")==="true",parent:null,level:ft(Number(e.getAttribute("data-level")))})},{tag:"h1",node:"heading",getAttrs:e=>({level:1,parent:v(e)})},{tag:"h2",node:"heading",getAttrs:e=>({level:2,parent:v(e)})},{tag:"h3",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"h4",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:e=>({lang:e.getAttribute("data-lang")||"",parent:v(e)})},{tag:"hr",node:"divider",getAttrs:e=>({parent:v(e)})},{tag:"aside.blockeditor-callout",node:"callout",getAttrs:e=>({parent:v(e)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:e=>{let n=e.querySelector("img"),t=et(n?.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",caption:e.querySelector("figcaption")?.textContent||"",width:gt(e.getAttribute("data-width")??n.getAttribute("width"),1),align:be(e.getAttribute("data-align")),parent:v(e)}:!1}},{tag:"img[src]",node:"image",getAttrs:e=>{let n=et(e.getAttribute("src"));return n?{src:n,alt:e.getAttribute("alt")||"",width:gt(e.getAttribute("width"),1),parent:v(e)}:!1}},{tag:'div.blockeditor-file, div[data-type="file"]',node:"file",getAttrs:e=>{let n=L(e.getAttribute("data-src"));return n?{src:n,name:e.getAttribute("data-name")||"file",size:gt(e.getAttribute("data-size")),mime:e.getAttribute("data-mime")||null,parent:v(e)}:!1}},{tag:"p",node:"paragraph",getAttrs:e=>({parent:v(e)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(e.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(e.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:e=>/font-style\s*:\s*italic/.test(e.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:e=>{let n=L(e.getAttribute("href"));return n?{href:n}:!1}},{tag:"blockquote",node:"quote",getAttrs:e=>({parent:v(e)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:e=>ct("highlight",{color:e.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:e=>ct("text_color",{color:e.getAttribute("data-color")})??!1}]);function cn(e,n){let t=n.selection.$from,o=n.selection instanceof x,r=o?n.doc.child(n.selection.span().lo):t.depth>=1?t.node(1):null,s=r?k(r):null,i=r&&S(r)?r.attrs.indent:0,a=new Map;e.content.forEach(m=>{A(m)&&m.attrs.id&&a.set(m.attrs.id,V())});let l=[];e.content.forEach(m=>{if(!m.type.spec.group?.includes("block")){l.push(m);return}let g=k(m),E={...m.attrs,pos:null,id:A(m)?a.get(m.attrs.id)??null:null,parent:g!==null&&a.has(g)?a.get(g):s};S(m)&&(E.indent=m.attrs.indent+i),l.push(m.type.create(E,m.content,m.marks))});let c=!r||!(S(r)||A(r)),d=m=>m&&(S(m)||A(m)),f=c&&d(l[0])?0:e.openStart,p=l[l.length-1],u=new Set(a.values()),h=c&&(d(p)||p&&u.has(k(p)))?0:e.openEnd;return new O.Slice(O.Fragment.from(l),o?0:f,o?0:h)}var St=class extends O.DOMSerializer{serializeFragment(n,t,o){let r=super.serializeFragment(n,t,o);if(!n.firstChild?.isBlock)return r;let s=[...r.childNodes];return n.forEach((i,a,l)=>{let c=s[l];!c||c.nodeType!==1||(k(i)!==null&&c.setAttribute("data-blockeditor-parent",k(i)),A(i)&&i.attrs.id&&c.setAttribute("data-blockeditor-toggle",i.attrs.id),i.type===M.image&&i.attrs.width&&c.setAttribute("data-width",String(i.attrs.width)))}),X?.copy(n,s),r}},le=O.DOMSerializer.fromSchema(T),ln=e=>{let{t:n,...t}=e.attrs.raw??{},{c:o,m:r}=_t(e.content);return o?{t:n,...t,c:o,...r.some(Boolean)?{m:Kt(r)}:{}}:{t:n,...t}},dn=e=>["div",{"data-type":"newer-format",...Gt(ln(e))},0],un=e=>["span",Xt(e.attrs.entries),0],fn={...le.nodes,opaque_block:dn},pn={...le.marks,[nt]:un},hn=new St(fn,pn);function mn(e,n,t){let{$from:o}=e.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!A(r)||r.attrs.open||t.content.childCount<2)return!1;let s=e.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(t);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gn(e){let n=!1;return e?.content?.descendants(t=>n?!1:((t.type===M.quote||t.isText&&t.marks.some(o=>qt.has(o.type.name)))&&(n=!0),!n)),n}function bn(e,n,t){let o=e.state.selection.from,r=e.state.selection.to,s=e.state.doc,i=()=>{let a=t.content.textBetween(0,t.content.size,`
4
- `," ");return!e.isDestroyed&&a&&e.state.doc===s&&e.dispatch(e.state.tr.insertText(a,o,r)),!1};return import("./c-ZFO5RW6G.js").then(({pasteFormats:a})=>a(e,t,o,r),i),!0}function no(){return new wt({view(){return sn(),{}},props:{handlePaste(e,n,t){return gn(t)?bn(e,n,t):mn(e,n,t)},clipboardSerializer:hn,clipboardTextSerializer:e=>X?.text(e),transformPastedHTML:e=>Ze(e),clipboardParser:an,clipboardTextParser:(e,n,t)=>t?null:Qe(e),transformPasted:(e,n)=>cn(e,n.state)}})}var W=tt.chainCommands(Ce,Oe,Be,ze,De),R=tt.chainCommands($e,Le,Pe),oo={Enter:tt.chainCommands(ve,Te,Ne,Ie),Backspace:W,"Shift-Backspace":W,"Mod-Backspace":W,"Alt-Backspace":W,"Ctrl-h":W,Delete:R,"Shift-Delete":R,"Mod-Delete":R,"Alt-Delete":R,"Ctrl-d":R,"Ctrl-Alt-Backspace":R,Tab:Me,"Shift-Tab":vt,"Mod-Shift-ArrowUp":Zt(-1),"Mod-Shift-ArrowDown":Zt(1),"Mod-Enter":Ve};function ao(){return new D.Plugin({view(e){let n=e.dom.ownerDocument.createElement("div");return n.className="blockeditor-live",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),e.dom.parentElement.appendChild(n),{destroy:()=>n.remove()}}})}function Ct(e,n){let t=e.dom.parentElement?.querySelector(".blockeditor-live");t&&(t.textContent="",t.textContent=n)}var de=new D.PluginKey("tableRect");var{Selection:kn,TextSelection:K,NodeSelection:xn,Plugin:yn,PluginKey:An}=D,Q=T.nodes,H=e=>Z.closeHistory(e).setMeta(Et,!0);function Y(e,n,t=n,o=y(e)){let{lo:r,hi:s}=z(o,Math.min(n,t),Math.max(n,t)),i=o[r].at,a=o[s].end;return n<=t?new x(e.resolve(i),e.resolve(a)):new x(e.resolve(a),e.resolve(i))}function Sn(e,n=y(e.doc)){let[t,o]=ne(e.doc,e.selection,n);return z(n,t,o)}var _=(e,n,t)=>{for(let o=n;o>=0&&o<e.length;o+=t)if(!e[o].hidden)return o;return-1};function wn(e,n){if(e.selection instanceof x)return!1;let t=Math.min(e.selection.$head.index(0),e.doc.childCount-1);return n&&n(e.tr.setSelection(Y(e.doc,t))),!0}var ue=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=e<0?_(r,s-1,-1):_(r,i+1,1);return a<0||t&&t(n.tr.setSelection(Y(n.doc,a)).scrollIntoView()),!0};function Dt(e,n,t,o){if(o<0)return n;let r=n;for(;e[r].subEnd<t;)r=e[r].subEnd+1;return r}function En(e,n){for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return n}var fe=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=o.anchor<=o.head,l=a?s:Dt(r,s,i,1),c=a?Dt(r,s,i,1):s;return e>0?a||s===i||c===l?c=_(r,(a?i:c)+1,1):c=_(r,r[c].subEnd+1,1):!a||c===l?c=_(r,(a?c:s)-1,-1):c=En(r,c),c<0||t&&t(n.tr.setSelection(Y(n.doc,l,c,r)).scrollIntoView()),!0};function at(e,n){let t=e.selection;if(!(t instanceof x))return!1;if(n){let o=e.tr.delete(t.from,t.to);o.doc.content.size===0&&o.insert(0,Q.paragraph.create()),o.setSelection(kn.near(o.doc.resolve(Math.min(t.from,o.doc.content.size)),-1)),n(H(o).scrollIntoView())}return!0}function Mn({columns:e={},cards:n={}}){let t=dt(e),o=new Map(t.map(i=>[i,V("c")])),r=lt(null,null,t.length),s={};for(let i of new Set([...t,...Object.values(n).map(a=>a.col)])){let a=dt(Object.fromEntries(Object.entries(n).filter(([,c])=>c.col===i))),l=lt(null,null,a.length);a.forEach((c,d)=>{s[V("k")]={...n[c],col:o.get(i)??i,pos:l[d]}})}return{columns:Object.fromEntries(t.map((i,a)=>[o.get(i),{...e[i],pos:r[a]}])),cards:s}}function vn(e,n){let t=y(e.doc);if(!t.length)return!1;let{lo:o,hi:r}=Sn(e,t);if(n){let s=new Map;for(let f=o;f<=r;f++)t[f].node.type===Q.toggle&&t[f].node.attrs.id&&s.set(t[f].node.attrs.id,V());let i=[];for(let f=o;f<=r;f++){let p=t[f].node,u=p.attrs.parent??null;i.push(p.type.create({...p.attrs,...p.type===Q.board?Mn(p.attrs):{},id:s.get(p.attrs.id)??null,pos:null,parent:s.get(u)??u},p.content,p.marks))}let a=t[r].end,l=a-t[o].at,c=e.tr.insert(a,i),d=e.selection;c.setSelection(d instanceof x?new x(c.doc.resolve(a),c.doc.resolve(a+l)):K.create(c.doc,d.anchor+l,d.head+l)),n(H(c).scrollIntoView())}return!0}var he=(e,n,t,o)=>{for(let r=t;r<=o;r++)if(n[r].node.isTextblock)return n[r].end-1;return-1};function pe(e,n){let t=e.selection;if(!(t instanceof x))return!1;let o=y(e.doc),{lo:r,hi:s}=t.span(e.doc);if(n){let i=he(e.doc,o,r,s);n(e.tr.setSelection(i>=0?K.create(e.doc,i):xn.create(e.doc,o[r].at)))}return!0}var Tn=({$from:e,$to:n})=>{if(e.depth<2||n.depth<2)return null;let t=e.node(1);return t.type.name==="table"&&n.node(1)===t?{from:e.before(1),to:e.after(1)}:null};function Nn(e,n){let t=e.selection,{$from:o,$to:r}=t,s=o.parent.isTextblock&&o.sameParent(r)&&!de.getState(e),i=s&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(s&&!i&&o.parent.content.size)return n&&n(e.tr.setSelection(K.create(e.doc,o.start(),o.end()))),!0;let a=Tn(t);return a&&!(t instanceof x&&t.from===a.from&&t.to===a.to)?(n&&n(e.tr.setSelection(new x(e.doc.resolve(a.from),e.doc.resolve(a.to)))),!0):(n&&n(e.tr.setSelection(new x(e.doc.resolve(0),e.doc.resolve(e.doc.content.size)))),!0)}var In=(e,n)=>{let t=e.state,o=t.selection;if(!(o instanceof x))return!1;let r=y(t.doc),{lo:s,hi:i}=o.span(t.doc),a=he(t.doc,r,s,i),l=t.tr;if(a<0){let c=r[i].end;l.insert(c,Q.paragraph.create({parent:r[s].node.attrs.parent??null})),l.setSelection(K.create(l.doc,c+1)),H(l)}else l.setSelection(K.create(l.doc,a));return l.insertText(n),e.dispatch(l.scrollIntoView()),!0},Cn=(e,n,t)=>{let o=e.selection;if(!(o instanceof K)||!t?.endOfTextblock("down"))return!1;let{$anchor:r,$head:s}=o;if(r.depth!==1||r.parent.type!==Q.toggle||r.parent.attrs.open||r.index(0)!==s.index(0))return!1;let i=y(e.doc),a=r.index(0),l=_(i,i[a].subEnd+1,1);return l<0?!1:(n&&n(e.tr.setSelection(Y(e.doc,a,l,i)).scrollIntoView()),!0)},On=e=>(n,t,o)=>n.selection instanceof x&&e(n,t,o),Dn={Escape:(e,n)=>pe(e,n)||wn(e,n),Enter:On(pe),ArrowUp:ue(-1),ArrowDown:ue(1),"Shift-ArrowUp":fe(-1),"Shift-ArrowDown":(e,n,t)=>fe(1)(e,n)||Cn(e,n,t),Backspace:at,"Alt-Backspace":at,"Ctrl-h":at,Delete:at,"Mod-d":vn,"Mod-a":Nn},Ot=new An("blockeditor-blocksel"),$n=e=>{let n=e.selection,{lo:t,hi:o}=n.span(e.doc);return y(e.doc).filter(r=>r.i>=t&&r.i<=o&&!r.hidden).length};function ko(){let e=Vt.keymap(Dn);return new yn({key:Ot,state:{init:()=>0,apply:(n,t,o,r)=>n.getMeta(ot)&&o.selection instanceof x&&!(r.selection instanceof x)?t+1:t},props:{handleKeyDown:(n,t)=>e.props.handleKeyDown(n,t),handleTextInput:(n,t,o,r)=>In(n,r),decorations(n){let t=n.selection;if(!(t instanceof x))return null;let o=[];return n.doc.nodesBetween(t.from,t.to,(r,s)=>(o.push($.Decoration.node(s,s+r.nodeSize,{class:"blockeditor-block-selected"})),!1)),$.DecorationSet.create(n.doc,o)},createSelectionBetween(n,t,o){let r=n.state.selection;return r instanceof x&&t.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(n,t){let o=n.state.selection;if(!t.shiftKey||!(o instanceof x)||t.button!==0)return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return!1;let s=y(n.state.doc),i=Math.min(n.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),s.length-1),{lo:a,hi:l}=o.span(n.state.doc),c=o.anchor<=o.head?a:Dt(s,a,l,1);return t.preventDefault(),n.dispatch(n.state.tr.setSelection(Y(n.state.doc,c,i,s))),!0}}},view:()=>({update(n,t){let o=n.state.selection,r=t.selection;if(o instanceof x&&!o.eq(r)){let s=$n(n.state);Ct(n,`${s} ${s===1?"block":"blocks"} selected`)}else r instanceof x&&!(o instanceof x)&&Ct(n,Ot.getState(n.state)!==Ot.getState(t)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Ln,PluginKey:Bn,TextSelection:J}=D,{Decoration:Pn,DecorationSet:zn}=$,U=T.marks.link,Vn=e=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(e.trim())&&L(e)!==null;function $t(e,n){let t=e.resolve(n);if(!t.parent.inlineContent)return null;let o=U.isInSet((t.nodeAfter??t.nodeBefore)?.marks??[]);if(!o)return null;let r=[];t.parent.forEach((c,d)=>r.push({n:c,off:d}));let s=r.findIndex(({n:c,off:d})=>d<=t.parentOffset&&t.parentOffset<=d+c.nodeSize&&o.isInSet(c.marks));if(s<0)return null;let i=s,a=s;for(;i>0&&o.isInSet(r[i-1].n.marks);)i--;for(;a<r.length-1&&o.isInSet(r[a+1].n.marks);)a++;let l=t.start();return{from:l+r[i].off,to:l+r[a].off+r[a].n.nodeSize,href:o.attrs.href}}function me(e,n,t,o){let r=e.tr.removeMark(n,t,U);return o&&r.addMark(n,t,U.create({href:o})),H(r)}var B=new Bn("blockeditor-link"),Lt=new WeakMap,ge=e=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Rn=ge('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),qn=ge('<path d="M4 4l8 8M12 4l-8 8"/>');function j(e,n,t,o={}){let r=e.createElement(n);t&&(r.className=t);for(let[s,i]of Object.entries(o))r.setAttribute(s,i);return r}function _n(e,n,t){let o=null;return e.doc.nodesBetween(n,t,r=>{let s=U.isInSet(r.marks);s&&(o=s.attrs.href)}),o}var Bt=class{constructor(n){this.view=n,this.shell=n.dom.parentElement,this.doc=n.dom.ownerDocument,this.mode=null,this.range=null;let t=this.doc;this.dom=j(t,"div","blockeditor-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=j(t,"input","blockeditor-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=j(t,"a","blockeditor-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=j(t,"a","blockeditor-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=Rn,this.edit=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=qn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Lt.set(n,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let n=this.view.state,t=n.selection;if(!(t instanceof J)||!t.$from.sameParent(t.$to)||!t.$from.parent.inlineContent||t.$from.parent.type.spec.code)return!1;let o=t.empty?$t(n.doc,t.head):null;return this.range=o??{from:t.from,to:t.to,href:t.empty?null:_n(n,t.from,t.to)},this.mode="edit",this.view.dispatch(n.tr.setMeta(B,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(n){let t=String(n).trim(),o=t?L(t):null;if(t&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,s=B.getState(r)??(this.mode==="view"?this.range:null);if(!s)return this.close();let i;if(s.from===s.to){if(!o)return this.close();i=r.tr.insert(s.from,T.text(t,[U.create({href:o})])),i.setSelection(J.create(i.doc,s.from+t.length))}else i=me(r,s.from,s.to,o),i.setSelection(J.create(i.doc,s.to));this.view.dispatch(H(i).setMeta(B,null)),this.close()}close(n=!0){this.mode=null,this.range=null,B.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta(B,null)),this.dom.hidden=!0,this.dom.dataset.mode="",n&&this.view.focus(),this.update(this.view)}render(){let n=this.mode==="edit",t=L(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!n,this.url.hidden=n,this.edit.hidden=n,this.open.hidden=!t,this.remove.hidden=!this.range?.href,t?(this.open.href=t,this.url.href=t,this.url.textContent=t.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let n=this.range;if(!n)return;let t=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(n.from),r=this.view.coordsAtPos(n.to,-1);this.dom.style.setProperty("--blockeditor-pop-x",`${Math.min(o.left,r.left)-t.left}px`),this.dom.style.setProperty("--blockeditor-pop-y",`${Math.max(o.bottom,r.bottom)-t.top+6}px`)}update(n){if(this.view=n,this.mode==="edit"){let r=B.getState(n.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let t=n.state.selection,o=t instanceof J&&t.empty&&n.hasFocus()?$t(n.state.doc,t.head):null;if(!o||t.head===o.from||t.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Lt.delete(this.view)}},Kn=e=>Lt.get(e)?.openEdit()??!1;function Hn(e,n){if(n.clipboardData?.files?.length)return!1;let t=n.clipboardData?.getData("text/plain")??"";if(!Vn(t))return!1;let o=e.state.selection;if(!(o instanceof J)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=L(t),s=o.empty?e.state.tr.replaceSelectionWith(T.text(t.trim(),[U.create({href:r})]),!1):me(e.state,o.from,o.to,r);return e.dispatch(s.scrollIntoView().setMeta("uiEvent","paste")),!0}function Eo(){return new Ln({key:B,state:{init:()=>null,apply(e,n){let t=e.getMeta(B);if(t!==void 0)return t;if(!n||!e.docChanged)return n;let o=e.mapping.mapResult(n.from,1),r=e.mapping.mapResult(n.to,n.from===n.to?1:-1);return o.deletedAcross||r.deletedAcross||n.from!==n.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:e=>new Bt(e),props:{decorations(e){let n=B.getState(e);return n&&n.from<n.to?zn.create(e.doc,[Pn.inline(n.from,n.to,{class:"blockeditor-link-pending"})]):null},handleKeyDown(e,n){return(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="k"?(n.preventDefault(),Kn(e)||!0):!1},handlePaste:Hn,handleClick(e,n,t){if(!(t.metaKey||t.ctrlKey))return!1;let o=$t(e.state.doc,n),r=L(o?.href);return r?(e.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{Kn as a,Eo as b,ao as c,Ct as d,de as e,Et as f,q as g,y as h,Jn as i,xe as j,Zn as k,ne as l,z as m,Ae as n,Se as o,x as p,G as q,re as r,Zt as s,Ee as t,Me as u,vt as v,to as w,eo as x,an as y,hn as z,no as A,oo as B,H as C,Y as D,Sn as E,at as F,vn as G,In as H,ko as I};
3
+ `);if(!n.some(r=>ee.test(r)))return null;let t=[],o=[];for(let r of n){if(!r.trim())continue;let s=ee.exec(r);if(!s){t.length=0,o.push(M.paragraph.create(null,r.trim()?T.text(r.trim()):null));continue}let i=s[1].replace(/\t/g," ").length;for(;t.length&&t[t.length-1]>i;)t.pop();(!t.length||t[t.length-1]<i)&&t.push(i);let a=Math.min(t.length-1,o.length&&S(o[o.length-1])?o[o.length-1].attrs.indent+1:0),l=s[4]!==void 0?"check":s[3]!==void 0?"ordered":"bullet";o.push(M.list_item.create({kind:l,indent:a,checked:s[4]==="x"||s[4]==="X"},s[5]?T.text(s[5]):null))}return new O.Slice(O.Fragment.from(o),0,0)}var ht=new Set(["UL","OL"]),mt=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE","BLOCKQUOTE","UL","OL","LI","DETAILS","SUMMARY","TABLE","HR","FIGURE"]);function Ye(e){let n=e.querySelector(":scope > input[type=checkbox], :scope > p > input[type=checkbox], :scope > label > input[type=checkbox]");if(n)return{check:!0,checked:n.checked||n.hasAttribute("checked")};if(e.getAttribute("role")==="checkbox"||e.hasAttribute("aria-checked"))return{check:!0,checked:e.getAttribute("aria-checked")==="true"};if(e.hasAttribute("data-checked"))return{check:!0,checked:e.getAttribute("data-checked")==="true"};let o=e.className||"";return/\b(checked|task-list-item|to-do)\b/.test(o)||e.closest?.("ul.to-do-list, ul.contains-task-list")?{check:!0,checked:/\bchecked\b/.test(o)||!!e.querySelector(".checkbox-on")}:{check:!1,checked:!1}}function Je(e){let n=(e.getAttribute("style")||"")+";"+(e.parentElement?.getAttribute("style")||""),t=/list-style-type\s*:\s*([a-z-]+)/i.exec(e.getAttribute("style")||"")?.[1];return t?/decimal|alpha|roman|latin|greek/.test(t)?"ordered":"bullet":e.parentElement?.tagName==="OL"?"ordered":"bullet"}function Ze(e,n=globalThis.document){let t=n.createElement("div");t.innerHTML=e;for(let u of t.querySelectorAll('b[style*="font-weight:normal"], b[style*="font-weight: normal"]'))u.replaceWith(...u.childNodes);let o=0,r=n.createElement("div"),s=u=>{let h=parseInt(u.getAttribute("aria-level"),10);if(h>0)return h-1;let m=-1;for(let g=u.parentElement;g&&g!==t;g=g.parentElement)ht.has(g.tagName)&&m++;return Math.max(0,m)},i=[];function a(u,h,m){let g=n.createElement("div"),{check:E,checked:b}=Ye(u);g.setAttribute("data-blockeditor-li",""),g.setAttribute("data-kind",E?"check":Je(u)),g.setAttribute("data-checked",b?"true":"false"),g.dataset.depth=String(s(u)),h&&g.setAttribute("data-blockeditor-parent",h);let N=!0,C=[];for(let w of[...u.childNodes]){if(w.nodeType===1&&ht.has(w.tagName)){C.push(w);continue}if(!(w.nodeType===1&&w.tagName==="INPUT")){if(w.nodeType===1&&mt.has(w.tagName)){N||g.appendChild(n.createElement("br"));for(let P of[...w.childNodes])P.nodeType===1&&P.tagName==="INPUT"||g.appendChild(P);N=!1;continue}g.appendChild(w),(w.nodeType!==3||w.textContent.trim())&&(N=!1)}}m.appendChild(g),i.push(g);for(let w of C)l(w,h,m)}function l(u,h,m){let g=null,E=b=>{g||(g=n.createElement("p"),h&&g.setAttribute("data-blockeditor-parent",h),m.appendChild(g)),g.appendChild(b)};for(let b of[...u.childNodes])if(!(b.nodeType===1&&(b.tagName==="META"||b.tagName==="STYLE"))){if(b.nodeType===1&&b.tagName==="BR"){g=null;continue}if(b.nodeType!==1){b.nodeType===3&&(g||b.textContent.trim())&&E(b);continue}if(!mt.has(b.tagName)&&b.tagName!=="ASIDE"){E(b);continue}if(g=null,ht.has(b.tagName)){l(b,h,m);continue}if(b.tagName==="LI"){a(b,h,m);continue}if(b.tagName==="DETAILS"){let N=`paste-${++o}`,C=b.querySelector(":scope > summary"),w=n.createElement("div");w.setAttribute("data-blockeditor-toggle",N),b.hasAttribute("open")&&w.setAttribute("data-open","true"),h&&w.setAttribute("data-blockeditor-parent",h);let P=C?.querySelector(":scope > h1, :scope > h2, :scope > h3");P?(w.setAttribute("data-level",P.tagName[1]),w.append(...P.childNodes)):C&&w.append(...C.childNodes),m.appendChild(w);for(let Pt of[...b.childNodes])if(Pt!==C){let zt=n.createElement("div");zt.appendChild(Pt),l(zt,N,m)}continue}if(b.tagName==="DIV"&&!b.hasAttribute("data-blockeditor-li")&&[...b.children].some(N=>mt.has(N.tagName))){l(b,h,m);continue}h&&b.setAttribute("data-blockeditor-parent",h),m.appendChild(b)}}l(t,null,r);let c=i.length?Math.min(...i.map(u=>+u.dataset.depth)):0,d=null;for(let u of i){let h=+u.dataset.depth-c,m=d&&u.previousElementSibling===d?+d.getAttribute("data-indent")+1:0;u.setAttribute("data-indent",String(Math.min(h,m))),u.removeAttribute("data-depth"),d=u}let f=u=>{if(u.nodeType!==1||u.tagName==="IMG")return[u.cloneNode(!0)];let h=[],m=u.cloneNode(!1);for(let g of u.childNodes)for(let E of f(g))E.nodeType===1&&E.tagName==="IMG"?(m.hasChildNodes()&&h.push(m),h.push(E),m=u.cloneNode(!1)):m.appendChild(E);return(m.hasChildNodes()||!h.length)&&h.push(m),h};for(let u of[...r.children]){if(!u.matches("p, h1, h2, h3, h4, h5, h6, aside, div[data-blockeditor-li], div.blockeditor-li")||!u.querySelector("img"))continue;let h=f(u),m=u.getAttribute("data-blockeditor-parent");if(m)for(let g of h)g.setAttribute("data-blockeditor-parent",m);u.replaceWith(...h)}let p=t.querySelector("[data-pm-slice]");return p&&r.firstElementChild?.setAttribute("data-pm-slice",p.dataset.pmSlice),r.innerHTML}var gt=(e,n=0)=>e!==null&&e!==""&&Number.isInteger(+e)&&+e>=n?+e:null,v=e=>e.getAttribute("data-blockeditor-parent")||null,tn=Rt([]).type,en=Object.create(T,{marks:{value:{...T.marks,[nt]:tn}}}),ce=e=>{let n;try{n=Qt(e)}catch{return null}return!n||typeof n.t!="string"||n.t==="opaque_block"||Object.hasOwn(Ft,n.t)?null:n},nn=e=>{let n=ce(e);return n?{raw:n,parent:v(e)}:!1},on=e=>{let n=ce(e);if(!n||typeof n.c!="string"||!n.c)return O.Fragment.empty;let t=Ht(n.m,n.c.length);return O.Fragment.from(jt(T,n.c,t,T.nodes.opaque_block))},rn=e=>{try{return{entries:Wt(e.getAttribute(ut))}}catch{return!1}},X=null,sn=()=>import("./c-T5IWJOMW.js").then(e=>{X=e},()=>{}),an=new O.DOMParser(en,[{tag:"table",node:"table",getAttrs:e=>X?.table(e)??!1,getContent:e=>X.rows(e)},{tag:`div[${Ut}]`,node:"opaque_block",getAttrs:nn,getContent:on},{tag:`span[${ut}]`,mark:nt,getAttrs:rn},{tag:"div[data-blockeditor-li]",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div.blockeditor-li",node:"list_item",getAttrs:e=>({kind:e.getAttribute("data-kind")||"bullet",indent:+e.getAttribute("data-indent")||0,checked:e.getAttribute("data-checked")==="true",parent:v(e)})},{tag:"div[data-blockeditor-toggle]",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-blockeditor-toggle"),open:e.getAttribute("data-open")==="true",parent:v(e),level:ft(Number(e.getAttribute("data-level")))})},{tag:"div.blockeditor-toggle",node:"toggle",getAttrs:e=>({id:e.getAttribute("data-id"),open:e.getAttribute("data-open")==="true",parent:null,level:ft(Number(e.getAttribute("data-level")))})},{tag:"h1",node:"heading",getAttrs:e=>({level:1,parent:v(e)})},{tag:"h2",node:"heading",getAttrs:e=>({level:2,parent:v(e)})},{tag:"h3",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"h4",node:"heading",getAttrs:e=>({level:3,parent:v(e)})},{tag:"pre",node:"code_block",preserveWhitespace:"full",getAttrs:e=>({lang:e.getAttribute("data-lang")||"",parent:v(e)})},{tag:"hr",node:"divider",getAttrs:e=>({parent:v(e)})},{tag:"aside.blockeditor-callout",node:"callout",getAttrs:e=>({parent:v(e)})},{tag:'figure:not([data-type]), figure[data-type="image"]',node:"image",getAttrs:e=>{let n=e.querySelector("img"),t=et(n?.getAttribute("src"));return t?{src:t,alt:n.getAttribute("alt")||"",caption:e.querySelector("figcaption")?.textContent||"",width:gt(e.getAttribute("data-width")??n.getAttribute("width"),1),align:be(e.getAttribute("data-align")),parent:v(e)}:!1}},{tag:"img[src]",node:"image",getAttrs:e=>{let n=et(e.getAttribute("src"));return n?{src:n,alt:e.getAttribute("alt")||"",width:gt(e.getAttribute("width"),1),parent:v(e)}:!1}},{tag:'div.blockeditor-file, div[data-type="file"]',node:"file",getAttrs:e=>{let n=L(e.getAttribute("data-src"));return n?{src:n,name:e.getAttribute("data-name")||"file",size:gt(e.getAttribute("data-size")),mime:e.getAttribute("data-mime")||null,parent:v(e)}:!1}},{tag:"p",node:"paragraph",getAttrs:e=>({parent:v(e)})},{tag:"br",node:"hard_break"},{tag:"strong",mark:"strong"},{tag:"b",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(normal|[1-5]00)\b/.test(e.getAttribute("style")||"")?!1:null},{tag:"span",mark:"strong",getAttrs:e=>/font-weight\s*:\s*(bold|[6-9]00)\b/.test(e.getAttribute("style")||"")?null:!1},{tag:"em",mark:"em"},{tag:"i",mark:"em"},{tag:"span",mark:"em",getAttrs:e=>/font-style\s*:\s*italic/.test(e.getAttribute("style")||"")?null:!1},{tag:"s",mark:"strike"},{tag:"del",mark:"strike"},{tag:"code",mark:"code"},{tag:"a[href]",mark:"link",getAttrs:e=>{let n=L(e.getAttribute("href"));return n?{href:n}:!1}},{tag:"blockquote",node:"quote",getAttrs:e=>({parent:v(e)})},{tag:"u",mark:"underline"},{tag:"mark",mark:"highlight",getAttrs:e=>ct("highlight",{color:e.getAttribute("data-color")})??!1},{tag:"span[data-color]",mark:"text_color",getAttrs:e=>ct("text_color",{color:e.getAttribute("data-color")})??!1}]);function cn(e,n){let t=n.selection.$from,o=n.selection instanceof x,r=o?n.doc.child(n.selection.span().lo):t.depth>=1?t.node(1):null,s=r?k(r):null,i=r&&S(r)?r.attrs.indent:0,a=new Map;e.content.forEach(m=>{A(m)&&m.attrs.id&&a.set(m.attrs.id,V())});let l=[];e.content.forEach(m=>{if(!m.type.spec.group?.includes("block")){l.push(m);return}let g=k(m),E={...m.attrs,pos:null,id:A(m)?a.get(m.attrs.id)??null:null,parent:g!==null&&a.has(g)?a.get(g):s};S(m)&&(E.indent=m.attrs.indent+i),l.push(m.type.create(E,m.content,m.marks))});let c=!r||!(S(r)||A(r)),d=m=>m&&(S(m)||A(m)),f=c&&d(l[0])?0:e.openStart,p=l[l.length-1],u=new Set(a.values()),h=c&&(d(p)||p&&u.has(k(p)))?0:e.openEnd;return new O.Slice(O.Fragment.from(l),o?0:f,o?0:h)}var St=class extends O.DOMSerializer{serializeFragment(n,t,o){let r=super.serializeFragment(n,t,o);if(!n.firstChild?.isBlock)return r;let s=[...r.childNodes];return n.forEach((i,a,l)=>{let c=s[l];!c||c.nodeType!==1||(k(i)!==null&&c.setAttribute("data-blockeditor-parent",k(i)),A(i)&&i.attrs.id&&c.setAttribute("data-blockeditor-toggle",i.attrs.id),i.type===M.image&&i.attrs.width&&c.setAttribute("data-width",String(i.attrs.width)))}),X?.copy(n,s),r}},le=O.DOMSerializer.fromSchema(T),ln=e=>{let{t:n,...t}=e.attrs.raw??{},{c:o,m:r}=_t(e.content);return o?{t:n,...t,c:o,...r.some(Boolean)?{m:Kt(r)}:{}}:{t:n,...t}},dn=e=>["div",{"data-type":"newer-format",...Gt(ln(e))},0],un=e=>["span",Xt(e.attrs.entries),0],fn={...le.nodes,opaque_block:dn},pn={...le.marks,[nt]:un},hn=new St(fn,pn);function mn(e,n,t){let{$from:o}=e.state.selection,r=o.depth>=1?o.node(1):null;if(!r||!A(r)||r.attrs.open||t.content.childCount<2)return!1;let s=e.state.tr.setNodeMarkup(o.before(1),null,{...r.attrs,open:!0}).replaceSelection(t);return e.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gn(e){let n=!1;return e?.content?.descendants(t=>n?!1:((t.type===M.quote||t.isText&&t.marks.some(o=>qt.has(o.type.name)))&&(n=!0),!n)),n}function bn(e,n,t){let o=e.state.selection.from,r=e.state.selection.to,s=e.state.doc,i=()=>{let a=t.content.textBetween(0,t.content.size,`
4
+ `," ");return!e.isDestroyed&&a&&e.state.doc===s&&e.dispatch(e.state.tr.insertText(a,o,r)),!1};return import("./c-BHLYQGTA.js").then(({pasteFormats:a})=>a(e,t,o,r),i),!0}function no(){return new wt({view(){return sn(),{}},props:{handlePaste(e,n,t){return gn(t)?bn(e,n,t):mn(e,n,t)},clipboardSerializer:hn,clipboardTextSerializer:e=>X?.text(e),transformPastedHTML:e=>Ze(e),clipboardParser:an,clipboardTextParser:(e,n,t)=>t?null:Qe(e),transformPasted:(e,n)=>cn(e,n.state)}})}var W=tt.chainCommands(Ce,Oe,Be,ze,De),R=tt.chainCommands($e,Le,Pe),oo={Enter:tt.chainCommands(ve,Te,Ne,Ie),Backspace:W,"Shift-Backspace":W,"Mod-Backspace":W,"Alt-Backspace":W,"Ctrl-h":W,Delete:R,"Shift-Delete":R,"Mod-Delete":R,"Alt-Delete":R,"Ctrl-d":R,"Ctrl-Alt-Backspace":R,Tab:Me,"Shift-Tab":vt,"Mod-Shift-ArrowUp":Zt(-1),"Mod-Shift-ArrowDown":Zt(1),"Mod-Enter":Ve};function ao(){return new D.Plugin({view(e){let n=e.dom.ownerDocument.createElement("div");return n.className="blockeditor-live",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),e.dom.parentElement.appendChild(n),{destroy:()=>n.remove()}}})}function Ct(e,n){let t=e.dom.parentElement?.querySelector(".blockeditor-live");t&&(t.textContent="",t.textContent=n)}var de=new D.PluginKey("tableRect");var{Selection:kn,TextSelection:K,NodeSelection:xn,Plugin:yn,PluginKey:An}=D,Q=T.nodes,H=e=>Z.closeHistory(e).setMeta(Et,!0);function Y(e,n,t=n,o=y(e)){let{lo:r,hi:s}=z(o,Math.min(n,t),Math.max(n,t)),i=o[r].at,a=o[s].end;return n<=t?new x(e.resolve(i),e.resolve(a)):new x(e.resolve(a),e.resolve(i))}function Sn(e,n=y(e.doc)){let[t,o]=ne(e.doc,e.selection,n);return z(n,t,o)}var _=(e,n,t)=>{for(let o=n;o>=0&&o<e.length;o+=t)if(!e[o].hidden)return o;return-1};function wn(e,n){if(e.selection instanceof x)return!1;let t=Math.min(e.selection.$head.index(0),e.doc.childCount-1);return n&&n(e.tr.setSelection(Y(e.doc,t))),!0}var ue=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=e<0?_(r,s-1,-1):_(r,i+1,1);return a<0||t&&t(n.tr.setSelection(Y(n.doc,a)).scrollIntoView()),!0};function Dt(e,n,t,o){if(o<0)return n;let r=n;for(;e[r].subEnd<t;)r=e[r].subEnd+1;return r}function En(e,n){for(let t=n-1;t>=0;t--)if(e[t].up===e[n].up)return t;return n}var fe=e=>(n,t)=>{let o=n.selection;if(!(o instanceof x))return!1;let r=y(n.doc),{lo:s,hi:i}=o.span(n.doc),a=o.anchor<=o.head,l=a?s:Dt(r,s,i,1),c=a?Dt(r,s,i,1):s;return e>0?a||s===i||c===l?c=_(r,(a?i:c)+1,1):c=_(r,r[c].subEnd+1,1):!a||c===l?c=_(r,(a?c:s)-1,-1):c=En(r,c),c<0||t&&t(n.tr.setSelection(Y(n.doc,l,c,r)).scrollIntoView()),!0};function at(e,n){let t=e.selection;if(!(t instanceof x))return!1;if(n){let o=e.tr.delete(t.from,t.to);o.doc.content.size===0&&o.insert(0,Q.paragraph.create()),o.setSelection(kn.near(o.doc.resolve(Math.min(t.from,o.doc.content.size)),-1)),n(H(o).scrollIntoView())}return!0}function Mn({columns:e={},cards:n={}}){let t=dt(e),o=new Map(t.map(i=>[i,V("c")])),r=lt(null,null,t.length),s={};for(let i of new Set([...t,...Object.values(n).map(a=>a.col)])){let a=dt(Object.fromEntries(Object.entries(n).filter(([,c])=>c.col===i))),l=lt(null,null,a.length);a.forEach((c,d)=>{s[V("k")]={...n[c],col:o.get(i)??i,pos:l[d]}})}return{columns:Object.fromEntries(t.map((i,a)=>[o.get(i),{...e[i],pos:r[a]}])),cards:s}}function vn(e,n){let t=y(e.doc);if(!t.length)return!1;let{lo:o,hi:r}=Sn(e,t);if(n){let s=new Map;for(let f=o;f<=r;f++)t[f].node.type===Q.toggle&&t[f].node.attrs.id&&s.set(t[f].node.attrs.id,V());let i=[];for(let f=o;f<=r;f++){let p=t[f].node,u=p.attrs.parent??null;i.push(p.type.create({...p.attrs,...p.type===Q.board?Mn(p.attrs):{},id:s.get(p.attrs.id)??null,pos:null,parent:s.get(u)??u},p.content,p.marks))}let a=t[r].end,l=a-t[o].at,c=e.tr.insert(a,i),d=e.selection;c.setSelection(d instanceof x?new x(c.doc.resolve(a),c.doc.resolve(a+l)):K.create(c.doc,d.anchor+l,d.head+l)),n(H(c).scrollIntoView())}return!0}var he=(e,n,t,o)=>{for(let r=t;r<=o;r++)if(n[r].node.isTextblock)return n[r].end-1;return-1};function pe(e,n){let t=e.selection;if(!(t instanceof x))return!1;let o=y(e.doc),{lo:r,hi:s}=t.span(e.doc);if(n){let i=he(e.doc,o,r,s);n(e.tr.setSelection(i>=0?K.create(e.doc,i):xn.create(e.doc,o[r].at)))}return!0}var Tn=({$from:e,$to:n})=>{if(e.depth<2||n.depth<2)return null;let t=e.node(1);return t.type.name==="table"&&n.node(1)===t?{from:e.before(1),to:e.after(1)}:null};function Nn(e,n){let t=e.selection,{$from:o,$to:r}=t,s=o.parent.isTextblock&&o.sameParent(r)&&!de.getState(e),i=s&&o.parentOffset===0&&r.parentOffset===r.parent.content.size;if(s&&!i&&o.parent.content.size)return n&&n(e.tr.setSelection(K.create(e.doc,o.start(),o.end()))),!0;let a=Tn(t);return a&&!(t instanceof x&&t.from===a.from&&t.to===a.to)?(n&&n(e.tr.setSelection(new x(e.doc.resolve(a.from),e.doc.resolve(a.to)))),!0):(n&&n(e.tr.setSelection(new x(e.doc.resolve(0),e.doc.resolve(e.doc.content.size)))),!0)}var In=(e,n)=>{let t=e.state,o=t.selection;if(!(o instanceof x))return!1;let r=y(t.doc),{lo:s,hi:i}=o.span(t.doc),a=he(t.doc,r,s,i),l=t.tr;if(a<0){let c=r[i].end;l.insert(c,Q.paragraph.create({parent:r[s].node.attrs.parent??null})),l.setSelection(K.create(l.doc,c+1)),H(l)}else l.setSelection(K.create(l.doc,a));return l.insertText(n),e.dispatch(l.scrollIntoView()),!0},Cn=(e,n,t)=>{let o=e.selection;if(!(o instanceof K)||!t?.endOfTextblock("down"))return!1;let{$anchor:r,$head:s}=o;if(r.depth!==1||r.parent.type!==Q.toggle||r.parent.attrs.open||r.index(0)!==s.index(0))return!1;let i=y(e.doc),a=r.index(0),l=_(i,i[a].subEnd+1,1);return l<0?!1:(n&&n(e.tr.setSelection(Y(e.doc,a,l,i)).scrollIntoView()),!0)},On=e=>(n,t,o)=>n.selection instanceof x&&e(n,t,o),Dn={Escape:(e,n)=>pe(e,n)||wn(e,n),Enter:On(pe),ArrowUp:ue(-1),ArrowDown:ue(1),"Shift-ArrowUp":fe(-1),"Shift-ArrowDown":(e,n,t)=>fe(1)(e,n)||Cn(e,n,t),Backspace:at,"Alt-Backspace":at,"Ctrl-h":at,Delete:at,"Mod-d":vn,"Mod-a":Nn},Ot=new An("blockeditor-blocksel"),$n=e=>{let n=e.selection,{lo:t,hi:o}=n.span(e.doc);return y(e.doc).filter(r=>r.i>=t&&r.i<=o&&!r.hidden).length};function ko(){let e=Vt.keymap(Dn);return new yn({key:Ot,state:{init:()=>0,apply:(n,t,o,r)=>n.getMeta(ot)&&o.selection instanceof x&&!(r.selection instanceof x)?t+1:t},props:{handleKeyDown:(n,t)=>e.props.handleKeyDown(n,t),handleTextInput:(n,t,o,r)=>In(n,r),decorations(n){let t=n.selection;if(!(t instanceof x))return null;let o=[];return n.doc.nodesBetween(t.from,t.to,(r,s)=>(o.push($.Decoration.node(s,s+r.nodeSize,{class:"blockeditor-block-selected"})),!1)),$.DecorationSet.create(n.doc,o)},createSelectionBetween(n,t,o){let r=n.state.selection;return r instanceof x&&t.pos===r.anchor&&o.pos===r.head?r:null},handleDOMEvents:{mousedown(n,t){let o=n.state.selection;if(!t.shiftKey||!(o instanceof x)||t.button!==0)return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});if(!r)return!1;let s=y(n.state.doc),i=Math.min(n.state.doc.resolve(r.inside>=0?r.inside:r.pos).index(0),s.length-1),{lo:a,hi:l}=o.span(n.state.doc),c=o.anchor<=o.head?a:Dt(s,a,l,1);return t.preventDefault(),n.dispatch(n.state.tr.setSelection(Y(n.state.doc,c,i,s))),!0}}},view:()=>({update(n,t){let o=n.state.selection,r=t.selection;if(o instanceof x&&!o.eq(r)){let s=$n(n.state);Ct(n,`${s} ${s===1?"block":"blocks"} selected`)}else r instanceof x&&!(o instanceof x)&&Ct(n,Ot.getState(n.state)!==Ot.getState(t)?"Block selection cleared because the document changed":"Selection cleared")}})})}var{Plugin:Ln,PluginKey:Bn,TextSelection:J}=D,{Decoration:Pn,DecorationSet:zn}=$,U=T.marks.link,Vn=e=>/^(https?:\/\/|mailto:|tel:|www\.)\S+$/i.test(e.trim())&&L(e)!==null;function $t(e,n){let t=e.resolve(n);if(!t.parent.inlineContent)return null;let o=U.isInSet((t.nodeAfter??t.nodeBefore)?.marks??[]);if(!o)return null;let r=[];t.parent.forEach((c,d)=>r.push({n:c,off:d}));let s=r.findIndex(({n:c,off:d})=>d<=t.parentOffset&&t.parentOffset<=d+c.nodeSize&&o.isInSet(c.marks));if(s<0)return null;let i=s,a=s;for(;i>0&&o.isInSet(r[i-1].n.marks);)i--;for(;a<r.length-1&&o.isInSet(r[a+1].n.marks);)a++;let l=t.start();return{from:l+r[i].off,to:l+r[a].off+r[a].n.nodeSize,href:o.attrs.href}}function me(e,n,t,o){let r=e.tr.removeMark(n,t,U);return o&&r.addMark(n,t,U.create({href:o})),H(r)}var B=new Bn("blockeditor-link"),Lt=new WeakMap,ge=e=>`<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,Rn=ge('<path d="M9 3h4v4M13 3 7.5 8.5M11 9.5V13H3V5h3.5"/>'),qn=ge('<path d="M4 4l8 8M12 4l-8 8"/>');function j(e,n,t,o={}){let r=e.createElement(n);t&&(r.className=t);for(let[s,i]of Object.entries(o))r.setAttribute(s,i);return r}function _n(e,n,t){let o=null;return e.doc.nodesBetween(n,t,r=>{let s=U.isInSet(r.marks);s&&(o=s.attrs.href)}),o}var Bt=class{constructor(n){this.view=n,this.shell=n.dom.parentElement,this.doc=n.dom.ownerDocument,this.mode=null,this.range=null;let t=this.doc;this.dom=j(t,"div","blockeditor-link",{role:"dialog","aria-label":"Link",hidden:""}),this.input=j(t,"input","blockeditor-link-input",{type:"url","aria-label":"Link address",placeholder:"Paste or type a link",autocomplete:"off",spellcheck:"false"}),this.url=j(t,"a","blockeditor-link-url",{target:"_blank",rel:"noopener noreferrer"}),this.open=j(t,"a","blockeditor-link-btn",{"data-act":"open",target:"_blank",rel:"noopener noreferrer","aria-label":"Open link in a new tab",title:"Open in a new tab"}),this.open.innerHTML=Rn,this.edit=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"edit"}),this.edit.textContent="Edit",this.remove=j(t,"button","blockeditor-link-btn",{type:"button","data-act":"remove","aria-label":"Remove link",title:"Remove link"}),this.remove.innerHTML=qn,this.dom.append(this.input,this.url,this.open,this.edit,this.remove),this.shell.append(this.dom),Lt.set(n,this),this.dom.addEventListener("mousedown",o=>{o.target!==this.input&&o.preventDefault()}),this.edit.addEventListener("click",()=>this.openEdit()),this.remove.addEventListener("click",()=>this.apply("")),this.input.addEventListener("keydown",o=>{o.isComposing||o.keyCode===229||(o.key==="Enter"?(o.preventDefault(),this.apply(this.input.value)):o.key==="Escape"&&(o.preventDefault(),this.close()))}),this.onDocDown=o=>{this.mode==="edit"&&!this.dom.contains(o.target)&&this.close(!1)},this.doc.addEventListener("mousedown",this.onDocDown,!0)}openEdit(){let n=this.view.state,t=n.selection;if(!(t instanceof J)||!t.$from.sameParent(t.$to)||!t.$from.parent.inlineContent||t.$from.parent.type.spec.code)return!1;let o=t.empty?$t(n.doc,t.head):null;return this.range=o??{from:t.from,to:t.to,href:t.empty?null:_n(n,t.from,t.to)},this.mode="edit",this.view.dispatch(n.tr.setMeta(B,{from:this.range.from,to:this.range.to})),this.render(),this.input.value=this.range.href??"",this.input.removeAttribute("aria-invalid"),this.input.focus(),this.input.select(),!0}apply(n){let t=String(n).trim(),o=t?L(t):null;if(t&&!o){this.input.setAttribute("aria-invalid","true");return}let r=this.view.state,s=B.getState(r)??(this.mode==="view"?this.range:null);if(!s)return this.close();let i;if(s.from===s.to){if(!o)return this.close();i=r.tr.insert(s.from,T.text(t,[U.create({href:o})])),i.setSelection(J.create(i.doc,s.from+t.length))}else i=me(r,s.from,s.to,o),i.setSelection(J.create(i.doc,s.to));this.view.dispatch(H(i).setMeta(B,null)),this.close()}close(n=!0){this.mode=null,this.range=null,B.getState(this.view.state)&&this.view.dispatch(this.view.state.tr.setMeta(B,null)),this.dom.hidden=!0,this.dom.dataset.mode="",n&&this.view.focus(),this.update(this.view)}render(){let n=this.mode==="edit",t=L(this.range?.href);this.dom.dataset.mode=this.mode??"",this.input.hidden=!n,this.url.hidden=n,this.edit.hidden=n,this.open.hidden=!t,this.remove.hidden=!this.range?.href,t?(this.open.href=t,this.url.href=t,this.url.textContent=t.replace(/^https?:\/\//,"")):(this.open.removeAttribute("href"),this.url.removeAttribute("href"),this.url.textContent=""),this.dom.hidden=!1,this.place()}place(){let n=this.range;if(!n)return;let t=this.shell.getBoundingClientRect(),o=this.view.coordsAtPos(n.from),r=this.view.coordsAtPos(n.to,-1);this.dom.style.setProperty("--blockeditor-pop-x",`${Math.min(o.left,r.left)-t.left}px`),this.dom.style.setProperty("--blockeditor-pop-y",`${Math.max(o.bottom,r.bottom)-t.top+6}px`)}update(n){if(this.view=n,this.mode==="edit"){let r=B.getState(n.state);if(r)return this.range={...this.range,...r},this.place();this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}let t=n.state.selection,o=t instanceof J&&t.empty&&n.hasFocus()?$t(n.state.doc,t.head):null;if(!o||t.head===o.from||t.head===o.to){this.mode=null,this.range=null,this.dom.hidden=!0,this.dom.dataset.mode="";return}this.mode="view",this.range=o,this.render()}destroy(){this.doc.removeEventListener("mousedown",this.onDocDown,!0),this.dom.remove(),Lt.delete(this.view)}},Kn=e=>Lt.get(e)?.openEdit()??!1;function Hn(e,n){if(n.clipboardData?.files?.length)return!1;let t=n.clipboardData?.getData("text/plain")??"";if(!Vn(t))return!1;let o=e.state.selection;if(!(o instanceof J)||!o.$from.sameParent(o.$to)||o.$from.parent.type.spec.code)return!1;let r=L(t),s=o.empty?e.state.tr.replaceSelectionWith(T.text(t.trim(),[U.create({href:r})]),!1):me(e.state,o.from,o.to,r);return e.dispatch(s.scrollIntoView().setMeta("uiEvent","paste")),!0}function Eo(){return new Ln({key:B,state:{init:()=>null,apply(e,n){let t=e.getMeta(B);if(t!==void 0)return t;if(!n||!e.docChanged)return n;let o=e.mapping.mapResult(n.from,1),r=e.mapping.mapResult(n.to,n.from===n.to?1:-1);return o.deletedAcross||r.deletedAcross||n.from!==n.to&&o.pos>=r.pos?null:{from:o.pos,to:r.pos}}},view:e=>new Bt(e),props:{decorations(e){let n=B.getState(e);return n&&n.from<n.to?zn.create(e.doc,[Pn.inline(n.from,n.to,{class:"blockeditor-link-pending"})]):null},handleKeyDown(e,n){return(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="k"?(n.preventDefault(),Kn(e)||!0):!1},handlePaste:Hn,handleClick(e,n,t){if(!(t.metaKey||t.ctrlKey))return!1;let o=$t(e.state.doc,n),r=L(o?.href);return r?(e.dom.ownerDocument.defaultView.open(r,"_blank","noopener,noreferrer"),!0):!1}}})}export{Kn as a,Eo as b,ao as c,Ct as d,de as e,Et as f,q as g,y as h,Jn as i,xe as j,Zn as k,ne as l,z as m,Ae as n,Se as o,x as p,G as q,re as r,Zt as s,Ee as t,Me as u,vt as v,to as w,eo as x,an as y,hn as z,no as A,oo as B,H as C,Y as D,Sn as E,at as F,vn as G,In as H,ko as I};
@@ -1 +1 @@
1
- import{c as h}from"./c-Q6BG3ZLO.js";import{i as k,j as y}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as g}from"./c-ZRGEN6QQ.js";import{d}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as m}from"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
1
+ import{c as h}from"./c-Q6BG3ZLO.js";import{i as k,j as y}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import{C as g}from"./c-3Y234AUB.js";import{d}from"./c-OH2FPYSY.js";import"./c-FSQXFG5T.js";import{b as m}from"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var b=e=>String(e).padStart(2,"0");function A(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let s=new Date(`${e}T12:00:00Z`);return Number.isFinite(s.valueOf())&&s.toISOString().slice(0,10)===e}var $=(e=new Date)=>`${e.getFullYear()}-${b(e.getMonth()+1)}-${b(e.getDate())}`,E=(e,s)=>{let a=new Date(`${e}T12:00:00Z`);return a.setUTCDate(a.getUTCDate()+s),a.toISOString().slice(0,10)},I=e=>{let s=E(e,1);return[{id:"today",name:`Today (${e})`,date:e},{id:"tomorrow",name:`Tomorrow (${s})`,date:s}]};function L({view:e=null}={}){if(!e)return{run:()=>({ok:!1,code:"not-editing"}),dispose(){}};let s=e.dom.ownerDocument,a=null;function l(t){let o=e.state;if(!o.selection.empty||o.selection.from!==t.from||t.from<0||t.from>o.doc.content.size)return null;let r=o.doc.resolve(t.from);return!r.parent.isTextblock||r.parent.type.spec.code||!r.parent.type.allowsMarkType(d.marks.date)?null:t.from}function D(t){try{let o=e.dom.parentElement?.getBoundingClientRect?.()??{left:0,top:0},r=e.coordsAtPos(t.from);return{x:Math.max(8,r.left-o.left),y:r.bottom+6-o.top}}catch{return null}}function u(t){let o=t.picker.activeId();o?e.dom.setAttribute("aria-activedescendant",o):e.dom.getAttribute("aria-activedescendant")?.startsWith(t.picker.el.id)&&e.dom.removeAttribute("aria-activedescendant")}function c(){let t=a;if(t){a=null;for(let[o,r,n,i]of t.listen)o.removeEventListener(r,n,i);e.dom.getAttribute("aria-activedescendant")?.startsWith(`${t.picker.el.id}-`)&&e.dom.removeAttribute("aria-activedescendant"),t.picker.destroy()}}function x(t,o){let r=String(o),n=e.state.tr.insertText(r,t,t);return n.addMark(t,t+r.length,d.marks.date.create({date:r})),n.insertText(" ",t+r.length),n.setSelection(m.TextSelection.create(n.doc,t+r.length+1)),e.dispatch(g(n)),e.focus(),{ok:!0,date:r}}async function f(t){let o=a;if(!o)return{ok:!1,code:"not-editing"};let r=o.picker.personAt(t),n=l(o);return n===null||!r||!A(r.date)?(c(),r?n===null?{ok:!1,code:"stale-target"}:{ok:!1,code:"invalid-date"}:{ok:!1,code:"no-date"}):(c(),k(e,()=>{let i=l(o);return i===null?{ok:!1,code:"stale-target"}:x(i,r.date)}))}function S(t){let o=a;if(!o||y(t,e))return;let r=()=>{t.preventDefault(),t.stopPropagation()};t.key==="ArrowDown"||t.key==="ArrowUp"?(r(),o.picker.move(t.key==="ArrowDown"?1:-1),u(o)):t.key==="Enter"?(r(),f(o.picker.index())):(t.key==="Escape"||t.key==="Tab")&&(r(),c())}function T(){c();let t={from:e.state.selection.from,days:I($()),picker:null,listen:[]};t.picker=h({document:s,label:"Insert a date",empty:"No date to insert",onPick:r=>f(r)}),a=t;let o=(r,n,i,p)=>{r.addEventListener(n,i,p),t.listen.push([r,n,i,p])};return o(s,"keydown",r=>S(r),!0),o(e.dom,"input",()=>c()),o(s,"mousedown",r=>{t.picker.el.contains(r.target)||c()},!0),(e.dom.parentElement??s.body).appendChild(t.picker.el),l(t)===null?(c(),{ok:!1,code:"stale-target"}):(t.picker.show(t.days,D(t)),u(t),{ok:!0,picker:!0})}return{async run(){return T()},dispose(){c()}}}export{L as createFeature,I as earlyDays,A as isISODate,$ as localISODate};
@@ -1,4 +1,4 @@
1
- import{c as p}from"./c-H3FNLBHN.js";import{w as u}from"./c-CV4T65JE.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-DD26VXAP.js";import"./c-CTGRDT6E.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-ZRGEN6QQ.js";import{d as h}from"./c-OH2FPYSY.js";import{a as n,b as r}from"./c-Q26XHBLQ.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-WCG6AKA7.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var m=`
1
+ import{c as p}from"./c-H3FNLBHN.js";import{w as u}from"./c-LUBZU4AZ.js";import"./c-GO635CRU.js";import"./c-V2V5FKXX.js";import"./c-T7LOTEWO.js";import"./c-A3OKSYRI.js";import"./c-7K4SCQB7.js";import"./c-WMRJKQ2V.js";import"./c-3Y234AUB.js";import{d as h}from"./c-OH2FPYSY.js";import{a as n,b as r}from"./c-Q26XHBLQ.js";import"./c-FSQXFG5T.js";import"./c-RETTCOWO.js";import"./c-JC4RZW4E.js";import"./c-3LDGIBMN.js";import"./c-57XDY6HC.js";import"./c-VHNSBD2M.js";var m=`
2
2
  .blockeditor-tool-block { position: relative; min-height: 48px; border: 1px solid var(--blockeditor-rule); border-radius: 8px; padding: 12px; }
3
3
  .blockeditor-tool-settings { position: absolute; top: 4px; inset-inline-end: 4px; border: 0; border-radius: 5px; background: var(--blockeditor-pop-bg); color: var(--blockeditor-ink-soft); font: 12px var(--blockeditor-font); padding: 5px 8px; cursor: pointer; opacity: 0; }
4
4
  .blockeditor-tool-block:hover .blockeditor-tool-settings, .blockeditor-tool-block:focus-within .blockeditor-tool-settings { opacity: 1; }
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./c-K2ZHQMPF.js";import"./c-4M2T676V.js";import"./c-EIDZHQHZ.js";import"./c-UL2YUY52.js";import"./c-QY7F6EN6.js";import"./c-OZOACVUD.js";import"./c-QHWJ5ZIJ.js";import"./c-J2ZW4HMR.js";import"./c-A5LASUEZ.js";import"./c-4JZDZFF6.js";import"./c-5RZNFTWD.js";import"./c-PKCCHJ5X.js";import"./c-46XYM55L.js";import"./c-NUHP2XDB.js";import"./c-VKEDWYDF.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";export{a as ask,b as consent,e as init,d as snippet,c as tell};
@@ -1 +1 @@
1
- import{d as R}from"./c-QHWJ5ZIJ.js";import{a as Y,c as j}from"./c-ESK4S67I.js";import{g as P,q as k}from"./c-MR75YPRT.js";import{b as H}from"./c-NUHP2XDB.js";var z=Symbol("clay.surfaceTheme"),L=(()=>{"use strict";let r=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];class d{constructor({targetModal:e,triggers:t=[],onShow:n=()=>{},onClose:u=()=>{},openTrigger:o="data-micromodal-trigger",closeTrigger:x="data-micromodal-close",openClass:F="is-open",disableScroll:E=!1,disableFocus:M=!1,awaitCloseAnimation:C=!1,awaitOpenAnimation:c=!1,debugMode:p=!1}){this.modal=typeof e=="string"?document.getElementById(e):e,this.config={debugMode:p,disableScroll:E,openTrigger:o,closeTrigger:x,openClass:F,onShow:n,onClose:u,awaitCloseAnimation:C,awaitOpenAnimation:c,disableFocus:M},t.length>0&&this.registerTriggers(...t),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}registerTriggers(...e){e.filter(Boolean).forEach(t=>{t.addEventListener("click",n=>this.showModal(n))})}showModal(e=null){if(this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.scrollBehaviour("disable"),this.addEventListeners(),this.config.awaitOpenAnimation){let t=()=>{this.modal.removeEventListener("animationend",t,!1),this.setFocusToFirstNode()};this.modal.addEventListener("animationend",t,!1)}else this.setFocusToFirstNode();this.config.onShow(this.modal,this.activeElement,e)}closeModal(e=null){this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.scrollBehaviour("enable"),this.config.onClose(this.modal,this.activeElement,e)}scrollBehaviour(e){if(!this.config.disableScroll)return;let t=document.querySelector("body");switch(e){case"enable":Object.assign(t.style,{overflow:""});break;case"disable":Object.assign(t.style,{overflow:"hidden"});break;default:}}addEventListeners(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}removeEventListeners(){this.modal&&(this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick)),document.removeEventListener("keydown",this.onKeydown)}onClick(e){(e.target.hasAttribute(this.config.closeTrigger)||e.target.parentNode.hasAttribute(this.config.closeTrigger))&&(e.preventDefault(),e.stopPropagation(),this.closeModal(e))}onKeydown(e){e.keyCode===27&&this.closeModal(e),e.keyCode===9&&this.retainFocus(e)}getFocusableNodes(){let e=this.modal.querySelectorAll(r);return Array(...e)}setFocusToFirstNode(){if(this.config.disableFocus)return;let e=this.getFocusableNodes();if(e.length===0)return;let t=e.filter(n=>!n.hasAttribute(this.config.closeTrigger));t.length>0&&t[0].focus(),t.length===0&&e[0].focus()}retainFocus(e){let t=this.getFocusableNodes();if(t.length!==0)if(t=t.filter(n=>n.offsetParent!==null),!this.modal.contains(document.activeElement))t[0].focus();else{let n=t.indexOf(document.activeElement);e.shiftKey&&n===0&&(t[t.length-1].focus(),e.preventDefault()),!e.shiftKey&&t.length>0&&n===t.length-1&&(t[0].focus(),e.preventDefault())}}}let l=null,g=(i,e)=>{let t=[];return i.forEach(n=>{let u=n.attributes[e].value;t[u]===void 0&&(t[u]=[]),t[u].push(n)}),t},f=i=>{if(!document.getElementById(i))return console.warn(`MicroModal: \u2757Seems like you have missed %c'${i}'`,"background-color: #f8f9fa;color: #50596c;font-weight: bold;","ID somewhere in your code. Refer example below to resolve it."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",`<div class="modal" id="${i}"></div>`),!1},a=i=>{if(i.length<=0)return console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'","background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",'<a href="#" data-micromodal-trigger="my-modal"></a>'),!1},m=(i,e)=>{if(a(i),!e)return!0;for(let t in e)f(t);return!0};return{init:i=>{let e=Object.assign({},{openTrigger:"data-micromodal-trigger"},i),t=[...document.querySelectorAll(`[${e.openTrigger}]`)],n=g(t,e.openTrigger);if(!(e.debugMode===!0&&m(t,n)===!1))for(let u in n){let o=n[u];e.targetModal=u,e.triggers=[...o],l=new d(e)}},show:(i,e)=>{let t=e||{};t.targetModal=i,!(t.debugMode===!0&&f(i)===!1)&&(l&&l.removeEventListeners(),l=new d(t),l.showModal())},close:()=>{l&&(l.closeModal(),l=null)}}})(),G=(()=>{let r="",d="",l="",g="100",f="",a="",m="",b,T=!0,v=!0,i=!1,e=[],t=[],n=[];return{isShowing:!1,open(){let o=e,x=t,F=n;e=[],t=[],n=[];let E=!1,M=()=>{E||(E=!0,x.forEach(s=>s()))};(this.isShowing||document.querySelector("[data-clay-modal]"))&&(this._dismiss?.(),this._cleanupListeners?.(),document.querySelectorAll("[data-clay-modal]").forEach(s=>{Y.get(s)?.(),s.remove()}),this.isShowing=!1,document.body.style.overflow=""),this._dismiss=M;let C=b===void 0?R():b,c=j({zIndex:g,closable:!!f,titled:!!a,...m?{width:m}:{},theme:C}),p=c.root,q=c.overlay,N=c.panel,O=c.body,A=c.footer,$=c.close,D={theme:C,parts:["dialog.button"],labelParts:["dialog.buttonLabel"]},y=P("",D),w=P("",{variant:"primary",...D});w.type="submit",A.append(y,w);let S=(s,h)=>{h instanceof Node?s.append(h):s.innerHTML=h};S(O,r),S(w.firstChild,d),S(y.firstChild,l),a&&S(c.heading,a),a&&N.setAttribute("aria-label",c.heading.textContent.trim()),k(O,!(r===""||r==null),"block"),(r===""||r==null)&&a&&H(A,"border-top","0"),document.body.prepend(p);let B=!1;function I(s){B=q.contains(s.target)&&!N.contains(s.target)}function _(s){(y.contains(s.target)||$?.contains(s.target)||T&&B&&!N.contains(s.target)&&q.contains(s.target))&&L.close(),B=!1}function K(s){if(p.contains(s.target)){s.preventDefault();let h=!0;for(let V of o)try{if(V()===!1){h=!1;break}}catch{h=!1;break}h&&(E=!0,L.close())}}document.addEventListener("mousedown",I),document.addEventListener("click",_),document.addEventListener("submit",K),this._cleanupListeners=()=>{document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K)};function U(){k(A,!!(d||l),"flex"),k(w,!!d,"inline-flex"),k(y,!!l,"inline-flex")}if(U(),L.show(p,{disableScroll:v,disableFocus:!0,onClose:s=>{M(),p.remove(),r="",d="",l="",g="100",f="",a="",m="",b=void 0,T=!0,v=!0,i=!1,this.isShowing=!1,document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K),this._cleanupListeners=null,this._dismiss=null}}),this.isShowing=!0,F.forEach(s=>s()),!i){let s=O.querySelector(":is(input,textarea,button):not([hidden])")||[w,y].find(h=>!h.hidden);s?.focus(),s?.setSelectionRange?.(-1,-1)}},close(){L.close()},get html(){return r},set html(o){r=o},get closeHtml(){return f},set closeHtml(o){f=o},get title(){return a},set title(o){a=o},get width(){return m},set width(o){m=o},get[z](){return b},set[z](o){b=o},get yes(){return d},set yes(o){d=o},get no(){return l},set no(o){l=o},get zIndex(){return g},set zIndex(o){g=o},get disableFocus(){return i},set disableFocus(o){i=o},get disableScroll(){return v},set disableScroll(o){v=o},get onYes(){return o=>{e.push(o)}},set onYes(o){e=[o]},get onNo(){return o=>{t.push(o)}},set onNo(o){t=[o]},get onOpen(){return o=>{n.push(o)}},set onOpen(o){n=[o]}}})(),ee=G;export{z as a,ee as b};
1
+ import{a as R,c as z}from"./c-OZOACVUD.js";import{d as j}from"./c-QHWJ5ZIJ.js";import{c as q,m as k}from"./c-J2ZW4HMR.js";import{b as Y}from"./c-NUHP2XDB.js";var $=Symbol("clay.surfaceTheme"),L=(()=>{"use strict";let r=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];class u{constructor({targetModal:e,triggers:t=[],onShow:n=()=>{},onClose:f=()=>{},openTrigger:o="data-micromodal-trigger",closeTrigger:x="data-micromodal-close",openClass:F="is-open",disableScroll:v=!1,disableFocus:M=!1,awaitCloseAnimation:C=!1,awaitOpenAnimation:c=!1,debugMode:p=!1}){this.modal=typeof e=="string"?document.getElementById(e):e,this.config={debugMode:p,disableScroll:v,openTrigger:o,closeTrigger:x,openClass:F,onShow:n,onClose:f,awaitCloseAnimation:C,awaitOpenAnimation:c,disableFocus:M},t.length>0&&this.registerTriggers(...t),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}registerTriggers(...e){e.filter(Boolean).forEach(t=>{t.addEventListener("click",n=>this.showModal(n))})}showModal(e=null){if(this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.scrollBehaviour("disable"),this.addEventListeners(),this.config.awaitOpenAnimation){let t=()=>{this.modal.removeEventListener("animationend",t,!1),this.setFocusToFirstNode()};this.modal.addEventListener("animationend",t,!1)}else this.setFocusToFirstNode();this.config.onShow(this.modal,this.activeElement,e)}closeModal(e=null){this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.scrollBehaviour("enable"),this.config.onClose(this.modal,this.activeElement,e)}scrollBehaviour(e){if(!this.config.disableScroll)return;let t=document.querySelector("body");switch(e){case"enable":Object.assign(t.style,{overflow:""});break;case"disable":Object.assign(t.style,{overflow:"hidden"});break;default:}}addEventListeners(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}removeEventListeners(){this.modal&&(this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick)),document.removeEventListener("keydown",this.onKeydown)}onClick(e){(e.target.hasAttribute(this.config.closeTrigger)||e.target.parentNode.hasAttribute(this.config.closeTrigger))&&(e.preventDefault(),e.stopPropagation(),this.closeModal(e))}onKeydown(e){e.keyCode===27&&this.closeModal(e),e.keyCode===9&&this.retainFocus(e)}getFocusableNodes(){let e=this.modal.querySelectorAll(r);return Array(...e)}setFocusToFirstNode(){if(this.config.disableFocus)return;let e=this.getFocusableNodes();if(e.length===0)return;let t=e.filter(n=>!n.hasAttribute(this.config.closeTrigger));t.length>0&&t[0].focus(),t.length===0&&e[0].focus()}retainFocus(e){let t=this.getFocusableNodes();if(t.length!==0)if(t=t.filter(n=>n.offsetParent!==null),!this.modal.contains(document.activeElement))t[0].focus();else{let n=t.indexOf(document.activeElement);e.shiftKey&&n===0&&(t[t.length-1].focus(),e.preventDefault()),!e.shiftKey&&t.length>0&&n===t.length-1&&(t[0].focus(),e.preventDefault())}}}let l=null,g=(i,e)=>{let t=[];return i.forEach(n=>{let f=n.attributes[e].value;t[f]===void 0&&(t[f]=[]),t[f].push(n)}),t},h=i=>{if(!document.getElementById(i))return console.warn(`MicroModal: \u2757Seems like you have missed %c'${i}'`,"background-color: #f8f9fa;color: #50596c;font-weight: bold;","ID somewhere in your code. Refer example below to resolve it."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",`<div class="modal" id="${i}"></div>`),!1},a=i=>{if(i.length<=0)return console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'","background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",'<a href="#" data-micromodal-trigger="my-modal"></a>'),!1},m=(i,e)=>{if(a(i),!e)return!0;for(let t in e)h(t);return!0};return{init:i=>{let e=Object.assign({},{openTrigger:"data-micromodal-trigger"},i),t=[...document.querySelectorAll(`[${e.openTrigger}]`)],n=g(t,e.openTrigger);if(!(e.debugMode===!0&&m(t,n)===!1))for(let f in n){let o=n[f];e.targetModal=f,e.triggers=[...o],l=new u(e)}},show:(i,e)=>{let t=e||{};t.targetModal=i,!(t.debugMode===!0&&h(i)===!1)&&(l&&l.removeEventListeners(),l=new u(t),l.showModal())},close:()=>{l&&(l.closeModal(),l=null)}}})(),G=(()=>{let r="",u="",l="",g="100",h="",a="",m="",b,T=!0,E=!0,i=!1,e=[],t=[],n=[];return{isShowing:!1,open(){let o=e,x=t,F=n;e=[],t=[],n=[];let v=!1,M=()=>{v||(v=!0,x.forEach(s=>s()))};(this.isShowing||document.querySelector("[data-clay-modal]"))&&(this._dismiss?.(),this._cleanupListeners?.(),document.querySelectorAll("[data-clay-modal]").forEach(s=>{R.get(s)?.(),s.remove()}),this.isShowing=!1,document.body.style.overflow=""),this._dismiss=M;let C=b===void 0?j():b,c=z({zIndex:g,closable:!!h,titled:!!a,...m?{width:m}:{},theme:C}),p=c.root,D=c.overlay,N=c.panel,O=c.body,A=c.footer,U=c.close,H={theme:C,parts:["dialog.button"],labelParts:["dialog.buttonLabel"]},y=q("",H),w=q("",{variant:"primary",...H});w.type="submit",A.append(y,w);let S=(s,d,P=!1)=>{d instanceof Node?s.append(d):P?s.innerHTML=d:s.textContent=d};S(O,r,!0),S(w.firstChild,u),S(y.firstChild,l),a&&S(c.heading,a),a&&N.setAttribute("aria-label",c.heading.textContent.trim()),k(O,!(r===""||r==null),"block"),(r===""||r==null)&&a&&Y(A,"border-top","0"),document.body.prepend(p);let B=!1;function I(s){B=D.contains(s.target)&&!N.contains(s.target)}function _(s){(y.contains(s.target)||U?.contains(s.target)||T&&B&&!N.contains(s.target)&&D.contains(s.target))&&L.close(),B=!1}function K(s){if(p.contains(s.target)){s.preventDefault();let d=!0;for(let P of o)try{if(P()===!1){d=!1;break}}catch{d=!1;break}d&&(v=!0,L.close())}}document.addEventListener("mousedown",I),document.addEventListener("click",_),document.addEventListener("submit",K),this._cleanupListeners=()=>{document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K)};function V(){k(A,!!(u||l),"flex"),k(w,!!u,"inline-flex"),k(y,!!l,"inline-flex")}if(V(),L.show(p,{disableScroll:E,disableFocus:!0,onClose:s=>{M(),p.remove(),r="",u="",l="",g="100",h="",a="",m="",b=void 0,T=!0,E=!0,i=!1,this.isShowing=!1,document.removeEventListener("mousedown",I),document.removeEventListener("click",_),document.removeEventListener("submit",K),this._cleanupListeners=null,this._dismiss=null}}),this.isShowing=!0,F.forEach(s=>s()),!i){let s=O.querySelector(":is(input,textarea,button):not([hidden])")||[w,y].find(d=>!d.hidden);s?.focus(),s?.setSelectionRange?.(-1,-1)}},close(){L.close()},get html(){return r},set html(o){r=o},get closeHtml(){return h},set closeHtml(o){h=o},get title(){return a},set title(o){a=o},get width(){return m},set width(o){m=o},get[$](){return b},set[$](o){b=o},get yes(){return u},set yes(o){u=o},get no(){return l},set no(o){l=o},get zIndex(){return g},set zIndex(o){g=o},get disableFocus(){return i},set disableFocus(o){i=o},get disableScroll(){return E},set disableScroll(o){E=o},get onYes(){return o=>{e.push(o)}},set onYes(o){e=[o]},get onNo(){return o=>{t.push(o)}},set onNo(o){t=[o]},get onOpen(){return o=>{n.push(o)}},set onOpen(o){n=[o]}}})(),ee=G;export{$ as a,ee as b};
@@ -1,4 +1,4 @@
1
- import{b as F,c as M}from"./c-DD26VXAP.js";import{C as N,d as $}from"./c-ZRGEN6QQ.js";import{A,b as X,c as Y,d as w,x as U}from"./c-OH2FPYSY.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-RETTCOWO.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=5;function v(n){let u=0;for(let i=0;i<n.childCount;i++){let s=n.child(i);if(s.type===w.nodes.heading&&s.attrs.level===1&&s.attrs.parent==null)return{index:i,at:u,node:s};u+=s.nodeSize}return null}var O=`
1
+ import{b as F,c as M}from"./c-T7LOTEWO.js";import{C as N,d as $}from"./c-3Y234AUB.js";import{A,b as X,c as Y,d as w,x as U}from"./c-OH2FPYSY.js";import{b as P}from"./c-QY7F6EN6.js";import"./c-RETTCOWO.js";import"./c-ICMAOOGK.js";import"./c-WRBKEJD4.js";import"./c-VHNSBD2M.js";var y=5;function v(n){let u=0;for(let i=0;i<n.childCount;i++){let s=n.child(i);if(s.type===w.nodes.heading&&s.attrs.level===1&&s.attrs.parent==null)return{index:i,at:u,node:s};u+=s.nodeSize}return null}var O=`
2
2
  :host{font:inherit !important;color:inherit !important}
3
3
  .blockeditor-cover-panel{display:flex;align-items:center;gap:8px;margin:8px 0;padding:6px 10px;border:1px solid var(--blockeditor-pop-line);border-radius:8px;background:var(--blockeditor-pop-bg);color:var(--blockeditor-pop-ink);box-shadow:var(--blockeditor-pop-shadow);font-size:.88em}
4
4
  .blockeditor-cover-msg{max-width:34ch}