@templatical/editor 0.52.0 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/README.md +1 -1
  2. package/dist/AiAltTextPopover-NMJqQKvD.js +106 -0
  3. package/dist/{AiAltTextReview-DE8t8Rud.js → AiAltTextReview-Ci4zHwRc.js} +68 -66
  4. package/dist/{AiChatPanel-7ftS7d40.js → AiChatPanel-DdhtfsmO.js} +223 -210
  5. package/dist/{AiPanels-CxGp6klr.js → AiPanels-HBx7xoJR.js} +6 -6
  6. package/dist/{AiRewriteMenu-DNI-5CUj.js → AiRewriteMenu-DPzSekZt.js} +78 -107
  7. package/dist/BlockIssueBadge-eIXZJ9M3.js +33 -0
  8. package/dist/BlockPreviewCanvas-DO-2TP_6.js +140 -0
  9. package/dist/{CloudHeaderExtras-CsgyNNV1.js → CloudHeaderExtras-XpjJjn3o.js} +4 -4
  10. package/dist/{CloudPanels-BDV4XQ_l.js → CloudPanels-i2kZdrdP.js} +44 -44
  11. package/dist/CollaborationNotices-DANsjl7c.js +65 -0
  12. package/dist/{CollaboratorBar-EeqqWcX6.js → CollaboratorBar-CbbAA0m1.js} +24 -24
  13. package/dist/CommentsPanel-CYW3LWis.js +16 -0
  14. package/dist/CommentsSidebar-CcF4ISMi.js +526 -0
  15. package/dist/{CountdownBlock-BT3ZTH1F.js → CountdownBlock-BMezkFbJ.js} +21 -21
  16. package/dist/CountdownToolbar-D3Lv74kU.js +258 -0
  17. package/dist/{IssuesPanel-BHFQ3wrP.js → IssuesPanel-BMAG9042.js} +141 -129
  18. package/dist/LanguageMenu-FlP_Jbup.js +403 -0
  19. package/dist/{LoadingTrack-DZA5AoP9.js → LoadingTrack-BG8cg9xi.js} +2 -2
  20. package/dist/LocaleNotices-DAnVszWu.js +46 -0
  21. package/dist/{LogicTagInsertButton-CSD9cfJB.js → LogicTagInsertButton-BjYs-UQX.js} +439 -430
  22. package/dist/{MediaEditModal-DQl5w44r.js → MediaEditModal-LnG-cF_S.js} +160 -160
  23. package/dist/{MediaPanels-BFWYuJot.js → MediaPanels-C2r5fiFo.js} +4 -4
  24. package/dist/{cdn/chunks/MergeTagInput-CFu9VXPS.js → MergeTagInput-BsnogCeY.js} +32 -34
  25. package/dist/{MergeTagModeToggle-DvD0ne7N.js → MergeTagModeToggle-DiufIQ-_.js} +49 -49
  26. package/dist/MergeTagTextarea-BweI-Xsi.js +126 -0
  27. package/dist/{ParagraphEditor-D-nqs82g.js → ParagraphEditor-qgBp5yIB.js} +286 -257
  28. package/dist/{RestoreVersionDialog-DqUPsLB9.js → RestoreVersionDialog-DdYUrFiK.js} +23 -23
  29. package/dist/{RichTextEditorContent-Xq9D0Zs3.js → RichTextEditorContent-C5MAzx3E.js} +54 -53
  30. package/dist/{SaveBlockDialog-DAPv70p4.js → SaveBlockDialog-eK6fjtTy.js} +86 -86
  31. package/dist/SavedBlocksBrowserModal-D2QHd2Yp.js +359 -0
  32. package/dist/{SavedBlocksPanels-ChbL9v9x.js → SavedBlocksPanels-Cl61f4Mf.js} +9 -9
  33. package/dist/{SavedBlocksPickBar-hRaiLNdu.js → SavedBlocksPickBar-CXP2dkeB.js} +15 -15
  34. package/dist/TemplateSettings-BKJrdZcH.js +294 -0
  35. package/dist/TestEmailModal-DQotJg6g.js +212 -0
  36. package/dist/{TestEmailPanel-COJQa2A9.js → TestEmailPanel-CwiTzJsh.js} +4 -4
  37. package/dist/TitleEditor-CzSvsPAn.js +202 -0
  38. package/dist/ToggleSwitch-R3wCCYE6.js +43 -0
  39. package/dist/Toolbar-Cd75ci5W.js +3711 -0
  40. package/dist/{TplModal-9IndEYk5.js → TplModal-ZoXu40T9.js} +17 -17
  41. package/dist/{VersionHistoryMenu-BG5qayvg.js → VersionHistoryMenu-BvhN-Ofk.js} +39 -39
  42. package/dist/{VersionHistoryPanels-hPg7Q5-f.js → VersionHistoryPanels-DPWMnYbd.js} +5 -5
  43. package/dist/VersionPreviewBanner-CuJnasxH.js +37 -0
  44. package/dist/WrapperBlock-D4fPwO0t.js +44 -0
  45. package/dist/{blockTypeIcons-yt7SLzub.js → blockTypeIcons-BXMxu86H.js} +27 -26
  46. package/dist/bundle-stats.json +8 -8
  47. package/dist/{cdn/chunks/ca-CD-Kt1qz.js → ca-DOuIxWRv.js} +114 -2
  48. package/dist/cdn/chunks/AiAltTextPopover-ByZ0FEqI.js +107 -0
  49. package/dist/cdn/chunks/AiAltTextPopover-ByZ0FEqI.js.map +1 -0
  50. package/dist/cdn/chunks/{AiAltTextReview-BafAtBoA.js → AiAltTextReview-Dtm3A2cD.js} +71 -69
  51. package/dist/cdn/chunks/AiAltTextReview-Dtm3A2cD.js.map +1 -0
  52. package/dist/cdn/chunks/AiChatPanel-DciEt27y.js +487 -0
  53. package/dist/cdn/chunks/AiChatPanel-DciEt27y.js.map +1 -0
  54. package/dist/cdn/chunks/{AiPanels-B4uAVRoO.js → AiPanels-BV5D1itk.js} +11 -11
  55. package/dist/cdn/chunks/{AiPanels-B4uAVRoO.js.map → AiPanels-BV5D1itk.js.map} +1 -1
  56. package/dist/cdn/chunks/{AiRewriteMenu-4F6vwhJ5.js → AiRewriteMenu-D3jkh6Xb.js} +80 -80
  57. package/dist/cdn/chunks/AiRewriteMenu-D3jkh6Xb.js.map +1 -0
  58. package/dist/cdn/chunks/BlockIssueBadge-DyEgBZtR.js +34 -0
  59. package/dist/cdn/chunks/BlockIssueBadge-DyEgBZtR.js.map +1 -0
  60. package/dist/cdn/chunks/BlockPreviewCanvas-RQFilqXC.js +142 -0
  61. package/dist/cdn/chunks/{BlockPreviewCanvas-Ny1X_mee.js.map → BlockPreviewCanvas-RQFilqXC.js.map} +1 -1
  62. package/dist/cdn/chunks/{CloudHeaderExtras-DtMORiLS.js → CloudHeaderExtras-BtqdN777.js} +4 -4
  63. package/dist/cdn/chunks/{CloudHeaderExtras-DtMORiLS.js.map → CloudHeaderExtras-BtqdN777.js.map} +1 -1
  64. package/dist/cdn/chunks/{CloudPanels-BkmLc2Fl.js → CloudPanels-BSJ-Z5Hw.js} +43 -43
  65. package/dist/cdn/chunks/{CloudPanels-BkmLc2Fl.js.map → CloudPanels-BSJ-Z5Hw.js.map} +1 -1
  66. package/dist/cdn/chunks/CollaborationNotices-BS7xrlPE.js +67 -0
  67. package/dist/cdn/chunks/CollaborationNotices-BS7xrlPE.js.map +1 -0
  68. package/dist/cdn/chunks/{CollaboratorBar-II8eYtKu.js → CollaboratorBar-Bc9914Az.js} +16 -16
  69. package/dist/cdn/chunks/{CollaboratorBar-II8eYtKu.js.map → CollaboratorBar-Bc9914Az.js.map} +1 -1
  70. package/dist/cdn/chunks/CommentsPanel-DbR9phAk.js +18 -0
  71. package/dist/cdn/chunks/{CommentsPanel-CAiwilM2.js.map → CommentsPanel-DbR9phAk.js.map} +1 -1
  72. package/dist/cdn/chunks/CommentsSidebar-BD4--XP2.js +496 -0
  73. package/dist/cdn/chunks/CommentsSidebar-BD4--XP2.js.map +1 -0
  74. package/dist/cdn/chunks/{CountdownBlock-Dyr5P0IP.js → CountdownBlock-CjMhMhnv.js} +26 -26
  75. package/dist/cdn/chunks/{CountdownBlock-Dyr5P0IP.js.map → CountdownBlock-CjMhMhnv.js.map} +1 -1
  76. package/dist/cdn/chunks/CountdownToolbar-DxwYBw-d.js +260 -0
  77. package/dist/cdn/chunks/CountdownToolbar-DxwYBw-d.js.map +1 -0
  78. package/dist/cdn/chunks/{IssuesPanel-pr7_nuLI.js → IssuesPanel-CUmI4HMm.js} +132 -120
  79. package/dist/cdn/chunks/IssuesPanel-CUmI4HMm.js.map +1 -0
  80. package/dist/cdn/chunks/LanguageMenu-3ydCozQJ.js +359 -0
  81. package/dist/cdn/chunks/LanguageMenu-3ydCozQJ.js.map +1 -0
  82. package/dist/cdn/chunks/{LoadingTrack-DfJ_C33G.js → LoadingTrack-DUYcDHOV.js} +2 -2
  83. package/dist/cdn/chunks/{LoadingTrack-DfJ_C33G.js.map → LoadingTrack-DUYcDHOV.js.map} +1 -1
  84. package/dist/cdn/chunks/LocaleNotices-BfoH6gST.js +47 -0
  85. package/dist/cdn/chunks/LocaleNotices-BfoH6gST.js.map +1 -0
  86. package/dist/cdn/chunks/{LogicTagInsertButton-B_ldj3TO.js → LogicTagInsertButton-5Z3fFzjc.js} +465 -456
  87. package/dist/cdn/chunks/LogicTagInsertButton-5Z3fFzjc.js.map +1 -0
  88. package/dist/cdn/chunks/{MediaEditModal-CGfzcHwP.js → MediaEditModal-DDCIwr9U.js} +439 -439
  89. package/dist/cdn/chunks/MediaEditModal-DDCIwr9U.js.map +1 -0
  90. package/dist/cdn/chunks/{MediaPanels-D0BdxdqP.js → MediaPanels-Dz79oy8P.js} +5 -5
  91. package/dist/cdn/chunks/{MediaPanels-D0BdxdqP.js.map → MediaPanels-Dz79oy8P.js.map} +1 -1
  92. package/dist/cdn/chunks/MergeTagInput-CIWy-cXf.js +82 -0
  93. package/dist/cdn/chunks/{MergeTagInput-CFu9VXPS.js.map → MergeTagInput-CIWy-cXf.js.map} +1 -1
  94. package/dist/cdn/chunks/{MergeTagModeToggle-BFpK5dxg.js → MergeTagModeToggle-BrP5GR-x.js} +50 -50
  95. package/dist/cdn/chunks/MergeTagModeToggle-BrP5GR-x.js.map +1 -0
  96. package/dist/cdn/chunks/MergeTagTextarea-D3nNDlhV.js +128 -0
  97. package/dist/cdn/chunks/MergeTagTextarea-D3nNDlhV.js.map +1 -0
  98. package/dist/cdn/chunks/ParagraphEditor-DDolH_Pf.js +660 -0
  99. package/dist/cdn/chunks/ParagraphEditor-DDolH_Pf.js.map +1 -0
  100. package/dist/cdn/chunks/{RestoreVersionDialog-B866zFP0.js → RestoreVersionDialog-Crj1DBqC.js} +18 -18
  101. package/dist/cdn/chunks/{RestoreVersionDialog-B866zFP0.js.map → RestoreVersionDialog-Crj1DBqC.js.map} +1 -1
  102. package/dist/cdn/chunks/{RichTextEditorContent-DaY63kye.js → RichTextEditorContent-rCCqFlwJ.js} +43 -43
  103. package/dist/cdn/chunks/{RichTextEditorContent-DaY63kye.js.map → RichTextEditorContent-rCCqFlwJ.js.map} +1 -1
  104. package/dist/cdn/chunks/{SaveBlockDialog-B7nftAAS.js → SaveBlockDialog-C34RW1aM.js} +71 -71
  105. package/dist/cdn/chunks/{SaveBlockDialog-B7nftAAS.js.map → SaveBlockDialog-C34RW1aM.js.map} +1 -1
  106. package/dist/cdn/chunks/SavedBlocksBrowserModal-CJnwWPT-.js +356 -0
  107. package/dist/cdn/chunks/{SavedBlocksBrowserModal-B9XCjDfm.js.map → SavedBlocksBrowserModal-CJnwWPT-.js.map} +1 -1
  108. package/dist/cdn/chunks/{SavedBlocksPanels-C3nK90pz.js → SavedBlocksPanels-CA2PqXIH.js} +9 -9
  109. package/dist/cdn/chunks/{SavedBlocksPanels-C3nK90pz.js.map → SavedBlocksPanels-CA2PqXIH.js.map} +1 -1
  110. package/dist/cdn/chunks/{SavedBlocksPickBar-B166Mek9.js → SavedBlocksPickBar-Dj3ortee.js} +16 -16
  111. package/dist/cdn/chunks/{SavedBlocksPickBar-B166Mek9.js.map → SavedBlocksPickBar-Dj3ortee.js.map} +1 -1
  112. package/dist/cdn/chunks/TemplateSettings-sW0ZlDl1.js +266 -0
  113. package/dist/cdn/chunks/TemplateSettings-sW0ZlDl1.js.map +1 -0
  114. package/dist/cdn/chunks/{TestEmailModal-DcwKhFnI.js → TestEmailModal-BXeCtTjU.js} +81 -78
  115. package/dist/cdn/chunks/TestEmailModal-BXeCtTjU.js.map +1 -0
  116. package/dist/cdn/chunks/{TestEmailPanel-BDBAvAfI.js → TestEmailPanel-CpZcpB9D.js} +5 -5
  117. package/dist/cdn/chunks/{TestEmailPanel-BDBAvAfI.js.map → TestEmailPanel-CpZcpB9D.js.map} +1 -1
  118. package/dist/cdn/chunks/TitleEditor-Bv3SmSO6.js +202 -0
  119. package/dist/cdn/chunks/TitleEditor-Bv3SmSO6.js.map +1 -0
  120. package/dist/cdn/chunks/ToggleSwitch-BSkySwA1.js +45 -0
  121. package/dist/cdn/chunks/ToggleSwitch-BSkySwA1.js.map +1 -0
  122. package/dist/cdn/chunks/Toolbar-BJKpJ2Mg.js +3626 -0
  123. package/dist/cdn/chunks/Toolbar-BJKpJ2Mg.js.map +1 -0
  124. package/dist/cdn/chunks/{TplModal-BDyeS69p.js → TplModal-DDDUDMYC.js} +19 -19
  125. package/dist/cdn/chunks/{TplModal-BDyeS69p.js.map → TplModal-DDDUDMYC.js.map} +1 -1
  126. package/dist/cdn/chunks/{VersionHistoryMenu-CmpgUI4Q.js → VersionHistoryMenu-DSElv3Sv.js} +36 -36
  127. package/dist/cdn/chunks/{VersionHistoryMenu-CmpgUI4Q.js.map → VersionHistoryMenu-DSElv3Sv.js.map} +1 -1
  128. package/dist/cdn/chunks/{VersionHistoryPanels-DB_FZyyg.js → VersionHistoryPanels-H2nuik1l.js} +6 -6
  129. package/dist/cdn/chunks/{VersionHistoryPanels-DB_FZyyg.js.map → VersionHistoryPanels-H2nuik1l.js.map} +1 -1
  130. package/dist/cdn/chunks/VersionPreviewBanner-Whwxh55w.js +39 -0
  131. package/dist/cdn/chunks/VersionPreviewBanner-Whwxh55w.js.map +1 -0
  132. package/dist/cdn/chunks/WrapperBlock-jTqsuLnS.js +46 -0
  133. package/dist/cdn/chunks/WrapperBlock-jTqsuLnS.js.map +1 -0
  134. package/dist/cdn/chunks/blockTypeIcons-DMgLcuI8.js +21 -0
  135. package/dist/cdn/chunks/blockTypeIcons-DMgLcuI8.js.map +1 -0
  136. package/dist/{ca-CD-Kt1qz.js → cdn/chunks/ca-DOuIxWRv.js} +116 -0
  137. package/dist/cdn/chunks/ca-DOuIxWRv.js.map +1 -0
  138. package/dist/cdn/chunks/composables-D0UYam2P.js +3039 -0
  139. package/dist/cdn/chunks/composables-D0UYam2P.js.map +1 -0
  140. package/dist/cdn/chunks/{createCloudRuntime-D6niZ2Rc.js → createCloudRuntime-BdsclY8_.js} +85 -83
  141. package/dist/cdn/chunks/createCloudRuntime-BdsclY8_.js.map +1 -0
  142. package/dist/{de-CeFJ6wbM.js → cdn/chunks/de-DaOUfYBX.js} +116 -0
  143. package/dist/cdn/chunks/de-DaOUfYBX.js.map +1 -0
  144. package/dist/{dist-CEdyyDn7.js → cdn/chunks/dist-BzXULHvI.js} +63 -61
  145. package/dist/cdn/chunks/{dist-C2epoAwW.js.map → dist-BzXULHvI.js.map} +1 -1
  146. package/dist/{dist-BA-jTQgw.js → cdn/chunks/dist-DqGgijFI.js} +108 -109
  147. package/dist/cdn/chunks/{dist-CONcGNwy.js.map → dist-DqGgijFI.js.map} +1 -1
  148. package/dist/cdn/chunks/{draggable-B8hTTYFO.js → draggable-DepKdldn.js} +1384 -1376
  149. package/dist/cdn/chunks/draggable-DepKdldn.js.map +1 -0
  150. package/dist/cdn/chunks/{editor-modal-cvYkpbHD.js → editor-modal-CPbgthOv.js} +986 -986
  151. package/dist/cdn/chunks/{editor-modal-cvYkpbHD.js.map → editor-modal-CPbgthOv.js.map} +1 -1
  152. package/dist/{en-D14i5nFh.js → cdn/chunks/en-C0pHHMiR.js} +116 -0
  153. package/dist/cdn/chunks/en-C0pHHMiR.js.map +1 -0
  154. package/dist/cdn/chunks/en-IYVryJRl.js +1 -0
  155. package/dist/{es-zDacbMhs.js → cdn/chunks/es-CxyEKr6n.js} +116 -0
  156. package/dist/cdn/chunks/es-CxyEKr6n.js.map +1 -0
  157. package/dist/cdn/chunks/{extensions-ClDhn88e.js → extensions-Uh9vuFfK.js} +57 -57
  158. package/dist/cdn/chunks/{extensions-ClDhn88e.js.map → extensions-Uh9vuFfK.js.map} +1 -1
  159. package/dist/{fr-CSgYtjOd.js → cdn/chunks/fr-CYbamiI6.js} +116 -0
  160. package/dist/cdn/chunks/fr-CYbamiI6.js.map +1 -0
  161. package/dist/cdn/chunks/{icons-HCBP93Ch.js → icons-CSSMtbGK.js} +187 -144
  162. package/dist/cdn/chunks/icons-CSSMtbGK.js.map +1 -0
  163. package/dist/{ja-B7H3ID8O.js → cdn/chunks/ja-DfaIAoGI.js} +116 -0
  164. package/dist/cdn/chunks/ja-DfaIAoGI.js.map +1 -0
  165. package/dist/cdn/chunks/keys-CoQtCqNv.js +11 -0
  166. package/dist/cdn/chunks/keys-CoQtCqNv.js.map +1 -0
  167. package/dist/cdn/chunks/languageName-DEEOhDWI.js +12 -0
  168. package/dist/cdn/chunks/languageName-DEEOhDWI.js.map +1 -0
  169. package/dist/cdn/chunks/{liquid.browser-DkLBNrft.js → liquid.browser-rubac0VA.js} +782 -746
  170. package/dist/cdn/chunks/liquid.browser-rubac0VA.js.map +1 -0
  171. package/dist/{nl-176ySmc5.js → cdn/chunks/nl-DkrB-VKZ.js} +116 -0
  172. package/dist/cdn/chunks/nl-DkrB-VKZ.js.map +1 -0
  173. package/dist/cdn/chunks/normalizeMergeTagMarkup-oGhwVscw.js +290 -0
  174. package/dist/cdn/chunks/normalizeMergeTagMarkup-oGhwVscw.js.map +1 -0
  175. package/dist/cdn/chunks/noticeTones-D7BPu-Le.js +16 -0
  176. package/dist/cdn/chunks/noticeTones-D7BPu-Le.js.map +1 -0
  177. package/dist/cdn/chunks/plural-CyxrJXL1.js +17 -0
  178. package/dist/cdn/chunks/plural-CyxrJXL1.js.map +1 -0
  179. package/dist/cdn/chunks/{preRenderCustomBlocks-D-dsBq5t.js → preRenderCustomBlocks-C8k7tw98.js} +5 -5
  180. package/dist/cdn/chunks/{preRenderCustomBlocks-D-dsBq5t.js.map → preRenderCustomBlocks-C8k7tw98.js.map} +1 -1
  181. package/dist/cdn/chunks/{pt-BR-dDlTwX18.js → pt-BR-CY5Ye7eP.js} +115 -1
  182. package/dist/cdn/chunks/pt-BR-CY5Ye7eP.js.map +1 -0
  183. package/dist/cdn/chunks/sanitizeHtml-DYklmvgX.js +61 -0
  184. package/dist/cdn/chunks/sanitizeHtml-DYklmvgX.js.map +1 -0
  185. package/dist/cdn/chunks/socialIcons-BAiuHyJs.js +2638 -0
  186. package/dist/cdn/chunks/socialIcons-BAiuHyJs.js.map +1 -0
  187. package/dist/cdn/chunks/src-CACM3o--.js +2606 -0
  188. package/dist/cdn/chunks/src-CACM3o--.js.map +1 -0
  189. package/dist/cdn/chunks/{src-CUH_EI7k.js → src-Ddpm4HsS.js} +225 -259
  190. package/dist/cdn/chunks/src-Ddpm4HsS.js.map +1 -0
  191. package/dist/cdn/chunks/{src-BKpAis_q.js → src-DheBmnvF.js} +635 -478
  192. package/dist/cdn/chunks/src-DheBmnvF.js.map +1 -0
  193. package/dist/{styleConstants-B8xVRiwX.js → cdn/chunks/styleConstants-CgiNKdnc.js} +7 -5
  194. package/dist/cdn/chunks/styleConstants-CgiNKdnc.js.map +1 -0
  195. package/dist/cdn/chunks/templateSettingsFields-cjlP-jdw.js.map +1 -1
  196. package/dist/cdn/chunks/{tiptap-ChSZybTi.js → tiptap-Dipw_zOQ.js} +48 -48
  197. package/dist/cdn/chunks/{tiptap-ChSZybTi.js.map → tiptap-Dipw_zOQ.js.map} +1 -1
  198. package/dist/cdn/chunks/{useCloudI18n-RJXyVnIf.js → useCloudI18n-Cc5NZqiI.js} +3 -3
  199. package/dist/cdn/chunks/{useCloudI18n-RJXyVnIf.js.map → useCloudI18n-Cc5NZqiI.js.map} +1 -1
  200. package/dist/cdn/chunks/useEditorRoot-D_LuZ_hE.js +9 -0
  201. package/dist/cdn/chunks/{useEditorRoot-BT3c9CXj.js.map → useEditorRoot-D_LuZ_hE.js.map} +1 -1
  202. package/dist/cdn/chunks/{useI18n-11iqzC6m.js → useI18n-BnJYydPv.js} +3 -3
  203. package/dist/cdn/chunks/{useI18n-11iqzC6m.js.map → useI18n-BnJYydPv.js.map} +1 -1
  204. package/dist/cdn/chunks/useLocalizedDisplay-yXbRKNrs.js +33 -0
  205. package/dist/cdn/chunks/useLocalizedDisplay-yXbRKNrs.js.map +1 -0
  206. package/dist/cdn/chunks/{useLogicTag-vy5KGg5D.js → useLogicTag-B7RpqVFQ.js} +5 -5
  207. package/dist/cdn/chunks/{useLogicTag-vy5KGg5D.js.map → useLogicTag-B7RpqVFQ.js.map} +1 -1
  208. package/dist/cdn/chunks/{useMergeTag-BFBBjnwh.js → useMergeTag-C-32ETjj.js} +6 -6
  209. package/dist/cdn/chunks/{useMergeTag-BFBBjnwh.js.map → useMergeTag-C-32ETjj.js.map} +1 -1
  210. package/dist/cdn/chunks/usePopoverPosition-BWAXWeBv.js +78 -0
  211. package/dist/cdn/chunks/usePopoverPosition-BWAXWeBv.js.map +1 -0
  212. package/dist/cdn/chunks/{useScrollToBlock-C0dawxGr.js → useScrollToBlock-Ct1AwLD-.js} +5 -5
  213. package/dist/cdn/chunks/useScrollToBlock-Ct1AwLD-.js.map +1 -0
  214. package/dist/cdn/chunks/{withCurrentFont-C3CquBQN.js → withCurrentFont-D33ZXoWp.js} +2 -2
  215. package/dist/cdn/chunks/{withCurrentFont-C3CquBQN.js.map → withCurrentFont-D33ZXoWp.js.map} +1 -1
  216. package/dist/cdn/editor.css +1 -1
  217. package/dist/cdn/editor.js +2503 -1809
  218. package/dist/cdn/editor.js.map +1 -1
  219. package/dist/{check-N3x4z_rH.js → check-ChQ0l8EQ.js} +1 -1
  220. package/dist/{chevron-down-gXu9qNwO.js → chevron-down-Bh6cp6PI.js} +1 -1
  221. package/dist/{chevron-right-rL0ayGk5.js → chevron-right-LUgdqdoW.js} +1 -1
  222. package/dist/{chevron-up-0ugh8HnW.js → chevron-up-XsDeJxQN.js} +1 -1
  223. package/dist/{circle-alert-B9Ls75B5.js → circle-alert-lODfDsrj.js} +1 -1
  224. package/dist/{clock-BqHBaCLm.js → clock-DrqFEZkT.js} +1 -1
  225. package/dist/composables-BOP3ERRP.js +4517 -0
  226. package/dist/{createCloudRuntime-B5VIdnwz.js → createCloudRuntime-DGV5a5Af.js} +47 -45
  227. package/dist/{createLucideIcon-BV7Gwz_Z.js → createLucideIcon-Dw5e5gVE.js} +16 -16
  228. package/dist/{cdn/chunks/de-CeFJ6wbM.js → de-DaOUfYBX.js} +114 -2
  229. package/dist/{cdn/chunks/dist-CONcGNwy.js → dist-0alKVRc_.js} +100 -99
  230. package/dist/{dist-Cy8I5scI.js → dist-54VCNoC0.js} +2 -2
  231. package/dist/dist-6DU0me3E.js +4 -0
  232. package/dist/{dist-p3wymUDt.js → dist-B8dY8drK.js} +2 -2
  233. package/dist/{dist-Dd5MU2Ev.js → dist-B9a7iVye.js} +2 -2
  234. package/dist/{dist-V7W1UhVr.js → dist-BWflWcpW.js} +2 -2
  235. package/dist/{dist-D6fZec6r.js → dist-C3hu_C3w.js} +2 -2
  236. package/dist/{cdn/chunks/dist-C2epoAwW.js → dist-CX7skkvG.js} +29 -31
  237. package/dist/dist-CcOn7WCo.js +4 -0
  238. package/dist/dist-Cdkm20M6.js +2542 -0
  239. package/dist/{dist-BS5uKktL.js → dist-ChOb5XHW.js} +2 -2
  240. package/dist/{dist-BF5zEHop.js → dist-DZ3X-uB8.js} +2 -2
  241. package/dist/{dist-CWSG7Kj0.js → dist-D_XrUEET.js} +5 -5
  242. package/dist/{dist-txQLT2sF.js → dist-TAv500j6.js} +2 -2
  243. package/dist/{dist-DDN7yR-w.js → dist-fqSers8_.js} +131 -131
  244. package/dist/{editor-modal-Du9VI9q4.js → editor-modal-B_2EAOjN.js} +907 -906
  245. package/dist/{cdn/chunks/en-D14i5nFh.js → en-C0pHHMiR.js} +114 -2
  246. package/dist/en-DTtwco2Q.js +1 -0
  247. package/dist/{cdn/chunks/es-zDacbMhs.js → es-CxyEKr6n.js} +114 -2
  248. package/dist/{extensions-FRYhx7qa.js → extensions-DOLZkLzV.js} +173 -173
  249. package/dist/{eye-BKj9Tfnc.js → eye-DChfk0gi.js} +1 -1
  250. package/dist/{cdn/chunks/fr-CSgYtjOd.js → fr-CYbamiI6.js} +114 -2
  251. package/dist/{image-DNdvdTla.js → image--Hj2by1G.js} +1 -1
  252. package/dist/index.d.ts +182 -14
  253. package/dist/{info-Bx-kBkbH.js → info-BbXgy82f.js} +1 -1
  254. package/dist/{cdn/chunks/ja-B7H3ID8O.js → ja-DfaIAoGI.js} +114 -2
  255. package/dist/keys-BCqskl51.js +9 -0
  256. package/dist/languageName-DEEOhDWI.js +10 -0
  257. package/dist/{link-D8-rYdIQ.js → link-C2_8yJno.js} +1 -1
  258. package/dist/{liquid.browser-D1RxawkY.js → liquid.browser-DUXEekoN.js} +781 -745
  259. package/dist/{list-BneisA27.js → list-DLGs2n0V.js} +1 -1
  260. package/dist/{loader-circle-DBEXphyx.js → loader-circle-BbDItE_O.js} +1 -1
  261. package/dist/{message-circle-Bg4xInCM.js → message-circle-NAModq0p.js} +1 -1
  262. package/dist/{cdn/chunks/nl-176ySmc5.js → nl-DkrB-VKZ.js} +114 -2
  263. package/dist/normalizeMergeTagMarkup-CUCo7B5X.js +288 -0
  264. package/dist/noticeTones-D7BPu-Le.js +14 -0
  265. package/dist/{package-B40Vkfsp.js → package-BuzsfRyH.js} +1 -1
  266. package/dist/{pencil-CYdAHTds.js → pencil-BTUUECH4.js} +1 -1
  267. package/dist/plural-CyxrJXL1.js +15 -0
  268. package/dist/plus-Dm7DN65T.js +13 -0
  269. package/dist/{preRenderCustomBlocks-AbZArwkR.js → preRenderCustomBlocks-Bs3N9no-.js} +4 -4
  270. package/dist/{pt-BR-dDlTwX18.js → pt-BR-CY5Ye7eP.js} +114 -0
  271. package/dist/{refresh-cw-Bb1FWrU0.js → refresh-cw-xMURqGWi.js} +2 -12
  272. package/dist/rotate-ccw-DqVcEIn5.js +13 -0
  273. package/dist/{runtime-dom.esm-bundler-CLGymEyk.js → runtime-dom.esm-bundler-DlHp8xgy.js} +167 -167
  274. package/dist/sanitizeHtml-mKgNUdME.js +962 -0
  275. package/dist/{search-BZEo08gi.js → search-Cfr3W44N.js} +1 -1
  276. package/dist/{send-DHtrnXQs.js → send-CH1SrvyB.js} +1 -1
  277. package/dist/{smartphone-dlN3vpA3.js → smartphone-pAkvzjdI.js} +1 -1
  278. package/dist/socialIcons-Dqr4DJOz.js +2705 -0
  279. package/dist/{sparkles-NOttoDnJ.js → sparkles-CRO0cCnp.js} +1 -1
  280. package/dist/{square-B1CJgdt2.js → square-CaQWMntx.js} +1 -1
  281. package/dist/style.css +1 -1
  282. package/dist/{cdn/chunks/styleConstants-B8xVRiwX.js → styleConstants-CgiNKdnc.js} +5 -7
  283. package/dist/templatical-editor.js +2294 -1608
  284. package/dist/{text-align-start-zpoXmb-Z.js → text-align-start-BQ39AaRK.js} +1 -1
  285. package/dist/{trash-CGbk4Sgt.js → trash-BL5gEFHN.js} +1 -1
  286. package/dist/{triangle-alert-CKLMyGVp.js → triangle-alert-BYbKu7zZ.js} +1 -1
  287. package/dist/{upload-DQoackAn.js → upload-BhmL4Vqx.js} +1 -1
  288. package/dist/{useCloudI18n-DcLtxOQZ.js → useCloudI18n-Dh2iydo1.js} +4 -4
  289. package/dist/useEditorRoot-DY3mgcHm.js +7 -0
  290. package/dist/{useI18n-CeTm777E.js → useI18n-CgtvtF4C.js} +4 -4
  291. package/dist/useLocalizedDisplay-DNNwDRxL.js +31 -0
  292. package/dist/{useLogicTag-DFDYJeMN.js → useLogicTag-BXXXQQmi.js} +4 -4
  293. package/dist/{useMergeTag-B46vACAG.js → useMergeTag-C9Okr87y.js} +5 -5
  294. package/dist/usePopoverPosition-VDQjyX_A.js +76 -0
  295. package/dist/{useScrollToBlock-C-NzvjeO.js → useScrollToBlock-C0Kapxdh.js} +5 -5
  296. package/dist/{vue.runtime.esm-bundler-CrlI8j5R.js → vue.runtime.esm-bundler-BJXc_Mri.js} +1247 -1239
  297. package/dist/withCurrentFont-DJiQqZzL.js +18 -0
  298. package/dist/{x-zcrnmcmU.js → x-B7NZYzhx.js} +1 -1
  299. package/package.json +23 -23
  300. package/dist/AiAltTextPopover-Cm11CsKH.js +0 -105
  301. package/dist/BlockIssueBadge-6Ri2FfX-.js +0 -33
  302. package/dist/BlockPreviewCanvas-Df9iz7sK.js +0 -140
  303. package/dist/CollaborationNotices-JQ3vQoqO.js +0 -75
  304. package/dist/CommentsPanel-BuftXc0U.js +0 -16
  305. package/dist/CommentsSidebar-Co3x4uH0.js +0 -499
  306. package/dist/CountdownToolbar-CrL4WKy9.js +0 -197
  307. package/dist/MergeTagInput-DE7kWwXx.js +0 -80
  308. package/dist/MergeTagTextarea-DVPQkiYY.js +0 -69
  309. package/dist/SavedBlocksBrowserModal-SRtN5h9q.js +0 -359
  310. package/dist/TemplateSettings-D0XcH32O.js +0 -236
  311. package/dist/TestEmailModal-Cb5t0yB2.js +0 -209
  312. package/dist/TitleEditor-BYk_9SpQ.js +0 -198
  313. package/dist/ToggleSwitch-poGWbduy.js +0 -36
  314. package/dist/Toolbar-Dku_pZni.js +0 -3145
  315. package/dist/VersionPreviewBanner-CSs7zum_.js +0 -37
  316. package/dist/WrapperBlock-DwjK_IdJ.js +0 -44
  317. package/dist/cdn/chunks/AiAltTextPopover-DjMoJCgU.js +0 -106
  318. package/dist/cdn/chunks/AiAltTextPopover-DjMoJCgU.js.map +0 -1
  319. package/dist/cdn/chunks/AiAltTextReview-BafAtBoA.js.map +0 -1
  320. package/dist/cdn/chunks/AiChatPanel-DXeZgc7D.js +0 -474
  321. package/dist/cdn/chunks/AiChatPanel-DXeZgc7D.js.map +0 -1
  322. package/dist/cdn/chunks/AiRewriteMenu-4F6vwhJ5.js.map +0 -1
  323. package/dist/cdn/chunks/BlockIssueBadge-DIJDqqcY.js +0 -34
  324. package/dist/cdn/chunks/BlockIssueBadge-DIJDqqcY.js.map +0 -1
  325. package/dist/cdn/chunks/BlockPreviewCanvas-Ny1X_mee.js +0 -142
  326. package/dist/cdn/chunks/CollaborationNotices-Hf8r08Sw.js +0 -77
  327. package/dist/cdn/chunks/CollaborationNotices-Hf8r08Sw.js.map +0 -1
  328. package/dist/cdn/chunks/CommentsPanel-CAiwilM2.js +0 -18
  329. package/dist/cdn/chunks/CommentsSidebar-Dj8sDiLN.js +0 -469
  330. package/dist/cdn/chunks/CommentsSidebar-Dj8sDiLN.js.map +0 -1
  331. package/dist/cdn/chunks/CountdownToolbar-CguFJdqn.js +0 -199
  332. package/dist/cdn/chunks/CountdownToolbar-CguFJdqn.js.map +0 -1
  333. package/dist/cdn/chunks/IssuesPanel-pr7_nuLI.js.map +0 -1
  334. package/dist/cdn/chunks/LogicTagInsertButton-B_ldj3TO.js.map +0 -1
  335. package/dist/cdn/chunks/MediaEditModal-CGfzcHwP.js.map +0 -1
  336. package/dist/cdn/chunks/MergeTagModeToggle-BFpK5dxg.js.map +0 -1
  337. package/dist/cdn/chunks/MergeTagTextarea-Zo0mYWbf.js +0 -71
  338. package/dist/cdn/chunks/MergeTagTextarea-Zo0mYWbf.js.map +0 -1
  339. package/dist/cdn/chunks/ParagraphEditor-DsPLVAgm.js +0 -631
  340. package/dist/cdn/chunks/ParagraphEditor-DsPLVAgm.js.map +0 -1
  341. package/dist/cdn/chunks/SavedBlocksBrowserModal-B9XCjDfm.js +0 -356
  342. package/dist/cdn/chunks/TemplateSettings-jWpmuWDR.js +0 -208
  343. package/dist/cdn/chunks/TemplateSettings-jWpmuWDR.js.map +0 -1
  344. package/dist/cdn/chunks/TestEmailModal-DcwKhFnI.js.map +0 -1
  345. package/dist/cdn/chunks/TitleEditor-R2lQw6WA.js +0 -198
  346. package/dist/cdn/chunks/TitleEditor-R2lQw6WA.js.map +0 -1
  347. package/dist/cdn/chunks/ToggleSwitch-BDMugNES.js +0 -38
  348. package/dist/cdn/chunks/ToggleSwitch-BDMugNES.js.map +0 -1
  349. package/dist/cdn/chunks/Toolbar-CnvfW72e.js +0 -3061
  350. package/dist/cdn/chunks/Toolbar-CnvfW72e.js.map +0 -1
  351. package/dist/cdn/chunks/VersionPreviewBanner-CZ--HOoa.js +0 -39
  352. package/dist/cdn/chunks/VersionPreviewBanner-CZ--HOoa.js.map +0 -1
  353. package/dist/cdn/chunks/WrapperBlock-D3obNGab.js +0 -46
  354. package/dist/cdn/chunks/WrapperBlock-D3obNGab.js.map +0 -1
  355. package/dist/cdn/chunks/blockTypeIcons-DFf7AyqI.js +0 -21
  356. package/dist/cdn/chunks/blockTypeIcons-DFf7AyqI.js.map +0 -1
  357. package/dist/cdn/chunks/ca-CD-Kt1qz.js.map +0 -1
  358. package/dist/cdn/chunks/createCloudRuntime-D6niZ2Rc.js.map +0 -1
  359. package/dist/cdn/chunks/de-CeFJ6wbM.js.map +0 -1
  360. package/dist/cdn/chunks/draggable-B8hTTYFO.js.map +0 -1
  361. package/dist/cdn/chunks/en-CKAXAo3Z.js +0 -1
  362. package/dist/cdn/chunks/en-D14i5nFh.js.map +0 -1
  363. package/dist/cdn/chunks/es-zDacbMhs.js.map +0 -1
  364. package/dist/cdn/chunks/fr-CSgYtjOd.js.map +0 -1
  365. package/dist/cdn/chunks/icons-HCBP93Ch.js.map +0 -1
  366. package/dist/cdn/chunks/ja-B7H3ID8O.js.map +0 -1
  367. package/dist/cdn/chunks/keys-BF9gazbd.js +0 -11
  368. package/dist/cdn/chunks/keys-BF9gazbd.js.map +0 -1
  369. package/dist/cdn/chunks/liquid.browser-DkLBNrft.js.map +0 -1
  370. package/dist/cdn/chunks/nl-176ySmc5.js.map +0 -1
  371. package/dist/cdn/chunks/normalizeMergeTagMarkup-DpHCSESZ.js +0 -198
  372. package/dist/cdn/chunks/normalizeMergeTagMarkup-DpHCSESZ.js.map +0 -1
  373. package/dist/cdn/chunks/pt-BR-dDlTwX18.js.map +0 -1
  374. package/dist/cdn/chunks/sanitizeHtml-B2h15u0_.js +0 -72
  375. package/dist/cdn/chunks/sanitizeHtml-B2h15u0_.js.map +0 -1
  376. package/dist/cdn/chunks/socialIcons-rJoqO1TJ.js +0 -2008
  377. package/dist/cdn/chunks/socialIcons-rJoqO1TJ.js.map +0 -1
  378. package/dist/cdn/chunks/src-BKpAis_q.js.map +0 -1
  379. package/dist/cdn/chunks/src-C9DTvn1H.js +0 -1423
  380. package/dist/cdn/chunks/src-C9DTvn1H.js.map +0 -1
  381. package/dist/cdn/chunks/src-CUH_EI7k.js.map +0 -1
  382. package/dist/cdn/chunks/styleConstants-B8xVRiwX.js.map +0 -1
  383. package/dist/cdn/chunks/useEditorCore-CjaEV_01.js +0 -2534
  384. package/dist/cdn/chunks/useEditorCore-CjaEV_01.js.map +0 -1
  385. package/dist/cdn/chunks/useEditorRoot-BT3c9CXj.js +0 -9
  386. package/dist/cdn/chunks/usePopoverPosition-AnVIwiVv.js +0 -70
  387. package/dist/cdn/chunks/usePopoverPosition-AnVIwiVv.js.map +0 -1
  388. package/dist/cdn/chunks/useScrollToBlock-C0dawxGr.js.map +0 -1
  389. package/dist/dist-CzrLYq2s.js +0 -1363
  390. package/dist/dist-DyFArF_G.js +0 -4
  391. package/dist/dist-pA3ooG6N.js +0 -4
  392. package/dist/en-CyEE7FPY.js +0 -1
  393. package/dist/keys-DBjrQkYH.js +0 -9
  394. package/dist/normalizeMergeTagMarkup-IH8COHzd.js +0 -196
  395. package/dist/sanitizeHtml-CnOA1efV.js +0 -942
  396. package/dist/socialIcons-B_d52_eS.js +0 -2075
  397. package/dist/useEditorCore-DG9UvWUm.js +0 -4011
  398. package/dist/useEditorRoot-BKr6nNkC.js +0 -7
  399. package/dist/usePopoverPosition-C42kD7zt.js +0 -68
  400. package/dist/withCurrentFont-v_a4Oso8.js +0 -18
@@ -0,0 +1,2638 @@
1
+ import { $ as e, C as t, F as n, H as r, M as i, O as a, Q as o, X as s, Y as c, _ as l, at as u, b as d, ct as f, dt as p, et as m, lt as h, mt as g, ot as _, p as v, pt as y, q as b, rt as x, tt as S, u as C, x as w } from "./draggable-DepKdldn.js";
2
+ import { $t as T, A as E, At as D, Bt as O, Dt as k, Ft as A, Gt as ee, Jt as j, Kt as M, Lt as N, Mt as te, N as ne, Nt as re, O as ie, P, Pt as F, Qt as I, Rt as ae, Vt as L, Wt as oe, Xt as R, Yt as se, Z as z, Zt as B, _n as V, bt as ce, ct as le, en as ue, jt as H, k as de, kt as fe, n as pe, on as U, qt as W, r as me, zt as he } from "./src-CACM3o--.js";
3
+ import { at as ge, s as G } from "./icons-CSSMtbGK.js";
4
+ import { B as _e, C as ve, U as ye, u as be } from "./keys-CoQtCqNv.js";
5
+ import { t as xe } from "./useI18n-BnJYydPv.js";
6
+ import { r as Se } from "./dist-DqGgijFI.js";
7
+ import { i as Ce, r as K } from "./usePopoverPosition-BWAXWeBv.js";
8
+ // ../core/src/localized-edit.ts
9
+ var q = (e) => typeof e == "object" && !!e && !Array.isArray(e), we = (e) => Array.isArray(e) && e.length > 0 && e.every((e) => q(e) && typeof e.id == "string"), Te = /* @__PURE__ */ new Set([
10
+ "id",
11
+ "type",
12
+ "children",
13
+ "columns",
14
+ "l10n",
15
+ "renderedHtml"
16
+ ]);
17
+ function Ee(e, t, n) {
18
+ let r = /* @__PURE__ */ new Set();
19
+ for (let i of n) {
20
+ if (!he(i)) continue;
21
+ let n = i.split("."), a = n.pop(), o = n.join("."), s = W(e, i), c = t;
22
+ for (let [t, i] of n.entries()) {
23
+ let a = n.slice(0, t + 1).join(".");
24
+ s !== void 0 && q(c) && W(c, i) === void 0 && q(W(e, a)) && (c[i] = {}, r.add(a)), c = W(c, i);
25
+ }
26
+ if (Array.isArray(c)) {
27
+ let e = c.findIndex((e) => q(e) && e.id === a);
28
+ if (e < 0) continue;
29
+ s === void 0 ? c.splice(e, 1) : c[e] = T(s);
30
+ } else q(c) && (s === void 0 ? delete c[a] : c[a] = T(s), o && Object.keys(c).length === 0 && W(e, o) === void 0 && Ee(e, t, [o]));
31
+ }
32
+ return r;
33
+ }
34
+ function J(e, t, n, r, i = !0, a = /* @__PURE__ */ new Set()) {
35
+ if (q(e) && q(t) && !a.has(n)) for (let o of /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)])) (n || !Te.has(o)) && J(e[o], t[o], n ? `${n}.${o}` : o, r, i, a);
36
+ else if (i && we(e) && we(t)) for (let o of t) {
37
+ if (o.id.includes(".")) continue;
38
+ let t = e.find((e) => e.id === o.id);
39
+ t && J(t, o, `${n}.${o.id}`, r, i, a);
40
+ }
41
+ else I(e, t) || r.set(n, t);
42
+ }
43
+ function De(e, t, n, r = [], i = /* @__PURE__ */ new Set()) {
44
+ let a = /* @__PURE__ */ new Map();
45
+ J(e, t, "", a, e.type !== "custom", i);
46
+ let o = new Set(e.type === "custom" ? R(e, r) : []), s = {}, c = {};
47
+ for (let [t, r] of a) if ((e.type === "custom" ? o.has(t) : L(e.type, t)) && typeof r == "string" && W(e, t) !== void 0) {
48
+ let i = n?.text?.[t];
49
+ s[t] = i && i.value === r ? i : {
50
+ value: r,
51
+ sourceHash: se(String(W(e, t) ?? ""))
52
+ };
53
+ } else c[t] = r === void 0 ? null : r;
54
+ let l = {};
55
+ return Object.keys(s).length && (l.text = s), Object.keys(c).length && (l.set = c), n?.hidden && (l.hidden = !0), l;
56
+ }
57
+ function Oe(e, t, n) {
58
+ let r = !1;
59
+ function i(e, t, n, a) {
60
+ let o = e[n], s = t[n], c = (e) => Array.isArray(e) && e.every((e) => q(e) && typeof e.id == "string");
61
+ if (c(o) && c(s) && (JSON.stringify(o.map((e) => e.id)) !== JSON.stringify(s.map((e) => e.id)) && (r = !0, e[n] = s.map((e) => T(o.find((t) => t.id === e.id) ?? e))), a)) for (let t of s) {
62
+ let r = e[n].find((e) => e.id === t.id);
63
+ r && i(r, t, a);
64
+ }
65
+ }
66
+ let a = e, o = t;
67
+ if (e.type === "menu" && i(a, o, "items"), e.type === "table" && i(a, o, "rows", "cells"), e.type === "social" && i(a, o, "icons"), e.type === "section" && t.type === "section") {
68
+ let i = (e) => e.map((e) => e.map((e) => e.id));
69
+ (e.columns !== t.columns || JSON.stringify(i(e.children)) !== JSON.stringify(i(t.children))) && (r = !0, e.columns = t.columns, e.children = t.children.map((e) => e.map((e) => T(n(e.id) ?? e))));
70
+ }
71
+ return r;
72
+ }
73
+ function ke(e, t, n) {
74
+ let r = (e) => {
75
+ let { locale: t, locales: n, l10n: r, ...i } = e;
76
+ return i;
77
+ }, i = /* @__PURE__ */ new Map();
78
+ J(r(e), r(t), "", i);
79
+ let a = {};
80
+ for (let [t, r] of i) if (A.includes(t) && typeof r == "string" && W(e, t) !== void 0) {
81
+ let i = n?.text?.[t];
82
+ (a.text ??= {})[t] = i?.value === r ? i : {
83
+ value: r,
84
+ sourceHash: se(String(W(e, t) ?? ""))
85
+ };
86
+ } else (a.set ??= {})[t] = r === void 0 ? null : r;
87
+ return a;
88
+ }
89
+ function Ae(e, t, n, r, i, a = []) {
90
+ let o = T(e ?? {}), s = [.../* @__PURE__ */ new Set([...a, ...[.../* @__PURE__ */ new Set([
91
+ ...Object.keys(t.text ?? {}),
92
+ ...Object.keys(t.set ?? {}),
93
+ ...Object.keys(n.text ?? {}),
94
+ ...Object.keys(n.set ?? {})
95
+ ])].filter((e) => !I(t.text?.[e], n.text?.[e]) || !I(t.set?.[e], n.set?.[e]))])], c = Object.keys(e?.set ?? {}).filter((e) => s.some((t) => t.startsWith(`${e}.`)));
96
+ for (let e of c) {
97
+ let t = W(i, e), n = s.filter((t) => t.startsWith(`${e}.`) && I(W(r, t), W(i, t)));
98
+ if (I(t, W(r, e))) delete o.set[e];
99
+ else if (n.length && q(W(r, e)) && q(t)) {
100
+ delete o.set[e];
101
+ let i = (e, t, a) => {
102
+ if (!n.some((t) => e === t || e.startsWith(`${t}.`))) {
103
+ if (q(t) && q(a)) for (let n of /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(a)])) i(`${e}.${n}`, t[n], a[n]);
104
+ else if (q(r) && r.type !== "custom" && we(t) && we(a)) for (let n of a) i(`${e}.${n.id}`, t.find((e) => e.id === n.id), n);
105
+ else q(r) && typeof r.type == "string" && O(r, e, a) || o.text?.[e] && o.text[e].value === a || ((o.set ??= {})[e] = a === void 0 ? null : T(a));
106
+ }
107
+ };
108
+ i(e, W(r, e), t);
109
+ } else o.set[e] = t === void 0 ? null : T(t);
110
+ for (let t of ["text", "set"]) for (let n of Object.keys(o[t] ?? {})) n.startsWith(`${e}.`) && (I(t === "text" ? o.text[n].value : o.set[n] ?? void 0, W(i, n)) || delete o[t][n]);
111
+ }
112
+ for (let e of s) if (!c.includes(e)) {
113
+ for (let t of ["text", "set"]) for (let n of Object.keys(o[t] ?? {})) (n === e || n.startsWith(`${e}.`)) && delete o[t][n];
114
+ n.text && Object.hasOwn(n.text, e) && ((o.text ??= {})[e] = n.text[e]), n.set && Object.hasOwn(n.set, e) && !c.some((t) => Object.hasOwn(o.set ?? {}, t) && e.startsWith(`${t}.`)) && ((o.set ??= {})[e] = n.set[e]);
115
+ }
116
+ return o.text && !Object.keys(o.text).length && delete o.text, o.set && !Object.keys(o.set).length && delete o.set, o;
117
+ }
118
+ // ../core/src/mutation-guard.ts
119
+ function je(e) {
120
+ return [
121
+ "addBlock",
122
+ "removeBlock",
123
+ "moveBlock",
124
+ "duplicateBlock"
125
+ ].includes(e);
126
+ }
127
+ function Me(e, t, n) {
128
+ if (e.canEdit && !e.canEdit()) return !1;
129
+ let r = t === "addBlock", i = t === "duplicateBlock", a = typeof n[0] == "string" ? n[0] : n[0].id, o = r ? n[0] : e.findBlock?.(a);
130
+ if (!r && e.findBlock && !o) return !1;
131
+ let s = r ? null : e.findBlockLocation?.(a);
132
+ if (!r && e.findBlockLocation && !s || !r && e.isBlockLocked(a, !0) || s?.targetSectionId && e.isBlockLocked(s.targetSectionId, !0)) return !1;
133
+ if (r && e.content) {
134
+ let t = {
135
+ ...e.content(),
136
+ blocks: [o]
137
+ };
138
+ de(t), E(t);
139
+ }
140
+ if (t === "removeBlock") return !0;
141
+ let c = i && n[1] === void 0 && n[2] === void 0, l = c ? s?.targetSectionId : n[t === "moveBlock" ? 2 : 1], u = (c ? s?.columnIndex : n[t === "moveBlock" ? 3 : 2]) ?? 0;
142
+ if (l) {
143
+ if (e.isBlockLocked(l, !0) || o?.type === "section") return !1;
144
+ if (e.findBlock) {
145
+ let t = e.findBlock(l);
146
+ if (t?.type !== "section" || u < 0 || u >= F(t.columns)) return !1;
147
+ }
148
+ }
149
+ return t !== "moveBlock" || s?.targetSectionId !== l || (s?.columnIndex ?? 0) !== u || s?.index !== n[1];
150
+ }
151
+ var Y = /* @__PURE__ */ new WeakMap();
152
+ function Ne(e, t) {
153
+ Y.set(e, t);
154
+ for (let n of Object.values(e)) typeof n == "function" && Y.set(n, t);
155
+ }
156
+ function Pe(e, t) {
157
+ let n = Y.get(e);
158
+ n && Y.set(t, n);
159
+ }
160
+ function X(e, t, n) {
161
+ let r = Reflect.get(e, t), i = Y.get(e) ?? (typeof r == "function" ? Y.get(r) : void 0);
162
+ if (i) return i(t, n);
163
+ if (!je(t)) return !0;
164
+ let a = Reflect.get(e, "isBlockLocked");
165
+ if (typeof a != "function") return !0;
166
+ let o = { isBlockLocked: (t, n) => a.call(e, t, n) }, c = Reflect.get(e, "content");
167
+ s(c) ? o.content = () => c.value : typeof c == "function" && (o.content = () => c.call(e));
168
+ for (let t of [
169
+ "canEdit",
170
+ "findBlock",
171
+ "findBlockLocation"
172
+ ]) {
173
+ let n = Reflect.get(e, t);
174
+ typeof n == "function" && (o[t] = n.bind(e));
175
+ }
176
+ return Me(o, t, n);
177
+ }
178
+ // ../core/src/error-reporting.ts
179
+ function Fe(e) {
180
+ return e instanceof Error ? e : Error(String(e), { cause: e });
181
+ }
182
+ function Z(e, t) {
183
+ try {
184
+ t();
185
+ } catch (t) {
186
+ e?.(Fe(t));
187
+ }
188
+ }
189
+ // ../core/src/editor.ts
190
+ function Ie(t) {
191
+ let n = t.content ?? le(t.defaultFontFamily, t.templateDefaults);
192
+ de(n), E(n);
193
+ let r = e({
194
+ template: null,
195
+ content: n,
196
+ activeLocale: null,
197
+ selectedBlockId: null,
198
+ viewport: "desktop",
199
+ darkMode: !1,
200
+ previewMode: !1,
201
+ isDirty: !1,
202
+ isSaving: !1,
203
+ isLoading: !1,
204
+ uiTheme: "auto"
205
+ }), i = u(r, "activeLocale"), a = [];
206
+ function o(e) {
207
+ let t = N(r.content);
208
+ if (e === t && (e = null), e !== null && !r.content.settings.locales?.includes(e)) throw new B(`This template has no "${e}" version.`, void 0, "unknown_locale");
209
+ i.value = e;
210
+ }
211
+ h(() => i.value ?? N(r.content), (e) => Z(t.onError, () => t.onLocaleChange?.(e))), h(() => r.content.settings.locales?.includes(i.value ?? ""), () => {
212
+ i.value && !r.content.settings.locales?.includes(i.value) && o(null);
213
+ });
214
+ function s() {
215
+ return i.value === null || t.localization === void 0 || t.localization.locales.includes(i.value);
216
+ }
217
+ function c(e) {
218
+ a = e;
219
+ }
220
+ function l(e) {
221
+ return re(r.content, e, a);
222
+ }
223
+ function d(e, n) {
224
+ if (!s()) return null;
225
+ if (e === "addLocale" && (!ae(n) || t.localization && !t.localization.locales.includes(n))) throw new B(`Locale "${n}" is not enabled.`, void 0, "unknown_locale");
226
+ let i = T(r.content);
227
+ return te(i, [{
228
+ op: e,
229
+ locale: n
230
+ }]), I(i, r.content) ? null : i;
231
+ }
232
+ function f(e, t) {
233
+ let n = d(e, t);
234
+ n && (r.content = n, A());
235
+ }
236
+ function p(e) {
237
+ f("addLocale", e);
238
+ }
239
+ function g(e) {
240
+ f("removeLocale", e);
241
+ }
242
+ function _(e, t) {
243
+ let n = i.value;
244
+ Object.keys(t).length ? e.l10n = {
245
+ ...e.l10n,
246
+ [n]: t
247
+ } : e.l10n && (delete e.l10n[n], Object.keys(e.l10n).length || delete e.l10n);
248
+ }
249
+ function v(e, t) {
250
+ let [n, o] = t;
251
+ if (!i.value || !s() || R(n)) return null;
252
+ let c = P(r.content.blocks, n);
253
+ if (!c) return null;
254
+ let l = c.l10n?.[i.value], u = oe(c, i.value, N(r.content)), d = De(c, u, l, a), f = e === "resetLocaleFields" && Array.isArray(o) ? Ee(c, u, o) : void 0, p = e === "resetLocaleFields" ? Ae(l, d, De(c, u, l, a, f), c, u, Array.isArray(o) ? o : []) : T(l ?? {});
255
+ if (e === "setBlockHidden") o ? p.hidden = !0 : delete p.hidden;
256
+ else if (e === "resetLocaleFields") o || (delete p.text, delete p.set, delete p.hidden);
257
+ else for (let e of o) {
258
+ let t = p.text?.[e];
259
+ t && (t.sourceHash = se(String(W(c, e) ?? "")));
260
+ }
261
+ return p.text && !Object.keys(p.text).length && delete p.text, p.set && !Object.keys(p.set).length && delete p.set, I(l ?? {}, p) ? null : {
262
+ block: c,
263
+ layer: p
264
+ };
265
+ }
266
+ function y(e, t) {
267
+ let n = v(e, t);
268
+ n && (_(n.block, n.layer), A());
269
+ }
270
+ function x(e, t) {
271
+ y("setBlockHidden", [e, t]);
272
+ }
273
+ function C(e, t) {
274
+ y("resetLocaleFields", [e, t]);
275
+ }
276
+ function w(e, t) {
277
+ y("keepTranslations", [e, t]);
278
+ }
279
+ let D = S(0), O = 0, k = 0;
280
+ function A() {
281
+ r.isDirty = !0, k++;
282
+ }
283
+ let ne = b({
284
+ get: () => r.content,
285
+ set: (e) => {
286
+ r.content = e, A();
287
+ }
288
+ }), ie = b(() => r.selectedBlockId ? P(r.content.blocks, r.selectedBlockId) : null);
289
+ function P(e, t) {
290
+ for (let n of e) {
291
+ if (n.id === t) return n;
292
+ if (n.type === "section") for (let e of n.children) {
293
+ let n = P(e, t);
294
+ if (n) return n;
295
+ }
296
+ }
297
+ return null;
298
+ }
299
+ function F(e, t) {
300
+ if (t.add(e.id), e.type === "section") for (let n of e.children) for (let e of n) F(e, t);
301
+ }
302
+ function L(e, t, n = { blocks: e }) {
303
+ for (let r = 0; r < e.length; r++) {
304
+ let i = e[r];
305
+ if (i.id === t) return n;
306
+ if (i.type === "section") for (let e = 0; e < i.children.length; e++) {
307
+ let n = L(i.children[e], t, {
308
+ blocks: i.children[e],
309
+ sectionId: i.id,
310
+ columnIndex: e
311
+ });
312
+ if (n) return n;
313
+ }
314
+ }
315
+ return null;
316
+ }
317
+ function R(e, n = !1) {
318
+ let r = i.value ?? t.lockLocale?.value ?? null;
319
+ for (let [i, a] of t.lockedBlocks?.value ?? []) {
320
+ let o = a;
321
+ if (o?.blockId === void 0) {
322
+ if (i === e) return !0;
323
+ } else if (o.blockId === e && o.holder?.sessionId !== t.lockSessionId && (n || r === null || o.locale == null || o.locale === r)) return !0;
324
+ }
325
+ return !1;
326
+ }
327
+ function z(e) {
328
+ let t = L(r.content.blocks, e);
329
+ if (!t) return null;
330
+ let n = t.blocks.findIndex((t) => t.id === e);
331
+ return n === -1 ? null : {
332
+ targetSectionId: t.sectionId,
333
+ columnIndex: t.columnIndex,
334
+ index: n
335
+ };
336
+ }
337
+ function V(e, t = !0) {
338
+ de(e), E(e), r.content = e, t && A();
339
+ }
340
+ function ce(e) {
341
+ e && R(e) || (r.selectedBlockId = e);
342
+ }
343
+ function ue(e) {
344
+ r.viewport = e;
345
+ }
346
+ function H(e) {
347
+ r.darkMode = e;
348
+ }
349
+ function fe(e) {
350
+ r.uiTheme = e;
351
+ }
352
+ function pe(e) {
353
+ r.previewMode = e, e && (r.selectedBlockId = null);
354
+ }
355
+ function U(e, t) {
356
+ if (!s()) return !1;
357
+ let n = P(r.content.blocks, e);
358
+ if (!n) return !1;
359
+ if ("l10n" in t) throw new B("l10n is immutable in updateBlock.", void 0, "invalid_operation");
360
+ let i = {
361
+ ...n,
362
+ ...t
363
+ };
364
+ return !R(e, Oe(T(n), i, (e) => P(r.content.blocks, e)));
365
+ }
366
+ function me(e, n) {
367
+ if (!U(e, n)) return;
368
+ let o = P(r.content.blocks, e);
369
+ if (!o) return;
370
+ let s = i.value;
371
+ if (s) {
372
+ let i = oe(o, s, N(r.content)), c = {
373
+ ...i,
374
+ ...n
375
+ }, l = T(o), u = Oe(l, c, (e) => P(r.content.blocks, e));
376
+ if (R(e, u)) return;
377
+ u && t.onStructureChange?.();
378
+ let d = ee(l);
379
+ delete o.l10n, Object.assign(o, d), _(o, Ae(o.l10n?.[s], De(o, i, o.l10n?.[s], a), De(o, c, o.l10n?.[s], a), o, c));
380
+ } else {
381
+ if (R(e, "children" in n || "columns" in n)) return;
382
+ let t = ee({
383
+ ...o,
384
+ ...n
385
+ });
386
+ delete o.l10n, Object.assign(o, t);
387
+ }
388
+ A();
389
+ }
390
+ function he(e) {
391
+ if ("locales" in e || "l10n" in e) throw new B("locales and l10n are immutable in updateSettings.", void 0, "invalid_operation");
392
+ if ("locale" in e && e.locale !== N(r.content) && r.content.settings.locales?.length) throw new B("The default locale can't change while language versions exist.", void 0, "invalid_operation");
393
+ }
394
+ function ge(e) {
395
+ if (!s()) return;
396
+ he(e);
397
+ let t = i.value;
398
+ if (!t) r.content.settings = M({
399
+ ...r.content.settings,
400
+ ...e
401
+ });
402
+ else {
403
+ let n = r.content.settings, i = j(r.content, t).settings, a = {
404
+ ...i,
405
+ locale: n.locale,
406
+ ...e
407
+ }, o = n.l10n?.[t], s = Ae(o, ke(n, i, o), ke(n, a, o), n, a);
408
+ Object.keys(s).length ? n.l10n = {
409
+ ...n.l10n,
410
+ [t]: s
411
+ } : n.l10n && (delete n.l10n[t], Object.keys(n.l10n).length || delete n.l10n);
412
+ }
413
+ A();
414
+ }
415
+ let G = {
416
+ canEdit: s,
417
+ content: () => r.content,
418
+ findBlock: (e) => P(r.content.blocks, e),
419
+ findBlockLocation: z,
420
+ isBlockLocked: R
421
+ };
422
+ function _e(e, n, a = 0, o) {
423
+ if (Me(G, "addBlock", [
424
+ e,
425
+ n,
426
+ a,
427
+ o
428
+ ])) {
429
+ if (n) {
430
+ let t = P(r.content.blocks, n);
431
+ if (t && t.type === "section") {
432
+ t.children[a] = t.children[a] || [];
433
+ let n = t.children[a];
434
+ o !== void 0 && o < n.length ? n.splice(o, 0, e) : n.push(e);
435
+ }
436
+ } else o !== void 0 && o < r.content.blocks.length ? r.content.blocks.splice(o, 0, e) : r.content.blocks.push(e);
437
+ i.value && t.onStructureChange?.(), A();
438
+ }
439
+ }
440
+ function ve(e) {
441
+ if (!Me(G, "removeBlock", [e])) return;
442
+ let n = L(r.content.blocks, e);
443
+ if (n) {
444
+ let a = n.blocks.findIndex((t) => t.id === e);
445
+ if (a !== -1) {
446
+ let [e] = n.blocks.splice(a, 1);
447
+ if (r.selectedBlockId) {
448
+ let t = /* @__PURE__ */ new Set();
449
+ F(e, t), t.has(r.selectedBlockId) && (r.selectedBlockId = null);
450
+ }
451
+ i.value && t.onStructureChange?.(), A();
452
+ }
453
+ }
454
+ }
455
+ function ye(e, n, a, o = 0) {
456
+ if (!Me(G, "moveBlock", [
457
+ e,
458
+ n,
459
+ a,
460
+ o
461
+ ])) return;
462
+ let s = L(r.content.blocks, e), c = s.blocks.findIndex((t) => t.id === e), l;
463
+ if (a) {
464
+ let e = P(r.content.blocks, a);
465
+ e.children[o] = e.children[o] || [], l = e.children[o];
466
+ } else l = r.content.blocks;
467
+ let [u] = s.blocks.splice(c, 1);
468
+ l.splice(n, 0, u), i.value && t.onStructureChange?.(), A();
469
+ }
470
+ function be() {
471
+ A();
472
+ }
473
+ function xe(e, t) {
474
+ throw new B(`[Templatical] Templates: ${e} ${t}`);
475
+ }
476
+ function Se(e) {
477
+ Z(t.onError, e);
478
+ }
479
+ function Ce(e) {
480
+ let { templates: n } = t;
481
+ return n || xe(e, "needs a templates provider. Pass one as `init({ templates })` to enable saving and loading."), n;
482
+ }
483
+ function K(e) {
484
+ r.template && (r.template = {
485
+ ...r.template,
486
+ name: e
487
+ }, A());
488
+ }
489
+ async function q(e) {
490
+ let n = Ce("create()"), { create: i } = n;
491
+ typeof i != "function" && xe("create()", "is disabled by the provider — its `create` is `false`.");
492
+ let a, o = ++O;
493
+ r.isLoading = !0;
494
+ try {
495
+ e?.content && (r.content = e.content);
496
+ let t = k;
497
+ a = await i(e?.name === void 0 ? { content: r.content } : {
498
+ name: e.name,
499
+ content: r.content
500
+ }), r.template = a, k === t && (r.isDirty = !1), D.value++;
501
+ } catch (e) {
502
+ throw t.onError?.(e), e;
503
+ } finally {
504
+ O === o && (r.isLoading = !1);
505
+ }
506
+ return Se(() => n.onCreated?.(a)), a;
507
+ }
508
+ async function we(e, n) {
509
+ let i = Ce("load()"), a, o = ++O;
510
+ r.isLoading = !0;
511
+ try {
512
+ if (a = await i.load(e), de(a.content), E(a.content), n && !n()) return a;
513
+ r.template = a, r.content = a.content, r.isDirty = !1, D.value++;
514
+ } catch (e) {
515
+ throw t.onError?.(e), e;
516
+ } finally {
517
+ O === o && (r.isLoading = !1);
518
+ }
519
+ return Se(() => i.onLoaded?.(a)), a;
520
+ }
521
+ async function Te(e = "api") {
522
+ let n = Ce("save()"), { save: i } = n;
523
+ typeof i != "function" && xe("save()", "is disabled by the provider — its `save` is `false`.");
524
+ let a = r.template;
525
+ a || xe("save()", "has no template loaded. Call create() or load() first.");
526
+ let o = a.name === void 0 ? { content: r.content } : {
527
+ name: a.name,
528
+ content: r.content
529
+ }, s;
530
+ r.isSaving = !0;
531
+ try {
532
+ let e = k;
533
+ if (s = await i(a.id, o), r.template?.id === a.id) {
534
+ let e = r.template.name;
535
+ r.template = e === a.name ? s : {
536
+ ...s,
537
+ name: e
538
+ };
539
+ }
540
+ k === e && (r.isDirty = !1);
541
+ } catch (e) {
542
+ throw t.onError?.(e), e;
543
+ } finally {
544
+ r.isSaving = !1;
545
+ }
546
+ return Se(() => n.onSaved?.(s, { trigger: e })), s;
547
+ }
548
+ function J() {
549
+ return r.template?.id !== void 0;
550
+ }
551
+ let Y = {
552
+ state: m(r),
553
+ loadVersion: m(D),
554
+ content: ne,
555
+ selectedBlock: ie,
556
+ activeLocale: i,
557
+ setActiveLocale: o,
558
+ addLocale: p,
559
+ removeLocale: g,
560
+ setBlockHidden: x,
561
+ resetLocaleFields: C,
562
+ keepTranslations: w,
563
+ setCustomBlockDefinitions: c,
564
+ createSetDefaultLocaleOperation: l,
565
+ isBlockLocked: R,
566
+ setContent: V,
567
+ selectBlock: ce,
568
+ setViewport: ue,
569
+ setDarkMode: H,
570
+ setUiTheme: fe,
571
+ setPreviewMode: pe,
572
+ updateBlock: me,
573
+ updateSettings: ge,
574
+ addBlock: _e,
575
+ removeBlock: ve,
576
+ moveBlock: ye,
577
+ markDirty: be,
578
+ findBlockLocation: z,
579
+ setName: K,
580
+ create: q,
581
+ load: we,
582
+ save: Te,
583
+ hasTemplate: J
584
+ };
585
+ return Ne(Y, (e, t) => je(e) ? Me(G, e, t) : s() ? e === "updateBlock" ? U(t[0], t[1]) : (e === "updateSettings" && he(t[0]), e === "addLocale" || e === "removeLocale" ? d(e, t[0]) !== null : e === "setBlockHidden" || e === "resetLocaleFields" || e === "keepTranslations" ? v(e, t) !== null : !0) : !1), Y;
586
+ }
587
+ // ../core/src/history.ts
588
+ var Le = 50, Re = 300, ze = 1500;
589
+ function Be(e) {
590
+ let { content: t, setContent: n, maxSize: r = Le } = e, i = S([]), a = S([]), o = S(!1), s = null, c = null, l = b(() => i.value.length > 0), u = b(() => a.value.length > 0);
591
+ function d() {
592
+ return T(t.value);
593
+ }
594
+ function f(e) {
595
+ i.value.push(e), i.value.length > r && i.value.splice(0, i.value.length - r);
596
+ }
597
+ function p() {
598
+ c &&= (clearTimeout(c.timeoutId), null);
599
+ }
600
+ function m() {
601
+ p(), f(d()), a.value = [];
602
+ }
603
+ function h(e) {
604
+ c && c.blockId === e ? (clearTimeout(c.timeoutId), c.timeoutId = setTimeout(() => {
605
+ c = null;
606
+ }, Re)) : (p(), f(d()), a.value = [], c = {
607
+ blockId: e,
608
+ timeoutId: setTimeout(() => {
609
+ c = null;
610
+ }, Re)
611
+ });
612
+ }
613
+ function g() {
614
+ o.value = !0, s && clearTimeout(s), s = setTimeout(() => {
615
+ o.value = !1, s = null;
616
+ }, ze);
617
+ }
618
+ function _() {
619
+ if (i.value.length === 0) return;
620
+ p();
621
+ let e = i.value.pop();
622
+ a.value.push(d()), n(e, !0), g();
623
+ }
624
+ function v() {
625
+ if (a.value.length === 0) return;
626
+ p();
627
+ let e = a.value.pop();
628
+ i.value.push(d()), n(e, !0), g();
629
+ }
630
+ function y() {
631
+ i.value = [], a.value = [], p();
632
+ }
633
+ function x() {
634
+ y(), s &&= (clearTimeout(s), null);
635
+ }
636
+ return {
637
+ canUndo: l,
638
+ canRedo: u,
639
+ isNavigating: o,
640
+ undo: _,
641
+ redo: v,
642
+ record: m,
643
+ recordDebounced: h,
644
+ clear: y,
645
+ destroy: x,
646
+ flushDebounce: p
647
+ };
648
+ }
649
+ // ../core/src/block-actions.ts
650
+ function Ve(e) {
651
+ let { addBlock: t, removeBlock: n, updateBlock: r, selectBlock: i, findBlockLocation: a } = e;
652
+ function o(n, r, a) {
653
+ let o = typeof e.blockDefaults == "function" ? e.blockDefaults() : e.blockDefaults, s = P(n, o);
654
+ return t(s, r, a), i(s.id), s;
655
+ }
656
+ function s(e, n, r) {
657
+ let o = ne(e);
658
+ if (!X(t, "duplicateBlock", [
659
+ e,
660
+ n,
661
+ r
662
+ ])) return o;
663
+ if (n !== void 0 || r !== void 0) t(o, n, r);
664
+ else {
665
+ let i = a?.(e.id) ?? null;
666
+ i ? t(o, i.targetSectionId, i.columnIndex, i.index + 1) : t(o, n, r);
667
+ }
668
+ return i(o.id), o;
669
+ }
670
+ function c(e) {
671
+ n(e);
672
+ }
673
+ function l(e, t, n) {
674
+ r(e, { [t]: n });
675
+ }
676
+ return {
677
+ createAndAddBlock: o,
678
+ duplicateBlock: s,
679
+ deleteBlock: c,
680
+ updateBlockProperty: l
681
+ };
682
+ }
683
+ // ../core/src/auto-save.ts
684
+ var He = 2e3;
685
+ function Ue(e) {
686
+ let { content: t, isDirty: n, onChange: r, debounce: i = He, enabled: a = !0 } = e, o = null, s = !1;
687
+ function c() {
688
+ return typeof a == "function" ? a() : a;
689
+ }
690
+ function l() {
691
+ s = !0, d();
692
+ }
693
+ function u() {
694
+ s = !1;
695
+ }
696
+ function d() {
697
+ o &&= (clearTimeout(o), null);
698
+ }
699
+ function f() {
700
+ d(), n() && r(JSON.parse(JSON.stringify(t.value)));
701
+ }
702
+ function p() {
703
+ c() && !s && (d(), o = setTimeout(() => {
704
+ o = null, c() && !s && n() && r(JSON.parse(JSON.stringify(t.value)));
705
+ }, i));
706
+ }
707
+ let m = h(t, () => {
708
+ p();
709
+ }, { deep: !0 });
710
+ function g() {
711
+ m(), d();
712
+ }
713
+ return {
714
+ flush: f,
715
+ cancel: d,
716
+ pause: l,
717
+ resume: u,
718
+ destroy: g
719
+ };
720
+ }
721
+ // ../core/src/condition-preview.ts
722
+ function We(t) {
723
+ let n = e(/* @__PURE__ */ new Set()), r = b(() => n.size > 0);
724
+ function i(e) {
725
+ return n.has(e);
726
+ }
727
+ function a(e) {
728
+ n.has(e) ? n.delete(e) : (n.add(e), t.state.selectedBlockId === e && t.selectBlock(null));
729
+ }
730
+ function o() {
731
+ n.clear();
732
+ }
733
+ return {
734
+ isHidden: i,
735
+ toggleBlock: a,
736
+ reset: o,
737
+ hasHiddenBlocks: r
738
+ };
739
+ }
740
+ // ../core/src/data-source-fetch.ts
741
+ function Ge(e) {
742
+ let t = S(!1), n = S(!1), r = b(() => !!e.definition.value?.dataSource), i = b(() => r.value && !e.block.value.dataSourceFetched);
743
+ async function a() {
744
+ let r = e.definition.value;
745
+ if (r?.dataSource) {
746
+ t.value = !0, n.value = !1;
747
+ try {
748
+ let t = await r.dataSource.onFetch({
749
+ fieldValues: { ...e.block.value.fieldValues },
750
+ blockId: e.block.value.id
751
+ });
752
+ if (t == null) return;
753
+ let n = { ...e.block.value.fieldValues };
754
+ for (let e of Object.keys(n)) e in t && (n[e] = t[e]);
755
+ e.onUpdate(n, !0);
756
+ } catch (e) {
757
+ console.warn("[Templatical] Data source fetch error:", e), n.value = !0;
758
+ } finally {
759
+ t.value = !1;
760
+ }
761
+ }
762
+ }
763
+ return {
764
+ isFetching: t,
765
+ fetchError: n,
766
+ fetch: a,
767
+ hasDataSource: r,
768
+ needsFetch: i
769
+ };
770
+ }
771
+ // ../core/src/history-interceptor.ts
772
+ function Ke(e, t) {
773
+ e.activeLocale && h(e.activeLocale, () => t.flushDebounce?.());
774
+ for (let n of [
775
+ "addLocale",
776
+ "removeLocale",
777
+ "setBlockHidden",
778
+ "resetLocaleFields",
779
+ "keepTranslations"
780
+ ]) {
781
+ let r = e[n];
782
+ r && (Object.assign(e, { [n]: (...i) => {
783
+ X(e, n, i) && (["addLocale", "removeLocale"].includes(n) || !e.isBlockLocked(i[0])) && (t.record(), r(...i));
784
+ } }), Pe(r, e[n]));
785
+ }
786
+ let n = e.addBlock, r = e.removeBlock, i = e.moveBlock, a = e.updateBlock, o = e.updateSettings;
787
+ e.addBlock = (r, i, a, o) => {
788
+ X(e, "addBlock", [
789
+ r,
790
+ i,
791
+ a,
792
+ o
793
+ ]) && (t.record(), n(r, i, a, o));
794
+ }, e.removeBlock = (n) => {
795
+ X(e, "removeBlock", [n]) && (t.record(), r(n));
796
+ }, e.moveBlock = (n, r, a, o) => {
797
+ X(e, "moveBlock", [
798
+ n,
799
+ r,
800
+ a,
801
+ o
802
+ ]) && (t.record(), i(n, r, a, o));
803
+ }, Pe(n, e.addBlock), Pe(r, e.removeBlock), Pe(i, e.moveBlock), e.updateBlock = (n, r) => {
804
+ X(e, "updateBlock", [n, r]) && (e.isBlockLocked(n) || (t.recordDebounced(n), a(n, r)));
805
+ }, e.updateSettings = (n) => {
806
+ X(e, "updateSettings", [n]) && (t.record(), o(n));
807
+ }, Pe(a, e.updateBlock), Pe(o, e.updateSettings);
808
+ }
809
+ // ../core/src/diff-content.ts
810
+ var qe = "root", Je = /* @__PURE__ */ new Set([
811
+ "id",
812
+ "type",
813
+ "children",
814
+ "l10n"
815
+ ]), Ye = /* @__PURE__ */ new Set([
816
+ "id",
817
+ "type",
818
+ "children",
819
+ "columns",
820
+ "l10n"
821
+ ]), Xe = /* @__PURE__ */ new Set(), Ze = /* @__PURE__ */ new Set(["locales", "l10n"]);
822
+ function Qe(e) {
823
+ return e === null ? qe : JSON.stringify([e.sectionId, e.column]);
824
+ }
825
+ function Q(e) {
826
+ let t = e.children;
827
+ return e.type === "section" && Array.isArray(t) ? t : [];
828
+ }
829
+ function $e(e) {
830
+ let t = /* @__PURE__ */ new Map(), n = (e, r) => {
831
+ e.forEach((e, i) => {
832
+ t.has(e.id) || t.set(e.id, {
833
+ block: e,
834
+ key: Qe(r),
835
+ index: i
836
+ }), Q(e).forEach((t, r) => {
837
+ Array.isArray(t) && n(t, {
838
+ sectionId: e.id,
839
+ column: r
840
+ });
841
+ });
842
+ });
843
+ };
844
+ return n(e, null), t;
845
+ }
846
+ function et(e) {
847
+ let t = [], n = Array(e.length).fill(-1);
848
+ e.forEach((r, i) => {
849
+ let a = 0, o = t.length;
850
+ for (; a < o;) {
851
+ let n = a + o >> 1;
852
+ e[t[n]] < r ? a = n + 1 : o = n;
853
+ }
854
+ a > 0 && (n[i] = t[a - 1]), t[a] = i;
855
+ });
856
+ let r = /* @__PURE__ */ new Set(), i = t.length > 0 ? t[t.length - 1] : -1;
857
+ for (; i !== -1;) r.add(i), i = n[i];
858
+ return r;
859
+ }
860
+ function tt(e, t, n) {
861
+ let r = {}, i = [];
862
+ for (let i of Object.keys(t)) n.has(i) || t[i] === void 0 || I(e[i], t[i]) || (r[i] = T(t[i]));
863
+ for (let r of Object.keys(e)) n.has(r) || e[r] === void 0 || t[r] === void 0 && i.push(r);
864
+ return {
865
+ set: r,
866
+ unset: i
867
+ };
868
+ }
869
+ function nt(e = {}, t = {}) {
870
+ let n = tt(e.text ?? {}, t.text ?? {}, Xe), r = tt(e.set ?? {}, t.set ?? {}, Xe), i = [.../* @__PURE__ */ new Set([...n.unset, ...r.unset])];
871
+ return {
872
+ ...Object.keys(n.set).length > 0 ? { text: n.set } : {},
873
+ ...Object.keys(r.set).length > 0 ? { set: r.set } : {},
874
+ ...i.length > 0 ? { unset: i } : {},
875
+ ...e.hidden === t.hidden ? {} : { hidden: t.hidden === !0 }
876
+ };
877
+ }
878
+ function rt(e, t) {
879
+ if (e.settings.locale !== t.settings.locale && (e.settings.locales?.length || t.settings.locales?.length)) return [{
880
+ op: "setContent",
881
+ content: T(t)
882
+ }];
883
+ let n = $e(e.blocks), r = $e(t.blocks), i = [], a = (e) => {
884
+ let t = r.get(e), i = n.get(e);
885
+ return t !== void 0 && i !== void 0 && t.block.type !== i.block.type;
886
+ }, o = (e) => r.has(e.id) && !a(e.id), s = (e) => Q(e).some((e) => Array.isArray(e) && e.some((e) => o(e) || !a(e.id) && s(e))), c = /* @__PURE__ */ new Set(), l = [], u = (e, t) => {
887
+ let n = "kept";
888
+ t === "dropped" ? (c.add(e.id), n = "dropped") : a(e.id) ? (i.push({
889
+ op: "deleteBlock",
890
+ blockId: e.id
891
+ }), c.add(e.id), n = "dropped") : r.has(e.id) || (t === "deferred" ? n = "deferred" : s(e) ? (l.push(e.id), n = "deferred") : (i.push({
892
+ op: "deleteBlock",
893
+ blockId: e.id
894
+ }), c.add(e.id), n = "dropped"));
895
+ for (let t of Q(e)) if (Array.isArray(t)) for (let e of t) u(e, n);
896
+ };
897
+ for (let t of e.blocks) u(t, "kept");
898
+ let d = (e) => n.has(e) && !c.has(e), f = (e) => {
899
+ let t = T(e);
900
+ return t.type === "section" && (t.children = Q(e).map((e) => Array.isArray(e) ? e.filter((e) => !d(e.id)).map((e) => T(e)) : e)), t;
901
+ }, p = (e, t, r) => {
902
+ let a = Qe(e), o = [], s = [];
903
+ t.forEach((e, t) => {
904
+ let r = n.get(e.id);
905
+ d(e.id) && r !== void 0 && r.key === a && (o.push(r.index), s.push(t));
906
+ });
907
+ let c = new Set([...et(o)].map((e) => s[e]));
908
+ t.forEach((n, a) => {
909
+ if (c.has(a) || r(n)) return;
910
+ let o = a > 0 ? t[a - 1].id : null;
911
+ i.push(d(n.id) ? {
912
+ op: "moveBlock",
913
+ blockId: n.id,
914
+ parent: e,
915
+ after: o
916
+ } : {
917
+ op: "addBlock",
918
+ block: f(n),
919
+ parent: e,
920
+ after: o
921
+ });
922
+ });
923
+ };
924
+ p(null, t.blocks, () => !1);
925
+ let m = t.blocks.filter((e) => e.type === "section"), h = /* @__PURE__ */ new Set(), g = (e) => {
926
+ for (let t of m) {
927
+ if (!d(t.id)) continue;
928
+ let r = Q(n.get(t.id).block).length, a = Q(t).length;
929
+ (e ? a > r : a < r) && (i.push({
930
+ op: "updateBlock",
931
+ blockId: t.id,
932
+ set: { columns: t.columns }
933
+ }), h.add(t.id));
934
+ }
935
+ };
936
+ g(!0);
937
+ for (let e of m) {
938
+ let t = !d(e.id);
939
+ Q(e).forEach((n, r) => {
940
+ Array.isArray(n) && p({
941
+ sectionId: e.id,
942
+ column: r
943
+ }, n, (e) => t && !d(e.id));
944
+ });
945
+ }
946
+ g(!1);
947
+ for (let e of l) i.push({
948
+ op: "deleteBlock",
949
+ blockId: e
950
+ });
951
+ for (let [e, t] of r) {
952
+ if (!d(e)) continue;
953
+ let { set: r, unset: a } = tt(n.get(e).block, t.block, h.has(e) ? Ye : Je);
954
+ (Object.keys(r).length !== 0 || a.length !== 0) && i.push({
955
+ op: "updateBlock",
956
+ blockId: e,
957
+ ...Object.keys(r).length > 0 ? { set: r } : {},
958
+ ...a.length > 0 ? { unset: a } : {}
959
+ });
960
+ }
961
+ let _ = tt(e.settings, t.settings, Ze);
962
+ (Object.keys(_.set).length > 0 || _.unset.length > 0) && i.push({
963
+ op: "updateSettings",
964
+ ...Object.keys(_.set).length > 0 ? { set: _.set } : {},
965
+ ..._.unset.length > 0 ? { unset: _.unset } : {}
966
+ });
967
+ let v = new Set(e.settings.locales ?? []), y = new Set(t.settings.locales ?? []);
968
+ for (let e of y) v.has(e) || i.push({
969
+ op: "addLocale",
970
+ locale: e
971
+ });
972
+ for (let [e, t] of r) {
973
+ if (!d(e)) continue;
974
+ let r = n.get(e).block.l10n ?? {}, a = t.block.l10n ?? {};
975
+ for (let t of /* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(a)])) {
976
+ if (!y.has(t)) continue;
977
+ let n = nt(r[t], a[t]);
978
+ Object.keys(n).length > 0 && i.push({
979
+ op: "updateBlockLocale",
980
+ blockId: e,
981
+ locale: t,
982
+ ...n
983
+ });
984
+ }
985
+ }
986
+ let b = e.settings.l10n ?? {}, x = t.settings.l10n ?? {};
987
+ for (let e of /* @__PURE__ */ new Set([...Object.keys(b), ...Object.keys(x)])) {
988
+ if (!y.has(e)) continue;
989
+ let t = nt(b[e], x[e]);
990
+ Object.keys(t).length > 0 && i.push({
991
+ op: "updateSettingsLocale",
992
+ locale: e,
993
+ ...t
994
+ });
995
+ }
996
+ for (let e of v) y.has(e) || i.push({
997
+ op: "removeLocale",
998
+ locale: e
999
+ });
1000
+ return i;
1001
+ }
1002
+ // ../core/src/localized-operations.ts
1003
+ function $(e) {
1004
+ let t = /* @__PURE__ */ new Map(), n = (e) => {
1005
+ t.set(e.id, e), e.type === "section" && e.children.flat().forEach(n);
1006
+ };
1007
+ return e.forEach(n), t;
1008
+ }
1009
+ function it(e, t) {
1010
+ if (t === null) return e.blocks;
1011
+ let n = $(e.blocks).get(t.sectionId);
1012
+ return n.type === "section" ? n.children[t.column] : [];
1013
+ }
1014
+ function at(e, t) {
1015
+ let n = (e, r) => {
1016
+ let i = e.findIndex((e) => e.id === t);
1017
+ if (i >= 0) return {
1018
+ parent: r,
1019
+ after: e[i - 1]?.id ?? null
1020
+ };
1021
+ for (let t of e) if (t.type === "section") for (let [e, r] of t.children.entries()) {
1022
+ let i = n(r, {
1023
+ sectionId: t.id,
1024
+ column: e
1025
+ });
1026
+ if (i) return i;
1027
+ }
1028
+ };
1029
+ return n(e.blocks, null);
1030
+ }
1031
+ function ot(e, t, n, r, i) {
1032
+ if (r !== null) return r;
1033
+ let a = it(t, n).find((e) => e.id !== i), o = it(e, n).filter((e) => e.id !== i);
1034
+ return o[(a ? o.findIndex((e) => e.id === a.id) : o.length) - 1]?.id ?? null;
1035
+ }
1036
+ function st(e, t, n) {
1037
+ Object.keys(n).length ? (e.l10n ??= {})[t] = n : e.l10n && (delete e.l10n[t], Object.keys(e.l10n).length || delete e.l10n);
1038
+ }
1039
+ function ct(e) {
1040
+ let t = T(e);
1041
+ return delete t.l10n, t.type === "section" && (t.children = t.children.map((e) => e.map(ct))), t;
1042
+ }
1043
+ function lt(e, t, n, r) {
1044
+ let i = j(e, t), a = T(e), o = T(i.settings), s = !1, c = /* @__PURE__ */ new Map(), l = (n, r) => {
1045
+ for (let [i, a] of $(n)) c.set(i, {
1046
+ initial: oe(a, t, N(e)),
1047
+ added: r,
1048
+ changed: !1
1049
+ });
1050
+ };
1051
+ l(i.blocks, !1);
1052
+ let u = [], d = (e, t, n) => {
1053
+ if (t.some((e) => e?.op === "setDefaultLocale")) throw new D("invalid_operation", n, "Changing the default language isn't possible in a language view; switch to the default language.");
1054
+ if (t.some((e) => e?.op === "setContent")) throw new D("invalid_operation", n, "Replacing the whole template isn't possible in a language view; switch to the default language.");
1055
+ try {
1056
+ return H(e, t);
1057
+ } catch (e) {
1058
+ throw e instanceof D ? new D(e.code, n, e.message, e.blockId) : e;
1059
+ }
1060
+ }, f = (e, t) => {
1061
+ a = d(a, e, t), u.push(...e);
1062
+ }, p = (e, n) => {
1063
+ let o = c.get(e);
1064
+ if (!o?.changed) return;
1065
+ let s = $(a.blocks).get(e), l = $(i.blocks).get(e), u = T(a), d = it(u, at(u, e).parent), p = T(s);
1066
+ if (o.added) p = ct(l), p.type === "section" && s.type === "section" && (p.children = s.children, p.columns = s.columns);
1067
+ else {
1068
+ Oe(p, p.type === "section" ? {
1069
+ ...l,
1070
+ children: p.children,
1071
+ columns: p.columns
1072
+ } : l, (e) => $(a.blocks).get(e) ?? null), p = ee(p);
1073
+ let e = p.l10n?.[t];
1074
+ st(p, t, Ae(e, De(p, o.initial, e, r), De(p, l, e, r), p, l));
1075
+ }
1076
+ d[d.findIndex((t) => t.id === e)] = p, f(rt(a, u), n), o.changed = !1;
1077
+ }, m = (e, t, n) => {
1078
+ let r = $(a.blocks).get(e.blockId), i = $(t.blocks).get(e.blockId);
1079
+ if (r.type !== "section" || i.type !== "section" || r.columns === i.columns) return;
1080
+ let o = i.children.length, s = r.children.slice(0, o), c = r.children.slice(o).flat(), l = [...s[o - 1] ?? [], ...c];
1081
+ for (let [e, t] of c.entries()) f([{
1082
+ op: "moveBlock",
1083
+ blockId: t.id,
1084
+ parent: {
1085
+ sectionId: r.id,
1086
+ column: o - 1
1087
+ },
1088
+ after: l[l.length - c.length + e - 1]?.id ?? null
1089
+ }], n);
1090
+ let u = $(a.blocks).get(e.blockId);
1091
+ f([{
1092
+ op: "updateBlock",
1093
+ blockId: e.blockId,
1094
+ set: { columns: i.columns },
1095
+ ...e.expect ? { expect: Object.fromEntries(Object.keys(e.expect).map((e) => [e, W(u, e) ?? null])) } : {}
1096
+ }], n);
1097
+ };
1098
+ n.forEach((e, t) => {
1099
+ e?.op === "updateSettings" && (Object.hasOwn(e.set ?? {}, "locale") || Array.isArray(e.unset) && e.unset.includes("locale")) && d(a, [e], t);
1100
+ let n = d(i, [e], t);
1101
+ switch (e.op) {
1102
+ case "addBlock": {
1103
+ let n = ct(e.block);
1104
+ f([{
1105
+ ...e,
1106
+ block: n,
1107
+ after: ot(a, i, e.parent, e.after)
1108
+ }], t), l([n], !0);
1109
+ break;
1110
+ }
1111
+ case "moveBlock":
1112
+ f([{
1113
+ ...e,
1114
+ after: ot(a, i, e.parent, e.after, e.blockId),
1115
+ ...e.expect ? { expect: at(a, e.blockId) } : {}
1116
+ }], t);
1117
+ break;
1118
+ case "deleteBlock": {
1119
+ let n = [...$([$(a.blocks).get(e.blockId)]).keys()];
1120
+ for (let e of n) p(e, t);
1121
+ f([{
1122
+ op: "deleteBlock",
1123
+ blockId: e.blockId
1124
+ }], t);
1125
+ for (let e of n) c.delete(e);
1126
+ break;
1127
+ }
1128
+ case "updateBlock":
1129
+ m(e, n, t), c.get(e.blockId).changed = !0;
1130
+ break;
1131
+ case "updateSettings":
1132
+ s = !0;
1133
+ break;
1134
+ default: f([e], t);
1135
+ }
1136
+ i = n;
1137
+ });
1138
+ for (let e of c.keys()) p(e, n.length - 1);
1139
+ if (s) {
1140
+ let e = T(a), r = e.settings.l10n?.[t];
1141
+ st(e.settings, t, Ae(r, ke(e.settings, o, r), ke(e.settings, i.settings, r), e.settings, i.settings)), f(rt(a, e), n.length - 1);
1142
+ }
1143
+ return u;
1144
+ }
1145
+ var ut = 1e3, dt = 1e4, ft = [
1146
+ 1e3,
1147
+ 2e3,
1148
+ 5e3,
1149
+ 1e4,
1150
+ 3e4
1151
+ ], pt = 50, mt = 100, ht = /* @__PURE__ */ new Set([
1152
+ "block_exists",
1153
+ "block_missing",
1154
+ "anchor_missing",
1155
+ "precondition_failed",
1156
+ "lock_held",
1157
+ "locked_by_others",
1158
+ "invalid_operation",
1159
+ "lock_lost",
1160
+ "content_too_large"
1161
+ ]);
1162
+ function gt(e, t) {
1163
+ return e.ops.some((e) => e.op === "setContent") ? e.view = t : delete e.view, e;
1164
+ }
1165
+ function _t(e) {
1166
+ let t = e?.code;
1167
+ return typeof t == "string" && ht.has(t) ? t : null;
1168
+ }
1169
+ function vt(e) {
1170
+ let t = e?.holder;
1171
+ return typeof t == "object" && t && typeof t.sessionId == "string" ? t : void 0;
1172
+ }
1173
+ function yt(e) {
1174
+ let t = e?.statusCode;
1175
+ return typeof t != "number" || t >= 500 || t === 408 || t === 429;
1176
+ }
1177
+ function bt(e, t) {
1178
+ return e.some((e) => {
1179
+ if (e.id === t) return !0;
1180
+ let n = e.children;
1181
+ return e.type === "section" && Array.isArray(n) && n.some((e) => Array.isArray(e) && bt(e, t));
1182
+ });
1183
+ }
1184
+ function xt(e) {
1185
+ if (e.length === 1 && e[0].op === "updateSettings") return !0;
1186
+ let t = e[0];
1187
+ return t.op === "updateBlock" && e.every((e) => e.op === "updateBlock" && e.blockId === t.blockId) || t.op === "updateBlockLocale" && e.every((e) => e.op === "updateBlockLocale" && e.blockId === t.blockId && e.locale === t.locale);
1188
+ }
1189
+ function St(e) {
1190
+ return e.map((e) => {
1191
+ if (!("expect" in e)) return e;
1192
+ let { expect: t, ...n } = e;
1193
+ return n;
1194
+ });
1195
+ }
1196
+ function Ct(e) {
1197
+ let { provider: t } = e, n = e.sessionId ?? crypto.randomUUID(), r = e.maxUndo ?? pt, i = typeof t.acquireLock == "function" && typeof t.renewLock == "function" && typeof t.releaseLock == "function", a = x([]), s = x(/* @__PURE__ */ new Map()), l = /* @__PURE__ */ new WeakSet(), u = /* @__PURE__ */ new WeakMap(), d = 0, f = S(null), p = S(null), m = S(0), g = S(0), _ = null, v = null, y = !1, C = !1, w = !1, E = !1, O = null, k = 0, A = !1, ee = [], j = null, M = null, N = Promise.resolve(), ne = null, re = b(() => (v?.undo.length ?? 0) > 0), ie = b(() => (v?.redo.length ?? 0) > 0);
1198
+ function P(t) {
1199
+ e.onError?.(t instanceof Error ? t : Error(String(t)));
1200
+ }
1201
+ function F(t, n = v) {
1202
+ n !== v || A || e.onNotice?.(t);
1203
+ }
1204
+ function ae() {
1205
+ return {
1206
+ locks: [...s.value.values()].map((e) => ({
1207
+ blockId: e.blockId,
1208
+ sessionId: e.holder.sessionId,
1209
+ locale: e.locale
1210
+ })),
1211
+ session: n
1212
+ };
1213
+ }
1214
+ function L() {
1215
+ g.value++;
1216
+ }
1217
+ function oe(e, t) {
1218
+ e.push(t), e.length > r && e.splice(0, e.length - r);
1219
+ }
1220
+ function R(e) {
1221
+ if (!_ || y) return;
1222
+ C = !0;
1223
+ try {
1224
+ let t = _.content.value, n = rt(t, e);
1225
+ if (n.length > 0) try {
1226
+ te(t, n);
1227
+ } catch {
1228
+ _.setContent(T(e), !1);
1229
+ }
1230
+ I(_.content.value, e) || _.setContent(T(e), !1);
1231
+ } finally {
1232
+ C = !1;
1233
+ }
1234
+ let t = _.state.selectedBlockId;
1235
+ t && !bt(e.blocks, t) && _.selectBlock(null);
1236
+ }
1237
+ function se() {
1238
+ C || E || (E = !0, queueMicrotask(() => {
1239
+ E = !1, B(!1);
1240
+ }));
1241
+ }
1242
+ function z() {
1243
+ O &&= (clearTimeout(O), null);
1244
+ }
1245
+ function B(e, t = !1) {
1246
+ let n = v;
1247
+ if (!_ || !n || y || C || _.state.isLoading && !t || _.state.template?.id !== n.templateId) return;
1248
+ let r = rt(n.view, _.content.value);
1249
+ if (r.length === 0) z();
1250
+ else {
1251
+ if (!e && xt(r)) {
1252
+ let e = Date.now();
1253
+ if (O === null && (k = e), e - k < 1e3) {
1254
+ O && clearTimeout(O), O = setTimeout(() => {
1255
+ O = null, B(!0);
1256
+ }, 300);
1257
+ return;
1258
+ }
1259
+ }
1260
+ z(), ce(n, r);
1261
+ }
1262
+ }
1263
+ function V() {
1264
+ B(!0);
1265
+ }
1266
+ function ce(e, t) {
1267
+ let n = t, r;
1268
+ try {
1269
+ r = H(e.view, n, ae());
1270
+ } catch (n) {
1271
+ if (!(n instanceof D)) throw n;
1272
+ R(e.view);
1273
+ let r = n.blockId === void 0 ? void 0 : je(n.blockId).find((e) => {
1274
+ let r = t[n.opIndex];
1275
+ return r.op !== "updateBlockLocale" || e.locale == null || e.locale === r.locale;
1276
+ })?.holder;
1277
+ F({
1278
+ type: "editRefused",
1279
+ code: n.code,
1280
+ ...r ? { holder: r } : {}
1281
+ }), n.code === "invalid_operation" && P(n);
1282
+ return;
1283
+ }
1284
+ let i = _.content.value;
1285
+ if (!I(r, i)) {
1286
+ P(/* @__PURE__ */ Error("[Templatical] Collaboration: a change couldn't be expressed as block operations, so the whole content was sent.")), n = [{
1287
+ op: "setContent",
1288
+ content: T(i)
1289
+ }];
1290
+ try {
1291
+ r = H(e.view, n, ae());
1292
+ } catch (t) {
1293
+ if (!(t instanceof D)) throw t;
1294
+ R(e.view), F({
1295
+ type: "editRefused",
1296
+ code: t.code
1297
+ });
1298
+ return;
1299
+ }
1300
+ }
1301
+ let a = gt({ ops: fe(e.view, n) }, r);
1302
+ oe(e.undo, a), e.redo = [], L();
1303
+ let o = e.view;
1304
+ e.view = r, le(e, n, "edit", a, o);
1305
+ }
1306
+ function le(e, t, n, r, i) {
1307
+ let a = { dropped: !1 }, o = 0, s = i;
1308
+ do {
1309
+ let i = t.slice(o, o + mt);
1310
+ if (e.pending.push({
1311
+ batchId: crypto.randomUUID(),
1312
+ ops: i,
1313
+ origin: n,
1314
+ entry: r,
1315
+ group: a,
1316
+ sent: !1,
1317
+ revision: null,
1318
+ ...s && i.some((e) => e.op === "setContent") ? { base: s } : {}
1319
+ }), o += mt, s && t.slice(o).some((e) => e.op === "setContent")) try {
1320
+ s = H(s, i);
1321
+ } catch {
1322
+ s = null;
1323
+ }
1324
+ } while (o < t.length);
1325
+ ue(e);
1326
+ }
1327
+ function ue(e) {
1328
+ if (e.inFlight || w) return;
1329
+ let t = e.pending.find((e) => !e.sent);
1330
+ t ? (t.sent = !0, e.inFlight = t, de(e, t, 0)) : ge(e);
1331
+ }
1332
+ function de(e, n, r) {
1333
+ t.submit(e.templateId, {
1334
+ batchId: n.batchId,
1335
+ baseRevision: n.baseRevision ??= e.revision,
1336
+ ops: n.ops,
1337
+ ...n.origin === "ai" ? { origin: "ai" } : {}
1338
+ }).then(({ revision: t }) => {
1339
+ e.inFlight = null, pe(e, n, t), ue(e);
1340
+ }, (t) => {
1341
+ if (_t(t) !== null) e.inFlight = null, he(e, n, t), ue(e);
1342
+ else if (yt(t)) {
1343
+ G(e, t);
1344
+ let i = ft[Math.min(r, ft.length - 1)];
1345
+ setTimeout(() => {
1346
+ A || de(e, n, r + 1);
1347
+ }, i);
1348
+ } else e.inFlight = null, P(t), he(e, n, t), ue(e);
1349
+ });
1350
+ }
1351
+ function pe(e, t, n) {
1352
+ t.revision === null && (t.revision = n, n <= e.revision ? (U(e, t), be(e)) : (e.own.set(n, t), ye(e)));
1353
+ }
1354
+ function U(e, t) {
1355
+ e.pending = e.pending.filter((e) => e !== t), ge(e);
1356
+ }
1357
+ function W(e, t) {
1358
+ if (t.entry) {
1359
+ for (let n of [e.undo, e.redo]) {
1360
+ let e = n.indexOf(t.entry);
1361
+ e !== -1 && n.splice(e, 1);
1362
+ }
1363
+ L();
1364
+ }
1365
+ }
1366
+ function me(e, t) {
1367
+ let n = !t.group.dropped;
1368
+ return t.group.dropped = !0, e.pending = e.pending.filter((e) => e.group !== t.group || e.sent), n && W(e, t), ge(e), n;
1369
+ }
1370
+ function he(e, t, n) {
1371
+ if (U(e, t), me(e, t)) {
1372
+ let r = _t(n) ?? "invalid_operation";
1373
+ if (t.origin === "edit" || t.origin === "ai") {
1374
+ let t = vt(n);
1375
+ F({
1376
+ type: "editRefused",
1377
+ code: r,
1378
+ ...t ? { holder: t } : {}
1379
+ }, e);
1380
+ } else F({
1381
+ type: "undoSkipped",
1382
+ code: r
1383
+ }, e);
1384
+ }
1385
+ be(e), e === v && K();
1386
+ }
1387
+ function ge(e) {
1388
+ if (!(e.pending.length > 0 || e.waiters.length === 0)) for (let t of e.waiters.splice(0)) t.resolve();
1389
+ }
1390
+ function G(e, t) {
1391
+ let n = t instanceof Error ? t : Error(String(t));
1392
+ for (let t of e.waiters.splice(0)) t.reject(n);
1393
+ }
1394
+ function _e(e, t) {
1395
+ if (t.revision <= e.revision) return;
1396
+ let n = e.pending.find((e) => e.batchId === t.batchId);
1397
+ n ? pe(e, n, t.revision) : (e.remote.set(t.revision, t), ye(e));
1398
+ }
1399
+ function ve(t, n) {
1400
+ let r = n.ops;
1401
+ if (e.normalizeRemoteOperations) try {
1402
+ r = e.normalizeRemoteOperations(n.ops, t.confirmed);
1403
+ } catch (e) {
1404
+ P(e);
1405
+ }
1406
+ return St(r);
1407
+ }
1408
+ function ye(t) {
1409
+ let n = [], r = !1;
1410
+ for (;;) {
1411
+ let e = t.revision + 1, i = t.remote.get(e), a = t.own.get(e);
1412
+ if (!i && !a) break;
1413
+ try {
1414
+ t.confirmed = H(t.confirmed, i ? ve(t, i) : a.ops);
1415
+ } catch {
1416
+ if (t.recovering) {
1417
+ t.remote.clear(), t.own.clear(), P(/* @__PURE__ */ Error("[Templatical] Collaboration: this editor can't follow the template's changes. Reload the page."));
1418
+ return;
1419
+ }
1420
+ q(t);
1421
+ return;
1422
+ }
1423
+ t.revision = e, i ? (t.remote.delete(e), n.push(i)) : (t.own.delete(e), a.group.dropped && (r = !0), U(t, a));
1424
+ }
1425
+ if (t === v && (m.value = t.revision), t.remote.size > 0 || t.own.size > 0 ? Se(t) : Ce(t), (n.length !== 0 || r) && (be(t), t === v)) for (let t of n) try {
1426
+ e.onRemoteChange?.({
1427
+ actor: t.actor,
1428
+ ops: t.ops,
1429
+ locale: t.ops.find((e) => e.op !== "setDefaultLocale" && "locale" in e)?.locale ?? null
1430
+ });
1431
+ } catch (e) {
1432
+ P(e);
1433
+ }
1434
+ }
1435
+ function be(e) {
1436
+ let t = !w;
1437
+ w = !0;
1438
+ try {
1439
+ xe(e);
1440
+ } finally {
1441
+ t && (w = !1);
1442
+ }
1443
+ t && ue(e);
1444
+ }
1445
+ function xe(e) {
1446
+ e === v && V();
1447
+ let t = e.confirmed;
1448
+ for (let n = 0; n < e.pending.length; n++) {
1449
+ let r = e.pending[n], i;
1450
+ if (r.base && !I(r.base, t)) i = "precondition_failed";
1451
+ else try {
1452
+ t = H(t, r.ops);
1453
+ continue;
1454
+ } catch (e) {
1455
+ i = e instanceof D ? e.code : "invalid_operation";
1456
+ }
1457
+ r.sent || (me(e, r) && F(r.origin === "edit" || r.origin === "ai" ? {
1458
+ type: "editRefused",
1459
+ code: i
1460
+ } : {
1461
+ type: "undoSkipped",
1462
+ code: i
1463
+ }, e), t = e.confirmed, n = -1);
1464
+ }
1465
+ e.view = t, ge(e), e === v && R(t);
1466
+ }
1467
+ function Se(e) {
1468
+ e.gapTimer ||= setTimeout(() => {
1469
+ e.gapTimer = null, e === v && K();
1470
+ }, ut);
1471
+ }
1472
+ function Ce(e) {
1473
+ e.gapTimer &&= (clearTimeout(e.gapTimer), null);
1474
+ }
1475
+ function K() {
1476
+ let e = v;
1477
+ return e ? (e.catchingUp ||= (async () => {
1478
+ try {
1479
+ let n = await t.operationsAfter(e.templateId, e.revision);
1480
+ if (e.retired) return;
1481
+ if ("resync" in n) {
1482
+ await q(e);
1483
+ return;
1484
+ }
1485
+ for (let t of n.batches) _e(e, t);
1486
+ } catch (e) {
1487
+ P(e);
1488
+ } finally {
1489
+ e.catchingUp = null;
1490
+ }
1491
+ })(), e.catchingUp) : Promise.resolve();
1492
+ }
1493
+ async function q(t) {
1494
+ t.recovering = !0;
1495
+ try {
1496
+ let n = await e.loadTemplate(t.templateId);
1497
+ if (t.retired) return;
1498
+ let r = n.revision ?? t.revision;
1499
+ t.confirmed = T(n.content), t.revision = r, t.remote = new Map([...t.remote].filter(([e]) => e > r));
1500
+ for (let [e, n] of [...t.own]) e <= r && (t.own.delete(e), U(t, n));
1501
+ t === v && (m.value = r), be(t), ye(t);
1502
+ } catch (e) {
1503
+ P(e);
1504
+ } finally {
1505
+ t.recovering = !1;
1506
+ }
1507
+ }
1508
+ function we(t) {
1509
+ let n = () => t === v && !t.retired;
1510
+ return {
1511
+ onBatch: (e) => {
1512
+ n() && _e(t, e);
1513
+ },
1514
+ onResync: (r, i) => {
1515
+ if (!(!n() || r <= t.revision)) {
1516
+ if (i) try {
1517
+ e.onRemoteResync?.({
1518
+ revision: r,
1519
+ actor: i
1520
+ });
1521
+ } catch (e) {
1522
+ P(e);
1523
+ }
1524
+ K();
1525
+ }
1526
+ },
1527
+ onLock: (e) => {
1528
+ n() && Y(e);
1529
+ },
1530
+ onUnlock: (e, t, r) => {
1531
+ n() && Ne(e, t, r);
1532
+ },
1533
+ onMembers: (e) => {
1534
+ n() && X(e);
1535
+ },
1536
+ onConnectionChange: (e) => {
1537
+ n() && De(t, e);
1538
+ }
1539
+ };
1540
+ }
1541
+ function Te(e, r) {
1542
+ let i = d;
1543
+ t.join(e.templateId, { sessionId: n }, we(e)).then((t) => {
1544
+ e.retired || e !== v ? r || t.leave() : (e.leave = t.leave, Pe(t.locks, !r, i), X(t.members), t.members.length > 0 && (p.value = "connected"), t.revision > e.revision && K(), r && Z());
1545
+ }, (e) => P(e));
1546
+ }
1547
+ function Ee(e) {
1548
+ let t = T(e.content), n = {
1549
+ templateId: e.id,
1550
+ confirmed: t,
1551
+ revision: e.revision ?? 0,
1552
+ pending: [],
1553
+ view: T(t),
1554
+ remote: /* @__PURE__ */ new Map(),
1555
+ own: /* @__PURE__ */ new Map(),
1556
+ inFlight: null,
1557
+ gapTimer: null,
1558
+ catchingUp: null,
1559
+ leave: null,
1560
+ retired: !1,
1561
+ recovering: !1,
1562
+ undo: [],
1563
+ redo: [],
1564
+ waiters: []
1565
+ };
1566
+ v = n, m.value = n.revision, L(), Te(n, !1), _?.state.selectedBlockId && Be(_.state.selectedBlockId), se();
1567
+ }
1568
+ function J(e) {
1569
+ e.retired = !0, Ce(e), e.leave?.(), e.leave = null, G(e, /* @__PURE__ */ Error("[Templatical] The template was closed."));
1570
+ }
1571
+ function De(e, t) {
1572
+ let n = p.value;
1573
+ p.value = t, t === "connected" && n !== null && n !== "connected" && Te(e, !0);
1574
+ }
1575
+ function Oe(e) {
1576
+ v && v.templateId === e?.id || (v &&= (z(), J(v), null), a.value = [], s.value = /* @__PURE__ */ new Map(), p.value = null, j = null, Z(), L(), e && Ee(e));
1577
+ }
1578
+ function ke(e, t) {
1579
+ return `${e}\u0000${t ?? ""}`;
1580
+ }
1581
+ function Ae(e, t, n) {
1582
+ return e.blockId === t && (n == null || e.locale == null || e.locale === n);
1583
+ }
1584
+ function je(e) {
1585
+ return [...s.value.values()].filter((t) => t.blockId === e);
1586
+ }
1587
+ function Me(e) {
1588
+ e !== f.value && (V(), f.value = e, Be(_?.state.selectedBlockId ?? null));
1589
+ }
1590
+ function Y(e, t = !1) {
1591
+ if (e.holder.sessionId === n) return;
1592
+ t ? l.add(e) : u.set(e, ++d);
1593
+ let r = new Map([...s.value].filter(([, t]) => t.holder.sessionId !== e.holder.sessionId));
1594
+ r.set(ke(e.blockId, e.locale), e), s.value = r, _?.state.selectedBlockId === e.blockId && (f.value === null || e.locale == null || e.locale === f.value) && (_.selectBlock(null), F({
1595
+ type: "selectionRefused",
1596
+ blockId: e.blockId,
1597
+ holder: e.holder
1598
+ }));
1599
+ }
1600
+ function Ne(e, t, n) {
1601
+ let r = ke(e, n), i = new Map([...s.value].filter(([n, i]) => i.holder.sessionId !== t || n !== r && !(i.blockId === e && l.has(i))));
1602
+ i.size !== s.value.size && (s.value = i);
1603
+ }
1604
+ function Pe(e, t, r) {
1605
+ let i = new Map([...s.value].filter(([, e]) => !l.has(e) && (t || (u.get(e) ?? 0) > r))), a = [...i.values()];
1606
+ for (let t of e) if (t.holder.sessionId !== n && !a.some((e) => e.holder.sessionId === t.holder.sessionId || Ae(e, t.blockId, t.locale))) {
1607
+ for (let [e, n] of i) n.holder.sessionId === t.holder.sessionId && i.delete(e);
1608
+ i.set(ke(t.blockId, t.locale), t);
1609
+ }
1610
+ s.value = i;
1611
+ }
1612
+ function X(e) {
1613
+ let t = new Set(e.map((e) => e.sessionId)), n = new Set(a.value.map((e) => e.sessionId).filter((e) => !t.has(e)));
1614
+ if (a.value = e, n.size === 0) return;
1615
+ let r = new Map([...s.value].filter(([, e]) => !n.has(e.holder.sessionId)));
1616
+ r.size !== s.value.size && (s.value = r);
1617
+ }
1618
+ function Fe(e) {
1619
+ N = N.then(e).catch(P);
1620
+ }
1621
+ function Z() {
1622
+ i && Fe(async () => {
1623
+ if (M && (j === null || M.templateId !== j.templateId || M.locale !== j.locale)) {
1624
+ let e = M;
1625
+ M = null, ze(), await t.releaseLock(e.templateId, e.blockId, e.locale);
1626
+ }
1627
+ let e = j;
1628
+ if (!(!e || M?.templateId === e.templateId && M.blockId === e.blockId && M.locale === e.locale)) try {
1629
+ let n = await t.acquireLock(e.templateId, e.blockId, e.locale);
1630
+ M = e, Re(), Ie(n.blockId, n.locale ?? null);
1631
+ } catch (n) {
1632
+ if (M?.templateId === e.templateId) {
1633
+ let e = M;
1634
+ M = null, ze(), await t.releaseLock(e.templateId, e.blockId, e.locale).catch(() => {});
1635
+ }
1636
+ if (j !== e) return;
1637
+ Le(e.blockId, n);
1638
+ }
1639
+ });
1640
+ }
1641
+ function Ie(e, t) {
1642
+ let n = new Map([...s.value].filter(([, n]) => !Ae(n, e, t)));
1643
+ n.size !== s.value.size && (s.value = n);
1644
+ }
1645
+ function Le(e, t) {
1646
+ let n = _t(t);
1647
+ if (n === "lock_held" || n === "block_missing") {
1648
+ j = null;
1649
+ let n = vt(t);
1650
+ n ? Y({
1651
+ blockId: e,
1652
+ holder: n,
1653
+ expiresAt: ""
1654
+ }, !0) : _?.state.selectedBlockId === e && _.selectBlock(null);
1655
+ } else P(t), setTimeout(() => {
1656
+ j?.blockId === e && Z();
1657
+ }, ft[0]);
1658
+ }
1659
+ function Re() {
1660
+ ne ||= setInterval(() => {
1661
+ Fe(async () => {
1662
+ let e = M;
1663
+ if (e) try {
1664
+ await t.renewLock(e.templateId, e.blockId, e.locale);
1665
+ } catch (e) {
1666
+ if (_t(e) === "lock_lost") {
1667
+ M = null, ze(), Z();
1668
+ return;
1669
+ }
1670
+ P(e);
1671
+ }
1672
+ });
1673
+ }, dt);
1674
+ }
1675
+ function ze() {
1676
+ ne &&= (clearInterval(ne), null);
1677
+ }
1678
+ function Be(e) {
1679
+ V(), v && (j = e ? {
1680
+ templateId: v.templateId,
1681
+ blockId: e,
1682
+ locale: f.value
1683
+ } : null, Z());
1684
+ }
1685
+ function Ve() {
1686
+ V(), M && i && (t.releaseLock(M.templateId, M.blockId, M.locale).catch(() => {}), M = null, ze()), v?.leave?.(), v && (v.leave = null);
1687
+ }
1688
+ function He(e) {
1689
+ let t = v;
1690
+ if (!t || y) return;
1691
+ V();
1692
+ let n = (e === "undo" ? t.undo : t.redo).pop();
1693
+ if (!n) return;
1694
+ if (L(), n.view && !I(n.view, t.view)) {
1695
+ F({
1696
+ type: "undoSkipped",
1697
+ code: "precondition_failed"
1698
+ });
1699
+ return;
1700
+ }
1701
+ let r;
1702
+ try {
1703
+ r = H(t.view, n.ops, ae());
1704
+ } catch (e) {
1705
+ if (!(e instanceof D)) throw e;
1706
+ F({
1707
+ type: "undoSkipped",
1708
+ code: e.code
1709
+ });
1710
+ return;
1711
+ }
1712
+ let i = gt({ ops: fe(t.view, n.ops) }, r);
1713
+ oe(e === "undo" ? t.redo : t.undo, i);
1714
+ let a = t.view;
1715
+ t.view = r, R(r), _?.markDirty(), le(t, n.ops, e, i, a);
1716
+ }
1717
+ function Ue(e, t) {
1718
+ let n = v;
1719
+ if (!_ || !n || y) return {
1720
+ applied: !1,
1721
+ error: new D("invalid_operation", 0, "No template is open for editing.")
1722
+ };
1723
+ if (t.origin === void 0) try {
1724
+ H(_.content.value, e, ae());
1725
+ } catch (e) {
1726
+ if (e instanceof D) return {
1727
+ applied: !1,
1728
+ error: e
1729
+ };
1730
+ throw e;
1731
+ }
1732
+ V();
1733
+ let r, i;
1734
+ try {
1735
+ r = H(n.view, e, ae()), i = fe(n.view, e);
1736
+ } catch (e) {
1737
+ if (e instanceof D) return {
1738
+ applied: !1,
1739
+ error: e
1740
+ };
1741
+ throw e;
1742
+ }
1743
+ let a = n.undo.at(-1), o;
1744
+ if (t.origin === "ai" && t.turn !== void 0 && a && a.turn === t.turn) {
1745
+ let e = a.view !== void 0 && !I(a.view, n.view);
1746
+ a.ops = [...i, ...a.ops], o = e ? a : gt(a, r);
1747
+ } else o = gt({
1748
+ ops: i,
1749
+ ...t.origin === "ai" && t.turn !== void 0 ? { turn: t.turn } : {}
1750
+ }, r), oe(n.undo, o);
1751
+ n.redo = [], L();
1752
+ let s = n.view;
1753
+ return n.view = r, R(r), _.markDirty(), le(n, e, t.origin ?? "edit", o, s), {
1754
+ applied: !0,
1755
+ inverse: i
1756
+ };
1757
+ }
1758
+ function We(e) {
1759
+ _ = e;
1760
+ let t = e;
1761
+ if (t.moveBlock && t.findBlockLocation) {
1762
+ let n = t.moveBlock, r = (...r) => {
1763
+ let i = v, a = i && !y && !C && !e.state.isLoading && e.state.template?.id === i.templateId;
1764
+ if (a && B(!0), n(...r), !a || I(i.view, e.content.value)) return;
1765
+ let o = t.findBlockLocation(r[0]);
1766
+ if (!o) return;
1767
+ let s = o.targetSectionId ? {
1768
+ sectionId: o.targetSectionId,
1769
+ column: o.columnIndex ?? 0
1770
+ } : null, c = s ? e.content.value.blocks.find((e) => e.id === s.sectionId) : void 0;
1771
+ ce(i, [{
1772
+ op: "moveBlock",
1773
+ blockId: r[0],
1774
+ parent: s,
1775
+ after: (s && c?.type === "section" ? c.children[s.column] : e.content.value.blocks)[o.index - 1]?.id ?? null
1776
+ }]);
1777
+ };
1778
+ t.moveBlock = r, ee.push(() => {
1779
+ t.moveBlock === r && (t.moveBlock = n);
1780
+ });
1781
+ }
1782
+ ee.push(h(() => e.state.template, (e) => Oe(e), { immediate: !0 }), h(() => e.content.value, se, { deep: !0 }), h(() => e.state.selectedBlockId, Be), h(() => e.state.isLoading, (e) => e ? B(!0, !0) : se())), typeof window < "u" && (window.addEventListener("pagehide", Ve), window.addEventListener("blur", V)), c() && o(Je);
1783
+ }
1784
+ function Ge() {
1785
+ V();
1786
+ let e = v;
1787
+ return !e || e.pending.length === 0 ? Promise.resolve() : new Promise((t, n) => e.waiters.push({
1788
+ resolve: t,
1789
+ reject: n
1790
+ }));
1791
+ }
1792
+ function Ke() {
1793
+ V(), y = !0;
1794
+ }
1795
+ function qe() {
1796
+ y = !1, v && R(v.view);
1797
+ }
1798
+ function Je() {
1799
+ if (!A) {
1800
+ V();
1801
+ for (let e of ee.splice(0)) e();
1802
+ z(), Ve(), A = !0, v && J(v), v = null, ze(), typeof window < "u" && (window.removeEventListener("pagehide", Ve), window.removeEventListener("blur", V));
1803
+ }
1804
+ }
1805
+ return {
1806
+ sessionId: n,
1807
+ members: a,
1808
+ locks: s,
1809
+ locksOf: je,
1810
+ lockLocale: f,
1811
+ setLockLocale: Me,
1812
+ connection: p,
1813
+ revision: m,
1814
+ canUndo: re,
1815
+ canRedo: ie,
1816
+ attach: We,
1817
+ undo: () => He("undo"),
1818
+ redo: () => He("redo"),
1819
+ clearHistory: () => {
1820
+ v && (v.undo = [], v.redo = [], L());
1821
+ },
1822
+ flush: V,
1823
+ settle: Ge,
1824
+ suspend: Ke,
1825
+ resume: qe,
1826
+ catchUp: K,
1827
+ hasConfirmedBlock: (e) => v ? bt(v.confirmed.blocks, e) : !1,
1828
+ applyOperations: Ue,
1829
+ destroy: Je
1830
+ };
1831
+ }
1832
+ // ../core/src/saved-blocks.ts
1833
+ function wt(e) {
1834
+ let { provider: t } = e, n = S([]), r = S(!1), i = v(() => {
1835
+ let e = /* @__PURE__ */ new Set();
1836
+ for (let t of n.value) {
1837
+ let n = t.category?.trim();
1838
+ n && e.add(n);
1839
+ }
1840
+ return [...e].sort((e, t) => e.localeCompare(t));
1841
+ }), a = v(() => typeof t.create == "function"), o = v(() => typeof t.update == "function"), s = v(() => typeof t.delete == "function");
1842
+ function c(e) {
1843
+ return o.value && e.canUpdate !== !1;
1844
+ }
1845
+ function l(e) {
1846
+ return s.value && e.canDelete !== !1;
1847
+ }
1848
+ function u(e, t) {
1849
+ throw new B(`[Templatical] Saved blocks: ${e} is ${t}. Check the capability before calling — the editor's own UI hides the action.`);
1850
+ }
1851
+ function d(t) {
1852
+ Z(e.onError, t);
1853
+ }
1854
+ async function f(i) {
1855
+ r.value = !0;
1856
+ try {
1857
+ n.value = await t.list(i);
1858
+ } catch (t) {
1859
+ throw e.onError?.(t), t;
1860
+ } finally {
1861
+ r.value = !1;
1862
+ }
1863
+ }
1864
+ async function p(r, i, a) {
1865
+ let { create: o } = t;
1866
+ typeof o != "function" && u("create", "disabled by the provider");
1867
+ try {
1868
+ let e = await o(a ? {
1869
+ name: r,
1870
+ content: i,
1871
+ category: a
1872
+ } : {
1873
+ name: r,
1874
+ content: i
1875
+ });
1876
+ return n.value = [e, ...n.value], d(() => t.onCreated?.(e)), e;
1877
+ } catch (t) {
1878
+ throw e.onError?.(t), t;
1879
+ }
1880
+ }
1881
+ async function m(r, i) {
1882
+ let { update: a } = t;
1883
+ typeof a != "function" && u("update", "disabled by the provider");
1884
+ let o = n.value.find((e) => e.id === r);
1885
+ o && o.canUpdate === !1 && u("update", `not permitted for entry "${r}"`);
1886
+ try {
1887
+ let e = await a(r, i);
1888
+ return n.value = n.value.map((t) => t.id === r ? e : t), d(() => t.onUpdated?.(e)), e;
1889
+ } catch (t) {
1890
+ throw e.onError?.(t), t;
1891
+ }
1892
+ }
1893
+ async function h(r) {
1894
+ let { delete: i } = t;
1895
+ typeof i != "function" && u("delete", "disabled by the provider");
1896
+ let a = n.value.find((e) => e.id === r) ?? null;
1897
+ a && a.canDelete === !1 && u("delete", `not permitted for entry "${r}"`);
1898
+ try {
1899
+ await i(r), n.value = n.value.filter((e) => e.id !== r), a && d(() => t.onDeleted?.(a));
1900
+ } catch (t) {
1901
+ throw e.onError?.(t), t;
1902
+ }
1903
+ }
1904
+ return {
1905
+ savedBlocks: n,
1906
+ isLoading: r,
1907
+ categories: i,
1908
+ canCreate: a,
1909
+ canUpdate: o,
1910
+ canDelete: s,
1911
+ canUpdateBlock: c,
1912
+ canDeleteBlock: l,
1913
+ load: f,
1914
+ create: p,
1915
+ update: m,
1916
+ remove: h
1917
+ };
1918
+ }
1919
+ // ../core/src/saved-blocks-local.ts
1920
+ var Tt = "templatical:saved-blocks";
1921
+ function Et(e = {}) {
1922
+ let t = e.key ?? Tt;
1923
+ function n() {
1924
+ if (typeof localStorage > "u") throw Error("[Templatical] createLocalStorageSavedBlocksProvider requires a browser environment with localStorage. Supply your own SavedBlocksProvider for server-side or non-browser use.");
1925
+ return localStorage;
1926
+ }
1927
+ function r() {
1928
+ let e = n().getItem(t);
1929
+ if (!e) return [];
1930
+ try {
1931
+ let t = JSON.parse(e);
1932
+ return Array.isArray(t) ? t : [];
1933
+ } catch {
1934
+ return [];
1935
+ }
1936
+ }
1937
+ function i(e) {
1938
+ n().setItem(t, JSON.stringify(e));
1939
+ }
1940
+ return {
1941
+ async list(e) {
1942
+ let t = r(), n = e?.search?.trim().toLowerCase(), i = e?.category?.trim();
1943
+ return t.filter((e) => !(n && !e.name.toLowerCase().includes(n) || i && e.category !== i));
1944
+ },
1945
+ async create(e) {
1946
+ let t = (/* @__PURE__ */ new Date()).toISOString(), n = {
1947
+ id: z(),
1948
+ name: e.name,
1949
+ content: e.content,
1950
+ ...e.category ? { category: e.category } : {},
1951
+ createdAt: t,
1952
+ updatedAt: t
1953
+ };
1954
+ return i([n, ...r()]), n;
1955
+ },
1956
+ async update(e, t) {
1957
+ let n = r(), a = n.findIndex((t) => t.id === e);
1958
+ if (a === -1) throw Error(`[Templatical] Saved block not found: ${e}`);
1959
+ let o = {
1960
+ ...n[a],
1961
+ ...t,
1962
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1963
+ }, s = [...n];
1964
+ return s[a] = o, i(s), o;
1965
+ },
1966
+ async delete(e) {
1967
+ let t = r();
1968
+ if (!t.some((t) => t.id === e)) throw Error(`[Templatical] Saved block not found: ${e}`);
1969
+ i(t.filter((t) => t.id !== e));
1970
+ }
1971
+ };
1972
+ }
1973
+ // ../core/src/media-local.ts
1974
+ var Dt = "templatical:media", Ot = 50;
1975
+ function kt(e = {}) {
1976
+ let t = e.key ?? Dt;
1977
+ function n() {
1978
+ if (typeof localStorage > "u") throw Error("[Templatical] createLocalStorageMediaProvider requires a browser environment with localStorage. Supply your own MediaProvider for server-side or non-browser use.");
1979
+ return localStorage;
1980
+ }
1981
+ function r() {
1982
+ let e = n().getItem(t);
1983
+ if (!e) return [];
1984
+ try {
1985
+ let t = JSON.parse(e);
1986
+ return Array.isArray(t) ? t : [];
1987
+ } catch {
1988
+ return [];
1989
+ }
1990
+ }
1991
+ function i(e) {
1992
+ n().setItem(t, JSON.stringify(e));
1993
+ }
1994
+ function a(e) {
1995
+ return typeof FileReader > "u" ? Promise.reject(/* @__PURE__ */ Error("[Templatical] createLocalStorageMediaProvider requires a browser environment with FileReader.")) : new Promise((t, n) => {
1996
+ let r = new FileReader();
1997
+ r.onload = () => {
1998
+ typeof r.result == "string" ? t(r.result) : n(/* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
1999
+ }, r.onerror = () => {
2000
+ n(r.error ?? /* @__PURE__ */ Error("[Templatical] Failed to read file as a data URL."));
2001
+ }, r.readAsDataURL(e);
2002
+ });
2003
+ }
2004
+ return {
2005
+ async list(e) {
2006
+ let t = r(), n = e?.search?.trim().toLowerCase(), i = n ? t.filter((e) => {
2007
+ let t = e.filename?.toLowerCase() ?? "", r = e.alt?.toLowerCase() ?? "";
2008
+ return t.includes(n) || r.includes(n);
2009
+ }) : t, a = e?.cursor ? Number.parseInt(e.cursor, 10) : 0, o = Number.isFinite(a) && a > 0 ? a : 0, s = i.slice(o, o + Ot), c = { items: s }, l = o + s.length;
2010
+ return l < i.length && (c.nextCursor = String(l)), c;
2011
+ },
2012
+ async create(e) {
2013
+ let t = await a(e.file), n = (/* @__PURE__ */ new Date()).toISOString(), o = {
2014
+ id: z(),
2015
+ url: t,
2016
+ filename: e.filename || e.file.name,
2017
+ createdAt: n,
2018
+ updatedAt: n,
2019
+ size: e.file.size
2020
+ };
2021
+ return e.alt !== void 0 && (o.alt = e.alt), e.file.type && (o.mimeType = e.file.type), e.folderId !== void 0 && (o.folderId = e.folderId), i([o, ...r()]), o;
2022
+ },
2023
+ async update(e, t) {
2024
+ let n = r(), a = n.findIndex((t) => t.id === e);
2025
+ if (a === -1) throw Error(`[Templatical] Media asset not found: ${e}`);
2026
+ let o = n[a], s = {
2027
+ ...o,
2028
+ ...t,
2029
+ id: o.id,
2030
+ url: o.url,
2031
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2032
+ }, c = [...n];
2033
+ return c[a] = s, i(c), s;
2034
+ },
2035
+ async delete(e) {
2036
+ let t = r();
2037
+ for (let n of e) if (!t.some((e) => e.id === n)) throw Error(`[Templatical] Media asset not found: ${n}`);
2038
+ let n = new Set(e);
2039
+ i(t.filter((e) => !n.has(e.id)));
2040
+ },
2041
+ folders: !1,
2042
+ replace: !1,
2043
+ importFromUrl: !1,
2044
+ checkUsage: !1,
2045
+ frequentlyUsed: !1,
2046
+ storage: !1
2047
+ };
2048
+ }
2049
+ // ../core/src/version-history.ts
2050
+ function At(e) {
2051
+ let { provider: t, getTemplateId: n } = e, r = S([]), i = S(!1), a = S(void 0), o = S(!1), s = /* @__PURE__ */ new Map(), c = v(() => typeof t.create == "function"), l = v(() => typeof t.restore == "function");
2052
+ function u(e) {
2053
+ let t = n();
2054
+ if (!t) throw new B(`[Templatical] Version history: ${e} needs a template. Call create() or load() first.`);
2055
+ return t;
2056
+ }
2057
+ function d(e) {
2058
+ throw new B(`[Templatical] Version history: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
2059
+ }
2060
+ function f(t) {
2061
+ Z(e.onError, t);
2062
+ }
2063
+ async function p(n) {
2064
+ let o = u("list");
2065
+ i.value = !0;
2066
+ try {
2067
+ let e = await t.list(o, n);
2068
+ r.value = e.versions, a.value = e.nextCursor;
2069
+ } catch (t) {
2070
+ throw e.onError?.(t), t;
2071
+ } finally {
2072
+ i.value = !1;
2073
+ }
2074
+ }
2075
+ function m(e) {
2076
+ return e.content ?? s.get(e.id) ?? null;
2077
+ }
2078
+ async function h(n) {
2079
+ let r = m(n);
2080
+ if (r) return r;
2081
+ let i = u("get");
2082
+ try {
2083
+ let e = await t.get(i, n.id);
2084
+ return s.set(n.id, e), e;
2085
+ } catch (t) {
2086
+ throw e.onError?.(t), t;
2087
+ }
2088
+ }
2089
+ async function g(n, i) {
2090
+ let { create: a } = t;
2091
+ typeof a != "function" && d("create");
2092
+ let o = u("create");
2093
+ try {
2094
+ let e = await a(o, n, i);
2095
+ return r.value = [e, ...r.value], f(() => t.onCreated?.(e)), e;
2096
+ } catch (t) {
2097
+ throw e.onError?.(t), t;
2098
+ }
2099
+ }
2100
+ async function _(n) {
2101
+ let { restore: r } = t;
2102
+ typeof r != "function" && d("restore");
2103
+ let i = u("restore"), a;
2104
+ o.value = !0;
2105
+ try {
2106
+ a = await r(i, n);
2107
+ } catch (t) {
2108
+ throw e.onError?.(t), t;
2109
+ } finally {
2110
+ o.value = !1;
2111
+ }
2112
+ return f(() => t.onRestored?.(a)), a;
2113
+ }
2114
+ return {
2115
+ nextCursor: a,
2116
+ versions: r,
2117
+ isLoading: i,
2118
+ isRestoring: o,
2119
+ canCreate: c,
2120
+ canRestore: l,
2121
+ load: p,
2122
+ peekContent: m,
2123
+ resolveContent: h,
2124
+ create: g,
2125
+ restore: _
2126
+ };
2127
+ }
2128
+ // ../core/src/comments.ts
2129
+ function jt(e) {
2130
+ let { provider: t, getTemplateId: n, getUser: r } = e, i = S([]), a = S(!1), o = S(!1), s = v(() => typeof t.create == "function"), c = v(() => typeof t.update == "function"), l = v(() => typeof t.delete == "function"), u = v(() => typeof t.setResolved == "function"), d = v(() => i.value.reduce((e, t) => e + 1 + (t.replies?.length ?? 0), 0)), f = v(() => i.value.filter((e) => !e.resolvedAt).length), p = v(() => {
2131
+ let e = /* @__PURE__ */ new Map();
2132
+ for (let t of i.value) t.blockId && e.set(t.blockId, (e.get(t.blockId) ?? 0) + 1 + (t.replies?.length ?? 0));
2133
+ return e;
2134
+ });
2135
+ function m(e) {
2136
+ let t = n();
2137
+ if (!t) throw new B(`[Templatical] Comments: ${e} needs a template. Call create() or load() first.`);
2138
+ return t;
2139
+ }
2140
+ function h(e) {
2141
+ let t = r();
2142
+ if (!t) throw new B(`[Templatical] Comments: ${e} needs to know who is commenting. Pass init({ user: { id, name } }) — an unattributed comment is not written.`);
2143
+ return t;
2144
+ }
2145
+ function g(e) {
2146
+ throw new B(`[Templatical] Comments: ${e} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`);
2147
+ }
2148
+ function _(e) {
2149
+ for (let t of i.value) {
2150
+ if (t.id === e) return t;
2151
+ for (let n of t.replies ?? []) if (n.id === e) return n;
2152
+ }
2153
+ return null;
2154
+ }
2155
+ function y(e) {
2156
+ let t = r();
2157
+ return t !== null && e.author.id === t.id;
2158
+ }
2159
+ function b(t) {
2160
+ let n = Fe(t);
2161
+ throw e.onError?.(n), n;
2162
+ }
2163
+ function x(t) {
2164
+ Z(e.onError, t);
2165
+ }
2166
+ function C(e, t, n) {
2167
+ return [
2168
+ ...e.slice(0, t),
2169
+ n,
2170
+ ...e.slice(t + 1)
2171
+ ];
2172
+ }
2173
+ function w(e, t) {
2174
+ return e !== void 0 && JSON.stringify(e) === JSON.stringify(t);
2175
+ }
2176
+ function T(e) {
2177
+ if (e.parentId) {
2178
+ let t = !1, n = i.value.map((n) => {
2179
+ if (n.id !== e.parentId) return n;
2180
+ let r = n.replies ?? [], i = r.findIndex((t) => t.id === e.id);
2181
+ return i !== -1 && w(r[i], e) ? n : (t = !0, {
2182
+ ...n,
2183
+ replies: i === -1 ? [...r, e] : C(r, i, e)
2184
+ });
2185
+ });
2186
+ return t && (i.value = n), t;
2187
+ }
2188
+ let t = i.value.findIndex((t) => t.id === e.id);
2189
+ if (t === -1) return i.value = [...i.value, e], !0;
2190
+ let n = {
2191
+ ...e,
2192
+ replies: e.replies ?? i.value[t].replies
2193
+ };
2194
+ return !w(i.value[t], n) && (i.value = C(i.value, t, n), !0);
2195
+ }
2196
+ function E(e, t) {
2197
+ let n = _(e), r = t ?? n?.parentId ?? null;
2198
+ return r ? i.value = i.value.map((t) => t.id === r ? {
2199
+ ...t,
2200
+ replies: (t.replies ?? []).filter((t) => t.id !== e)
2201
+ } : t) : i.value = i.value.filter((t) => t.id !== e), n;
2202
+ }
2203
+ async function D(e) {
2204
+ let n = m("list");
2205
+ a.value = !0;
2206
+ try {
2207
+ i.value = await t.list(n, e);
2208
+ } catch (e) {
2209
+ b(e);
2210
+ } finally {
2211
+ a.value = !1;
2212
+ }
2213
+ }
2214
+ async function O(e) {
2215
+ let { create: n } = t;
2216
+ typeof n != "function" && g("create");
2217
+ let r = m("create");
2218
+ h("create"), o.value = !0;
2219
+ try {
2220
+ let i = await n(r, e);
2221
+ return T(i), x(() => t.onCreated?.(i, { origin: "local" })), i;
2222
+ } catch (e) {
2223
+ b(e);
2224
+ } finally {
2225
+ o.value = !1;
2226
+ }
2227
+ }
2228
+ async function k(e, n) {
2229
+ let { update: r } = t;
2230
+ typeof r != "function" && g("update");
2231
+ let i = m("update");
2232
+ h("update"), o.value = !0;
2233
+ try {
2234
+ let a = await r(i, e, n);
2235
+ return T(a), x(() => t.onUpdated?.(a, { origin: "local" })), a;
2236
+ } catch (e) {
2237
+ b(e);
2238
+ } finally {
2239
+ o.value = !1;
2240
+ }
2241
+ }
2242
+ async function A(e) {
2243
+ let { delete: n } = t;
2244
+ typeof n != "function" && g("delete");
2245
+ let r = m("delete");
2246
+ h("delete");
2247
+ let i = _(e);
2248
+ o.value = !0;
2249
+ try {
2250
+ await n(r, e), E(e), i && x(() => t.onDeleted?.(i, { origin: "local" }));
2251
+ } catch (e) {
2252
+ b(e);
2253
+ } finally {
2254
+ o.value = !1;
2255
+ }
2256
+ }
2257
+ async function ee(e, n) {
2258
+ let { setResolved: r } = t;
2259
+ typeof r != "function" && g("setResolved");
2260
+ let i = m("setResolved");
2261
+ h("setResolved"), o.value = !0;
2262
+ try {
2263
+ let a = await r(i, e, n);
2264
+ return T(a), x(() => (a.resolvedAt ? t.onResolved : t.onUnresolved)?.(a, { origin: "local" })), a;
2265
+ } catch (e) {
2266
+ b(e);
2267
+ } finally {
2268
+ o.value = !1;
2269
+ }
2270
+ }
2271
+ function j(e) {
2272
+ T(e) && x(() => t.onCreated?.(e, { origin: "remote" }));
2273
+ }
2274
+ function M(e) {
2275
+ T(e) && x(() => (e.resolvedAt ? t.onResolved : t.onUpdated)?.(e, { origin: "remote" }));
2276
+ }
2277
+ function N(e, n) {
2278
+ let r = E(e, n);
2279
+ r && x(() => t.onDeleted?.(r, { origin: "remote" }));
2280
+ }
2281
+ return {
2282
+ comments: i,
2283
+ isLoading: a,
2284
+ isSubmitting: o,
2285
+ canCreate: s,
2286
+ canUpdate: c,
2287
+ canDelete: l,
2288
+ canResolve: u,
2289
+ totalCount: d,
2290
+ unresolvedCount: f,
2291
+ commentCountByBlock: p,
2292
+ load: D,
2293
+ create: O,
2294
+ update: k,
2295
+ remove: A,
2296
+ setResolved: ee,
2297
+ find: _,
2298
+ isOwn: y,
2299
+ applyRemoteCreate: j,
2300
+ applyRemoteUpdate: M,
2301
+ applyRemoteDelete: N
2302
+ };
2303
+ }
2304
+ function Mt(e) {
2305
+ let { comments: t, provider: n, getTemplateId: i } = e, { subscribe: a } = n;
2306
+ if (typeof a != "function") return;
2307
+ let s = null;
2308
+ function c() {
2309
+ s?.(), s = null;
2310
+ }
2311
+ r(() => i(), (e) => {
2312
+ c(), e && (s = a(e, (e) => {
2313
+ switch (e.type) {
2314
+ case "created":
2315
+ t.applyRemoteCreate(e.comment);
2316
+ break;
2317
+ case "updated":
2318
+ t.applyRemoteUpdate(e.comment);
2319
+ break;
2320
+ case "deleted": t.applyRemoteDelete(e.commentId, e.parentId);
2321
+ }
2322
+ }));
2323
+ }, { immediate: !0 }), o(c);
2324
+ }
2325
+ // src/constants/timeouts.ts
2326
+ var Nt = 1e4;
2327
+ // src/composables/useImageUrlResolver.ts
2328
+ function Pt(t) {
2329
+ let n = e(/* @__PURE__ */ new Map()), r = /* @__PURE__ */ new Set();
2330
+ function i(e) {
2331
+ return n.get(e);
2332
+ }
2333
+ function a(e) {
2334
+ return n.has(e) || r.has(e);
2335
+ }
2336
+ function o(e) {
2337
+ if (a(e)) return;
2338
+ let i;
2339
+ try {
2340
+ i = t(e);
2341
+ } catch {
2342
+ n.set(e, null);
2343
+ return;
2344
+ }
2345
+ i === null || typeof i == "string" ? n.set(e, i) : (r.add(e), Promise.resolve(i).then((t) => {
2346
+ n.set(e, typeof t == "string" ? t : null);
2347
+ }, () => {
2348
+ n.set(e, null);
2349
+ }).finally(() => r.delete(e)));
2350
+ }
2351
+ return {
2352
+ get: i,
2353
+ has: a,
2354
+ lookup: o
2355
+ };
2356
+ }
2357
+ function Ft(e) {
2358
+ let t = a(ve, null), n = v(e);
2359
+ if (!t) return n;
2360
+ let i;
2361
+ function s() {
2362
+ i !== void 0 && (clearTimeout(i), i = void 0);
2363
+ }
2364
+ c() && o(s);
2365
+ let l = !0;
2366
+ return r(n, (e) => {
2367
+ s();
2368
+ let n = l;
2369
+ l = !1, e && !t.has(e) && (n ? t.lookup(e) : i = setTimeout(() => {
2370
+ i = void 0, t.lookup(e);
2371
+ }, 300));
2372
+ }, { immediate: !0 }), v(() => {
2373
+ let e = n.value;
2374
+ if (!e) return e;
2375
+ let r = t.get(e);
2376
+ return typeof r == "string" && r.length > 0 ? r : e;
2377
+ });
2378
+ }
2379
+ function It(e, t) {
2380
+ if (!e || !t) return t;
2381
+ let n = e.get(t);
2382
+ return typeof n == "string" && n.length > 0 ? n : t;
2383
+ }
2384
+ function Lt(e, t) {
2385
+ return typeof e?.url == "string" && me(e.url, t);
2386
+ }
2387
+ function Rt(e, t) {
2388
+ let n = e?.url;
2389
+ if (typeof n == "string" && n.trim() !== "") return me(n, t) ? void 0 : n;
2390
+ }
2391
+ function zt(e) {
2392
+ let t = a(_e, pe.liquid), n = Ft(() => Rt(e(), t));
2393
+ return v(() => Lt(e(), t) ? null : n.value);
2394
+ }
2395
+ function Bt(e, t, n) {
2396
+ return Lt(t, n) ? null : It(e, Rt(t, n));
2397
+ }
2398
+ // src/utils/blockTypeLabels.ts
2399
+ function Vt(e, t) {
2400
+ return t.blocks[e] ?? e;
2401
+ }
2402
+ function Ht(e, t, n = []) {
2403
+ if (e.type !== "custom") return Vt(e.type, t);
2404
+ let { customType: r } = e;
2405
+ return n.find((e) => e.type === r)?.name ?? r;
2406
+ }
2407
+ // src/utils/resolveFieldColors.ts
2408
+ function Ut(e, t) {
2409
+ let n = Ce({ presets: e.presets }, K), r = n.presets.length === 0;
2410
+ return {
2411
+ presets: r ? t.presets : n.presets,
2412
+ allowCustom: t.allowCustom === !1 ? !1 : e.allowCustom ?? t.allowCustom,
2413
+ invalidPresets: n.invalidPresets,
2414
+ emptyPresets: e.presets !== void 0 && e.presets.length === 0,
2415
+ presetsInherited: r,
2416
+ allowCustomIgnored: e.allowCustom === !0 && t.allowCustom === !1
2417
+ };
2418
+ }
2419
+ // src/utils/imageNaturalSize.ts
2420
+ function Wt(e) {
2421
+ return typeof e == "number" && Number.isFinite(e) && e > 0;
2422
+ }
2423
+ function Gt(e, t) {
2424
+ return Wt(e) && Wt(t) ? {
2425
+ width: e,
2426
+ height: t
2427
+ } : null;
2428
+ }
2429
+ function Kt(e) {
2430
+ return Gt(e.naturalWidth, e.naturalHeight);
2431
+ }
2432
+ function qt(e) {
2433
+ return e ? {
2434
+ naturalWidth: e.width,
2435
+ naturalHeight: e.height
2436
+ } : {
2437
+ naturalWidth: void 0,
2438
+ naturalHeight: void 0
2439
+ };
2440
+ }
2441
+ function Jt(e, t) {
2442
+ if (typeof Image > "u") return t(null), () => {};
2443
+ let n = new Image(), r = () => {
2444
+ n.onload = null, n.onerror = null;
2445
+ };
2446
+ return n.onload = () => {
2447
+ r(), t(Gt(n.naturalWidth, n.naturalHeight));
2448
+ }, n.onerror = () => {
2449
+ r(), t(null);
2450
+ }, n.src = e, r;
2451
+ }
2452
+ function Yt(e) {
2453
+ return new Promise((t) => {
2454
+ let n = setTimeout(() => {
2455
+ r(), t(null);
2456
+ }, Nt), r = Jt(e, (e) => {
2457
+ clearTimeout(n), t(e);
2458
+ });
2459
+ });
2460
+ }
2461
+ // src/components/MediaDropOverlay.vue
2462
+ var Xt = /* @__PURE__ */ t({
2463
+ __name: "MediaDropOverlay",
2464
+ props: {
2465
+ uploading: { type: Boolean },
2466
+ size: { default: "field" }
2467
+ },
2468
+ setup(e) {
2469
+ let t = e, { t: r } = xe(), i = {
2470
+ field: {
2471
+ gap: "tpl:gap-1.5",
2472
+ icon: 18,
2473
+ veil: "90%"
2474
+ },
2475
+ canvas: {
2476
+ gap: "tpl:gap-2",
2477
+ icon: 20,
2478
+ veil: "85%"
2479
+ }
2480
+ }, a = v(() => i[t.size]);
2481
+ return (t, i) => (n(), l("div", {
2482
+ class: p(["tpl:pointer-events-none tpl:absolute tpl:inset-0 tpl:z-10 tpl:flex tpl:flex-col tpl:items-center tpl:justify-center tpl:rounded tpl:border-2 tpl:border-dashed tpl:text-xs tpl:font-medium tpl:border-[var(--tpl-primary)] tpl:text-[var(--tpl-primary)]", a.value.gap]),
2483
+ style: y({ backgroundColor: `color-mix(in srgb, var(--tpl-bg) ${a.value.veil}, transparent)` })
2484
+ }, [e.uploading ? (n(), l(C, { key: 0 }, [w(f(ge), {
2485
+ class: "tpl-spinner",
2486
+ size: a.value.icon,
2487
+ "stroke-width": 2
2488
+ }, null, 8, ["size"]), d(" " + g(f(r).image.uploading), 1)], 64)) : (n(), l(C, { key: 1 }, [w(f(G), {
2489
+ size: a.value.icon,
2490
+ "stroke-width": 1.5
2491
+ }, null, 8, ["size"]), d(" " + g(f(r).image.dropToUpload), 1)], 64))], 6));
2492
+ }
2493
+ });
2494
+ // src/composables/useAliveFlag.ts
2495
+ function Zt() {
2496
+ let e = { alive: !0 };
2497
+ return i(() => {
2498
+ e.alive = !1;
2499
+ }), e;
2500
+ }
2501
+ // src/composables/useImageDrop.ts
2502
+ var Qt = "image/";
2503
+ function $t(e) {
2504
+ let { target: t, onFiles: n, enabled: r } = e, i = () => r === void 0 || _(r), { isOverDropZone: a } = Se(t, {
2505
+ preventDefaultForUnhandled: !0,
2506
+ onDrop: (e) => {
2507
+ if (!i()) return;
2508
+ let t = (e ?? []).filter((e) => e.type.startsWith(Qt));
2509
+ t.length > 0 && n([t[0]]);
2510
+ }
2511
+ });
2512
+ return { isOver: v(() => i() && a.value) };
2513
+ }
2514
+ // src/composables/useMediaDropField.ts
2515
+ function en(e) {
2516
+ let { target: t, blocked: n, apply: r } = e, i = a(ye, null), o = a(be, null), s = Zt();
2517
+ async function c() {
2518
+ let e = await i?.({ accept: ["images"] });
2519
+ s.alive && e && r(e);
2520
+ }
2521
+ let l = S(!1), u = v(() => (o?.value ?? !!i) && !l.value && !_(n));
2522
+ async function d(e) {
2523
+ if (i) {
2524
+ l.value = !0;
2525
+ try {
2526
+ let t = await i({
2527
+ accept: ["images"],
2528
+ files: e
2529
+ });
2530
+ if (!s.alive) return;
2531
+ t && r(t);
2532
+ } finally {
2533
+ s.alive && (l.value = !1);
2534
+ }
2535
+ }
2536
+ }
2537
+ let { isOver: f } = $t({
2538
+ target: t,
2539
+ enabled: u,
2540
+ onFiles: d
2541
+ }), p = v(() => u.value && f.value || l.value);
2542
+ return {
2543
+ canBrowse: !!i,
2544
+ dropEnabled: u,
2545
+ isUploading: l,
2546
+ showOverlay: p,
2547
+ openMediaBrowser: c
2548
+ };
2549
+ }
2550
+ function tn(e, t = "desktop") {
2551
+ return t === "mobile" ? 375 : e?.width ?? 600;
2552
+ }
2553
+ var nn = "width 300ms cubic-bezier(0.34, 1.56, 0.64, 1)", rn = {
2554
+ 1: [100],
2555
+ 2: [50, 50],
2556
+ 3: [
2557
+ 33.33,
2558
+ 33.33,
2559
+ 33.34
2560
+ ],
2561
+ "1-2": [33.33, 66.67],
2562
+ "2-1": [66.67, 33.33]
2563
+ };
2564
+ function an(e, t) {
2565
+ let n = (e) => Math.trunc(e ?? 0), r = (e) => V(e) === null ? 0 : Math.trunc(e.width);
2566
+ return n(e?.left) + n(e?.right) + r(t?.left) + r(t?.right);
2567
+ }
2568
+ function on(e, t) {
2569
+ return Math.floor(e) - an(t);
2570
+ }
2571
+ function sn(e, t) {
2572
+ let n = "border" in e ? e.border : void 0;
2573
+ return Math.floor(t) - an(e.styles.padding, n);
2574
+ }
2575
+ function* cn(e, t) {
2576
+ for (let n of e) k(n) ? yield* cn(n.children, on(t, n.styles.padding)) : yield {
2577
+ block: n,
2578
+ bandWidth: ce(n) && n.wrapper ? on(t, n.wrapper.padding) : t
2579
+ };
2580
+ }
2581
+ function ln(e, t, n = N(e)) {
2582
+ if (!t) return e;
2583
+ try {
2584
+ return ie(j(t, n, { missing: "default" }), e);
2585
+ } catch {
2586
+ return e;
2587
+ }
2588
+ }
2589
+ function un(e, t, n, r) {
2590
+ let i = ln(e, n, r);
2591
+ for (let { block: e, bandWidth: n } of cn(i.blocks, i.settings.width)) if (ce(e)) {
2592
+ let r = U(e)?.applied ? void 0 : e.border, i = Math.floor(n) - an(e.styles.padding, r), a = rn[e.columns] ?? [100];
2593
+ for (let n = 0; n < e.children.length; n++) {
2594
+ let r = Math.floor(i * (a[n] ?? 100) / 100), o = e.children[n].find((e) => e.id === t);
2595
+ if (o) return sn(o, r);
2596
+ }
2597
+ } else if (e.id === t) return sn(e, n);
2598
+ return null;
2599
+ }
2600
+ function dn(e, t, n, r) {
2601
+ let i = ln(e, n, r);
2602
+ for (let { block: e, bandWidth: n } of cn(i.blocks, i.settings.width)) if (e.id === t) return Math.floor(n);
2603
+ return null;
2604
+ }
2605
+ function fn(e) {
2606
+ let t = ce(e) ? U(e) : null;
2607
+ return !!t?.applied && t.height === "image";
2608
+ }
2609
+ function pn(e, t, n, r) {
2610
+ if (fn(e)) return (t ? dn(t, e.id, n, r) : null) ?? tn(t?.settings);
2611
+ }
2612
+ // src/constants/socialIcons.ts
2613
+ var mn = ue, hn = {
2614
+ small: 24,
2615
+ medium: 32,
2616
+ large: 48
2617
+ }, gn = [
2618
+ "facebook",
2619
+ "twitter",
2620
+ "instagram",
2621
+ "linkedin",
2622
+ "youtube",
2623
+ "tiktok",
2624
+ "pinterest",
2625
+ "email",
2626
+ "website",
2627
+ "whatsapp",
2628
+ "telegram",
2629
+ "discord",
2630
+ "snapchat",
2631
+ "reddit",
2632
+ "github",
2633
+ "dribbble",
2634
+ "behance"
2635
+ ];
2636
+ export { Et as A, Be as B, Bt as C, jt as D, Mt as E, Ge as F, We as I, He as L, Ct as M, lt as N, At as O, Ke as P, Ue as R, Rt as S, Ft as T, Ie as V, Gt as _, fn as a, Vt as b, nn as c, Zt as d, Xt as f, Kt as g, qt as h, un as i, wt as j, kt as k, tn as l, Yt as m, mn as n, pn as o, Jt as p, gn as r, dn as s, hn as t, en as u, Ut as v, zt as w, Pt as x, Ht as y, Ve as z };
2637
+
2638
+ //# sourceMappingURL=socialIcons-BAiuHyJs.js.map